Exemplo n.º 1
0
        private void menuNew_Click(object sender, EventArgs e)
        {
            StandbyList.StandbyList st;

            var stold = Core.StandbyLists.FirstOrDefault(t => t.Year == calendar1.DrawYear && t.Month == calendar1.DrawMonth);

            if (stold != null)
            {
                st = stold;
            }
            else
            {
                st = new StandbyList.StandbyList();
                st.SetDate(calendar1.DrawYear, calendar1.DrawMonth);
                var prevst = Core.StandbyLists.LastOrDefault(t => t.Year <= st.Year && t.Month < st.Month);
                if (prevst != null)
                {
                    if (MessageBox.Show("以前の設定を引き続き使用しますか?", "確認", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        st.Persons              = prevst.Persons;
                        st.FooterMessage        = prevst.FooterMessage;
                        st.FooterMessage_cannot = prevst.FooterMessage_cannot;
                    }
                }
                Core.StandbyLists.Add(st);
                Core.Sort();
                CreateStandbyEmpty();
                //Core.StandbyLists.Add(st);
            }
            calendar1.Enabled         = true;
            btnCreate.Enabled         = true;
            mnuCreate.Enabled         = true;
            mnuPrint.Enabled          = true;
            menuGlobalSetting.Enabled = true;
        }
Exemplo n.º 2
0
        private void CreateStandbyEmpty()
        {
            calendar1.RemoveMonth(calendar1.DrawYear, calendar1.DrawMonth);
            StandbyList.StandbyList st = Core.StandbyLists.FirstOrDefault(t => t.Year == calendar1.DrawYear && t.Month == calendar1.DrawMonth);
            if (st == null)
            {
                return;
            }

            StandbyList.DutyPersonsCollection sp;
            st.CreateEmpty();
            sp = st.Standby;
            var stold = Core.StandbyLists.FirstOrDefault(t => t.Year == st.Year && t.Month == st.Month);

            if (stold != null)
            {
                Core.StandbyLists.Remove(stold);
            }
            Core.StandbyLists.Add(st);
            Core.Sort();
            for (int i = 0; i < sp.Count; i++)
            {
                CalendarControl.Schedule item = new Schedule();
                item.Start       = new DateTime(st.Year, st.Month, i + 1);
                item.Item        = null;
                item.Description = "duty";
                item.BackColor   = Setting.DutyFieldColor;
                item.Alignment   = StringAlignment.Center;
                calendar1.AddSchedule(item);
            }
            ShowAgrregationForm();
        }
Exemplo n.º 3
0
        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();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 当直を交代可能な人のリストを作成します
        /// </summary>
        /// <param name="day">交代する対象の日にち(交代してほしい日にち)</param>
        /// <returns></returns>
        private List <SwapableList> GetSwapableList(int day)
        {
            var list = new List <SwapableList>();

            StandbyList.StandbyList st = Core.StandbyLists.FirstOrDefault(t => t.Year == calendar1.DrawYear && t.Month == calendar1.DrawMonth);
            // 対象の日にちに設定してあるPersonを一時的に削除する
            Person tmptp = st.Standby[day];

            st.Standby.SetDuty(day, null);
            for (int i = 0; i < DateTime.DaysInMonth(calendar1.DrawYear, calendar1.DrawMonth); i++)
            {
                // 1日から順番に走査して、交代が可能であればリストに追加していく
                // 交代相手の日にちのPersonも一時的に削除して、双方のPersonが双方の日にちで当直が可能かどうかを検討する
                Person tmpp = st.Standby[i + 1];
                st.Standby.SetDuty(i + 1, null);
                LimitedPerson lp  = st.PossiblePerson(new DateTime(calendar1.DrawYear, calendar1.DrawMonth, day), tmpp, st.Standby, Core.StandbyLists);
                LimitedPerson ltp = st.PossiblePerson(new DateTime(calendar1.DrawYear, calendar1.DrawMonth, i + 1), tmptp, st.Standby, Core.StandbyLists);
                if (lp != null && lp.LimitStatus == LimitedPerson.Limit.None && ltp != null && ltp.LimitStatus == LimitedPerson.Limit.None)
                {
                    if (tmpp.ID != tmptp.ID)
                    {
                        var swap = new SwapableList()
                        {
                            Day = i + 1, Person = tmpp
                        };
                        list.Add(swap);
                    }
                }
                st.Standby.SetDuty(i + 1, tmpp); //削除していたPersonを元に戻す
            }
            st.Standby.SetDuty(day, tmptp);

            return(list);
        }
Exemplo n.º 5
0
        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();
            }
        }
