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

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_ProRes_DeptAllInfo : 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.Panel1.Visible = true;
  21.             }
  22.         }
  23.         else
  24.         {
  25.             Response.Write("<script language=javascript>top.location.href='../../Index.aspx'</script>");
  26.         }
  27.         if (!IsPostBack)
  28.         {
  29.             SqlData da = new SqlData();
  30.             string str = Request["ID"].ToString();
  31.             string cmdtxt1 = "select * from tb_Department where ID='" + str + "'";
  32.             SqlCommand Com1 = new SqlCommand(cmdtxt1, da.ExceCon());
  33.             SqlDataReader dr1 = Com1.ExecuteReader();
  34.             dr1.Read();
  35.             if (dr1.HasRows)
  36.             {
  37.                 this.txtDeptName.Text = dr1["DepName"].ToString();
  38.                 this.txtDeptManager.Text = dr1["DepManager"].ToString();
  39.                 this.txtDeptAddress.Text = dr1["DepAddress"].ToString();
  40.                 this.txtDeptPhone.Text = dr1["DepPhone"].ToString();
  41.                 this.txtDescript.Text = dr1["DepDescription"].ToString();
  42.                 this.txtPostCard.Text = dr1["DepPost"].ToString();
  43.                 this.txtBaseTime.Text = Convert.ToDateTime(dr1["DepBaseTime"]).ToString("yyyy-MM-dd");
  44.             }
  45.             dr1.Close();
  46.             string cmdtxt2 = "select * from tb_User";
  47.             SqlCommand Com2 = new SqlCommand(cmdtxt2,da.ExceCon());
  48.             SqlDataReader dr2 = Com2.ExecuteReader();
  49.             while (dr2.Read())
  50.             {
  51.                 this.DropDownList1.Items.Add(dr2["Name"].ToString());
  52.             }
  53.             dr2.Close();
  54.         }
  55.     }
  56.     protected void btnEdit_Click(object sender, EventArgs e)
  57.     {
  58.         this.Panel2.Visible = false;
  59.         this.Panel3.Visible = true;
  60.         this.btnSave.Enabled = true ;
  61.         this.btnDelete.Enabled = true;
  62.         this.txtBaseTime.ReadOnly = false;
  63.         this.txtDeptAddress.ReadOnly = false;
  64.         this.txtDeptPhone.ReadOnly = false;
  65.         this.txtDescript.ReadOnly = false;
  66.         this.txtPostCard.ReadOnly = false;
  67.     }
  68.     protected void btnSave_Click(object sender, EventArgs e)
  69.     {
  70.         string cmdtxt = "Update tb_Department set DepName='" + this.txtDeptName.Text + "',DepManager='" + this.DropDownList1.SelectedValue + "'";
  71.         cmdtxt += ",DepPhone='" + this.txtDeptPhone.Text + "',DepBaseTime='" + this.txtBaseTime.Text + "',DepPost='" + this.txtPostCard.Text + "'";
  72.         cmdtxt += ",DepAddress='" + this.txtDeptAddress.Text + "',DepDescription='" + this.txtDescript.Text + "' where ID='"+Request["ID"].ToString()+"'";
  73.         SqlData da = new SqlData();
  74.         if (da.ExceSQL(cmdtxt))
  75.         {
  76.             Response.Write("<script language=javascript>alert('操作成功!');location='DeptInfo.aspx'</script>");
  77.         }
  78.         else
  79.         {
  80.             Response.Write("<script language=javascript>alert('操作失败!');location='javascript:history.go(-1)'</script>");
  81.         }
  82.     }
  83.     protected void btnDelete_Click(object sender, EventArgs e)
  84.     {
  85.         string cmdtxt = "DELETE FROM tb_Department where ID='"+Request["ID"].ToString()+"'";
  86.         SqlData da = new SqlData();
  87.         if (da.ExceSQL(cmdtxt))
  88.         {
  89.             Response.Write("<script language=javascript>alert('操作成功!');this.parent.rightFrame.location='DeptInfo.aspx'</script>");
  90.         }
  91.         else
  92.         {
  93.             Response.Write("<script language=javascript>alert('操作失败!');location='javascript:history.go(-1)'</script>");
  94.         }      
  95.     }
  96.     protected void btnBack_Click(object sender, EventArgs e)
  97.     {
  98.         Response.Write("<script>this.parent.rightFrame.location='DeptInfo.aspx'</script>");
  99.     }
  100. }