/EQT_V1/EQTWebApp/EquipKeptReg.aspx.cs

http://sgsoft-las.googlecode.com/ · C# · 143 lines · 109 code · 20 blank · 14 comment · 12 complexity · eb55b18237e9baa97f1bb91e44052c87 MD5 · raw file

  1. /*----------------------------------------------------------------
  2. // Copyright (C) 2009
  3. // ?????
  4. //
  5. // ????
  6. // ???????????????
  7. //
  8. //
  9. // ?????
  10. // ????????
  11. // ?????
  12. // ?????
  13. //----------------------------------------------------------------*/
  14. using System;
  15. using System.Data;
  16. using System.Configuration;
  17. using System.Collections;
  18. using System.Web;
  19. using System.Web.Security;
  20. using System.Web.UI;
  21. using System.Web.UI.WebControls;
  22. using System.Web.UI.WebControls.WebParts;
  23. using System.Web.UI.HtmlControls;
  24. using EQT.Dal;
  25. using System.Threading;
  26. using EQT.Model;
  27. using Wuqi.Webdiyer;
  28. public partial class EquipKeptReg : System.Web.UI.Page
  29. {
  30. private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  31. private DaKeptLog dalKept = new DaKeptLog();
  32. private DaDept dalDept = new DaDept();
  33. private DaEmployee dalEmp = new DaEmployee();
  34. private UserContext context;
  35. protected void Page_Load(object sender, EventArgs e)
  36. {
  37. context = Session["USER_CONTEXT"] as UserContext;
  38. OperationResult.Text = "";
  39. divResult.Visible = false;
  40. if (!IsPostBack)
  41. {
  42. DataSet dsDept = dalDept.Query(string.Empty);
  43. Utility.BindDataSet2Combox(dsDept, CreateDdlDeptID1, "Dept_Name", "Dept_ID");
  44. Utility.BindDataSet2Combox(dsDept, CreateDdlDeptID2, "Dept_Name", "Dept_ID");
  45. CreateDdlDeptID1.Items.Insert(0, new ListItem("", ""));
  46. CreateDdlDeptID2.Items.Insert(0, new ListItem("", ""));
  47. if (!string.IsNullOrEmpty(Request.QueryString["EquipID"]))
  48. {
  49. CreateEquip_ID.Text = Request.QueryString["EquipID"].ToString();
  50. MoKeptLog mod = dalKept.GetEquipLastKept(Request.QueryString["EquipID"].ToString());
  51. if (mod != null)
  52. {
  53. MoDept moddept = dalEmp.GetEmpDepartment(mod.User_Code2);
  54. CreateDdlDeptID1.SelectedValue = moddept == null ? "" : moddept.Dept_Id;
  55. this.CreateDdlDeptID1_SelectedIndexChanged(null, null);
  56. if (CreateUser_Code1.Items.FindByValue(mod.User_Code2) != null)
  57. {
  58. CreateUser_Code1.SelectedValue = mod.User_Code2;
  59. }
  60. CreateDdlDeptID1.Enabled = false;
  61. CreateUser_Code1.Enabled = false;
  62. LastKeptID.Value = mod.Kpt_Log_Id.ToString();
  63. }
  64. CreateEquip_ID.Enabled = false;
  65. }
  66. }
  67. }
  68. protected void CreateDdlDeptID1_SelectedIndexChanged(object sender, EventArgs e)
  69. {
  70. CreateUser_Code1.Items.Clear();
  71. string deptid = CreateDdlDeptID1.SelectedValue;
  72. if (!string.IsNullOrEmpty(deptid))
  73. {
  74. Utility.BindDataSet2Combox(dalEmp.GetEmploreeByDeptID(deptid), CreateUser_Code1, "FullName", "Emp_Id");
  75. CreateUser_Code1.Items.Insert(0, new ListItem("", ""));
  76. }
  77. }
  78. protected void CreateDdlDeptID2_SelectedIndexChanged(object sender, EventArgs e)
  79. {
  80. CreateUser_Code2.Items.Clear();
  81. string deptid = CreateDdlDeptID2.SelectedValue;
  82. if (!string.IsNullOrEmpty(deptid))
  83. {
  84. Utility.BindDataSet2Combox(dalEmp.GetEmploreeByDeptID(deptid), CreateUser_Code2, "FullName", "Emp_Id");
  85. }
  86. }
  87. protected void CreateGo_Click(object sender, EventArgs e)
  88. {
  89. MoKeptLog mod = new MoKeptLog();
  90. try
  91. {
  92. //mod.Kpt_Log_Id = SequenceKeys.GenerateSampleKeptID();
  93. mod.Equip_Id = CreateEquip_ID.Text.Trim();
  94. mod.Kpt_Addr = CreateKpt_Addr.Text.Trim();
  95. mod.Kpt_Begin = DateTime.Now;
  96. mod.Kpt_Status = 1;
  97. mod.Rem = CreateRem.Text.Trim();
  98. if (!string.IsNullOrEmpty(CreateUser_Code1.SelectedValue))
  99. {
  100. mod.User_Code1 = CreateUser_Code1.SelectedValue;
  101. }
  102. mod.User_Code2 = CreateUser_Code2.SelectedValue;
  103. int rtn = dalKept.CreateKeptLog(mod, LastKeptID.Value);
  104. if (rtn == 1)
  105. {
  106. OperationResult.Text = "?????????"; divResult.Visible = true;
  107. }
  108. else
  109. {
  110. OperationResult.Text = "?????????"; divResult.Visible = true;
  111. }
  112. }
  113. catch (Exception ex)
  114. {
  115. log.Error("????????", ex);
  116. OperationResult.Text = "???????????"; divResult.Visible = true;
  117. }
  118. }
  119. protected void BtnBack_Click(object sender, EventArgs e)
  120. {
  121. Response.Redirect("Equipment.aspx");
  122. }
  123. }