您目前尚未登陆,请选择【登陆】或【注册
首页->行政办公->人事管理系统(课程设计)源码>>WebFiles/Employee/DisplayEmployee.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:人事管理系统(课程设计)源码
当前文件:文件类型 Mispersonal/WebFiles/Employee/DisplayEmployee.aspx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using System.Data.SqlClient; 12public partial class WebFiles_Employee_DisplayEmployee : System.Web.UI.Page 13{ 14 protected void Page_Load(object sender, EventArgs e) 15 { 16 if (!IsPostBack) 17 { 18 this.TxtBirth.Attributes.Add("onfocus", "javascript:calendar()"); 19 string id = Request["E_ID"]; 20 string name = Request["E_Name"]; 21 Session["E_ID"] = id; 22 Session["E_Name"] = name; 23 Bond(); 24 25 string connstr = ConfigurationManager.ConnectionStrings["Mispersonalconn"].ConnectionString; 26 SqlConnection Sqlconn = new SqlConnection(connstr); 27 DataSet ds = new DataSet(); 28 string Agreerstr = "select D_ID,D_Name from Tb_department order by D_ID desc"; 29 SqlDataAdapter SqlAgreer = new SqlDataAdapter(Agreerstr, Sqlconn); 30 SqlAgreer.Fill(ds, "Agreer"); 31 Agreer.DataSource = ds.Tables["Agreer"].DefaultView; 32 Agreer.DataTextField = "D_Name"; 33 Agreer.DataValueField = "D_ID"; 34 Agreer.DataBind(); 35 Sqlconn.Close(); 36 } 37 } 38 private void Bond() 39 { 40 string id = (string)Session["E_ID"]; 41 string sql = "select * from [Tb_employee] where E_ID='" + id + "'"; 42 string connstr = ConfigurationManager.ConnectionStrings["Mispersonalconn"].ConnectionString; 43 SqlConnection Sqlconn = new SqlConnection(connstr); 44 Sqlconn.Open(); 45 SqlCommand sc = new SqlCommand(sql, Sqlconn); 46 SqlDataReader myreader = sc.ExecuteReader(); 47 if(myreader.Read()) 48 { 49 TxtID.Text =myreader[0].ToString(); 50 TxtName.Text =myreader[1].ToString(); 51 TxtBirth.Text = myreader[3].ToString(); 52 TxtTel.Text =myreader[4].ToString(); 53 TxtAddress.Text =myreader[5].ToString(); 54 TxtIntro.Text = myreader[6].ToString(); 55 Pic.ImageUrl = myreader[7].ToString(); 56 Sqlconn.Close(); 57 } 58 } 59 protected void btn_edit_Click(object sender, EventArgs e) 60 { 61 if ((string)Session["Name"] != "") 62 { 63 if ((string)Session["role"] == "管理员") 64 { 65 string id = (string)Session["E_ID"]; 66 string sql = "update [Tb_employee] set E_Name='" 67 + TxtName.Text.Trim() + "',E_Sex='" 68 + Sex.SelectedValue + "',E_Birth='" 69 + TxtBirth.Text + "',E_Tel='" 70 + TxtTel.Text.Trim() + "',E_Address='" 71 + TxtAddress.Text.Trim() + "',D_Name='" 72 +Agreer.SelectedValue + "',E_Intro='" 73 + TxtIntro.Text.Trim() + "',E_Picurl='" 74 + picurl.SelectedValue + "'"+"where E_ID='" 75 +TxtID.Text.Trim()+ "'"; 76 string connstr = ConfigurationManager.ConnectionStrings["Mispersonalconn"].ConnectionString; 77 SqlConnection Sqlconn = new SqlConnection(connstr); 78 Sqlconn.Open(); 79 SqlCommand sc = new SqlCommand(sql, Sqlconn); 80 sc.ExecuteNonQuery(); 81 lbMessage.Text = "您已成功更新1条记录!"; 82 Sqlconn.Close(); 83 } 84 else 85 { 86 Response.Write("<script>alert('只有管理员才可以进行此操作!')</script>"); 87 } 88 } 89 else 90 { 91 Response.Redirect("Default.aspx"); ; 92 } 93 94 } 95 96 protected void btn_delete_Click(object sender, EventArgs e) 97 { 98 if ((string)Session["Name"] != "") 99 { 100 if ((string)Session["role"] == "管理员") 101 { 102 string id = (string)Session["E_ID"]; 103 string sql = "delete from [Tb_employee] where E_ID='" + id + "'"; 104 string connstr = ConfigurationManager.ConnectionStrings["Mispersonalconn"].ConnectionString; 105 SqlConnection Sqlconn = new SqlConnection(connstr); 106 Sqlconn.Open(); 107 SqlCommand sc = new SqlCommand(sql, Sqlconn); 108 sc.ExecuteNonQuery(); 109 Sqlconn.Close(); 110 Response.Redirect("~/WebFiles/Employee/List_employee.aspx"); 111 } 112 113 else 114 { 115 Response.Write("<script>alert('只有管理员才可以进行此操作!')</script>"); 116 } 117 } 118 else 119 { 120 Response.Redirect("Default.aspx"); ; 121 } 122 } 123} 124
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:人事管理系统(课程设计)源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号