/// <summary> /// 根据传入员工ID和月份(年-月:2011-6),更新指定月份员工作息记录 /// </summary> /// <param name="strEmployeeID"></param> public void UpdateAttendRecordByEmployeeIdWithLeaveRecord(string strEmployeeID, string strCurMonth) { try { if (string.IsNullOrWhiteSpace(strEmployeeID) || string.IsNullOrWhiteSpace(strCurMonth)) { return; } DateTime dtCheck = new DateTime(); DateTime dtStart = new DateTime(), dtEnd = new DateTime(); DateTime.TryParse(strCurMonth + "-1", out dtStart); if (dtStart <= dtCheck) { return; } dtEnd = dtStart.AddMonths(1).AddSeconds(-1); IQueryable <T_HR_ATTENDANCERECORD> entAttRds = GetAttendanceRecordByEmployeeIDAndDate(strEmployeeID, dtStart, dtEnd); EmployeeLeaveRecordBLL bllLeave = new EmployeeLeaveRecordBLL(); IQueryable <T_HR_EMPLOYEELEAVERECORD> entLeaveRds = bllLeave.GetEmployeeLeaveRdListByEmployeeIDAndDate(strEmployeeID, dtStart, dtEnd, "2"); if (entAttRds == null || entLeaveRds == null) { return; } if (entAttRds.Count() == 0 || entLeaveRds.Count() == 0) { return; } List <T_HR_EMPLOYEELEAVERECORD> entCheckLeaveRds = entLeaveRds.ToList(); List <T_HR_ATTENDANCERECORD> entCheckAttRds = new List <T_HR_ATTENDANCERECORD>(); foreach (T_HR_ATTENDANCERECORD item in entAttRds) { bool bIsLeave = false; foreach (T_HR_EMPLOYEELEAVERECORD checkItem in entCheckLeaveRds) { DateTime dtCheckStart = DateTime.Parse(checkItem.STARTDATETIME.Value.ToString("yyyy-MM-dd")); DateTime dtCheckEnd = DateTime.Parse(checkItem.ENDDATETIME.Value.ToString("yyyy-MM-dd")); if (dtCheckStart <= item.ATTENDANCEDATE && dtCheckEnd >= item.ATTENDANCEDATE) { bIsLeave = true; break; } } if (!bIsLeave) { continue; } item.ATTENDANCESTATE = (Convert.ToInt32(Common.AttendanceState.Leave) + 1).ToString(); ModifyAttRd(item); entCheckAttRds.Add(item); } if (entCheckAttRds.Count() > 0) { RemoveWrongSignRds(entCheckAttRds); } } catch (Exception ex) { Utility.SaveLog(ex.ToString()); } }