public long?CreateHoliday(DateTime date, string name, long ptoCycle) { long returnValue; try { using (var context = new PTOMEntities()) { returnValue = GetSequenceNextValue(context, "PTOMS.HOLIDAY_ID_SQ"); var holiday = new HOLIDAY { HOLIDAY_ID = returnValue, NAME = name, HOLIDAY_DATE = date, PTO_CYCLE = ptoCycle }; context.HOLIDAY.AddObject(holiday); context.SaveChanges(); } } catch (Exception ex) { LoggingHelper.LogServiceMessage(LoggingHelper.MessageType.Error, string.Empty, ex); throw; } return(returnValue); }
public bool QueryIsHoliday(HolidayManager hgr, DateTime t1) { string today = t1.ToString("yyyyMMdd"); //string status = null; HOLIDAY holiday = hgr.Query("SELECT * FROM HOLIDAY WHERE TO_CHAR(DAY,'yyyyMMdd') = " + today + "").FirstOrDefault(); if (holiday != null && (!"0".Equals(holiday.STATUS))) { return(true); // 非工作日 } else { return(false); // 工作日 } }