EmpVita.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 EmpVita : qminoa.Webs.PageBase
  17. {
  18. protected System.Web.UI.WebControls.ValidationSummary ValidationSummary1;
  19. protected System.Web.UI.WebControls.Label lblErr;
  20. protected System.Web.UI.WebControls.Label lblVisaID;
  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 txtPosition;
  27. protected System.Web.UI.WebControls.Label Label3;
  28. protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
  29. protected System.Web.UI.WebControls.LinkButton cmdPosition;
  30. protected System.Web.UI.WebControls.TextBox txtNote;
  31. protected System.Web.UI.WebControls.TextBox txtDepName;
  32. protected System.Web.UI.WebControls.Label Label5;
  33. protected System.Web.UI.WebControls.TextBox txtCompany;
  34. protected System.Web.UI.WebControls.Label Label4;
  35. protected System.Web.UI.WebControls.TextBox txtTDate;
  36. protected System.Web.UI.WebControls.Label Label2;
  37. protected System.Web.UI.WebControls.TextBox txtFDate;
  38. protected System.Web.UI.WebControls.Label Label1;
  39. private const string PARAM_VISAID = "visaID";
  40. protected System.Web.UI.WebControls.Label lblEmpID;
  41. private void Page_Load(object sender, System.EventArgs e)
  42. {
  43. this.PageBegin("人员管理",true);
  44. if(!Page.IsPostBack)
  45. {
  46. FillPage();
  47. }
  48. }
  49. private void FillPage()
  50. {
  51. string str = Request.Params[PARAM_VISAID];
  52. if(str!=null)
  53. {
  54. int visaID = Convert.ToInt16(str,10);
  55. lblVisaID.Text = visaID.ToString();
  56. DataTable visaTB = (new EmpSystem()).GetEmpVisaTB_By_VisaID(visaID);
  57. DataRow row = visaTB.Rows[0];
  58. txtFDate.Text = ((System.DateTime)row[EmpVisaData.FDATE_FIELD]).ToString("d");
  59. txtTDate.Text = ((System.DateTime)row[EmpVisaData.TDATE_FIELD]).ToString("d");
  60. txtCompany.Text = row[EmpVisaData.COMMPANY_FIELD].ToString();
  61. txtDepName.Text = row[EmpVisaData.DEPNAME_FIELD].ToString();
  62. txtPosition.Text = row[EmpVisaData.POSITION_FIELD].ToString();
  63. txtNote.Text = row[EmpVisaData.VISANOTE_FIELD].ToString();
  64. lblEmpID.Text = row["EmpID"].ToString();
  65. }
  66. else
  67. {
  68. lblEmpID.Text = Request.Params["empid"];
  69. }
  70. }
  71. private bool SaveVisaInf()
  72. {
  73. if(this.EmpRightCode  >= 3)
  74. {
  75. bool result;
  76. if(lblVisaID.Text!=string.Empty)
  77. {
  78. EmpVisaData visaData = new EmpVisaData();
  79. DataTable table = visaData.Tables[EmpVisaData.EMPVISA_TABLE_NAME];
  80. DataRow row = table.NewRow();
  81. table.Rows.Add(row);
  82. table.AcceptChanges();
  83. row[EmpVisaData.VISAID_FIELD] = Convert.ToInt16(lblVisaID.Text,10);
  84. row[EmpVisaData.FDATE_FIELD] = Convert.ToDateTime(txtFDate.Text);
  85. row[EmpVisaData.TDATE_FIELD] = Convert.ToDateTime(txtTDate.Text);
  86. row[EmpVisaData.COMMPANY_FIELD] = txtCompany.Text;
  87. row[EmpVisaData.DEPNAME_FIELD] = txtDepName.Text;
  88. row[EmpVisaData.POSITION_FIELD] = txtPosition.Text;
  89. row[EmpVisaData.VISANOTE_FIELD] = txtNote.Text;
  90. result = (new EmpSystem()).UpdateMrVita(visaData);
  91. }
  92. else
  93. {
  94. EmpVisaData visaData = new EmpVisaData();
  95. DataTable table = visaData.Tables[EmpVisaData.EMPVISA_TABLE_NAME];
  96. DataRow row = table.NewRow();
  97. row[EmpBaseData.EMPID_FIELD] = Convert.ToInt16(lblEmpID.Text);
  98. row[EmpVisaData.FDATE_FIELD] = Convert.ToDateTime(txtFDate.Text);
  99. row[EmpVisaData.TDATE_FIELD] = Convert.ToDateTime(txtTDate.Text);
  100. row[EmpVisaData.COMMPANY_FIELD] = txtCompany.Text;
  101. row[EmpVisaData.DEPNAME_FIELD] = txtDepName.Text;
  102. row[EmpVisaData.POSITION_FIELD] = txtPosition.Text;
  103. row[EmpVisaData.VISANOTE_FIELD] = txtNote.Text;
  104. table.Rows.Add(row);
  105. result = (new EmpSystem()).InsertMrVita(visaData);
  106. }
  107. return result;
  108. }
  109. else
  110. {
  111. JScript.Alert("您没有权限进行此操作!");
  112. return false;
  113. }
  114. }
  115. #region Web Form Designer generated code
  116. override protected void OnInit(EventArgs e)
  117. {
  118. //
  119. // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
  120. //
  121. InitializeComponent();
  122. base.OnInit(e);
  123. }
  124. /// <summary>
  125. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  126. /// 此方法的内容。
  127. /// </summary>
  128. private void InitializeComponent()
  129. {    
  130. this.cmdSaveExi.Click += new System.Web.UI.ImageClickEventHandler(this.cmdSaveExi_Click);
  131. this.cmdExit.Click += new System.Web.UI.ImageClickEventHandler(this.cmdExit_Click);
  132. this.Load += new System.EventHandler(this.Page_Load);
  133. }
  134. #endregion
  135. private void cmdSaveExi_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  136. {
  137. if(!SaveVisaInf())
  138. {
  139. JScript.Alert("操作失败!");
  140. }
  141. else
  142. {
  143. JScript.Alert("操作成功!");
  144. Response.Redirect("EmpVisaInf.aspx?PARAM_EMPID="+lblEmpID.Text,false);
  145. }
  146. }
  147. private void cmdExit_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  148. {
  149. Response.Redirect("EmpVisaInf.aspx?PARAM_EMPID="+lblEmpID.Text,false);
  150. }
  151. }
  152. }