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

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. public partial class Module_Employee_ProRes_DeptInfo : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         if (Session["UserName"] != null)
  17.         {
  18.             if (Session["Popedom"].ToString() == "0")
  19.             {
  20.                 this.lnkbtnAdd.Visible = true;
  21.             }
  22.         }
  23.         else
  24.         {
  25.             Response.Write("<script language=javascript>top.location.href='../../Index.aspx'</script>");
  26.         }
  27.         SqlData da = new SqlData();
  28.         string cmdtxt1 = "select * from tb_Department";
  29.         this.GridView1.DataSource = da.ExceDS(cmdtxt1, "tb_Department");
  30.         this.GridView1.DataKeyNames = new string[] { "ID"};
  31.         this.GridView1.DataBind();
  32.         if (!IsPostBack)
  33.         {
  34.             string cmdtxt2 = "select Distinct Name from tb_User";
  35.             SqlDataReader dr = da.ExceDr(cmdtxt2);
  36.             while (dr.Read())
  37.             {
  38.                 this.DropDownList1.Items.Add(dr["Name"].ToString());
  39.             }
  40.             dr.Close();
  41.         }  
  42.     }
  43.     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  44.     {
  45.        this.GridView1.PageIndex = e.NewPageIndex;
  46.        SqlData da = new SqlData();
  47.        string search = this.dropClass.SelectedValue;
  48.        switch (search)
  49.        {
  50.            case "部门ID":
  51.                da.BindData(this.GridView1, "Select * From tb_Department Where ID  Like  '%" + this.txtKeyWord.Text + "%'", "tb_Department");
  52.                break;
  53.            case "部门名称":
  54.                da.BindData(this.GridView1, "Select * From tb_Department Where DepName  Like  '%" + this.txtKeyWord.Text + "%'", "tb_Department");
  55.                break;
  56.            case "部门经理":
  57.                da.BindData(this.GridView1, "Select * From tb_Department Where DepManager  Like  '%" + this.txtKeyWord.Text + "%'", "tb_Department");
  58.                break;
  59.            default:
  60.                Response.Write("<script lanuage=javascript>alert('出错拉!');location='javascript:history.go(-1)'</script>");
  61.                break;
  62.        }
  63.    }
  64.     protected void lnkbtnAdd_Click1(object sender, EventArgs e)
  65.     {
  66.         this.Panel3.Visible = false;
  67.         this.Panel1.Visible = true;
  68.     }
  69.     protected void btnOK_Click(object sender, EventArgs e)
  70.     {
  71.         string cmdtxt = "INSERT INTO tb_Department(DepName,DepManager,DepPhone,DepBaseTime,DepPost,DepAddress,DepDescription) VALUES('" + this.txtDeptName.Text + "','" + this.DropDownList1.SelectedValue + "'";
  72.         cmdtxt += ",'" + this.txtDeptPhone.Text + "','" + this.txtBaseTime.Text + "','" + this.txtPostCard.Text + "'";
  73.         cmdtxt += ",'" + this.txtDeptAddress.Text + "','" + this.txtDescript.Text + "')";
  74.         SqlData da = new SqlData();
  75.         if (da.ExceSQL(cmdtxt))
  76.         {
  77.             Response.Write("<script language=javascript>alert('操作成功!');location='DeptInfo.aspx'</script>");
  78.             CommonClass.WriteNote(this.txtDeptName.Text, 0, Session["UserName"].ToString());
  79.         }
  80.         else
  81.         {
  82.             Response.Write("<script language=javascript>alert('操作失败!');location='javascript:history.go(-1)'</script>");
  83.         }
  84.     }
  85.     protected void btnFind_Click(object sender, EventArgs e)
  86.     {
  87.         if (this.txtKeyWord.Text == "")
  88.         {
  89.             Response.Write("<script language=javascript>alert('关键字不能为空!');location='DeptInfo.aspx'</script>");
  90.             return;
  91.         }
  92.         SqlData da = new SqlData();
  93.         string search = this.dropClass.SelectedValue;
  94.         switch (search)
  95.         {
  96.             case "部门ID":
  97.                 da.BindData(this.GridView1, "Select * From tb_Department Where ID  Like  '%" + this.txtKeyWord.Text + "%'", "tb_Department");
  98.                 break;
  99.             case "部门名称":
  100.                 da.BindData(this.GridView1, "Select * From tb_Department Where DepName  Like  '%" + this.txtKeyWord.Text + "%'", "tb_Department");
  101.                 break;
  102.             case "部门经理":
  103.                 da.BindData(this.GridView1, "Select * From tb_Department Where DepManager  Like  '%" + this.txtKeyWord.Text + "%'", "tb_Department");
  104.                 break;
  105.             default:
  106.                 Response.Write("<script lanuage=javascript>alert('出错拉!');location='javascript:history.go(-1)'</script>");
  107.                 break;
  108.         }
  109.     }
  110.     protected void btnBack_Click(object sender, EventArgs e)
  111.     {
  112.         Response.Write("<script>this.parent.rightFrame.location='DeptInfo.aspx'</script>");
  113.     }
  114. }