Exemplo n.º 6
0
        private static void LoadDatasElement(XmlElement ms)
        {
            foreach (XmlElement s in ms.ChildNodes)
            {
                switch (s.Name)
                {
                case YEAR_MONTH:
                    StandbyList.StandbyList st = null;
                    int year  = 1999;
                    int month = 1;
                    foreach (XmlElement ss in s.ChildNodes)
                    {
                        switch (ss.Name)
                        {
                        case DATE_YEAR:
                            year = int.Parse(ss.InnerText);
                            break;

                        case DATE_MONTH:
                            month = int.Parse(ss.InnerText);
                            st    = new StandbyList.StandbyList(year, month);
                            break;

                        case PERSONS:
                            st.Persons.AddRange(LoadPersonsElement(ss, year, month));
                            break;

                        case DUTYLISTS:
                            DutyPersonsCollection standby = new DutyPersonsCollection(year, month);
                            foreach (XmlElement dl in ss.ChildNodes)
                            {
                                int    day    = int.Parse(dl.Name.TrimStart('_'));
                                Person person = null;
                                try
                                {
                                    person = st.Persons.FirstOrDefault(t => t.ID == long.Parse(dl.FirstChild.InnerText));
                                }
                                catch { person = null; }
                                switch (dl.FirstChild.Name)
                                {
                                case "duty":
                                    standby.SetDuty(day, person ?? new Person(-1)
                                    {
                                        Name = dl.FirstChild.InnerText
                                    });
                                    break;
                                }
                            }
                            st.Standby = standby;
                            break;
                        }
                    }
                    Core.StandbyLists.Add(st);
                    break;
                }
            }
        }
Exemplo n.º 7
0
 private void PersonsAggregation(AggregationForm.DateInterval di)
 {
     StandbyList.StandbyList st = Core.StandbyLists.FirstOrDefault(t => t.Year == calendar1.DrawYear && t.Month == calendar1.DrawMonth);
     if (st == null)
     {
         return;
     }
     // 再カウント
     Core.TotalBurden(st.Persons, new DateTime(calendar1.Year, calendar1.Month, 1), di.Start, true);
 }
Exemplo n.º 8
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();
            }
        }
Exemplo n.º 9
0
        private void CreateStandbyEmpty()
        {
            calendar1.RemoveMonth(calendar1.DrawYear, calendar1.DrawMonth);
            StandbyList.StandbyList st = Core.StandbyLists.FirstOrDefault(t => t.Year == calendar1.DrawYear && t.Month == calendar1.DrawMonth);
            if (st == null)
            {
                return;
            }

            StandbyList.StandbyPersons[] sp;
            st.CreateEmpty();
            sp = st.Standby;
            var stold = Core.StandbyLists.FirstOrDefault(t => t.Year == st.Year && t.Month == st.Month);

            if (stold != null)
            {
                Core.StandbyLists.Remove(stold);
            }
            Core.StandbyLists.Add(st);
            Core.Sort();
            for (int i = 0; i < sp.Count(); i++)
            {
                CalendarControl.Schedule item = new Schedule();
                item.Start       = new DateTime(st.Year, st.Month, i + 1);
                item.Item        = null;
                item.Description = "1st";
                item.BackColor   = Setting.FirstColor;
                item.Alignment   = StringAlignment.Center;
                calendar1.AddSchedule(item);
                Schedule item2 = new Schedule();
                item2.Start       = new DateTime(st.Year, st.Month, i + 1);
                item2.Item        = null;
                item2.Description = "2nd";
                item2.BackColor   = Setting.SecondColor;
                item2.Alignment   = StringAlignment.Center;
                calendar1.AddSchedule(item2);
                Schedule item3 = new Schedule();
                item3.Start       = new DateTime(st.Year, st.Month, i + 1);
                item3.Item        = null;
                item3.Description = "3rd";
                item3.BackColor   = Setting.ThirdColor;
                item3.Alignment   = StringAlignment.Center;
                calendar1.AddSchedule(item3);
                Schedule item4 = new Schedule();
                item4.Start       = new DateTime(st.Year, st.Month, i + 1);
                item4.Item        = null;
                item4.Description = "PCI";
                item4.BackColor   = Setting.PCIColor;
                item4.Alignment   = StringAlignment.Center;
                calendar1.AddSchedule(item4);
            }
            PersonsAggregation();
        }
