Beispiel #1
0
        private void ShowSubForm(ScheduleLabel schedulelabel)
        {
            SubForm form = new SubForm();
            List <LimitedPerson> list;

            StandbyList.StandbyList st = Core.StandbyLists.FirstOrDefault(t => t.Year == calendar1.DrawYear && t.Month == calendar1.DrawMonth);
            if (st == null)
            {
                return;
            }
            list      = st.PossibleList(schedulelabel.Schedule.Start, st.Standby, Core.StandbyLists);
            form.Date = schedulelabel.Schedule.Start;
            form.AddRange(list);
            form.AddRange(GetSwapableList(schedulelabel.Schedule.Start.Day));
            form.SelectionChanged += SubForm_SwapViewSelectionChanged;
            form.FormClosed       += SubForm_FormClosed;
            int day = schedulelabel.Schedule.Start.Day;

            if (schedulelabel != null)
            {
                if (schedulelabel.Schedule.Description == "duty")
                {
                    form.Person = st.Standby[day];
                }
            }
            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (form.Person != null)
                {
                    switch (form.Type)
                    {
                    case SubForm.SubFormType.Change:
                        if (schedulelabel.Schedule.Description == "duty")
                        {
                            st.Standby.SetDuty(day, form.Person);
                            schedulelabel.Schedule.Item = form.Person;
                        }
                        break;

                    case SubForm.SubFormType.Swap:
                        st.Standby.SetDuty(form.Date.Day, schedulelabel.Schedule.Item as Person);
                        st.Standby.SetDuty(schedulelabel.Schedule.Start.Day, form.Person);
                        var swapschedule = calendar1.GetSchedule(form.Date);
                        swapschedule[0].Item        = schedulelabel.Schedule.Item;
                        schedulelabel.Schedule.Item = form.Person;
                        form.SelectionChanged      -= SubForm_SwapViewSelectionChanged;

                        break;
                    }
                }
                ShowAgrregationForm();
            }
        }
