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