/// <summary> /// 根据编号获取特定的员工宴请申请记录 /// </summary> /// <param name="id"></param> /// <returns></returns> public static StaffMealApply GetStaffMealApplyByID(int id) { SqlConnection conn = new SqlConnection(connString); SqlCommand cmd = new SqlCommand("SELECT * FROM [MealApplies] WHERE [ApplyID] = @ApplyID", conn); cmd.Parameters.Add("@ApplyID", SqlDbType.Int).Value = id; conn.Open(); SqlDataReader sdr = cmd.ExecuteReader(); StaffMealApply si = null; if (sdr.Read()) { si = new StaffMealApply(); si.staffName = (string)sdr["StaffName"]; si.departmentName = (string)sdr["Department"]; si.position = (string)sdr["Position"]; si.reason = (string)sdr["Reason"]; si.persons = (int)sdr["Persons"]; si.money = (double)sdr["Money"]; si.standard = (string)sdr["Standard"]; si.mealDate = Convert.ToDateTime(sdr["MealDate"]); si.legal = (bool)sdr["Legal"]; si.style = (bool)sdr["Style"]; si.ApproveProcess = sdr["ApproveProcess"] == DBNull.Value ? "" : (string)sdr["ApproveProcess"]; } sdr.Close(); conn.Close(); return(si); }
private void updateApprove(string if_agree, string next, BasicInfo info, bool if_back) { Users usr = (Users)Session["Identify"]; int recordID = Convert.ToInt32(Request["RecordID"]); StaffMealApply si = StaffMealApply.GetStaffMealApplyByID(recordID); si.ApproveProcess += info.StaffName.Trim() + "-" + if_agree + ","; StaffMealApply.SetStaffMealApplyByID(recordID, si); string nextApprover = next; int applyID = Convert.ToInt32(Request["ApplyID"]); Apply.UpdateNextApprover(applyID, nextApprover, if_back); }
/// <summary> /// 新增或更新一条员工用餐申请 /// </summary> /// <param name="id"></param> /// <param name="si"></param> /// <param name="usrID"></param> public static void SetStaffMealApplyByID(int id, StaffMealApply si) { SqlConnection conn = new SqlConnection(connString); SqlCommand cmd; bool isExist = HasStaffMealApplyInfo(id); if (isExist) { cmd = new SqlCommand("UPDATE [MealApplies] SET [StaffName] = @StaffName, [Department]=@Department, [Position]=@Position, [Money]=@Money, [MealDate] = @MealDate, [Persons]=@Persons, [Reason]=@Reason, [Standard]=@Standard, [Legal]=@Legal, [Style]=@Style, [ApproveProcess]=@ApproveProcess WHERE [ApplyID] = @ApplyID", conn); } else { cmd = new SqlCommand("INSERT INTO [MealApplies] ( [StaffName], [Department], [Position], [MealDate], [Persons], [Money], [Reason], [Standard], [Legal], [Style]) VALUES (@StaffName, @Department, @Position, @MealDate, @Persons, @Money, @Reason, @Standard, @Legal, @Style) Select @@Identity as 'Identity'", conn); } cmd.Parameters.Add("@ApplyID", SqlDbType.Int).Value = id; cmd.Parameters.Add("@StaffName", SqlDbType.VarChar).Value = si.staffName; cmd.Parameters.Add("@Department", SqlDbType.VarChar).Value = si.departmentName; cmd.Parameters.Add("@Position", SqlDbType.VarChar).Value = si.position; cmd.Parameters.Add("@MealDate", SqlDbType.DateTime).Value = si.mealDate; cmd.Parameters.Add("@Persons", SqlDbType.Int).Value = si.persons; cmd.Parameters.Add("@Money", SqlDbType.Float).Value = si.money; cmd.Parameters.Add("@Reason", SqlDbType.VarChar).Value = si.reason; cmd.Parameters.Add("@Standard", SqlDbType.VarChar).Value = si.standard; cmd.Parameters.Add("@Style", SqlDbType.Bit).Value = si.style; cmd.Parameters.Add("@Legal", SqlDbType.Bit).Value = si.legal; cmd.Parameters.Add("@ApproveProcess", SqlDbType.VarChar).Value = si.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 = si.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(si.DepartmentName).ResponsiblePerson; cmd2.Parameters.Add("@Result", SqlDbType.Bit).Value = false; cmd2.ExecuteNonQuery(); } conn.Close(); }
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); StaffMealApply si = StaffMealApply.GetStaffMealApplyByID(recordID); staffName.Text = si.StaffName; department.Text = si.DepartmentName; position.Text = si.Position; mealDate.Text = si.MealDate.ToShortDateString(); reason.Text = si.Reason; persons.Text = si.Persons.ToString(); money.Text = si.Money.ToString(); legal.SelectedIndex = si.Legal == true ? 0 : 1; style.SelectedIndex = si.Style == true ? 0 : 1; standard.Text = si.Standard; processShow.Text = si.ApproveProcess; //用户权限相关显示功能 Users usr = (Users)Session["Identify"]; BasicInfo info = BasicInfo.GetBasicInfoByID(usr.UserID); if (!rejected && ap.NextApprover == si.StaffName) { agreeButton.Visible = false; disagreeButton.Visible = false; whyDisagree.Visible = false; //可打印状态 depManager.Text = "已签字"; company.Text = "已签字"; } else if (info.StaffName.Trim() == si.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) { StaffMealApply si = new StaffMealApply(); si.StaffName = staffName.Text; si.DepartmentName = department.Text; si.Position = position.Text; si.Reason = reason.Value; si.Persons = Convert.ToInt16(persons.Value); si.Money = Convert.ToDouble(money.Text); si.Standard = standard.Value; si.MealDate = Convert.ToDateTime(mealDate.Value); si.Legal = Convert.ToBoolean(legal.SelectedValue); si.Style = Convert.ToBoolean(style.SelectedValue); si.ApproveProcess = ""; Users usr = (Users)Session["Identify"]; StaffMealApply.SetStaffMealApplyByID(-1, si); Response.Redirect("~/Account/ApplyListPage.aspx"); }