/// <summary> /// 根据编号获取办公用品申购记录 /// </summary> /// <param name="id"></param> /// <returns></returns> public static OfficeSupplyApply GetOfficeSupplyApplyByID(int id) { SqlConnection conn = new SqlConnection(connString); SqlCommand cmd = new SqlCommand("SELECT * FROM [OfficeSupplyApplies] WHERE [ApplyID] = @ApplyID", conn); cmd.Parameters.Add("@ApplyID", SqlDbType.Int).Value = id; conn.Open(); SqlDataReader sdr = cmd.ExecuteReader(); OfficeSupplyApply oi = null; if (sdr.Read()) { oi = new OfficeSupplyApply(); oi.officeList = new List <OfficeSupplySingle>(); oi.staffName = (string)sdr["StaffName"]; oi.department = (string)sdr["Department"]; oi.reason = (string)sdr["Reason"]; oi.applyDate = Convert.ToDateTime(sdr["ApplyDate"]); oi.ApproveProcess = sdr["ApproveProcess"] == DBNull.Value ? "" : (string)sdr["ApproveProcess"]; } sdr.Close(); conn.Close(); double all = 0.0; List <OfficeSupplySingle> result = OfficeSupplySingle.GetOfficeSupplyListByID(id); oi.officeList.AddRange(result); foreach (OfficeSupplySingle o in result) { all += o.AllExpense; } oi.allExpensive = all; return(oi); }
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); OfficeSupplyApply oi = OfficeSupplyApply.GetOfficeSupplyApplyByID(recordID); staffName.Text = oi.StaffName; department.Text = oi.Department; reason.Text = oi.Reason; applyDate.Text = oi.ApplyDate.ToShortDateString(); processShow.Text = oi.ApproveProcess; double money = 0.0; supplyList.Text = transResult(oi.OfficeList, ref money); allExpensive.Text = money.ToString(); allExpensiveUpper.Text = MoneyConvert.convertToCapital(money.ToString()); //用户权限相关显示功能 Users usr = (Users)Session["Identify"]; BasicInfo info = BasicInfo.GetBasicInfoByID(usr.UserID); if (!rejected && ap.NextApprover == oi.StaffName) { agreeButton.Visible = false; disagreeButton.Visible = false; whyDisagree.Visible = false; //可打印状态 proManager.Text = "已签字"; depManager.Text = "已签字"; counter.Text = "已签字"; cashier.Text = "已签字"; company.Text = "已签字"; } else if (info.StaffName.Trim() == oi.StaffName.Trim()) { agreeButton.Visible = false; disagreeButton.Visible = false; if (info.Position.Trim() != "出纳") { whyDisagree.Visible = false; } } //测试阶段保持处理流程可见,运行阶段记得去掉 processShow.Visible = true; }
private void updateApprove(string if_agree, string next, BasicInfo info, bool if_back) { Users usr = (Users)Session["Identify"]; int recordID = Convert.ToInt32(Request["RecordID"]); OfficeSupplyApply oi = OfficeSupplyApply.GetOfficeSupplyApplyByID(recordID); oi.ApproveProcess += info.StaffName.Trim() + "-" + if_agree + ","; OfficeSupplyApply.SetOfficeSupplyApplyByID(recordID, oi, proManager.Text); string nextApprover = next; int applyID = Convert.ToInt32(Request["ApplyID"]); Apply.UpdateNextApprover(applyID, nextApprover, if_back); }
/// <summary> /// 根据编号新增或更新办公用品申购记录 /// </summary> /// <param name="id"></param> /// <param name="oi"></param> /// <param name="projectName"></param> public static int SetOfficeSupplyApplyByID(int id, OfficeSupplyApply oi, string manager) { SqlConnection conn = new SqlConnection(connString); SqlCommand cmd; bool isExist = HasOfficeSupplyApplyInfo(id); if (isExist) { cmd = new SqlCommand("UPDATE [OfficeSupplyApplies] SET [StaffName] = @StaffName, [Department]=@Department, [Reason]=@Reason, [ApplyDate]=@ApplyDate, [ApproveProcess]=@ApproveProcess WHERE [ApplyID] = @ApplyID", conn); } else { cmd = new SqlCommand("INSERT INTO [OfficeSupplyApplies] ([StaffName], [Department], [Reason], [ApplyDate], [Money]) VALUES (@StaffName, @Department, @Reason, @ApplyDate, @Money) Select @@Identity as 'Identity'", conn); } cmd.Parameters.Add("@ApplyID", SqlDbType.Int).Value = id; cmd.Parameters.Add("@StaffName", SqlDbType.VarChar).Value = oi.staffName; cmd.Parameters.Add("@Department", SqlDbType.VarChar).Value = oi.department; cmd.Parameters.Add("@Money", SqlDbType.Float).Value = oi.allExpensive; cmd.Parameters.Add("@Reason", SqlDbType.VarChar).Value = oi.reason; cmd.Parameters.Add("@ApplyDate", SqlDbType.DateTime).Value = oi.applyDate; cmd.Parameters.Add("@ApproveProcess", SqlDbType.VarChar).Value = oi.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 = oi.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 = manager; cmd2.Parameters.Add("@Result", SqlDbType.Bit).Value = false; cmd2.ExecuteNonQuery(); } conn.Close(); return(recordId); }
protected void confirm_Click(object sender, EventArgs e) { OfficeSupplyApply oi = new OfficeSupplyApply(); oi.StaffName = staffName.Text; oi.Department = department.Text; oi.ApplyDate = DateTime.Today; oi.Reason = reason.Text; oi.ApproveProcess = ""; int recordid = OfficeSupplyApply.SetOfficeSupplyApplyByID(-1, oi, ProjectInfo.getProjectInfoByCode(projectCodeList.SelectedValue).Manager); double allExpense = 0.0; List <OfficeSupplySingle> supplyList = getSupplyList(ref allExpense); OfficeSupplySingle.SetOfficeSupplySingle(supplyList, recordid); oi.AllExpensive = allExpense; OfficeSupplyApply.SetOfficeSupplyApplyByID(recordid, oi, ProjectInfo.getProjectInfoByCode(projectCodeList.SelectedValue).Manager); Response.Redirect("~/Account/ApplyListPage.aspx"); }