/// <summary> /// 根据编号返回特定的保修记录 /// </summary> /// <param name="id"></param> /// <returns></returns> public static RepairApply GetRepairApplyByID(int id) { SqlConnection conn = new SqlConnection(connString); SqlCommand cmd = new SqlCommand("SELECT * FROM [RepairApplies] WHERE [ApplyID] = @ApplyID", conn); cmd.Parameters.Add("@ApplyID", SqlDbType.Int).Value = id; conn.Open(); SqlDataReader sdr = cmd.ExecuteReader(); RepairApply ri = null; if (sdr.Read()) { ri = new RepairApply(); ri.equipmentName = (string)sdr["EquipmentName"]; ri.equipmentType = (string)sdr["EquipmentType"]; ri.staffName = (string)sdr["StaffName"]; ri.departmentName = (string)sdr["Department"]; ri.buyDate = Convert.ToDateTime(sdr["BuyDate"]); ri.bugDate = Convert.ToDateTime(sdr["BugDate"]); ri.bugDetail = (string)sdr["BugDetail"]; ri.fixDate = Convert.ToDateTime(sdr["FixDate"]); ri.duringGuarantee = (bool)sdr["DuringGuarantee"]; ri.repairSelf = (bool)sdr["RepairSelf"]; ri.budget = Convert.ToDouble(sdr["Budget"]); ri.settleType = (string)sdr["SettleType"]; ri.sentToRepair = Convert.ToDateTime(sdr["SentToRepair"]); ri.ApproveProcess = sdr["ApproveProcess"] == DBNull.Value ? "" : (string)sdr["ApproveProcess"]; } sdr.Close(); conn.Close(); return(ri); }
/// <summary> /// 新增或更新特定编号的固定资产报修记录 /// </summary> /// <param name="id"></param> /// <param name="ri"></param> public static void SetRepairApplyByID(int id, RepairApply ri) { SqlConnection conn = new SqlConnection(connString); SqlCommand cmd; bool isExist = HasRepairApplyInfo(id); if (isExist) { cmd = new SqlCommand("UPDATE [RepairApplies] SET [EquipmentName]=@EquipmentName, [EquipmentType]=@EquipmentType, [StaffName] = @StaffName, [Department]=@Department, [BuyDate]=@BuyDate, [BugDate]=@BugDate, [BugDetail]=@BugDetail, [FixDate]=@FixDate, [DuringGuarantee] = @DuringGuarantee, [RepairSelf]=@RepairSelf, [Budget]=@Budget, [SettleType]=@SettleType, [SentToRepair]=@SentToRepair, [ApproveProcess]=@ApproveProcess WHERE [ApplyID] = @ApplyID", conn); } else { cmd = new SqlCommand("INSERT INTO [RepairApplies] ([EquipmentName], [EquipmentType], [StaffName], [Department], [BuyDate], [BugDate], [BugDetail], [FixDate], [DuringGuarantee], [RepairSelf], [Budget], [SettleType], [SentToRepair]) VALUES (@EquipmentName, @EquipmentType, @StaffName, @Department, @BuyDate, @BugDate, @BugDetail, @FixDate, @DuringGuarantee, @RepairSelf, @Budget, @SettleType, @SentToRepair) Select @@Identity as 'Identity'", conn); } cmd.Parameters.Add("@ApplyID", SqlDbType.Int).Value = id; cmd.Parameters.Add("@EquipmentName", SqlDbType.VarChar).Value = ri.equipmentName; cmd.Parameters.Add("@EquipmentType", SqlDbType.VarChar).Value = ri.equipmentType; cmd.Parameters.Add("@StaffName", SqlDbType.VarChar).Value = ri.staffName; cmd.Parameters.Add("@Department", SqlDbType.VarChar).Value = ri.departmentName; cmd.Parameters.Add("@BuyDate", SqlDbType.DateTime).Value = ri.buyDate; cmd.Parameters.Add("@BugDate", SqlDbType.DateTime).Value = ri.bugDate; cmd.Parameters.Add("@SentToRepair", SqlDbType.DateTime).Value = ri.sentToRepair; cmd.Parameters.Add("@BugDetail", SqlDbType.VarChar).Value = ri.bugDetail; cmd.Parameters.Add("@FixDate", SqlDbType.DateTime).Value = ri.fixDate; cmd.Parameters.Add("@DuringGuarantee", SqlDbType.Bit).Value = ri.duringGuarantee; cmd.Parameters.Add("@RepairSelf", SqlDbType.Bit).Value = ri.repairSelf; cmd.Parameters.Add("@Budget", SqlDbType.Float).Value = ri.budget; cmd.Parameters.Add("@SettleType", SqlDbType.VarChar).Value = ri.settleType; cmd.Parameters.Add("@ApproveProcess", SqlDbType.VarChar).Value = ri.approveProcess; conn.Open(); //同时在标准化申请表中插入一条记录 int recordId = Convert.ToInt32(cmd.ExecuteScalar()); if (!isExist) { SqlCommand cmd2 = new SqlCommand("INSERT INTO [AllApplies] ( [ApplyStaff], [ApplyDate], [ApplyType], [NextApprover], [RecordID], [Result]) VALUES (@ApplyStaff, @ApplyDate, @ApplyType, @NextApprover, @RecordID, @Result)", conn); cmd2.Parameters.Add("@ApplyStaff", SqlDbType.VarChar).Value = ri.staffName; cmd2.Parameters.Add("@ApplyDate", SqlDbType.DateTime).Value = DateTime.Now; cmd2.Parameters.Add("@ApplyType", SqlDbType.VarChar).Value = "固定资产保修申请"; cmd2.Parameters.Add("@RecordID", SqlDbType.Int).Value = recordId; cmd2.Parameters.Add("@NextApprover", SqlDbType.VarChar).Value = Department.GetDepartmentByName(ri.departmentName).ResponsiblePerson; cmd2.Parameters.Add("@Result", SqlDbType.Bit).Value = false; cmd2.ExecuteNonQuery(); } conn.Close(); }
private void updateApprove(string if_agree, string next, BasicInfo info, bool if_back) { int recordID = Convert.ToInt32(Request["RecordID"]); RepairApply ri = RepairApply.GetRepairApplyByID(recordID); ri.ApproveProcess += info.StaffName.Trim() + "-" + if_agree + ","; RepairApply.SetRepairApplyByID(recordID, ri); string nextApprover = next; int applyID = Convert.ToInt32(Request["ApplyID"]); Apply.UpdateNextApprover(applyID, nextApprover, if_back); }
protected void Page_Load(object sender, EventArgs e) { int recordID = Convert.ToInt32(Request["RecordID"]); int applyID = Convert.ToInt32(Request["ApplyID"]); bool rejected = Convert.ToBoolean(Request["rejected"]); Apply ap = Apply.GetApplyByID(applyID); RepairApply ri = RepairApply.GetRepairApplyByID(recordID); equipmentName.Text = ri.EquipmentName; equipmentType.Text = ri.EquipmentType; staffName.Text = ri.StaffName; department.Text = ri.DepartmentName; buyDate.Text = ri.BuyDate.ToShortDateString(); bugDate.Text = ri.BugDate.ToShortDateString(); bugDetail.Text = ri.BugDetail; fixDate.Text = ri.FixDate.ToShortDateString(); duringGuarantee.Text = ri.DuringGuarantee ? "是" : "否"; repairSelf.Text = ri.RepairSelf ? "是" : "否"; budget.Text = ri.Budget.ToString(); settleType.Text = ri.SettleType; sentToRepair.Text = ri.SentToRepair.ToShortDateString(); processShow.Text = ri.ApproveProcess; //用户权限相关显示功能 Users usr = (Users)Session["Identify"]; BasicInfo info = BasicInfo.GetBasicInfoByID(usr.UserID); if (!rejected && ap.NextApprover == ri.StaffName) { agreeButton.Visible = false; disagreeButton.Visible = false; whyDisagree.Visible = false; //可打印状态 proManager.Text = "已签字"; depManager.Text = "已签字"; guanwei.Text = "已签字"; } else if (info.StaffName.Trim() == ri.StaffName.Trim() || info.Position.Trim() == "出纳") { agreeButton.Visible = false; disagreeButton.Visible = false; if (info.Position.Trim() != "出纳") { whyDisagree.Visible = false; } } //测试阶段保持处理流程可见,运行阶段记得去掉 processShow.Visible = true; }
protected void confirm_Click(object sender, EventArgs e) { RepairApply ri = new RepairApply(); ri.EquipmentName = equipmentName.Value; ri.EquipmentType = equipmentType.Value; ri.StaffName = staffName.Text; ri.DepartmentName = department.Text; ri.BuyDate = Convert.ToDateTime(buyDate.Value); ri.BugDate = Convert.ToDateTime(bugDate.Value); ri.SentToRepair = Convert.ToDateTime(sentToRepair.Value); ri.BugDetail = bugDetail.Text; ri.FixDate = Convert.ToDateTime(fixDate.Value); ri.DuringGuarantee = !Convert.ToBoolean(duringGuarantee.SelectedIndex); ri.RepairSelf = !Convert.ToBoolean(RepairSelf.SelectedIndex); ri.Budget = Convert.ToDouble(budget.Text); ri.SettleType = settleType.SelectedValue == "签单"?Request["checkBill"]:settleType.SelectedValue; ri.ApproveProcess = ""; RepairApply.SetRepairApplyByID(-1, ri); Response.Redirect("~/Account/ApplyListPage.aspx"); }