Beispiel #2
0
        private void ShowSubForm(ScheduleLabel schedulelabel)
        {
            SubForm form = new SubForm();
            List <LimitedPerson> list;

            StandbyList.StandbyList.StandbyPosition pos;
            if (schedulelabel.Schedule.Description == "1st")
            {
                pos = StandbyList.StandbyList.StandbyPosition.First;
            }
            else if (schedulelabel.Schedule.Description == "2nd")
            {
                pos = StandbyList.StandbyList.StandbyPosition.Second;
            }
            else if (schedulelabel.Schedule.Description == "3rd")
            {
                pos = StandbyList.StandbyList.StandbyPosition.Third;
            }
            else
            {
                pos = StandbyList.StandbyList.StandbyPosition.PCI;
            }
            StandbyList.StandbyList st = Core.StandbyLists.FirstOrDefault(t => t.Year == calendar1.DrawYear && t.Month == calendar1.DrawMonth);
            if (st == null)
            {
                return;
            }
            list = st.PossibleList(schedulelabel.Schedule.Start, st.Standby, pos);            //.Where(p => p.LimitStatus == LimitedPerson.Limit.None).Select(t => t.Person).ToList();
            //if (list.Count != 0 && list[0][schedulelabel.Schedule.Start] == StandbyList.PossibleDays.Status.Duty) list.Clear();
            form.AddRange(list);
            ;
            int day = schedulelabel.Schedule.Start.Day - 1;

            if (schedulelabel != null)
            {
                if (schedulelabel.Schedule.Description == "1st")
                {
                    form.Person = st.Standby[day].First;
                }
                else if (schedulelabel.Schedule.Description == "2nd")
                {
                    form.Person = st.Standby[day].Second;
                }
                else if (schedulelabel.Schedule.Description == "3rd")
                {
                    form.Person = st.Standby[day].Third;
                }
                else if (schedulelabel.Schedule.Description == "PCI")
                {
                    form.Person = st.Standby[day].PCI;
                }
            }
            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (form.Person != null)
                {
                    if (schedulelabel.Schedule.Description == "1st")
                    {
                        if (st.Standby[day].First != null)
                        {
                            st.Standby[day].First.FirstCounter--;
                        }
                        form.Person.FirstCounter++;
                        if (schedulelabel.Schedule.Start.DayOfWeek == DayOfWeek.Saturday ||
                            schedulelabel.Schedule.Start.DayOfWeek == DayOfWeek.Sunday ||
                            !(CalendarControl.GenCalendar.HolidayChecker.Holiday(schedulelabel.Schedule.Start).holiday == CalendarControl.GenCalendar.HolidayChecker.HolidayInfo.HOLIDAY.WEEKDAY))
                        {
                            if (st.Standby[day].First != null)
                            {
                                st.Standby[day].First.HolidayCounter--;
                            }
                            form.Person.HolidayCounter++;
                        }
                        st.Standby[day].First       = form.Person;
                        schedulelabel.Schedule.Item = form.Person;
                    }
                    else if (schedulelabel.Schedule.Description == "2nd")
                    {
                        if (st.Standby[day].Second != null)
                        {
                            st.Standby[day].Second.SecondCounter--;
                        }
                        form.Person.SecondCounter++;
                        if (schedulelabel.Schedule.Start.DayOfWeek == DayOfWeek.Saturday ||
                            schedulelabel.Schedule.Start.DayOfWeek == DayOfWeek.Sunday ||
                            !(CalendarControl.GenCalendar.HolidayChecker.Holiday(schedulelabel.Schedule.Start).holiday == CalendarControl.GenCalendar.HolidayChecker.HolidayInfo.HOLIDAY.WEEKDAY))
                        {
                            if (st.Standby[day].Second != null)
                            {
                                st.Standby[day].Second.SecondHolidayCounter--;
                            }
                            form.Person.SecondHolidayCounter++;
                        }
                        st.Standby[day].Second      = form.Person;
                        schedulelabel.Schedule.Item = form.Person;
                    }
                    else if (schedulelabel.Schedule.Description == "3rd")
                    {
                        if (st.Standby[day].Third != null)
                        {
                            st.Standby[day].Third.ThirdCounter--;
                        }
                        form.Person.ThirdCounter++;
                        if (schedulelabel.Schedule.Start.DayOfWeek == DayOfWeek.Saturday ||
                            schedulelabel.Schedule.Start.DayOfWeek == DayOfWeek.Sunday ||
                            !(CalendarControl.GenCalendar.HolidayChecker.Holiday(schedulelabel.Schedule.Start).holiday == CalendarControl.GenCalendar.HolidayChecker.HolidayInfo.HOLIDAY.WEEKDAY))
                        {
                            if (st.Standby[day].Third != null)
                            {
                                st.Standby[day].Third.ThirdHolidayCounter--;
                            }
                            form.Person.ThirdHolidayCounter++;
                        }

                        st.Standby[day].Third       = form.Person;
                        schedulelabel.Schedule.Item = form.Person;
                    }
                    else if (schedulelabel.Schedule.Description == "PCI")
                    {
                        if (st.Standby[day].PCI != null)
                        {
                            st.Standby[day].PCI.PCICounter--;
                        }
                        form.Person.PCICounter++;
                        if (schedulelabel.Schedule.Start.DayOfWeek == DayOfWeek.Saturday ||
                            schedulelabel.Schedule.Start.DayOfWeek == DayOfWeek.Sunday ||
                            !(CalendarControl.GenCalendar.HolidayChecker.Holiday(schedulelabel.Schedule.Start).holiday == CalendarControl.GenCalendar.HolidayChecker.HolidayInfo.HOLIDAY.WEEKDAY))
                        {
                            if (st.Standby[day].PCI != null)
                            {
                                st.Standby[day].PCI.PCIHolidayCounter--;
                            }
                            form.Person.PCIHolidayCounter++;
                        }
                        st.Standby[day].PCI         = form.Person;
                        schedulelabel.Schedule.Item = form.Person;
                    }
                }
                PersonsAggregation();
            }
        }