public ActionResult ShiftDetEdit(ShiftAll shiftAll, ShiftDetail shiftDetail) { shiftDetail.Shift = shiftAll.Code; if (ModelState.IsValid) { if (shiftAll.EndDate != null & shiftAll.StartDate != null) { if (System.DateTime.Compare((System.DateTime)shiftAll.EndDate, (System.DateTime)shiftAll.StartDate) < 1) { SaveErrorMessage(Resources.MD.WorkingCalendar.Errors_StartDateGreaterThanEndDate); return PartialView(shiftAll); } } this.genericMgr.UpdateWithTrim(shiftDetail); SaveSuccessMessage(Resources.MD.WorkingCalendar.ShiftDetail_Updated); } return PartialView(shiftAll); }
public ActionResult ShiftMstrNew(ShiftAll shiftAll, ShiftMaster shiftMaster, ShiftDetail shiftDetail) { if (ModelState.IsValid) { if (this.genericMgr.FindAll<long>(shiftMstrDuiplicateVerifyStatement, new object[] { shiftMaster.Code })[0] > 0) { SaveErrorMessage(Resources.SYS.ErrorMessage.Errors_Existing_Code, shiftMaster.Code.ToString()); } else { if (shiftAll.EndDate != null & shiftAll.StartDate != null) { if (System.DateTime.Compare((System.DateTime)shiftAll.EndDate, (System.DateTime)shiftAll.StartDate) < 1) { SaveErrorMessage(Resources.MD.WorkingCalendar.Errors_StartDateGreaterThanEndDate); return PartialView(shiftAll); } } shiftDetail.Shift = shiftAll.Code; WorkingCalendarMgr.CreateShiftMasterAndShiftDetail(shiftMaster, shiftDetail); SaveSuccessMessage(Resources.MD.WorkingCalendar.ShiftMaster_Added); return RedirectToAction("ShiftMstrEdit/" + shiftAll.Code); } } return PartialView(shiftAll); }
private void ValidatTime(ShiftDetail shiftDet, DateTime dayStartTime) { shiftDet.Start = ParseDateTime(shiftDet.StartTime); if (shiftDet.Start == DateTime.MinValue) { throw new BusinessException(Resources.PRD.ShiftDetail.Errors_From_LineValidatTime, shiftDet.Sequence.ToString(), Resources.PRD.ShiftDetail.Errors_Form_StartTime); } shiftDet.End = ParseDateTime(shiftDet.EndTime); if (shiftDet.End == DateTime.MinValue) { throw new BusinessException(Resources.PRD.ShiftDetail.Errors_From_LineValidatTime, shiftDet.Sequence.ToString(), Resources.PRD.ShiftDetail.Errors_Form_EndTime); } if (shiftDet.Start < dayStartTime) shiftDet.Start = shiftDet.Start.AddDays(1); // 如果结束结束时间小于 工作日开始时间,则视为第二天 if (shiftDet.End <= dayStartTime) shiftDet.End = shiftDet.End.AddDays(1); if (shiftDet.Start > shiftDet.End) { throw new BusinessException(Resources.PRD.ShiftDetail.Errors_From_LineValidatTime, shiftDet.Sequence.ToString(), Resources.PRD.ShiftDetail.Errors_StartTimeGreaterThanEndTime); } dayStartTime = dayStartTime.AddDays(1); if (shiftDet.Start < dayStartTime && shiftDet.End > dayStartTime) { throw new BusinessException(Resources.PRD.ShiftDetail.Errors_From_LineValidatTime, shiftDet.Sequence.ToString(), Resources.PRD.ShiftDetail.Errors_StartTimeLessThanDayOfStartTimeThenEndTimeCanNotGreatherThan); } }
private void Validate(ShiftDetail shiftDet, ShiftDetail lastDetail) { if (lastDetail == null) return; // 起始时间小于前一个班次明细的起始时间 if (shiftDet.Start < lastDetail.Start) { throw new BusinessException("第 {0} 行开始时间 {1} 不能小于第 {2} 行中的开始时间 {3}", shiftDet.Sequence.ToString(), shiftDet.StartTime, lastDetail.Sequence.ToString(), lastDetail.StartTime); } // 开始时间小于前一个班次明细的结束时间 if (shiftDet.Start < lastDetail.End) { throw new BusinessException("第 {0} 行开始时间 {1} 不能小于第 {2} 行中的结束时间 {3}", shiftDet.Sequence.ToString(), shiftDet.StartTime, lastDetail.Sequence.ToString(), lastDetail.EndTime); } }
public ActionResult _AjaxDetailList(GridCommand command, ShiftDetailSearchModel searchModel) { string hql = selectDetailStatement + " where sd.Shift='" + searchModel.Shift + "'"; if (searchModel.StartTime != null) { hql += " and sd.StartTime='" + searchModel.StartTime + "'"; } if (searchModel.EndTime != null) { hql += " and sd.EndTime='" + searchModel.EndTime + "'"; } hql += " order by Sequence"; IList<ShiftDetail> ShiftDetailList = base.genericMgr.FindAll<ShiftDetail>(hql); if (ShiftDetailList.Count() < 48) { for (int i = ShiftDetailList.Count() + 1; i <= 48; i++) { var shiftDetail = new ShiftDetail { Sequence = (short)i }; ShiftDetailList.Add(shiftDetail); } } TempData["Shift"] = searchModel.Shift; return PartialView(new GridModel<ShiftDetail>(ShiftDetailList)); }