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); } }
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); } }