/// <summary> /// 新增/修改请假申请 /// </summary> /// <param name="leave">请假数据集</param> /// <param name="error">错误信息</param> /// <returns>成功返回True,失败返回False</returns> public bool AddLeaveBill(HR_LeaveBill leave, out string error) { error = ""; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from a in dataContxt.HR_LeaveBill where a.ID == leave.ID select a; if (result.Count() > 0) { HR_LeaveBill leaveList = result.Single(); leaveList.BeginTime = leave.BeginTime; leaveList.BillStatus = leave.BillStatus; leaveList.EndTime = leave.EndTime; leaveList.OtherExplanation = leave.OtherExplanation; leaveList.RealHours = leave.RealHours; leaveList.Date = leaveList.Date; new AttendanceAnalysis().DataTimeIsRepeat <HR_LeaveBill>(dataContxt, leaveList, leave.Applicant); } else { var resultList = from a in dataContxt.HR_LeaveBill where a.Applicant == leave.Applicant && a.BeginTime == leave.BeginTime select a; if (resultList.Count() == 0) { new AttendanceAnalysis().DataTimeIsRepeat <HR_LeaveBill>(dataContxt, leave, leave.Applicant); dataContxt.HR_LeaveBill.InsertOnSubmit(leave); } else { error = "您在同一时间已经申请了请假单"; return(false); } } dataContxt.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 修改请假信息 /// </summary> /// <param name="leave">请假申请数据集</param> /// <param name="roleType">角色类型(部门主管审批,部门负责人审批 /// 分管领导审批,总经理审批,人力资源部复审)</param> /// <param name="error">错误信息</param> /// <returns>成功返回true,失败返回False</returns> public bool UpdateLeave(HR_LeaveBill leave, string roleType, out string error) { error = ""; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; dataContxt.Connection.Open(); dataContxt.Transaction = dataContxt.Connection.BeginTransaction(); try { var result = from a in dataContxt.HR_LeaveBill where a.ID == leave.ID select a; if (result.Count() != 1) { error = "信息有误,请查证后再操作!"; return(false); } HR_LeaveBill bill = result.Single(); bill.BillStatus = leave.BillStatus; switch (roleType) { case "部门主管审批": bill.DeptDirector = leave.DeptDirector; bill.DeptDirectorSignatureDate = leave.DeptDirectorSignatureDate; break; case "部门负责人审批": bill.DeptPrincipal = leave.DeptPrincipal; bill.DeptPrincipalSignatureDate = leave.DeptPrincipalSignatureDate; bill.Authorize = leave.Authorize; bill.UnexcusedReason = leave.UnexcusedReason; bill.Leader = leave.Leader; bill.LeaderSignatureDate = leave.LeaderSignatureDate; break; case "分管领导审批": bill.Leader = leave.Leader; bill.LeaderSignatureDate = leave.LeaderSignatureDate; bill.Authorize = leave.Authorize; bill.UnexcusedReason = leave.UnexcusedReason; break; case "总经理审批": bill.GeneralManager = leave.GeneralManager; bill.GM_SignatureDate = leave.GM_SignatureDate; bill.Authorize = leave.Authorize; bill.UnexcusedReason = leave.UnexcusedReason; break; case "人力资源部复审": bill.HR_Signature = leave.HR_Signature; bill.HR_SignatureDate = leave.HR_SignatureDate; bill.LeaveTypeID = leave.LeaveTypeID; break; default: break; } dataContxt.SubmitChanges(); if (GlobalObject.GeneralFunction.StringConvertToEnum <LeaveBillStatus>(bill.BillStatus) == LeaveBillStatus.已完成) { ITimeExceptionServer service = ServerModuleFactory.GetServerModule <ITimeExceptionServer>(); service.OperationTimeException_Replenishments(dataContxt, bill.ID.ToString(), CE_HR_AttendanceExceptionType.请假); } dataContxt.Transaction.Commit(); return(true); } catch (Exception ex) { dataContxt.Transaction.Rollback(); error = ex.Message; return(false); } }