/// <summary> /// 根据编号获取特定的宴请申请记录 /// </summary> /// <param name="id"></param> /// <returns></returns> public static EntertainApply GetEntertainApplyByID(int id) { SqlConnection conn = new SqlConnection(connString); SqlCommand cmd = new SqlCommand("SELECT * FROM [EntertainApplies] WHERE [ApplyID] = @ApplyID", conn); cmd.Parameters.Add("@ApplyID", SqlDbType.Int).Value = id; conn.Open(); SqlDataReader sdr = cmd.ExecuteReader(); EntertainApply ei = null; if (sdr.Read()) { ei = new EntertainApply(); ei.staffName = (string)sdr["StaffName"]; ei.department = (string)sdr["Department"]; ei.manager = (string)sdr["Manager"]; ei.applyDate = Convert.ToDateTime(sdr["ApplyDate"]); ei.treatDate = Convert.ToDateTime(sdr["TreatDate"]); ei.treatStandard = (string)sdr["TreatStandard"]; ei.reason = (string)sdr["Reason"]; ei.treated = (string)sdr["Treated"]; ei.budget = Convert.ToDouble(sdr["Budget"]); ei.treatStyle = (string)sdr["TreatStyle"]; ei.ApproveProcess = sdr["ApproveProcess"] == DBNull.Value ? "" : (string)sdr["ApproveProcess"]; } sdr.Close(); conn.Close(); return(ei); }
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); EntertainApply ei = EntertainApply.GetEntertainApplyByID(recordID); if (!IsPostBack) { staffName.Text = ei.StaffName; department.Text = ei.Department; manager.Text = ei.Manager; applyDate.Text = ei.ApplyDate.ToShortDateString(); treatDate.Text = ei.TreatDate.ToShortDateString(); treated.Text = ei.Treated; treatStandard.Text = ei.TreatStandard; treatStyle.Text = ei.TreatStyle; reason.Text = ei.Reason; budget.Text = ei.Budget.ToString(); processShow.Text = ei.ApproveProcess; } //用户权限相关显示功能 Users usr = (Users)Session["Identify"]; BasicInfo info = BasicInfo.GetBasicInfoByID(usr.UserID); if (!rejected && ap.NextApprover == ei.StaffName) { agreeButton.Visible = false; disagreeButton.Visible = false; whyDisagree.Visible = false; //可打印状态 financial.Text = "已签字"; company.Text = "已签字"; } else if (info.StaffName.Trim() == ei.StaffName.Trim() || info.Position.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"]); EntertainApply ei = EntertainApply.GetEntertainApplyByID(recordID); ei.ApproveProcess += info.StaffName.Trim() + "-" + if_agree + ","; EntertainApply.SetEntertainApplyByID(recordID, ei); string nextApprover = next; int applyID = Convert.ToInt32(Request["ApplyID"]); Apply.UpdateNextApprover(applyID, nextApprover, if_back); }
/// <summary> /// 插入或更新一条宴请申请记录 /// </summary> /// <param name="id"></param> /// <param name="ei"></param> public static void SetEntertainApplyByID(int id, EntertainApply ei) { SqlConnection conn = new SqlConnection(connString); SqlCommand cmd; bool isExist = HasEntertainApplyInfo(id); if (isExist) { cmd = new SqlCommand("UPDATE [EntertainApplies] SET [StafffName] = @StaffName, [Departments] = @Departments, [Manager] = @Manager, [ApplyDate] = @ApplyDate, [TreatDate] = @TreatDate, [Reason] = @Reason, [Treated] = @Treated, [Budget] = @Budget,[TreatStandard]=@TreatStandard, [TreatStyle] = @TreatStyle, [ApproveProcess] = @ApproveProcess WHERE [ApplyID] = @ApplyID", conn); } else { cmd = new SqlCommand("INSERT INTO [EntertainApplies] ([StaffName], [Department], [ApplyDate],[TreatDate],[Manager],[Reason],[Treated],[Budget],[TreatStandard], [TreatStyle],[ApproveProcess]) VALUES (@StaffName, @Department, @ApplyDate,@TreatDate,@Manager,@Reason,@Treated,@Budget,@TreatStandard, @TreatStyle,@ApproveProcess)", conn); } cmd.Parameters.Add("@StaffName", SqlDbType.VarChar).Value = ei.staffName; cmd.Parameters.Add("@Department", SqlDbType.VarChar).Value = ei.department; cmd.Parameters.Add("@Manager", SqlDbType.VarChar).Value = ei.manager; cmd.Parameters.Add("@ApplyDate", SqlDbType.DateTime).Value = ei.applyDate; cmd.Parameters.Add("@TreatDate", SqlDbType.DateTime).Value = ei.treatDate; cmd.Parameters.Add("@TreatStandard", SqlDbType.VarChar).Value = ei.treatStandard; cmd.Parameters.Add("@Reason", SqlDbType.VarChar).Value = ei.reason; cmd.Parameters.Add("@Treated", SqlDbType.VarChar).Value = ei.treated; cmd.Parameters.Add("@Budget", SqlDbType.Float).Value = ei.budget; cmd.Parameters.Add("@TreatStyle", SqlDbType.VarChar).Value = ei.treatStyle; cmd.Parameters.Add("@TreatStandard", SqlDbType.VarChar).Value = ei.treatStandard; cmd.Parameters.Add("@ApproveProcess", SqlDbType.VarChar).Value = ei.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 = ei.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 = BasicInfo.GetOrganizationResponsible(); cmd2.Parameters.Add("@Result", SqlDbType.Bit).Value = false; cmd2.ExecuteNonQuery(); } conn.Close(); }
protected void confirm_Click(object sender, EventArgs e) { EntertainApply ei = new EntertainApply(); ei.StaffName = Request["staffName"]; ei.Department = depList.SelectedValue; ei.Manager = manager.Text; ei.ApplyDate = Convert.ToDateTime(applyDate.Value); ei.TreatDate = Convert.ToDateTime(treatDate.Value); ei.Reason = Request["reason"]; ei.Treated = Request["treated"]; ei.TreatStandard = Request["treatStandard"]; ei.TreatStyle = Request["treatStyle"]; ei.Budget = Convert.ToDouble(budget.Text); ei.ApproveProcess = ""; EntertainApply.SetEntertainApplyByID(-1, ei); Response.Redirect("~/Account/BasicInfo.aspx"); }