public static Holiday HasHoliday(Holiday entity) { EntityModelContainer context = GetContext(); if (entity.EntityState == EntityState.Unchanged) return null; return context.ObjectStateManager.GetObjectStateEntries ((EntityState.Added | EntityState.Modified | EntityState.Unchanged)) .Select(e => e.Entity).OfType<Holiday>() .FirstOrDefault(x => x.Date == entity.Date); }
public static Visit[] HasHolidayVisit(Holiday entity) { EntityModelContainer context = GetContext(); return context.Visits.Execute(MergeOption.NoTracking).Where(v => v.ToTime.Date == entity.Date.Date).ToArray(); }
/// <summary> /// Create a new Holiday object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="date">Initial value of the Date property.</param> public static Holiday CreateHoliday(global::System.Int32 id, global::System.DateTime date) { Holiday holiday = new Holiday(); holiday.Id = id; holiday.Date = date; return holiday; }
/// <summary> /// Deprecated Method for adding a new object to the Holidays EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToHolidays(Holiday holiday) { base.AddObject("Holidays", holiday); }
private void faMonthView_DrawCurrentDay(object sender, FarsiLibrary.Win.Events.CustomDrawDayEventArgs e) { e.Handled = true; DateTime selectedDate = faMonthView.SelectedDateTime; DateTime eDate = PersianDateConverter.ToGregorianDateTime(new PersianDate(e.Year, e.Month, e.Day)); string dayNo = toFarsi.Convert(e.Day.ToString()); //see if e is public Holiday : color it and return string title; if ((title= Methods.ayyam(eDate)) != "") { if (test && selectedDate.Date == eDate.Date) { lblHolidayTitle.Text = title; test = false; } using (LinearGradientBrush br2 = new LinearGradientBrush(e.Rectangle, Color.MediumSpringGreen, Color.RosyBrown, 45, true)) { e.Graphics.FillRectangle(br2, e.Rectangle); e.Graphics.DrawString(dayNo, font, holidayBrush, e.Rectangle, fmt); } return; } //see if is clicked to add or remove from holidays Holiday hd = new Holiday(); hd.Date = eDate.Date; Holiday memHoliday = DataLayer.HasHoliday(hd); if (test && selectedDate.Date == eDate.Date) { if (memHoliday != null) { Visit[] vis = DataLayer.HasHolidayVisit(memHoliday); if (vis.Count() == 0 || Methods.ShowStandardMsgBox(FormMessageType.Question, "اخطار", "در این روز ویزیت تعریف شده است. آیا مایلید این روز تعطیل شود؟") == DialogResult.Yes) { DataLayer.Remove(memHoliday); memHoliday = null; } } else { DataLayer.Insert(hd); memHoliday = hd; } test = false; } //paint the calender depend on its holiday or not if (memHoliday != null) { using (LinearGradientBrush br2 = new LinearGradientBrush(e.Rectangle, Color.Red, Color.RosyBrown, 45, true)) { e.Graphics.FillRectangle(br2, e.Rectangle); e.Graphics.DrawString(dayNo, font, holidayBrush, e.Rectangle, fmt); } } else { using (LinearGradientBrush br2 = new LinearGradientBrush(e.Rectangle, Color.White, Color.White, 45, true)) { e.Graphics.FillRectangle(br2, e.Rectangle); e.Graphics.DrawString(dayNo, font, normalBrush, e.Rectangle, fmt); //faMonthView.Painter.DrawFocusRect(e.Graphics, e.Rectangle); } } }