private void ShowfreeCommentForm(ScheduleLabel schedulelabel) { FormComment form = new FormComment(); Person person = null; if (schedulelabel.Schedule.Item != null) { person = schedulelabel.Schedule.Item as Person; } StandbyList.StandbyList st = Core.StandbyLists.FirstOrDefault(t => t.Year == calendar1.DrawYear && t.Month == calendar1.DrawMonth); if (st == null) { return; } int day = schedulelabel.Schedule.Start.Day; if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (form.Person != null) { st.Standby.SetDuty(day, form.Person); schedulelabel.Schedule.Item = form.Person; } ShowAgrregationForm(); } }
private void DeleteSchedule() { ScheduleLabel label = calendar1.SelectedScheduleLabel; StandbyList.StandbyList st = Core.StandbyLists.FirstOrDefault(t => t.Year == calendar1.Year && t.Month == calendar1.Month); if (st == null) { return; } int day = label.Schedule.Start.Day; if (label != null) { Person p = label.Schedule.Item as Person; if (p != null) { Person newp = new Person(-1) { Name = "-" }; if (label.Schedule.Description == "duty") { st.Standby.SetDuty(day, newp); label.Schedule.Item = newp; } } ShowAgrregationForm(); } }
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(); } }
private void RandomSelect() { ScheduleLabel label = calendar1.SelectedScheduleLabel; if (label == null) { return; } StandbyList.StandbyList st = Core.StandbyLists.FirstOrDefault(t => t.Year == calendar1.DrawYear & t.Month == calendar1.DrawMonth); if (st != null) { var plist = st.PossibleList(calendar1.SelectedDate, st.Standby, Core.StandbyLists); if (plist.Count == 0) { MessageBox.Show("この日に設定できる候補者が存在しません"); return; } plist = plist.OrderBy(u => Guid.NewGuid()).ToList(); st.Standby.SetDuty(label.Schedule.Start.Day, plist[0].Person); label.Schedule.Item = plist[0].Person; ShowAgrregationForm(); } }
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(); } }
private void ShowfreeCommentForm(ScheduleLabel schedulelabel) { FormComment form = new FormComment(); StandbyList.StandbyList.StandbyPosition pos; Person person = null; if (schedulelabel.Schedule.Item != null) { person = schedulelabel.Schedule.Item as Person; } 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; } int day = schedulelabel.Schedule.Start.Day - 1; if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (form.Person != null) { if (pos == StandbyList.StandbyList.StandbyPosition.First) { if (person != null) { person.FirstCounter--; if (CalendarControl.GenCalendar.HolidayChecker.IsHoliday(schedulelabel.Schedule.Start)) { person.HolidayCounter--; } } st.Standby[day].First = form.Person; schedulelabel.Schedule.Item = form.Person; } else if (pos == StandbyList.StandbyList.StandbyPosition.Second) { if (person != null) { person.SecondCounter--; if (CalendarControl.GenCalendar.HolidayChecker.IsHoliday(schedulelabel.Schedule.Start)) { person.SecondHolidayCounter--; } } st.Standby[day].Second = form.Person; schedulelabel.Schedule.Item = form.Person; } else if (pos == StandbyList.StandbyList.StandbyPosition.Third) { if (person != null) { person.ThirdCounter--; if (CalendarControl.GenCalendar.HolidayChecker.IsHoliday(schedulelabel.Schedule.Start)) { person.ThirdHolidayCounter--; } } st.Standby[day].Third = form.Person; schedulelabel.Schedule.Item = form.Person; } else if (pos == StandbyList.StandbyList.StandbyPosition.PCI) { if (person != null) { person.PCICounter--; if (CalendarControl.GenCalendar.HolidayChecker.IsHoliday(schedulelabel.Schedule.Start)) { person.PCIHolidayCounter--; } } st.Standby[day].PCI = form.Person; schedulelabel.Schedule.Item = form.Person; } } PersonsAggregation(); } }
private void DeleteSchedule() { ScheduleLabel label = calendar1.SelectedScheduleLabel; StandbyList.StandbyList st = Core.StandbyLists.FirstOrDefault(t => t.Year == calendar1.Year && t.Month == calendar1.Month); if (st == null) { return; } int day = label.Schedule.Start.Day - 1; if (label != null) { Person p = label.Schedule.Item as Person; if (p != null) { Person newp = new Person() { Name = "-" }; if (label.Schedule.Description == "1st") { p.FirstCounter--; if (CalendarControl.GenCalendar.HolidayChecker.IsHoliday(label.Schedule.Start)) { p.HolidayCounter--; } st.Standby[day].First = newp; label.Schedule.Item = newp; } else if (label.Schedule.Description == "2nd") { p.SecondCounter--; if (CalendarControl.GenCalendar.HolidayChecker.IsHoliday(label.Schedule.Start)) { p.SecondHolidayCounter--; } st.Standby[day].Second = newp; label.Schedule.Item = newp; } else if (label.Schedule.Description == "3rd") { p.ThirdCounter--; if (CalendarControl.GenCalendar.HolidayChecker.IsHoliday(label.Schedule.Start)) { p.ThirdHolidayCounter--; } st.Standby[day].Third = newp; label.Schedule.Item = newp; } else if (label.Schedule.Description == "PCI") { p.PCICounter--; if (CalendarControl.GenCalendar.HolidayChecker.IsHoliday(label.Schedule.Start)) { p.PCIHolidayCounter--; } st.Standby[day].PCI = new Person() { Name = "×" }; label.Schedule.Item = st.Standby[day].PCI; } } PersonsAggregation(); } }