/// <summary> /// 修改请假类别后同时修改流水明细 /// </summary> /// <param name="billNo">请假单号</param> /// <param name="type">请假类别</param> /// <param name="error">错误信息</param> /// <returns>成功返回true,失败返回false</returns> public bool UpdateAttendanceDaybook(string billNo, string type, out string error) { error = ""; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from a in dataContxt.HR_AttendanceDaybookList where a.BillNo == billNo && a.ResultType == "4" select a; if (result.Count() > 0) { foreach (HR_AttendanceDaybookList item in result) { HR_AttendanceDaybookList list = item; list.ResultSubclass = type; } } dataContxt.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
double GetAlreadyHours(DepotManagementDataContext ctx, HR_AttendanceDaybookList dayBookList, string workID) { var varData = from a in ctx.HR_AttendanceDaybookList join b in ctx.HR_AttendanceDaybook on a.DayBookID equals b.ID where a.ResultType == dayBookList.ResultType && a.BillNo == dayBookList.BillNo && b.WorkID == workID select a; if (varData.Count() == 0) { return(0); } else { return(varData.Select(k => k.Hours).Sum()); } }
/// <summary> /// 修改考勤异常登记信息(强制处理) /// </summary> /// <param name="timeException">考勤异常登记信息数据集</param> /// <param name="error">错误信息</param> /// <returns>成功返回true失败返回False</returns> public bool UpdateTimeException(HR_TimeException timeException, out string error) { error = ""; DateTime starTime = Convert.ToDateTime(timeException.Date.Date); DateTime endTime = Convert.ToDateTime(timeException.Date.ToShortDateString() + " " + "23:59:59"); string[] leaveType = new LeaveServer().GetLeaveTypeByWorkID(timeException.WorkID, starTime, endTime).Split(';'); string onbusinessBill = new OnBusinessBillServer().IsExistOnBusinessBillByWorkIDAndTime( timeException.WorkID, starTime, Convert.ToDateTime(endTime.AddDays(1).ToShortDateString())); DataTable dtOverTime = new OverTimeBillServer().IsExistOverTimeByWorkID(timeException.WorkID, starTime.Date, starTime.AddDays(1).Date); try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from a in dataContxt.HR_TimeException where a.ID == timeException.ID select a; if (result.Count() > 0) { HR_TimeException exceptionList = result.Single(); exceptionList.RealExceptionType = timeException.RealExceptionType; exceptionList.HR_Signature = timeException.HR_Signature; exceptionList.HR_SignatureDate = timeException.HR_SignatureDate; exceptionList.ExceptionDescription = timeException.ExceptionDescription; var resultList = from a in dataContxt.HR_AttendanceDaybookList where a.TimeExceptionRelevanceID == exceptionList.DayBookUniqueID select a; if (resultList.Count() > 0) { HR_AttendanceDaybookList dayBookList = resultList.Single(); if (timeException.RealExceptionType == 4 && leaveType != null && leaveType[0] != "") { dayBookList.ResultType = "4"; dayBookList.BillNo = leaveType[0]; if (dayBookList.BillNo != "") { dayBookList.ResultSubclass = leaveType[1]; dayBookList.Remark = timeException.ExceptionDescription; } else { dayBookList.ResultSubclass = ""; } } else if (timeException.RealExceptionType == 7 && onbusinessBill != null) { dayBookList.ResultType = "7"; dayBookList.BillNo = onbusinessBill; } else if (timeException.RealExceptionType == 9 || timeException.RealExceptionType == 8 || timeException.RealExceptionType == 10 || timeException.RealExceptionType == 1 || timeException.RealExceptionType == 2 || timeException.RealExceptionType == 3 || timeException.RealExceptionType == 11 || timeException.RealExceptionType == 12) { dayBookList.ResultType = timeException.RealExceptionType.ToString(); dayBookList.BillNo = ""; dayBookList.ResultSubclass = ""; } else if (timeException.RealExceptionType == 5 && dtOverTime != null && dtOverTime.Rows.Count > 0) { dayBookList.ResultType = "5"; if (dayBookList.BillNo == null || dayBookList.BillNo.Trim().Length == 0 || dayBookList.Hours == 0) { dayBookList.BillNo = dtOverTime.Rows[0]["单据号"].ToString(); dayBookList.ResultSubclass = dtOverTime.Rows[0]["补偿方式"].ToString(); dayBookList.Hours = Convert.ToDouble(dtOverTime.Rows[0]["实际小时数"].ToString()); } } else { timeException.RealExceptionType = timeException.RealExceptionType; timeException.ExceptionDescription += " 没有检测到关联单;已被" + BasicInfo.LoginName + "强制处理"; } dayBookList.Remark = timeException.ExceptionDescription + " 异常类型由之前的" + new AttendanceMachineServer().GetExceptionTypeName(result.Single().ExceptionType) + "更改为" + new AttendanceMachineServer().GetExceptionTypeName(timeException.RealExceptionType); } } dataContxt.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 修改考勤异常登记信息 /// </summary> /// <param name="timeException">考勤异常登记信息数据集</param> /// <param name="role">角色(部门审核、人力资源审核)</param> /// <param name="error">错误信息</param> /// <returns>成功返回true失败返回False</returns> public bool UpdateTimeException(HR_TimeException timeException, string role, out string error) { error = ""; DateTime starTime = Convert.ToDateTime(timeException.Date.ToShortDateString() + " " + "08:30:00"); DateTime endTime = Convert.ToDateTime(timeException.Date.ToShortDateString() + " " + "17:30:00"); //string[] leaveType = new LeaveServer().GetLeaveTypeByWorkID(timeException.WorkID, endTime, starTime).Split(';'); //DataTable onbusinessDt = new OnBusinessBillServer().GetOnBusinessInfo_TimeExceptionJudge(timeException); //DataTable dtOverTime = new OverTimeBillServer().GetOverTimeByWorkID(timeException.WorkID,starTime.Date,starTime.AddDays(1).Date); try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from a in dataContxt.HR_TimeException where a.ID == timeException.ID select a; if (result.Count() > 0) { HR_TimeException exceptionList = result.Single(); switch (role) { case "部门审核": exceptionList.DeptAuditor = timeException.DeptAuditor; exceptionList.DeptAuditorSignatureDate = timeException.DeptAuditorSignatureDate; exceptionList.ExceptionDescription = timeException.ExceptionDescription; exceptionList.RealExceptionType = timeException.RealExceptionType; if (timeException.RealExceptionType == 8) { //DateTime starDate = new DateTime(timeException.Date.Year, timeException.Date.Month, 1); //int Days = DateTime.DaysInMonth(timeException.Date.Year, timeException.Date.Month); //DateTime endDate = new DateTime(timeException.Date.Year, timeException.Date.Month, Days); //if (!IsTimeExceptionCount(timeException.WorkID, starDate, endDate, // timeException.RealExceptionType.ToString(), out error))//漏打卡次数大于3 //{ // error = "每人每个月漏打卡次数不能超过3次!" + // UniversalFunction.GetPersonnelName(timeException.WorkID) + "已有三次"; // return false; //} exceptionList.RealExceptionType = timeException.RealExceptionType; } #region 文员只能处理已登记与漏打卡 //if (timeException.RealExceptionType == 7) //{ // if (onbusinessDt.Rows.Count > 0 && onbusinessDt.Rows[0]["单据号"].ToString() != "") // { // exceptionList.RealExceptionType = timeException.RealExceptionType; // } // else // { // error = m_personnerServer.GetPersonnelInfo(timeException.WorkID).Name + timeException.Date + "没有出差单或单据没有完成"; // return false; // } //} //else if (timeException.RealExceptionType == 4) //{ // if (leaveType != null && leaveType[0] != "") // { // exceptionList.RealExceptionType = timeException.RealExceptionType; // } // else // { // error = m_personnerServer.GetPersonnelInfo(timeException.WorkID).Name + timeException.Date + "没有请假单或单据没有完成"; // return false; // } //} //else if (timeException.RealExceptionType == 8) //{ // DateTime starDate = new DateTime(timeException.Date.Year, timeException.Date.Month, 1); // int Days = DateTime.DaysInMonth(timeException.Date.Year, timeException.Date.Month); // DateTime endDate = new DateTime(timeException.Date.Year, timeException.Date.Month, Days); // if (!IsTimeExceptionCount(timeException.WorkID, starDate, endDate, // timeException.RealExceptionType.ToString(), out error))//漏打卡次数大于3 // { // error = "每人每个月漏打卡次数不能超过3次!" + // UniversalFunction.GetPersonnelName(timeException.WorkID) + "已有三次"; // return false; // } // exceptionList.RealExceptionType = timeException.RealExceptionType; //} #endregion break; case "人力资源审核": exceptionList.RealExceptionType = timeException.RealExceptionType; exceptionList.HR_Signature = timeException.HR_Signature; exceptionList.HR_SignatureDate = timeException.HR_SignatureDate; exceptionList.ExceptionDescription = timeException.ExceptionDescription; var varData = from a in dataContxt.HR_AttendanceDaybookList where a.TimeExceptionRelevanceID == exceptionList.DayBookUniqueID select a; if (varData.Count() == 1) { HR_AttendanceDaybookList dayBookList = varData.Single(); dayBookList.ResultType = timeException.RealExceptionType.ToString(); dayBookList.BillNo = ""; dayBookList.ResultSubclass = ""; if (result.Single().ExceptionType != timeException.RealExceptionType) { if (exceptionList.DeptAuditor != null && exceptionList.DeptAuditor != "") { dayBookList.Remark = timeException.ExceptionDescription + " 异常类型由之前的" + new AttendanceMachineServer().GetExceptionTypeName(result.Single().ExceptionType) + "更改为" + new AttendanceMachineServer().GetExceptionTypeName(timeException.RealExceptionType) + ";更改人:" + new PersonnelArchiveServer().GetPersonnelInfo(exceptionList.DeptAuditor).Name; } else { dayBookList.Remark = timeException.ExceptionDescription + " 异常类型由之前的" + new AttendanceMachineServer().GetExceptionTypeName(result.Single().ExceptionType) + "更改为" + new AttendanceMachineServer().GetExceptionTypeName(timeException.RealExceptionType) + ";更改人:" + BasicInfo.LoginName; } } } #region 文员只能处理已登记与漏打卡 //var varData = from a in dataContxt.HR_AttendanceDaybookList // where a.TimeExceptionRelevanceID == exceptionList.DayBookUniqueID // select a; //if (varData.Count() == 1) //{ // HR_AttendanceDaybookList dayBookList = varData.Single(); // //请假 // if (timeException.RealExceptionType == 4 && leaveType != null && leaveType[0] != "") // { // dayBookList.ResultType = "4"; // dayBookList.BillNo = leaveType[0]; // dayBookList.ResultSubclass = leaveType[1]; // }//加班 // else if (timeException.RealExceptionType == 5 && dtOverTime != null && dtOverTime.Rows.Count > 0) // { // dayBookList.ResultType = "5"; // if (dayBookList.BillNo == null || dayBookList.BillNo.Trim().Length == 0 || dayBookList.Hours == 0) // { // dayBookList.BillNo = dtOverTime.Rows[0]["单据号"].ToString(); // dayBookList.ResultSubclass = dtOverTime.Rows[0]["补偿方式"].ToString(); // double alreadyHours = GetAlreadyHours(dataContxt, dayBookList, timeException.WorkID); // dayBookList.Hours = Convert.ToDouble(dtOverTime.Rows[0]["实际小时数"].ToString()) < alreadyHours ? // dayBookList.Hours : Convert.ToDouble(dtOverTime.Rows[0]["实际小时数"].ToString()) - alreadyHours; // } // } // else if (timeException.RealExceptionType == 7 && (onbusinessDt != null && onbusinessDt.Rows.Count > 0 // && onbusinessDt.Rows[0]["单据号"].ToString() != "")) // { // dayBookList.ResultType = "7"; // dayBookList.BillNo = onbusinessDt.Rows[0]["单据号"].ToString(); // } // else if (timeException.RealExceptionType == 9 || timeException.RealExceptionType == 8 // || timeException.RealExceptionType == 10 || timeException.RealExceptionType == 1 // || timeException.RealExceptionType == 2 || timeException.RealExceptionType == 3 // || timeException.RealExceptionType == 11 || timeException.RealExceptionType == 12 // || timeException.RealExceptionType == 13) // { // dayBookList.ResultType = timeException.RealExceptionType.ToString(); // dayBookList.BillNo = ""; // dayBookList.ResultSubclass = ""; // } // else // { // error = "没有检测到关联单"; // error += "【工号】:" + exceptionList.WorkID + "【时间】:" + exceptionList.Date.ToShortDateString(); // timeException.ExceptionDescription += ";没有检测到关联单;"; // timeException.ExceptionDescription += "【工号】:" + exceptionList.WorkID + "【时间】:" + exceptionList.Date.ToShortDateString(); // return false; // } // if (result.Single().ExceptionType != timeException.RealExceptionType) // { // if (exceptionList.DeptAuditor != null && exceptionList.DeptAuditor != "") // { // dayBookList.Remark = timeException.ExceptionDescription + // " 异常类型由之前的" + new AttendanceMachineServer().GetExceptionTypeName(result.Single().ExceptionType) + // "更改为" + new AttendanceMachineServer().GetExceptionTypeName(timeException.RealExceptionType) + // ";更改人:" + new PersonnelArchiveServer().GetPersonnelInfo(exceptionList.DeptAuditor).Name; // } // else // { // dayBookList.Remark = timeException.ExceptionDescription + // " 异常类型由之前的" + new AttendanceMachineServer().GetExceptionTypeName(result.Single().ExceptionType) + // "更改为" + new AttendanceMachineServer().GetExceptionTypeName(timeException.RealExceptionType) + // ";更改人:" + BasicInfo.LoginName; // } // } // break; //} #endregion break; default: exceptionList.RealExceptionType = timeException.RealExceptionType; exceptionList.ExceptionDescription = timeException.ExceptionDescription; break; } } dataContxt.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }