长春职业技术学院
学生个案学习计划书
学生姓名:
所属分院:
填表日期:20 年 月 日
提前就业学生个人学习计划书
附件:(每门课程附加一份附件)
第二篇:实训学习文档(C# net)
(1) 在表中加入数据代码:
一、 if (dt.Rows.Count== 0) // dt 自己定义的一个数据表
{
DataRow dr = dt.NewRow();
dr["AreaID"] = 0;
dr["AreaName"] = "-----没有相关的地域信息---------";
dr["TypeName"] = "";
dt.Rows.Add(dr);
}
二、 DDLCategory.Items.Insert(0, new ListItem("不是推荐线路", "0"));
三、GVPic.Rows[0].Cells[0].Text = "";
(2) 在对错误处理上要根据错误代码的编号判断 如: EX.Number==2627 代表相同的数据不能用
cmd.parameters.add("@34",sqldbType.int )value=
(3) // sdr代表一个SQLDataread()
对一个实休输入值:
一、entity.AdminID=sdr["ADminID"].toString()
二、entity.AdminID=sdr.GetString["AdminID"].tosting();
(4) cmd=new sqlcommand(" ",con.GetOpen()); //常用来加数据库代码和打开数据库
(5) sda=new SqlDataAdapter(cmd); // SQlDATAREader
sda.Fill(dt); //对数据表加入数据
(6)清空页面中相应文体中数据表的信息
foreach (System.Web.UI.Control control in Controls)
{
for (int i = 0; i < control.Controls.Count; i++)
{
if (control.Controls[i] is System.Web.UI.WebControls.TextBox) {
System.Web.UI.WebControls.TextBox tb = (System.Web.UI.WebControls.TextBox)control.Controls[i];
tb.Text = "";
}
}
}
(7) 数据库连接 sqlconnection con= null; con=new Sqlconnection(str);
if(con.State== ConnectionState.Closed)
{con.Open();}
con.ConnectionString = ConfigurationSettings.AppSettings["ConStr"].ToString();
一、 con.ConnectionString = "Data Source=.;Initial Catalog=hjyDB;Integrated Security=True";
二、 <add name ="Constr" connectionString="Data Source=.;Initial Catalog=hjyDB;Integrated Security=True"/>
con.ConnectionString = ConfigurationManager.ConnectionStrings["Constr"].ToString();
(8)检查是否登录
public bool CheckLogin()
{
if (HttpContext.Current.Session["AdminID"] == null)
{
HttpContext.Current.Response.Write("<script>top.location.href='Login.aspx'</script>");
return false;
}
return true;
}
(9) 样式表:
body
{
font-size:9pt;
font-family:宋体;
}
TABLE
{
font-size:9pt;
}
TR
{font-size:9pt;
}
TD
{font-size:9pt;
}
SELECT
{font-size:9pt;
}
TEXTAREA
{font-size:9pt;
}
INPUT
{font-size:9pt;
}
A:hover
{
font-size: 9pt;
text-decoration: none;
}
A:link
{font-size: 9pt;
text-decoration: none;
}
A:visited
{font-size: 9pt;
text-decoration: none;
}
(10)在公共类中加入提示信息,并反到相应的页面中:
public string MessageBox(string message,string url)
{
string str;
str = "<script language=javascript>alert('" + message + "');location='"+url +"'</script>";
return str;
}
(11)一个对不同的条件查结果的方法:
using System.Text;
public DataTable GetSignByCondition(int lineID, string startDate, string endDate, string person, byte flag)
{
DataTable dt = new DataTable();
try
{
StringBuilder sb = new StringBuilder("Select s.LineID,s.SignID,l.LineName,s.SignPerson,s.PostDate From Sign s,Line l Where s.flag="+flag.ToString()+"And s.LineID=l.LineID ");
if (lineID > 0)
{
sb.Append(" and s.LineID=" +lineID );
}
if (startDate.Length>0)
{
sb.Append(" and Postdate>' "+startDate +" '" );
}
if(endDate.Length>0)
{
sb.Append(" and Postdate<'"+DateTime.Parse(endDate ).AddDays(1).ToString("yyyy-MM-dd")+" ' " ); }
if(person.Length>0)
{
sb.Append(" and SignPerson like '%"+ person +" %'");
}
cmd = new SqlCommand(sb.ToString (),con.GetConOpen());
sda = new SqlDataAdapter(cmd );
sda.Fill(dt);
if (dt.Rows.Count == 0)
{
DataRow dr = dt.NewRow();
dr[0] = 0;
dr[1] = 0;
dr[2] = "没有符合的报名信息";
dr[3] = "";
dr[4] = DBNull.Value;
dr[5] = DBNull.Value;
dt.Rows.Add(dr);
}
}
catch
{
}
finally
{
con.GetConClose();
}
return dt;
}
(12)对数据库进行输入数据并返回一个自动增长的例:
public string InsertSign(SignEntity entity,out string signID)
{
string result = "";
string newID = "";
try
{
cmd = new SqlCommand(" insert into Sign (LineID,StartDate,Number,SignPerson,WorkPlace,Email,Address,Postcode,Telephone,Mobile,Fax,IDCard,Comment,PostDate,Flag) values("+entity.LineID +","+Convert.ToDateTime (entity.StartDate )+","+entity.Number +"'"+entity.SignPerson +"','"+entity.WorkPlace +"','"+entity.Email +"','"+entity.Address +"','"+entity.Postcode +"','"+entity.Telephone +"','"+entity.Mobile +"','"+entity.Fax +"','"+entity.IDCard +"','"+entity.Comment +"','"+Convert.ToDateTime ( entity.PostDate) +"','"+entity.Flag.ToString() +"') Set @SignID=@@Identity ",con.GetConOpen ());
// cmd.Parameters.Add("@Flag", SqlDbType.Bit ).Value = entity.Flag; SqlParameter aParam = new SqlParameter();
aParam.ParameterName = "@SignID";
aParam.Direction = ParameterDirection.Output;
aParam.SqlDbType=SqlDbType.Int;
cmd.Parameters.Add(aParam);
int count = cmd.ExecuteNonQuery();
if (count == 1)
{
newID = cmd.Parameters["@SignID"].Value.ToString(); result = "OK";
}
else
{
result = "没有报名信息被添加!";
}
}
catch
{
result = "添加报名信息出错,请检查!";
}
finally
{
con.GetConClose();
}
signID = newID;
return result;
}
编号自动增加
(1)安当前日期算
(2)安系统数据库中的自动增长 ------out 12
sdr.GetString[0].toString():
(3) 在页面加Page_load事件中
(a). btnClose.Attributes.add("OnClick","Window.close()");
(b.)在一个控制ONclick中可以加return confirm("确定要干什么吗?");
对数据行的操作:GVSignList.Rows[0].Visible = false;
(13) 从所在数据表中找行的主健值
主健的绑定: GVPic.DataKeyNames = new string[] { "PicID" };
主健的引用: GVCate.DataKeys[gvr.RowIndex ].Value.ToString();
在RowCommand中得到e.CommandArgument中相关的数据:
if (e.CommandName == "Deal")
int signID = Convert.ToInt32(e.CommandArgument);
StringBuilder sb = new StringBuilder();
CheckBox cb = null;
foreach (GridViewRow gvr in GVCate.Rows)
{
cb = (CheckBox )gvr.FindControl("Chk");
if (cb.Checked)
{
sb.Append(GVCate.DataKeys[gvr.RowIndex ].Value.ToString()+","); }
}
if (sb.Length > 0)
{
sb.Remove(sb.Length -1,1);
string result = open.DeleteCategoryByIDs(sb.ToString());
DropDownList ddlType =(DropDownList)GVArea.Rows[e.RowIndex ].FindControl("DDLEditArea");
TextBox txtArea=(TextBox )GVArea.Rows[e.RowIndex ].FindControl ("TxtEditArea");
int areaID = (int)GVArea.DataKeys[e.RowIndex].Value;
(14) 怎么在GV中找行的数值,,FindControl使用 foot中的数据
TextBox txtTitle = (TextBox)GVPic.FooterRow.FindControl("TxtTitle");
foreach (GridViewRow grv in GVDepartMent.Rows)
{
txtDepartmentID = (TextBox)GVDepartMent.Rows[grv.RowIndex].FindControl("txtOldID");
txtDepartmentName = (TextBox)GVDepartMent.Rows[grv.RowIndex].FindControl("txtOldName");
txtDepartmentRespon = (TextBox)GVDepartMent.Rows[grv.RowIndex].FindControl("txtResponOld");
(15)在GV中常用到对编辑和分页中起用
GVArea.PageIndex = e.NewPageIndex; //在PageIndexChanging中用分页
BindGVArea();//一个绑定的的方法
GVArea.EditIndex = e.NewEditIndex;//在GVRowEditing中用
BindGVArea();
GVArea.ShowFooter = false ;
GVArea.EditIndex = -1;
在系统自带加入DElete中 取得当前行中的相应的数据: GVSignList.DataKeys[e.RowIndex].Value
(16)数据表中DataBind中的对行中的数据类型应用:
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView drv = (DataRowView)e.Row.DataItem;
//if (drv["PostDate"] != null)
//{
// e.Row.Cells[0].Text = Convert.ToDateTime(drv["PostDate"]).ToString("yyyy-MM-dd");
//}
((LinkButton)e.Row.Cells[5].Controls[0]).Attributes.Add("onclick","return confirm('确定删除当前行?');" );
}