Exemplo n.º 10
0
        /// <summary>
        /// 総負荷を計算します。(平日当直1、休日当直2の割合で計算)
        /// </summary>
        /// <param name="persons">計算する月のPersonリスト</param>
        /// <param name="date">計算する月</param>
        /// <param name="backnum">何ヶ月前までさかのぼって計算するか</param>
        /// <param name="containpresentmonth">計算する月も計算に含めるかどうか。含める場合はtrue、含めない場合はfalse</param>
        public static void TotalBurden(List <Person> persons, DateTime date, int backnum, bool containpresentmonth)
        {
            persons.ForEach(p => p.TotalBurden = 0);
            // 総負荷を計算
            int start = containpresentmonth ? 0 : 1;

            for (int i = start; i <= backnum; i++)
            {
                DateTime tdate = date.AddMonths(-1 * i);
                StandbyList.StandbyList st2 = Core.StandbyLists.FirstOrDefault(t => t.Year == tdate.Year && t.Month == tdate.Month);
                if (st2 != null)
                {
                    persons.ForEach(t =>
                    {
                        t.TotalBurden += st2.DutyCount(t);
                    });
                }
            }
        }
Exemplo n.º 11
0
        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();
            }
        }
Exemplo n.º 12
0
        public static void LoadDatas(string filename)
        {
            if (string.IsNullOrEmpty(filename))
            {
                throw new FileNotFoundException();
            }
            Core.StandbyLists = new List <StandbyList.StandbyList>();

            try
            {
                using (XmlReader reader = XmlReader.Create(filename))
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.LocalName)
                            {
                            case COLOR1ST:
                                Setting.FirstColor = Color.FromName(reader.ReadString());
                                break;

                            case COLOR2ND:
                                Setting.SecondColor = Color.FromName(reader.ReadString());
                                break;

                            case COLOR3RD:
                                Setting.ThirdColor = Color.FromName(reader.ReadString());
                                break;

                            case COLORPCI:
                                Setting.PCIColor = Color.FromName(reader.ReadString());
                                break;

                            case TRYCOUNT:
                                Setting.TryCount = int.Parse(reader.ReadString());
                                break;

                            case YEAR_MONTH:
                                reader.Read();
                                StandbyList.StandbyList st = new StandbyList.StandbyList();
                                st.Persons.Clear();
                                int year  = 1999;
                                int month = 1;
                                while (!(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == YEAR_MONTH))
                                {
                                    if (reader.NodeType == XmlNodeType.Element)
                                    {
                                        switch (reader.LocalName)
                                        {
                                        case DATE_YEAR:
                                            year = int.Parse(reader.ReadString());
                                            break;

                                        case DATE_MONTH:
                                            month = int.Parse(reader.ReadString());
                                            st.SetDate(year, month);
                                            break;

                                        case FOOTERMESSAGE:
                                            st.FooterMessage = reader.ReadString();
                                            break;

                                        case FOOTERMESSAGE_CANNOT:
                                            st.FooterMessage_cannot = reader.ReadString();
                                            break;

                                        case PERSONS:
                                            reader.Read();
                                            while (!(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == PERSONS))
                                            {
                                                Person person = new Person();
                                                while (!(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == PERSON))
                                                {
                                                    if (reader.NodeType == XmlNodeType.Element)
                                                    {
                                                        switch (reader.LocalName)
                                                        {
                                                        case NAME:
                                                            person.Name = reader.ReadString();
                                                            break;

                                                        case ATTRIBUTE:
                                                            person.Attre = (Person.Attributes) int.Parse(reader.ReadString());
                                                            break;

                                                        case _1ST_COUNT:
                                                            person.Requirement.FirstCallPossibleTimes = int.Parse(reader.ReadString());
                                                            break;

                                                        case _2ND_COUNT:
                                                            person.Requirement.SecondCallPossibleTimes = int.Parse(reader.ReadString());
                                                            break;

                                                        case _3RD_COUNT:
                                                            person.Requirement.ThirdCallPossibleTimes = int.Parse(reader.ReadString());
                                                            break;

                                                        case _PCI_COUNT:
                                                            person.Requirement.PCIPossibleTimes = int.Parse(reader.ReadString());
                                                            break;

                                                        case _1ST_HOLIDAYCOUNT:
                                                            person.Requirement.HolidayPossibleTimes = int.Parse(reader.ReadString());
                                                            break;

                                                        case _2ND_HOLIDAYCOUNT:
                                                            person.Requirement.SecondHolidayPossibleTimes = int.Parse(reader.ReadString());
                                                            break;

                                                        case _3RD_HOLIDAYCOUNT:
                                                            person.Requirement.ThirdHolidayPossibleTimes = int.Parse(reader.ReadString());
                                                            break;

                                                        case _PCI_HOLIDAYCOUNT:
                                                            person.Requirement.PCIHolidayPossibleTimes = int.Parse(reader.ReadString());
                                                            break;

                                                        case _1ST_INTERVAL:
                                                            person.Requirement.Interval = int.Parse(reader.ReadString());
                                                            break;

                                                        case _2ND_INTERVAL:
                                                            person.Requirement.SecondInterval = int.Parse(reader.ReadString());
                                                            break;

                                                        case _3RD_INTERVAL:
                                                            person.Requirement.ThirdInterval = int.Parse(reader.ReadString());
                                                            break;

                                                        case _PCI_INTERVAL:
                                                            person.Requirement.PCIInterval = int.Parse(reader.ReadString());
                                                            break;

                                                        case POSSIBLES:
                                                            reader.Read();
                                                            while (!(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == POSSIBLES))
                                                            {
                                                                if (reader.NodeType == XmlNodeType.Element)
                                                                {
                                                                    int day = int.Parse(reader.LocalName.TrimStart('_'));
                                                                    person[new DateTime(year, month, day)] = (PossibleDays.Status) int.Parse(reader.ReadString());
                                                                }
                                                                reader.Read();
                                                            }
                                                            break;
                                                        }
                                                    }
                                                    reader.Read();
                                                }

                                                st.Persons.Add(person);
                                                reader.Read();
                                                reader.Read();
                                            }
                                            break;

                                        case STANDBYLISTS:
                                            reader.Read();
                                            StandbyPersons[] stanby = new StandbyPersons[DateTime.DaysInMonth(year, month)];
                                            while (!(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == STANDBYLISTS))
                                            {
                                                if (reader.NodeType == XmlNodeType.Element)
                                                {
                                                    int day = int.Parse(reader.LocalName.TrimStart('_'));
                                                    stanby[day - 1] = new StandbyPersons();
                                                    reader.Read();
                                                    while (!(reader.NodeType == XmlNodeType.EndElement && reader.LocalName == "_" + day.ToString()))
                                                    {
                                                        if (reader.NodeType == XmlNodeType.Element)
                                                        {
                                                            string tmp    = reader.ReadString();
                                                            Person person = st.Persons.FirstOrDefault(t => t.Name == tmp);
                                                            switch (reader.LocalName)
                                                            {
                                                            case "_1st":
                                                                stanby[day - 1].First = person ?? new Person()
                                                                {
                                                                    Name = tmp
                                                                };
                                                                break;

                                                            case "_2nd":
                                                                stanby[day - 1].Second = person ?? new Person()
                                                                {
                                                                    Name = tmp
                                                                };
                                                                break;

                                                            case "_3rd":
                                                                stanby[day - 1].Third = person ?? new Person()
                                                                {
                                                                    Name = tmp
                                                                };
                                                                break;

                                                            case "_PCI":
                                                                stanby[day - 1].PCI = person ?? new Person()
                                                                {
                                                                    Name = tmp
                                                                };
                                                                break;
                                                            }
                                                        }
                                                        reader.Read();
                                                    }
                                                }
                                                reader.Read();
                                            }
                                            st.Standby = stanby;
                                            break;
                                        }
                                        //reader.Read();
                                    }
                                    reader.Read();
                                }
                                Core.StandbyLists.Add(st);
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "ファイルの読み込みに失敗しました。");
            }
        }
