Exemplo n.º 1
0
        public void LoadCollections()
        {
            Areas.Clear();
            Operations.Clear();
            Personal.Clear();
            Shifts.Clear();

            foreach (var area in _collectionsRepository.LoadWorkAreas())
            {
                Areas.Add(area);
            }

            foreach (var operation in _collectionsRepository.LoadWorks())
            {
                Operations.Add(operation);
            }

            foreach (var employee in _collectionsRepository.LoadPersonal())
            {
                Personal.Add(employee);
            }

            foreach (var shift in _collectionsRepository.LoadShiftSet())
            {
                Shifts.Add(shift);
            }
        }
        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 SetCreateTemplateScheduleClicked()
 {
     Mediator.GetInstance().CreateTemplateScheduleButtonClicked += (templateSchedule) =>
     {
         if (IsVisible)
         {
             if (Shifts.Count == 0)
             {
                 MessageBox.Show("No shifts has been added!");
             }
             else
             {
                 try
                 {
                     TemplateScheduleProxy templateScheduleProxy = new TemplateScheduleProxy();
                     templateSchedule.TemplateShifts = Shifts;
                     templateScheduleProxy.AddTemplateScheduleToDb(templateSchedule);
                     Shifts.Clear();
                     MessageBox.Show("Template schedule is now saved onto database");
                     Clear();
                 }
                 catch (Exception)
                 {
                     MessageBox.Show("Something went wrong! Templateschedule could not be saved! Too bad");
                 }
             }
         }
     };
 }
 public void SetOnDepartmentSelectionChanged()
 {
     Mediator.GetInstance().DepartmentBoxChanged += (d) =>
     {
         if (IsVisible)
         {
             if (Shifts.Count > 0)
             {
                 if (MessageBox.Show("Your work will be lost. Are you sure?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.No)
                 {
                     Shifts.Clear();
                     Clear();
                 }
             }
         }
     };
 }
Exemplo n.º 5
0
        internal void ResetLogin()
        {
            var startTime = DateTime.Now;

            _log.Info("ResetLogin method call started");
            LoginModel.UserName = string.Empty;
            LoginModel.Password = string.Empty;
            LoginModel.TillNumbers?.Clear();
            LoginModel.Shifts?.Clear();
            Shifts?.Clear();
            IsUserNameEnabled = true;
            IsPasswordEnabled = true;

            var endTime = DateTime.Now;

            _log.Info(string.Format("ResetLogin method call ended in {0}ms",
                                    (endTime - startTime).TotalMilliseconds));
        }
 public void SetTemplateScheduleSelected()
 {
     Mediator.GetInstance().TemplateScheduleSelected += (s, e) =>
     {
         if (IsVisible)
         {
             Clear();
             Shifts.Clear();
             AddShifts(e.TemplateSchedule.TemplateShifts);
             if (e.TemplateSchedule.NoOfWeeks > 1)
             {
                 BtnNextWeek.IsEnabled = true;
             }
             numOfWeeks = e.TemplateSchedule.NoOfWeeks;
             LoadShiftsIntoCalendar();
         }
     };
 }
Exemplo n.º 7
0
 private void LoadFromFile()
 {
     try
     {
         Shifts.Clear();
         if (File.Exists(Filepath))
         {
             Shifts = JsonConvert.DeserializeObject <List <ShiftItem> >(File.ReadAllText(Filepath));
         }
         foreach (var shift in Shifts)
         {
             shift.Position.AdjustColorBoundaries();
         }
     }
     catch (Exception e) {
         Shifts = new List <ShiftItem>();
         System.Windows.MessageBox.Show("Failed reading shifts storage: " + e.Message, Helpers.application_name, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
     }
 }
Exemplo n.º 8
0
 public void Reset()
 {
     Shifts.Clear();
     NotifyOnChange();
 }