EmployeeAllInfo.aspx.cs
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:7k
源码类别:

Email客户端

开发平台:

Visual C++

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.SqlClient;
  12. using System.Text;
  13. using System.IO;
  14. public partial class Module_ProRes_EmployeeAllInfo : System.Web.UI.Page
  15. {
  16.     protected void Page_Load(object sender, EventArgs e)
  17.     {
  18.         if (Session["UserName"] != null)
  19.         {
  20.             if (Session["Popedom"].ToString() == "0")
  21.             {
  22.                 this.Panel1.Visible = true;
  23.             }
  24.         }
  25.         else
  26.         {
  27.             Response.Write("<script language=javascript>top.location.href='../../Index.aspx'</script>");
  28.         }
  29.         if (!IsPostBack)
  30.         {
  31.             string cmdtxt = "select * from tb_User where ID='" + Request["ID"].ToString() + "'";
  32.             SqlData da = new SqlData();
  33.             SqlCommand Com = new SqlCommand(cmdtxt, da.ExceCon());
  34.             SqlDataReader dr = Com.ExecuteReader();
  35.             dr.Read();
  36.             if (dr.HasRows)
  37.             {
  38.                 this.txtUid.Text = dr["UserName"].ToString();
  39.                 this.txtPwd.Text = dr["PassWord"].ToString();
  40.                 this.txtPost.Text = dr["Post"].ToString();
  41.                 this.txtPostCard.Text = dr["PostCard"].ToString();
  42.                 this.txtAddress.Text = dr["Address"].ToString();
  43.                 this.txtBirthday.Text = Convert.ToDateTime(dr["Birthday"]).ToString("yyyy-MM-dd");
  44.                 this.txtIdenCard.Text = dr["IdenCard"].ToString();
  45.                 this.txtIP.Text = dr["IP"].ToString();
  46.                 this.txtJobCompanyTime.Text = Convert.ToDateTime(dr["JobCompanyTime"]).ToString("yyyy-MM-dd");
  47.                 this.txtJobTime.Text = Convert.ToDateTime(dr["JobTime"]).ToString("yyyy-MM-dd");
  48.                 this.txtLearn.Text = dr["Learn"].ToString();
  49.                 this.txtName.Text = dr["Name"].ToString();
  50.                 this.txtNaPlace.Text = dr["NativePlace"].ToString();
  51.                 this.txtNation.Text = dr["Nation"].ToString();
  52.                 this.txtPactEnd.Text = Convert.ToDateTime(dr["PactEndTime"]).ToString("yyyy-MM-dd");
  53.                 this.txtPactStart.Text = Convert.ToDateTime(dr["PactStartTime"]).ToString("yyyy-MM-dd");
  54.                 this.txtPhoneH.Text = dr["PhoneH"].ToString();
  55.                 this.txtPhoneJ.Text = dr["PhoneJ"].ToString();
  56.                 this.txtPhoneM.Text = dr["PhoneM"].ToString();
  57.                 this.RadioButtonList1.SelectedValue = dr["Sex"].ToString();
  58.                 this.RadioButtonList2.SelectedValue = dr["IsPost"].ToString();
  59.                 this.RadioButtonList3.SelectedIndex = Convert.ToInt32(dr["Popedom"].ToString());
  60.                 this.Image1.ImageUrl = dr["Picture"].ToString();
  61.                 this.txtDepartment.Text = dr["DepName"].ToString();
  62.             }
  63.             string cmdtxt1 = "select * from tb_Department";
  64.             SqlCommand Com1 = new SqlCommand(cmdtxt1, da.ExceCon());
  65.             SqlDataReader dr1 = Com1.ExecuteReader();
  66.             while (dr1.Read())
  67.             {
  68.                 this.dropDept.Items.Add(dr1["DepName"].ToString());
  69.             }
  70.             dr1.Close();
  71.         }
  72.     }
  73.     protected void btnEdit_Click(object sender, EventArgs e)
  74.     {
  75.         this.txtAddress.ReadOnly = false;
  76.         this.txtBirthday.ReadOnly = false;
  77.         this.txtIdenCard.ReadOnly = false;
  78.         this.txtJobCompanyTime.ReadOnly = false;
  79.         this.txtJobTime.ReadOnly = false;
  80.         this.txtLearn.ReadOnly = false;
  81.         this.txtName.ReadOnly = false;
  82.         this.txtNaPlace.ReadOnly = false;
  83.         this.txtNation.ReadOnly = false;
  84.         this.txtPactEnd.ReadOnly = false;
  85.         this.txtPactStart.ReadOnly = false;
  86.         this.txtPhoneH.ReadOnly = false;
  87.         this.txtPhoneJ.ReadOnly = false;
  88.         this.txtPhoneM.ReadOnly = false;
  89.         this.txtPost.ReadOnly = false;
  90.         this.txtPostCard.ReadOnly = false;
  91.         this.txtPwd.ReadOnly = false;
  92.         this.txtUid.ReadOnly = false;
  93.         this.RadioButtonList1.Enabled = true;
  94.         this.RadioButtonList2.Enabled = true;
  95.         this.RadioButtonList3.Enabled = true;
  96.         this.btnDelete.Enabled = true;
  97.         this.btnSave.Enabled = true;
  98.         this.Panel2.Visible = false;
  99.         this.Panel3.Visible = true;
  100.     }
  101.     protected void btnDelete_Click(object sender, EventArgs e)
  102.     {
  103.         string mappath=null ;
  104.         string cmdtxt1 = "select * from tb_User where ID='" + Request["ID"].ToString() + "'";
  105.         SqlData da = new SqlData();
  106.         SqlCommand Com = new SqlCommand(cmdtxt1, da.ExceCon());
  107.         SqlDataReader dr = Com.ExecuteReader();
  108.         dr.Read();
  109.         if (dr.HasRows)
  110.         {
  111.             mappath = Server.MapPath(dr["Picture"].ToString());
  112.             FileInfo file = new FileInfo(mappath);
  113.             if (file.Exists)
  114.             {
  115.                 file.Delete();
  116.             }
  117.         }
  118.         string cmdtxt = "DELETE FROM tb_User where ID='" + Request["ID"].ToString() + "'";
  119.         if (da.ExceSQL(cmdtxt))
  120.         {
  121.             Response.Write("<script language=javascript>alert('操作成功!');location='EmployeeInfo.aspx'</script>");
  122.             CommonClass.WriteNote(Request["ID"].ToString(), 3, Session["UserName"].ToString());
  123.         }
  124.         else
  125.         {
  126.             Response.Write("<script language=javascript>alert('操作失败!');location='javascript:history.go(-1)'</script>");
  127.         }
  128.     }
  129.     protected void btnSave_Click(object sender, EventArgs e)
  130.     {
  131.         SqlData da = new SqlData();
  132.         string cmdtxt = "UPDATE tb_User SET UserName='"+this.txtUid.Text+"',PassWord='"+this.txtPwd.Text+"',Name='"+this.txtName.Text+"'";
  133.         cmdtxt +=",Sex='"+this.RadioButtonList1.SelectedValue+"',Birthday='"+this.txtBirthday.Text+"',Learn='"+this.txtLearn.Text+"'";
  134.         cmdtxt += ",DepName='" + this.dropDept.SelectedValue + "',Post='" + this.txtPost.Text + "',Address='" + this.txtAddress.Text + "',PhoneH='" + this.txtPhoneH.Text + "'";
  135.         cmdtxt += ",PhoneJ='"+this.txtPhoneJ.Text+"',PhoneM='"+this.txtPhoneM.Text+"',IdenCard='"+this.txtIdenCard.Text+"'";
  136.         cmdtxt +=",JobTime='"+this.txtJobTime.Text+"',JobCompanyTime='"+this.txtJobCompanyTime.Text+"',NativePlace='"+this.txtNaPlace.Text+"'";
  137.         cmdtxt +=",Nation='"+this.txtNation.Text+"',PactStartTime='"+this.txtPactStart.Text+"',PactEndTime='"+this.txtPactEnd.Text+"'";
  138.         cmdtxt +=",IsPost='"+this.RadioButtonList2.SelectedValue+"',Popedom='"+this.RadioButtonList3.SelectedIndex+"' where ID='"+Request["ID"].ToString()+"'";
  139.         if (da.ExceSQL(cmdtxt))
  140.         {
  141.             Response.Write("<script language=javascript>alert('操作成功!');location='EmployeeInfo.aspx'</script>");
  142.         }
  143.         else
  144.         {
  145.             Response.Write("<script language=javascript>alert('操作失败!');location='javascript:history.go(-1)'</script>");
  146.         }
  147.     }
  148.     protected void btnBack_Click(object sender, EventArgs e)
  149.     {
  150.         Response.Write("<script>this.parent.rightFrame.location='EmployeeInfo.aspx'</script>");
  151.     }
  152. }