public void SetOnDepartmentSelected() { Mediator.GetInstance().CBoxDepartmentChanged += (department) => { if (department != null) { ScheduleProxy scheduleProxy = new ScheduleProxy(); try { Clear(); Schedule = scheduleProxy.GetScheduleByDepartmentIdAndDate(department.Id, DateBoxes[0].Date); Shifts = Schedule.Shifts; LoadShiftsIntoCalendar(); } catch (Exception) { Shifts.Clear(); Schedule = null; Clear(); AddTxtNoSchedule(); } } DepartmentId = department.Id; return(Schedule); }; }
private void PreviousBtnClickedAsViewEditCalendar() { SelectedWeekStartDate = SelectedWeekStartDate.AddDays(-7); UpdateDateBoxes(); NavCalendar.SelectedDate = SelectedWeekStartDate; Clear(); if (Schedule != null && Schedule.StartDate.CompareTo(DateBoxes[0].Date) >= 0) { try { Schedule = new ScheduleProxy().GetScheduleByDepartmentIdAndDate(DepartmentId, DateBoxes[0].Date); Shifts = Schedule.Shifts; } catch (Exception) { AddTxtNoSchedule(); Schedule = null; } } else if (Schedule == null) { try { Schedule = new ScheduleProxy().GetScheduleByDepartmentIdAndDate(DepartmentId, DateBoxes[0].Date); Shifts = Schedule.Shifts; } catch (Exception) { AddTxtNoSchedule(); Schedule = null; } } Mediator.GetInstance().OnNewScheduleActive(Schedule); }
public ViewScheduleView() { scheduleProxy = new ScheduleProxy(); departmentProxy = new DepartmentProxy(); InitializeComponent(); BindComboBoxData(); SetOnNewScheduleActive(); EventChangesListener(); HideStartEndTxt(); }
private void FromProxy(ScheduleProxy proxy) { this._enabled = proxy.Enabled; this._paused = proxy.Paused; this._frequency = proxy.Frequency; this._startDateTime = proxy.StartTime; this._recurEveryDays = proxy.RecurEveryDays; this._recurEveryWeeks = proxy.RecurEveryWeeks; this._repeatUnit = proxy.RepeatUnit; this._repeatFrequency = proxy.RepeatFrequency; this._repeat = proxy.Repeat; this._daysOfWeek = proxy.DaysOfWeek; this._months = proxy.Months; this._days = proxy.Days; this._lastRunTime = this.LastRunTime; }
private void SetOnResetButtonClicked() { Mediator.GetInstance().ResetButtonClicked += () => { try { Schedule = new ScheduleProxy().GetScheduleByDepartmentIdAndDate(Schedule.Department.Id, DateBoxes[0].Date); Clear(); Shifts = Schedule.Shifts; LoadShiftsIntoCalendar(); } catch (Exception) { MessageBox.Show("Something went wrong! Could not reset"); } }; }
public ActionResult GetEvents() { ScheduleProxy scheduleProxy = new ScheduleProxy(); Employee employee = (Employee)Session["employee"]; try { List <ScheduleShift> shifts = scheduleProxy.GetScheduleByDepartmentIdAndDate(employee.DepartmentId, DateTime.Now).Shifts; return(new JsonResult { Data = shifts, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } catch (Exception e) { } return(null); }
public void SetOnEditScheduleClicked() { Mediator.GetInstance().EditScheduleClicked += () => { try { ScheduleProxy scheduleProxy = new ScheduleProxy(); if (Schedule != null) { scheduleProxy.UpdateScheduleWithDelete(Schedule, DeletedShifts); MessageBox.Show("Schedule for " + Schedule.Department.Name + " Saved sucessfully"); } } catch (Exception) { MessageBox.Show("Something went wrong! Schedule could not be saved to database! "); } }; }
private ScheduleProxy ToProxy() { ScheduleProxy proxy = new ScheduleProxy(); proxy.Enabled = this.Enabled; proxy.Paused = this.Paused; proxy.Frequency = this.Frequency; proxy.StartTime = this.StartTime; proxy.RecurEveryDays = this.RecurEveryDays; proxy.RecurEveryWeeks = this.RecurEveryWeeks; proxy.RepeatUnit = this.RepeatUnit; proxy.RepeatFrequency = this.RepeatFrequency; proxy.Repeat = this.Repeat; proxy.DaysOfWeek = this._daysOfWeek; proxy.Months = this._months; proxy.Days = this._days; proxy.NextDueTime = this.NextDueTime; proxy.LastRunTime = this.LastRunTime; return(proxy); }
private void BlackOutDatePicker(int departmentId) { DatePicker.BlackoutDates.Clear(); DatePicker.SelectedDate = null; ScheduleProxy scheduleProxy = new ScheduleProxy(); try { List <Schedule> schedules = scheduleProxy.GetSchedulesByDepartmentId(departmentId); foreach (Schedule s in schedules) { CalendarDateRange blackOutDates = new CalendarDateRange(); blackOutDates.Start = s.StartDate; blackOutDates.End = s.EndDate; DatePicker.BlackoutDates.Add(blackOutDates); } } catch (Exception) { } }
private void BtnGenerateSchedule_Click(object sender, RoutedEventArgs e) { if (DatePicker.SelectedDate != null && ListTemplateSchedule.SelectedIndex != -1) { try { TemplateSchedule templateSchedule = (TemplateSchedule)ListTemplateSchedule.SelectedItem; DateTime startTime = (DateTime)DatePicker.SelectedDate; Schedule schedule = new ScheduleProxy().GenerateScheduleFromTemplateScheduleAndStartDate(templateSchedule, startTime); Mediator.GetInstance().OnGenerateScheduleButtonClicked(schedule); BtnPublishSchedule.IsEnabled = true; } catch (Exception) { MessageBox.Show("Could not generate Schedule! Please check all parameters and try again"); } } else { MessageBox.Show("Please select both, department, templateschedule and start date"); } }
public void SetOnCreateScheduleClicked() { Mediator.GetInstance().CreateScheduleClicked += () => { if (Schedule != null) { try { ScheduleProxy scheduleProxy = new ScheduleProxy(); scheduleProxy.InsertScheduleToDb(Schedule); MessageBox.Show("The schedule for " + Schedule.Department.Name + " StartDate: " + Schedule.StartDate.ToShortDateString() + " EndDate: " + Schedule.EndDate.ToShortDateString() + " was succesfully published"); } catch (DataInInvalidStateException) { MessageBox.Show("Hurlumhej!"); } catch (Exception e) { MessageBox.Show("Something went wrong!"); } } }; }