Exemplo n.º 13
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();
            }
        }
Exemplo n.º 14
0
        private void CreateStandby()
        {
            calendar1.RemoveMonth(calendar1.DrawYear, calendar1.DrawMonth);
            StandbyList.StandbyList st = Core.StandbyLists.FirstOrDefault(t => t.Year == calendar1.Year && t.Month == calendar1.Month);
            if (st == null)
            {
                return;
            }

            StandbyList.StandbyPersons[]        sp;
            List <StandbyList.StandbyPersons[]> tmpsp = new List <StandbyPersons[]>();
            int count = 0;

            while (true)
            {
                count++;
                st.Create();
                sp = st.Standby;
                tmpsp.Add(sp);
                if (sp.All(p => p.Judge()) || count >= Setting.TryCount)
                {
                    if (count >= Setting.TryCount)
                    {
                        MessageBox.Show(count.ToString() + "通りの組合せを検討した結果、条件を満たす組合せが見つかりませんでした。最適と考えられる組合せを表示します。" +
                                        "必要であれば「設定」から個人の必要条件を変更の上、再度お試し下さい。");
                        StandbyPersons[] most = null;
                        int nullcount         = DateTime.DaysInMonth(calendar1.DrawYear, calendar1.DrawMonth) * 2;
                        tmpsp.ForEach(t =>
                        {
                            if (most == null)
                            {
                                most = t;
                            }
                            else
                            {
                                int c = t.ToList().Sum(u => u.NullCount());
                                if (nullcount >= c)
                                {
                                    most      = t;
                                    nullcount = c;
                                }
                            }
                        });
                        st.Standby = most;
                    }
                    //var stold = Core.StandbyLists.FirstOrDefault(t => t.Year == st.Year && t.Month == st.Month);
                    //if (stold != null)
                    //{
                    //	Core.StandbyLists.Remove(stold);
                    //}
                    //Core.StandbyLists.Add(st);
                    //Core.Sort();
                    break;
                }
            }
            sp = st.Standby;
            for (int i = 0; i < sp.Count(); i++)
            {
                CalendarControl.Schedule item = new CalendarControl.Schedule();
                item.Start = new DateTime(calendar1.DrawYear, calendar1.DrawMonth, i + 1);
                item.Item  = sp[i].First;
                if (sp[i].First != null)
                {
                    var status = sp[i].First.Possible.First(t => t.Year == calendar1.DrawYear && t.Month == calendar1.DrawMonth).PossibleDay[i];
                    if (status == StandbyList.PossibleDays.Status.Duty)
                    {
                        item.ForeColor = Setting.DutyColor;
                    }
                }
                item.Description = "1st";
                item.BackColor   = Setting.FirstColor;
                item.Alignment   = StringAlignment.Center;
                calendar1.AddSchedule(item);

                CalendarControl.Schedule item2 = new CalendarControl.Schedule();
                item2.Start = new DateTime(calendar1.DrawYear, calendar1.DrawMonth, i + 1);

                item2.Item        = sp[i].Second;
                item2.BackColor   = Setting.SecondColor;
                item2.Alignment   = StringAlignment.Center;
                item2.Description = "2nd";
                calendar1.AddSchedule(item2);

                CalendarControl.Schedule item3 = new CalendarControl.Schedule();
                item3.Start       = new DateTime(calendar1.DrawYear, calendar1.DrawMonth, i + 1);
                item3.Item        = sp[i].Third;
                item3.BackColor   = Setting.ThirdColor;
                item3.Alignment   = StringAlignment.Center;
                item3.Description = "3rd";
                calendar1.AddSchedule(item3);

                CalendarControl.Schedule item4 = new CalendarControl.Schedule();
                item4.Start       = new DateTime(calendar1.DrawYear, calendar1.DrawMonth, i + 1);
                item4.Item        = sp[i].PCI;
                item4.BackColor   = Setting.PCIColor;
                item4.Alignment   = StringAlignment.Center;
                item4.Description = "PCI";
                calendar1.AddSchedule(item4);
            }
            PersonsAggregation();
        }
