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

.net编程

开发平台:

Others

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Web;
  7. using System.Web.SessionState;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.HtmlControls;
  11. using qminoa.BLL;
  12. using qminoa.Common;
  13. using qminoa.Common.Data;
  14. namespace qminoa.Webs.MR
  15. {
  16. public class EmpCont : qminoa.Webs.PageBase
  17. {
  18. protected System.Web.UI.WebControls.ValidationSummary ValidationSummary1;
  19. protected System.Web.UI.WebControls.Label lblConID;
  20. protected System.Web.UI.WebControls.Label lblErr;
  21. protected System.Web.UI.WebControls.ImageButton cmdExit;
  22. protected System.Web.UI.WebControls.ImageButton cmdSaveExi;
  23. protected System.Web.UI.WebControls.RangeValidator RangeValidator2;
  24. protected System.Web.UI.WebControls.RangeValidator RangeValidator1;
  25. protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
  26. protected System.Web.UI.WebControls.TextBox txtAnnSala;
  27. protected System.Web.UI.WebControls.Label Label8;
  28. protected System.Web.UI.WebControls.DropDownList dropStatus;
  29. protected System.Web.UI.WebControls.Label Label7;
  30. protected System.Web.UI.WebControls.DropDownList dropCate;
  31. protected System.Web.UI.WebControls.Label Label6;
  32. protected System.Web.UI.WebControls.Label Label3;
  33. protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
  34. protected System.Web.UI.WebControls.TextBox txtNote;
  35. protected System.Web.UI.WebControls.TextBox txtSalaLevl;
  36. protected System.Web.UI.WebControls.Label Label5;
  37. protected System.Web.UI.WebControls.TextBox txtPosiLevl;
  38. protected System.Web.UI.WebControls.Label Label4;
  39. protected System.Web.UI.WebControls.TextBox txtTDate;
  40. protected System.Web.UI.WebControls.Label Label2;
  41. protected System.Web.UI.WebControls.TextBox txtFDate;
  42. protected System.Web.UI.WebControls.Label Label1;
  43. protected System.Web.UI.WebControls.Label lblEmpID;
  44. private const string PARAM_CONID = "ConID";
  45. private void Page_Load(object sender, System.EventArgs e)
  46. {
  47. this.PageBegin("人员管理",true);
  48. if(Page.IsPostBack)
  49. {
  50. return;
  51. }
  52. FillPage();
  53. }
  54. /// <summary>
  55. /// 
  56. /// </summary>
  57. private void FillPage()
  58. {
  59. string str = Request.Params[PARAM_CONID];
  60. if(str!=null)
  61. {
  62. int conID = Convert.ToInt16(str,10);
  63. lblConID.Text = conID.ToString();
  64. DataTable table = (new EmpSystem()).GetEmpConTB_By_ConID(conID);
  65. DataRow row = table.Rows[0];
  66. dropCate.SelectedIndex = -1;
  67. foreach(ListItem item in dropCate.Items)
  68. {
  69. if(item.Text==row[EmpConData.CATETORY_FIELD].ToString())
  70. item.Selected = true;
  71. }
  72. txtFDate.Text = ((DateTime)row[EmpConData.FDATE_FIELD]).ToString("d");
  73. txtTDate.Text = ((DateTime)row[EmpConData.TDATE_FIELD]).ToString("d");
  74. txtPosiLevl.Text = row[EmpConData.POSILEVL_FIELD].ToString();
  75. txtSalaLevl.Text = row[EmpConData.SALALEVL_FIELD].ToString();
  76. txtAnnSala.Text = row[EmpConData.ANNSALA_FIELD].ToString();
  77. txtNote.Text = row[EmpConData.CONNOTE_FIELD].ToString();
  78. lblEmpID.Text = row["EmpID"].ToString();
  79. dropStatus.SelectedIndex = -1;
  80. foreach(ListItem item in dropStatus.Items)
  81. {
  82. if(item.Text==row[EmpConData.STATUS_FIELD].ToString())
  83. item.Selected = true;
  84. }
  85. }
  86. else
  87. {
  88. lblEmpID.Text = Request.Params["empid"];
  89. }
  90. }
  91. private bool SaveConInf()
  92. {
  93. if(this.EmpRightCode  >= 3)
  94. {
  95. bool result;
  96. if(lblConID.Text!=string.Empty)
  97. {
  98. EmpConData data = new EmpConData();
  99. DataTable table = data.Tables[EmpConData.EMPCONTACT_TABLE_NAME];
  100. DataRow row = table.NewRow();
  101. table.Rows.Add(row);
  102. table.AcceptChanges();
  103. row[EmpConData.CONID_FIELD] = Convert.ToInt16(lblConID.Text,10);
  104. row[EmpConData.FDATE_FIELD] = Convert.ToDateTime(txtFDate.Text);
  105. row[EmpConData.TDATE_FIELD] = Convert.ToDateTime(txtTDate.Text);
  106. row[EmpConData.CATETORY_FIELD] = dropCate.SelectedItem.Text;
  107. row[EmpConData.POSILEVL_FIELD] = txtPosiLevl.Text;
  108. row[EmpConData.SALALEVL_FIELD] = txtSalaLevl.Text;
  109. row[EmpConData.ANNSALA_FIELD] = txtAnnSala.Text;
  110. row[EmpConData.STATUS_FIELD] = dropStatus.SelectedItem.Text;
  111. row[EmpConData.CONNOTE_FIELD] = txtNote.Text;
  112. result = (new EmpSystem()).UpdateMrContact(data);
  113. }
  114. else
  115. {
  116. EmpConData data = new EmpConData();
  117. DataTable table = data.Tables[EmpConData.EMPCONTACT_TABLE_NAME];
  118. DataRow row = table.NewRow();
  119. row[EmpBaseData.EMPID_FIELD] = Convert.ToInt16(lblEmpID.Text);
  120. row[EmpConData.FDATE_FIELD] = Convert.ToDateTime(txtFDate.Text);
  121. row[EmpConData.TDATE_FIELD] = Convert.ToDateTime(txtTDate.Text);
  122. row[EmpConData.CATETORY_FIELD] = dropCate.SelectedItem.Text;
  123. row[EmpConData.POSILEVL_FIELD] = txtPosiLevl.Text;
  124. row[EmpConData.SALALEVL_FIELD] = txtSalaLevl.Text;
  125. row[EmpConData.ANNSALA_FIELD] = txtAnnSala.Text;
  126. row[EmpConData.STATUS_FIELD] = dropStatus.SelectedItem.Text;
  127. row[EmpConData.CONNOTE_FIELD] = txtNote.Text;
  128. table.Rows.Add(row);
  129. result = (new EmpSystem()).InsertMrContact(data);
  130. }
  131. return result;
  132. }
  133. else
  134. {
  135. JScript.Alert("您没有权限进行此操作!");
  136. return false;
  137. }
  138. }
  139. #region Web Form Designer generated code
  140. override protected void OnInit(EventArgs e)
  141. {
  142. //
  143. // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
  144. //
  145. InitializeComponent();
  146. base.OnInit(e);
  147. }
  148. /// <summary>
  149. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  150. /// 此方法的内容。
  151. /// </summary>
  152. private void InitializeComponent()
  153. {    
  154. this.cmdSaveExi.Click += new System.Web.UI.ImageClickEventHandler(this.cmdSaveExi_Click);
  155. this.cmdExit.Click += new System.Web.UI.ImageClickEventHandler(this.cmdExit_Click);
  156. this.Load += new System.EventHandler(this.Page_Load);
  157. }
  158. #endregion
  159. private void cmdSaveExi_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  160. {
  161. if(!SaveConInf())
  162. JScript.Alert("操作失败!");
  163. else
  164. Response.Redirect("EmpContInf.aspx?PARAM_EMPID="+lblEmpID.Text,false);
  165. }
  166. private void cmdExit_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  167. {
  168. Response.Redirect("EmpContInf.aspx?PARAM_EMPID="+lblEmpID.Text,false);
  169. }
  170. }
  171. }