示例#1
0
        public void DeleteDate()
        {
            string cb_text;
            object test             = cb_ShiftWorkersList.SelectedItem;
            int    selected_listbox = ListBox.SelectedIndex;

            foreach (var record in list.ListOfWorkers)
            {
                cb_text = $"Shifts: {record.shift_list.Count} | {record.GetFunction()} | {record.GetWorkerData()} ";
                if (cb_text.Equals(test))
                {
                    record.shift_list.RemoveAt(selected_listbox);
                }
            }

            mw.Serialize_NewShift(list);
            Refresh.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
        }
示例#2
0
        public void Update_Date(string d)
        {
            object test             = cb_ShiftWorkersList.SelectedItem;
            string selected_listbox = ListBox.SelectedItem.ToString();
            bool   val_result;
            bool   failed = false;

            string text;

            list = MainWindow.Deserialize();

            foreach (var record in list.ListOfWorkers)
            {
                text = $"Shifts: {record.shift_list.Count} | {record.GetFunction()} | {record.GetWorkerData()} ";
                if (text.Equals(test))
                {
                    foreach (var item in record.shift_list)
                    {
                        string   to_compare = $"{item.date.ToShortDateString()}";
                        DateTime new_date   = Convert.ToDateTime(d);
                        val_result = ns.ShiftValidate(record.shift_list, new_date);
                        if (val_result.Equals(false))
                        {
                            MessageBox.Show(
                                "Can't update shift - 1 or 2 validation criterias failed\n1) Max 10 shifts in month\n2) Two or more cardiologist/urologist/etc. can't have shift at the same day");
                            failed = true;
                        }
                        else
                        {
                            item.date = new_date;
                            mw.Serialize_NewShift(list);
                            Refresh.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
                            break;
                        }

                        if (failed)
                        {
                            break;
                        }
                    }
                }
            }
        }