Exemplo n.º 15
0
        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();
            }
        }
Exemplo n.º 16
0
        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();
            }
        }
Exemplo n.º 17
0
        private void PersonsAggregation()
        {
            if (AgForm == null || AgForm.Visible == false)
            {
                AgForm = new AggregationForm();
            }
            AgForm.Year  = calendar1.DrawYear;
            AgForm.Month = calendar1.DrawMonth;
            AgForm.dgView.Columns.Clear();
            AgForm.dgView.Columns.Add("name", "名前");
            AgForm.dgView.Columns.Add("総数", "待機数");
            AgForm.dgView.Columns.Add("1stの回数", "1st数");
            AgForm.dgView.Columns.Add("2ndの回数", "2nd数");
            AgForm.dgView.Columns.Add("3rdの回数", "3rd数");
            AgForm.dgView.Columns.Add("PCI待機回数", "PCI数");
            AgForm.dgView.Columns.Add("1stの休日", "1st休日数");
            AgForm.dgView.Columns.Add("2ndの休日", "2ndの休日数");
            AgForm.dgView.Columns[0].Width = 70;
            AgForm.dgView.Columns[1].Width = 65;
            AgForm.dgView.Columns[2].Width = 65;
            AgForm.dgView.Columns[3].Width = 65;
            AgForm.dgView.Columns[4].Width = 65;
            AgForm.dgView.Rows.Clear();
            StandbyList.StandbyList st = Core.StandbyLists.FirstOrDefault(t => t.Year == calendar1.DrawYear && t.Month == calendar1.DrawMonth);
            if (st == null)
            {
                return;
            }
            // 再カウント
            st.Persons.ForEach(p =>
            {
                p.FirstCounter         = 0;
                p.SecondCounter        = 0;
                p.ThirdCounter         = 0;
                p.PCICounter           = 0;
                p.HolidayCounter       = 0;
                p.SecondHolidayCounter = 0;
                p.ThirdHolidayCounter  = 0;
                p.PCIHolidayCounter    = 0;
            });
            for (int i = 0; i < st.Standby.Count(); i++)
            {
                var date = new DateTime(calendar1.DrawYear, calendar1.DrawMonth, i + 1);
                if (st.Standby[i].First != null)
                {
                    Person person = st.Standby[i].First;
                    if (person[date] != PossibleDays.Status.Duty)
                    {
                        person.FirstCounter++;
                        if (CalendarControl.GenCalendar.HolidayChecker.IsHoliday(date))
                        {
                            person.HolidayCounter++;
                        }
                    }
                }
                if (st.Standby[i].Second != null)
                {
                    Person person = st.Standby[i].Second;
                    person.SecondCounter++;
                    if (CalendarControl.GenCalendar.HolidayChecker.IsHoliday(date))
                    {
                        person.SecondHolidayCounter++;
                    }
                }
                if (st.Standby[i].Third != null)
                {
                    Person person = st.Standby[i].Third;
                    person.ThirdCounter++;
                    if (CalendarControl.GenCalendar.HolidayChecker.IsHoliday(date))
                    {
                        person.ThirdHolidayCounter++;
                    }
                }
                if (st.Standby[i].PCI != null)
                {
                    Person person = st.Standby[i].PCI;
                    person.PCICounter++;
                    if (CalendarControl.GenCalendar.HolidayChecker.IsHoliday(date))
                    {
                        person.PCIHolidayCounter++;
                    }
                }
            }

            st.Persons.ForEach(p =>
            {
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(AgForm.dgView);
                int firstnotholiday = p.FirstCounter - p.HolidayCounter;
                row.Cells[0].Value  = p;
                row.Cells[1].Value  = p.FirstCounter + p.SecondCounter + p.ThirdCounter;
                row.Cells[2].Value  = p.FirstCounter + "(" + firstnotholiday + "+" + p.HolidayCounter + ")" + "/" + p.Requirement.FirstCallPossibleTimes;
                row.Cells[3].Value  = p.SecondCounter + "/" + p.Requirement.SecondCallPossibleTimes;
                row.Cells[4].Value  = p.ThirdCounter + "/" + p.Requirement.ThirdCallPossibleTimes;
                row.Cells[5].Value  = p.PCICounter + "/" + p.Requirement.PCIPossibleTimes;
                row.Cells[6].Value  = p.HolidayCounter + "/" + p.Requirement.HolidayPossibleTimes;
                row.Cells[7].Value  = p.SecondHolidayCounter + "/" + p.Requirement.SecondHolidayPossibleTimes;
                AgForm.dgView.Rows.Add(row);
            });
            if (!AgForm.Visible)
            {
                AgForm.Show(this);
            }
        }
