您目前尚未登陆,请选择【登陆】或【注册
首页->行政办公->人事管理系统(课程设计)源码>>WebFiles/User/DisplayUser.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:人事管理系统(课程设计)源码
当前文件:文件类型 Mispersonal/WebFiles/User/DisplayUser.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_User_User_view : System.Web.UI.Page 13{ 14 protected void Page_Load(object sender, EventArgs e) 15 { 16 if (!IsPostBack) 17 { 18 string id=Request["ID"]; 19 string name=Request["userName"]; 20 Session["ID"] = id; 21 Session["userName"] = name; 22 Bond(); 23 } 24 } 25 private void Bond() 26 { 27 string id=(string)Session["ID"]; 28 //string name=Session["userName"]; 29 string sql = "select * from [Tb_User_Login] where ID='" + id + "'"; 30 string connstr = ConfigurationManager.ConnectionStrings["Mispersonalconn"].ConnectionString; 31 SqlConnection Sqlconn = new SqlConnection(connstr); 32 SqlDataAdapter sda = new SqlDataAdapter(sql,Sqlconn); 33 SqlCommandBuilder sc=new SqlCommandBuilder(sda); 34 DataSet ds = new DataSet(); 35 36 sda.Fill(ds,"temp"); 37 ds.Tables["temp"].DefaultView.Sort="id"; 38 int index=ds.Tables["temp"].DefaultView.Find(id); 39 TxtUserID.Text=(string)ds.Tables["temp"].Rows[index]["ID"]; 40 TxtUser.Text=(string)ds.Tables["temp"].Rows[index]["userName"]; 41 TxtPass.Text=(string)ds.Tables["temp"].Rows[index]["userPass"]; 42 TxtPass1.Text=(string)ds.Tables["temp"].Rows[index]["userPass"]; 43 role.SelectedValue=(string)ds.Tables["temp"].Rows[index]["userRole"]; 44 45 } 46 protected void Edit_Click(object sender, EventArgs e) 47 { 48 if ((string)Session["Name"] != "") 49 { 50 if ((string)Session["role"] == "管理员") 51 { 52 string id = (string)Session["ID"]; 53 //string name=Session["userName"]; 54 string sql = "select * from [Tb_User_Login] where ID='" + id + "'"; 55 string connstr = ConfigurationManager.ConnectionStrings["Mispersonalconn"].ConnectionString; 56 SqlConnection Sqlconn = new SqlConnection(connstr); 57 SqlDataAdapter sda = new SqlDataAdapter(sql, Sqlconn); 58 SqlCommandBuilder sc = new SqlCommandBuilder(sda); 59 DataSet ds = new DataSet(); 60 61 sda.Fill(ds, "temp"); 62 ds.Tables["temp"].DefaultView.Sort = "id"; 63 int index = ds.Tables["temp"].DefaultView.Find(id); 64 ds.Tables["temp"].Rows[index]["ID"] = TxtUserID.Text.Trim(); 65 ds.Tables["temp"].Rows[index]["userName"] = TxtUser.Text.Trim(); 66 ds.Tables["temp"].Rows[index]["userPass"] = TxtPass.Text.Trim(); 67 ds.Tables["temp"].Rows[index]["userRole"] = role.SelectedValue.Trim(); 68 int rows = sda.Update(ds, "temp"); 69 lbMessage.Text = "您已成功更新" + rows + "条记录!"; 70 } 71 else 72 { 73 Response.Write("<script>alert('只有管理员才可以进行此操作!')</script>"); 74 } 75 } 76 else 77 { 78 Response.Redirect("Default.aspx"); ; 79 } 80 } 81 protected void Delete_Click(object sender, EventArgs e) 82 { 83 if ((string)Session["Name"] != "") 84 { 85 if ((string)Session["role"] == "管理员") 86 { 87 string id = (string)Session["ID"]; 88 //string name=Session["userName"]; 89 string sql = "delete from [Tb_User_Login] where ID='" + id + "'"; 90 string connstr = ConfigurationManager.ConnectionStrings["Mispersonalconn"].ConnectionString; 91 SqlConnection Sqlconn = new SqlConnection(connstr); 92 Sqlconn.Open(); 93 SqlCommand sc = new SqlCommand(sql, Sqlconn); 94 // SqlDataAdapter sda= new SqlDataAdapter(); 95 // sda.DeleteCommand = sc; 96 sc.ExecuteNonQuery(); 97 Sqlconn.Close(); 98 // DataSet ds = new DataSet(); 99 // DataTable temp = new DataTable(); 100 // sda.Fill(temp); 101 // SqlCommandBuilder scb = new SqlCommandBuilder(sda); 102 // sda.Update(temp); 103 Response.Redirect("~/WebFiles/User/User_List.aspx"); 104 } 105 else 106 { 107 Response.Write("<script>alert('只有管理员才可以进行此操作!')</script>"); 108 } 109 } 110 else 111 { 112 Response.Redirect("Default.aspx"); ; 113 } 114 115 } 116} 117
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:人事管理系统(课程设计)源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号