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

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.IO;
  12. using System.Data.SqlClient;
  13. public partial class Module_Employee_ProRes_EmployeeInfo : System.Web.UI.Page
  14. {
  15.     static string path;  //保存图片路径
  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.lnkbtnAdd.Visible = true;
  23.             }
  24.         }
  25.         else
  26.         {
  27.             Response.Write("<script language=javascript>top.location.href='../../Index.aspx'</script>");
  28.         }
  29.         SqlData da = new SqlData();
  30.         string cmdtxt = "select * from tb_User";
  31.         this.GridView1.DataSource = da.ExceDS(cmdtxt, "tb_User");
  32.         this.GridView1.DataBind();
  33.         if (!IsPostBack)
  34.         {
  35.             string cmdtxt1 = "select Distinct DepName from tb_Department";
  36.             SqlCommand Com = new SqlCommand(cmdtxt1, da.ExceCon());
  37.             SqlDataReader dr = Com.ExecuteReader();
  38.             while (dr.Read())
  39.             {
  40.                 this.dropDept.Items.Add(dr["DepName"].ToString());
  41.             }
  42.             dr.Close();
  43.         }
  44.     }
  45.     protected void btnFind_Click(object sender, EventArgs e)
  46.     {
  47.         if (this.txtKeyWord.Text == "")
  48.         {
  49.             Response.Write("<script language=javascript>alert('关键字不能为空!');location='EmployeeInfo.aspx'</script>");
  50.             return;
  51.         }
  52.         SqlData da = new SqlData();
  53.         string search = this.dropClass.SelectedValue;
  54.         switch (search)
  55.         {
  56.             case "员工ID":
  57.                 da.BindData(this.GridView1, "Select * From tb_User Where ID  Like  '%" + this.txtKeyWord.Text + "%'", "tb_User");
  58.                 break;
  59.             case "员工姓名":
  60.                 da.BindData(this.GridView1, "Select * From tb_User Where Name  Like  '%" + this.txtKeyWord.Text + "%'", "tb_User");
  61.                 break;
  62.             case "员工学历":
  63.                 da.BindData(this.GridView1, "Select * From tb_User Where Learn  Like  '%" + this.txtKeyWord.Text + "%'", "tb_User");
  64.                 break;
  65.             default:
  66.                 Response.Write("<script lanuage=javascript>alert('出错拉!');location='javascript:history.go(-1)'</script>");
  67.                 break;
  68.         }
  69.     }
  70.     protected void lnkbtnAdd_Click1(object sender, EventArgs e)
  71.     {
  72.         this.Panel3.Visible = false;
  73.         this.Panel1.Visible = true;
  74.     }
  75.     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  76.     {
  77.         this.GridView1.PageIndex = e.NewPageIndex;
  78.         SqlData da = new SqlData();
  79.         string search = this.dropClass.SelectedValue;
  80.         switch (search)
  81.         {
  82.             case "员工ID":
  83.                 da.BindData(this.GridView1, "Select * From tb_User Where ID  Like  '%" + this.txtKeyWord.Text + "%'", "tb_User");
  84.                 break;
  85.             case "员工姓名":
  86.                 da.BindData(this.GridView1, "Select * From tb_User Where Name  Like  '%" + this.txtKeyWord.Text + "%'", "tb_User");
  87.                 break;
  88.             case "员工学历":
  89.                 da.BindData(this.GridView1, "Select * From tb_User Where Learn  Like  '%" + this.txtKeyWord.Text + "%'", "tb_User");
  90.                 break;
  91.             default:
  92.                 Response.Write("<script lanuage=javascript>alert('出错拉!');location='javascript:history.go(-1)'</script>");
  93.                 break;
  94.         }
  95.     }
  96.     protected void btnUpload_Click1(object sender, EventArgs e)
  97.     {
  98.         string str = this.FileUpload1.PostedFile.FileName;
  99.         if (str == "")
  100.         {
  101.             Response.Write("<script language=javascript>alert('请选择上传的图片!')</script>");
  102.             return;
  103.         }
  104.         string ss = str.Substring(str.LastIndexOf("\") + 1);
  105.         string s = Server.MapPath("..\..\Images\Picture\" + ss);
  106.         path = "..\..\Images\Picture\" + ss;
  107.         if (File.Exists(s))
  108.         {
  109.             Response.Write("<script language=javascript>alert('图片已经存在!')</script>");
  110.             return;
  111.         }
  112.         this.FileUpload1.PostedFile.SaveAs(s);
  113.         Image1.ImageUrl = path;
  114.     }
  115.     protected void btnOK_Click(object sender, EventArgs e)
  116.     {
  117.         SqlData da = new SqlData();
  118.         SqlCommand Com = new SqlCommand("select * from tb_User where UserName='" + this.txtUid.Text + "'",da.ExceCon());
  119.         SqlDataReader read = Com.ExecuteReader();
  120.         read.Read();
  121.         if (read.HasRows)
  122.         {
  123.             if (this.txtUid.Text == read["UserName"].ToString())
  124.             {
  125.                 Response.Write("<script language=javascript>alert('对不起,该用户已经注册!');location='javascript:history.go(-1)'</script>");
  126.                 return;
  127.             }
  128.             if (this.txtIdenCard.Text == read["IdenCard"].ToString())
  129.             {
  130.                 Response.Write("<script language=javascript>alert('对不起,该身份证号已经注册!');location='javascript:history.go(-1)'</script>");
  131.                 return;
  132.             }
  133.         }
  134.         read.Close();
  135.         string cmdtxt = "INSERT INTO tb_User(UserName,PassWord,Name,Sex,Birthday,Learn,Picture,DepName,Post,Address,PhoneH";
  136.         cmdtxt += ",PhoneJ,PhoneM,IdenCard,JobTime,JobCompanyTime,NativePlace,Nation,PactStartTime,PactEndTime,IsPost,Popedom,IP,PostCard)";
  137.         cmdtxt +=" VALUES('"+this.txtUid.Text+"','"+this.txtPwd.Text+"','"+this.txtName.Text+"','"+this.RadioButtonList1.SelectedValue+"'";
  138.         cmdtxt += ",'"+this.txtBirthday.Text+"','"+this.txtLearn.Text+"','"+path+"','"+this.dropDept.SelectedValue+"'";
  139.         cmdtxt += ",'"+this.txtPost.Text+"','"+this.txtAddress.Text+"','"+this.txtPhoneH.Text+"','"+this.txtPhoneJ.Text+"'";
  140.         cmdtxt += ",'"+this.txtPhoneM.Text+"','"+this.txtIdenCard.Text+"','"+this.txtJobTime.Text+"','"+this.txtJobCompanyTime.Text+"'";
  141.         cmdtxt += ",'"+this.txtNaPlace.Text+"','"+this.txtNation.Text+"','"+this.txtPactStart.Text+"','"+this.txtPactEnd.Text+"'";
  142.         cmdtxt += ",'"+this.RadioButtonList2.SelectedValue+"','"+this.RadioButtonList3.SelectedIndex+"','"+Request.UserHostAddress+"','"+this.txtPostCard.Text+"')";
  143.         if (da.ExceSQL(cmdtxt))
  144.         {
  145.             Response.Write("<script language=javascript>alert('操作成功!');location='EmployeeInfo.aspx'</script>");
  146.         }
  147.         else
  148.         {
  149.             Response.Write("<script language=javascript>alert('操作失败!')</script>");
  150.         }
  151.     }
  152.     protected void btnVial_Click(object sender, EventArgs e)
  153.     {
  154.         SqlData da = new SqlData();
  155.         SqlCommand Com = new SqlCommand("select * from tb_User where UserName='" + this.txtUid.Text + "'", da.ExceCon());
  156.         SqlDataReader read = Com.ExecuteReader();
  157.         read.Read();
  158.         if (read.HasRows)
  159.         {
  160.             if (this.txtUid.Text == read["UserName"].ToString())
  161.             {
  162.                 Response.Write("<script language=javascript>alert('对不起,该用户已经注册!')</script>");
  163.             }
  164.         }
  165.         else
  166.         {
  167.             Response.Write("<script language=javascript>alert('恭喜您,该用户可以注册!')</script>");
  168.         }
  169.         read.Close();
  170.     }
  171.     protected void btnBack_Click(object sender, EventArgs e)
  172.     {
  173.         Response.Write("<script>this.parent.rightFrame.location='EmployeeInfo.aspx'</script>");
  174.     }
  175. }