Exemplo n.º 18
0
        private void menuNew_Click(object sender, EventArgs e)
        {
            StandbyList.StandbyList st;

            var stold = Core.StandbyLists.FirstOrDefault(t => t.Year == calendar1.DrawYear && t.Month == calendar1.DrawMonth);

            if (stold != null)
            {
                if (MessageBox.Show("データを初期化してもよろしいですか?", "確認", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    if (MessageBox.Show("設定も初期化してよろしいですか?", "確認", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Core.StandbyLists.Remove(stold);
                    }
                    else
                    {
                        stold.Standby = new DutyPersonsCollection(calendar1.DrawYear, calendar1.DrawMonth);
                        CreateStandbyEmpty();
                        return;
                    }
                }
            }

            st = new StandbyList.StandbyList(calendar1.DrawYear, calendar1.DrawMonth);
            Core.Sort();
            var prevst = Core.StandbyLists.LastOrDefault(t => t.Year < st.Year || (t.Year <= st.Year && t.Month < st.Month));

            if (prevst != null)
            {
                if (MessageBox.Show(string.Format("以前の設定({0}年{1}月)を引き続き使用しますか?", prevst.Year, prevst.Month), "確認", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    prevst.Persons.ForEach(p =>
                    {
                        var targetperson = p.Clone() as Person;
                        if (targetperson == null)
                        {
                            return;
                        }
                        p.Requirement.RepeatRule.ForEach(rule =>
                        {
                            // 有効期限が切れているRuleは削除
                            if (rule.End < new DateTime(calendar1.DrawYear, calendar1.DrawMonth, DateTime.DaysInMonth(calendar1.DrawYear, calendar1.DrawMonth)))
                            {
                                targetperson.Requirement.RepeatRule.Remove(rule);
                            }
                            else
                            {
                                // 新規月の不都合日に当たる日を取得し、不都合日を設定する。
                                var days = rule.GetDays(calendar1.DrawYear, calendar1.DrawMonth);
                                days.Where(day => day > 0 && day <= DateTime.DaysInMonth(calendar1.DrawYear, calendar1.DrawMonth)).ToList().ForEach(day =>
                                {
                                    var date           = new DateTime(calendar1.DrawYear, calendar1.DrawMonth, day);
                                    targetperson[date] = PossibleDays.Status.Affair;
                                });
                            }
                        });
                        st.Persons.Add(targetperson);
                    });
                }

                Core.StandbyLists.Add(st);
                Core.Sort();
                CreateStandbyEmpty();
                //Core.StandbyLists.Add(st);
            }
            calendar1.Enabled         = true;
            btnCreate.Enabled         = true;
            mnuCreate.Enabled         = true;
            mnuPrint.Enabled          = true;
            menuGlobalSetting.Enabled = true;
        }
Exemplo n.º 19
0
        private void CreateStandby()
        {
            calendar1.RemoveMonth(calendar1.DrawYear, calendar1.DrawMonth);
            StandbyList.StandbyList st = Core.StandbyLists.FirstOrDefault(t => t.Year == calendar1.Year && t.Month == calendar1.Month);
            if (st == null)
            {
                return;
            }
            st.CreateEmpty();             // 現在のデータを初期化する。

            List <StandbyList.StandbyList> tmpsp = new List <StandbyList.StandbyList>();
            List <double> listbunsan             = new List <double>();
            List <double> listbunsanh            = new List <double>();
            List <double> listbunsant            = new List <double>();
            int           count = 0;
            int           index = 0;

            StandbyList.StandbyList most = null;

            while (true)
            {
                count++;
                st.Create(Core.StandbyLists);

                tmpsp.Add(st.Clone() as StandbyList.StandbyList);
                st.Clear();
                // *分散を求めて、最も分散が小さいものを選択。(平日の当直回数のバラツキが最も少ないものを選択)
                double dutycount    = 0;
                double holidaycount = 0;
                double totalcount   = 0;
                st.Persons.ForEach(t =>
                {
                    dutycount    += st.OrdinaryDutyCount(t);
                    holidaycount += st.HolidayCount(t);
                    totalcount   += st.DutyCount(t);
                });
                double dutyaverage    = dutycount / st.Persons.Count;
                double holidayaverage = holidaycount / st.Persons.Count;
                double totalaverage   = totalcount / st.Persons.Count;

                double dutybunsan    = 0;
                double holidaybunsan = 0; // 今の所、こちらは使わない。
                double totalbunsan   = 0;

                st.Persons.ForEach(t =>
                {
                    dutybunsan    += Math.Pow((dutyaverage - st.OrdinaryDutyCount(t)), 2);
                    holidaybunsan += Math.Pow((holidayaverage - st.HolidayCount(t)), 2);
                    totalbunsan   += Math.Pow((totalaverage - st.DutyCount(t)), 2);
                });

                listbunsan.Add(dutybunsan);
                listbunsanh.Add(holidaybunsan);
                listbunsant.Add(totalbunsan);
                // *ここまで
                if (count >= 1000 /*Setting.TryCount*/)
                {
                    int nullcount = DateTime.DaysInMonth(calendar1.DrawYear, calendar1.DrawMonth);
                    tmpsp.ForEach(t =>
                    {
                        if (most == null)
                        {
                            most = t;
                        }
                        else
                        {
                            int c = t.Standby.NullCount();
                            if (nullcount >= c)
                            {
                                most      = t;
                                nullcount = c;
                            }
                        }
                    });


                    break;
                }
            }
            while (tmpsp.Count > 0)
            {
                double min = listbunsant.Min(); // 求めた分散の中で最も小さいものを選別。
                index = listbunsant.IndexOf(min);
                // 分散で選んだ予定表候補に抜けがないかをチェック。抜けがある場合はリストから削除し、再度最小の分散を選択する。
                if (tmpsp[index].Standby.NullCheck())
                {
                    Core.StandbyLists.Remove(st);
                    Core.StandbyLists.Add(tmpsp[index]);
                    break;
                }
                else
                {
                    tmpsp.RemoveAt(index);
                    listbunsant.RemoveAt(index);
                }
            }
            // 抜けのない予定表候補が見つからない場合はあきらめる。
            if (tmpsp.Count == 0)
            {
                MessageBox.Show(count.ToString() + "通りの組合せを検討した結果、条件を満たす組合せが見つかりませんでした。" +
                                "「設定」から個人の必要条件を変更の上、再度お試し下さい。");
                Core.StandbyLists.Remove(st);
                Core.StandbyLists.Add(most);
                //st = most;
            }
            // カレンダーへの表示処理
            StandbyList.StandbyList resultlist = Core.StandbyLists.FirstOrDefault(t => t.Year == calendar1.Year && t.Month == calendar1.Month);
            for (int i = 0; i < resultlist.Standby.Count; i++)
            {
                CalendarControl.Schedule item = new CalendarControl.Schedule();
                item.Start = new DateTime(calendar1.DrawYear, calendar1.DrawMonth, i + 1);
                item.Item  = resultlist.Standby[i + 1];
                if (resultlist.Standby[i + 1] != null)
                {
                    // これは削除可能?
                    var status = resultlist.Standby[i + 1].Possible.First(t => t.Year == calendar1.DrawYear && t.Month == calendar1.DrawMonth).PossibleDay[i];
                }
                item.Description = "duty";
                item.BackColor   = Setting.DutyFieldColor;
                item.Alignment   = StringAlignment.Center;
                calendar1.AddSchedule(item);
            }
            // 集計
            ShowAgrregationForm();
        }
Exemplo n.º 20
0
        private void ShowAgrregationForm()
        {
            if (AgForm == null)
            {
                AgForm = new AggregationForm();

                AgForm.dgView.Columns.Clear();
                AgForm.dgView.Columns.Add("name", "名前");
                AgForm.dgView.Columns.Add("total", "総数");
                AgForm.dgView.Columns.Add("当直回数", "平日当直");
                AgForm.dgView.Columns.Add("休日当直", "休日当直");
                AgForm.dgView.Columns.Add("総負荷", "総負荷");
                AgForm.dgView.Columns[0].Width = 70;
                AgForm.dgView.Columns[1].Width = 65;
                AgForm.dgView.Columns[2].Width = 65;
                AgForm.dgView.Columns[3].Width = 65;
                AgForm.dgView.Columns[4].Width = 70;
                AgForm.SelectionChanged       += AgForm_SelectionChanged;
                AgForm.FormClosed += AgForm_FormClosed;
                AgForm.AggregationIntervalChanged += AgForm_AggregationIntervalChanged;
            }
            AgForm.Year  = calendar1.DrawYear;
            AgForm.Month = calendar1.DrawMonth;
            PersonsAggregation(new AggregationForm.DateInterval(AgForm.CriteriaDate));
            AgForm.Reload();
            // 現在選択中のRowを仮保存
            DataGridViewRow selected = null;

            if (AgForm.dgView.SelectedRows.Count != 0)
            {
                selected = AgForm.dgView.SelectedRows[0];
            }
            AgForm.dgView.Rows.Clear();
            StandbyList.StandbyList st = Core.StandbyLists.FirstOrDefault(t => t.Year == calendar1.DrawYear && t.Month == calendar1.DrawMonth);
            if (st != null)
            {
                st.Persons.ForEach(p =>
                {
                    DataGridViewRow row = new DataGridViewRow();
                    row.CreateCells(AgForm.dgView);
                    if (p.Attre == Person.Attributes.助教)
                    {
                        row.DefaultCellStyle.BackColor = Color.AliceBlue;
                    }
                    row.Tag            = p;
                    row.Cells[0].Value = p;
                    row.Cells[1].Value = p.OrdinaryDutyCount + p.HolidayCount;
                    row.Cells[2].Value = p.OrdinaryDutyCount + "/" + p.Requirement.PossibleTimes;
                    row.Cells[3].Value = p.HolidayCount + "/" + p.Requirement.HolidayPossibleTimes;
                    row.Cells[4].Value = p.TotalBurden;
                    AgForm.dgView.Rows.Add(row);
                });
                if (selected != null)
                {
                    var trow = AgForm.dgView.Rows.Cast <DataGridViewRow>().FirstOrDefault(r => (r.Cells[0].Value as Person).ID == (selected.Cells[0].Value as Person).ID);
                    if (trow != null)
                    {
                        AgForm.dgView.Rows[trow.Index].Selected = true;
                    }
                }
            }
            if (!AgForm.Visible)
            {
                AgForm.Show(this);
            }
        }