DepUp.aspx.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:5k
源码类别:

.net编程

开发平台:

Others

  1. using System;
  2. using System.Data;
  3. using System.Web;
  4. using System.Web.UI;
  5. using System.Web.UI.WebControls;
  6. using qminoa.BLL;
  7. using qminoa.Common;
  8. using qminoa.Common.Data;
  9. namespace qminoa.Webs.MR
  10. {
  11. public class DepAddUp : qminoa.Webs.PageBase
  12. {
  13. protected System.Web.UI.WebControls.Label lblDepID;
  14. protected System.Web.UI.WebControls.Label lblErr;
  15. protected System.Web.UI.WebControls.ValidationSummary ValidationSummary1;
  16. protected System.Web.UI.WebControls.ImageButton cmdExi;
  17. protected System.Web.UI.WebControls.ImageButton cmdSaveExi;
  18. protected System.Web.UI.WebControls.DropDownList lstBranch;
  19. protected System.Web.UI.WebControls.RequiredFieldValidator valName;
  20. protected System.Web.UI.WebControls.TextBox txtPostCode;
  21. protected System.Web.UI.WebControls.Label Label13;
  22. protected System.Web.UI.WebControls.Label Label12;
  23. protected System.Web.UI.WebControls.Label Label11;
  24. protected System.Web.UI.WebControls.TextBox txtStreet;
  25. protected System.Web.UI.WebControls.Label Label10;
  26. protected System.Web.UI.WebControls.TextBox txtDistrict;
  27. protected System.Web.UI.WebControls.Label Label9;
  28. protected System.Web.UI.WebControls.TextBox txtCity;
  29. protected System.Web.UI.WebControls.Label Label8;
  30. protected System.Web.UI.WebControls.TextBox txtProvince;
  31. protected System.Web.UI.WebControls.Label Label7;
  32. protected System.Web.UI.WebControls.TextBox txtTel2;
  33. protected System.Web.UI.WebControls.Label Label6;
  34. protected System.Web.UI.WebControls.TextBox txtTel1;
  35. protected System.Web.UI.WebControls.Label Label5;
  36. protected System.Web.UI.WebControls.TextBox txtFax;
  37. protected System.Web.UI.WebControls.Label Label4;
  38. protected System.Web.UI.WebControls.TextBox txtManager;
  39. protected System.Web.UI.WebControls.Label Label3;
  40. protected System.Web.UI.WebControls.TextBox txtName;
  41. protected System.Web.UI.WebControls.Label Label1;
  42. private string PARAM_KEY_DEPID = "DepID";
  43. private void Page_Load(object sender, System.EventArgs e)
  44. {
  45. this.PageBegin("部门管理",true);
  46. if(!Page.IsPostBack)
  47. {
  48. DataBind();
  49. FillPage();
  50. }
  51. }
  52. private void FillPage()
  53. {
  54. int depID = Convert.ToInt32(Request.Params[PARAM_KEY_DEPID],10);
  55. DataTable depTB = (new DepSystem()).GetDepTB_By_DepID(depID);
  56. DataRow row = depTB.Rows[0];
  57. lblDepID.Text = row[DepData.DEPID_FIELD].ToString();
  58. txtName.Text = row[DepData.DEPNAME_FIELD].ToString();
  59. txtManager.Text = row[DepData.MANAGER_FIELD].ToString();
  60. txtTel1.Text = row[DepData.TEL1_FIELD].ToString();
  61. txtTel2.Text = row[DepData.TEL2_FIELD].ToString();
  62. txtFax.Text = row[DepData.FAX_FIELD].ToString();
  63. txtPostCode.Text = row[DepData.POSTCODE_FIELD].ToString();
  64. txtProvince.Text = row[DepData.PROVINCE_FIELD].ToString();
  65. txtCity.Text = row[DepData.CITY_FIELD].ToString();
  66. txtDistrict.Text = row[DepData.DISTRICT_FIELD].ToString();
  67. txtStreet.Text = row[DepData.STREET_FIELD].ToString();
  68. int branchID = (int)row[DepData.BRANCHID_FIELD];
  69. foreach(ListItem item in lstBranch.Items)
  70. {
  71. if(Convert.ToInt32(item.Value,10) == branchID)
  72. item.Selected = true;
  73. }
  74. }
  75. public void UpdateDep()
  76. {
  77. DepData depData = new DepData();
  78. DataTable depTB = depData.Tables[DepData.DEP_TABLE_NAME]; 
  79. DataRow row = depTB.NewRow();
  80. depTB.Rows.Add(row);
  81. depTB.AcceptChanges();
  82. row[DepData.DEPID_FIELD] = Convert.ToInt32(lblDepID.Text,10);
  83. row[DepData.BRANCHID_FIELD] = Convert.ToInt32(lstBranch.SelectedItem.Value,10);
  84. row[DepData.DEPNAME_FIELD] = txtName.Text;
  85. row[DepData.MANAGER_FIELD] = txtManager.Text;
  86. row[DepData.TEL1_FIELD] = txtTel1.Text;
  87. row[DepData.TEL2_FIELD] = txtTel2.Text;
  88. row[DepData.FAX_FIELD] = txtFax.Text;
  89. row[DepData.POSTCODE_FIELD] = txtPostCode.Text;
  90. row[DepData.PROVINCE_FIELD] = txtProvince.Text;
  91. row[DepData.CITY_FIELD] = txtCity.Text;
  92. row[DepData.DISTRICT_FIELD] = txtDistrict.Text;
  93. row[DepData.STREET_FIELD] = txtStreet.Text;
  94. bool result = (new DepSystem()).UpdateDep(depData);
  95. }
  96. public DataTable BraTB
  97. {
  98. get
  99. {
  100. DataTable braTB = (new DepSystem()).GetBraTB();
  101. return braTB;
  102. }
  103. }
  104. #region Web Form Designer generated code
  105. override protected void OnInit(EventArgs e)
  106. {
  107. //
  108. // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
  109. //
  110. InitializeComponent();
  111. base.OnInit(e);
  112. }
  113. /// <summary>
  114. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  115. /// 此方法的内容。
  116. /// </summary>
  117. private void InitializeComponent()
  118. {    
  119. this.cmdSaveExi.Click += new System.Web.UI.ImageClickEventHandler(this.cmdSaveExi_Click);
  120. this.cmdExi.Click += new System.Web.UI.ImageClickEventHandler(this.cmdExi_Click);
  121. this.Load += new System.EventHandler(this.Page_Load);
  122. }
  123. #endregion
  124. private void cmdSaveExi_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  125. {
  126. if(this.EmpRightCode  >= 3)
  127. {
  128. UpdateDep();
  129. Response.Redirect("./DepInf.aspx",false);
  130. }
  131. else
  132. JScript.Alert("您没有权限进行此操作!");
  133. }
  134. private void cmdExi_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  135. {
  136. Response.Redirect("./DepInf.aspx",false);
  137. }
  138. }
  139. }