private void calendar1_DoubleClick(object sender, EventArgs e) { var schedule = calendar1.GetSchedule(calendar1.SelectedDate); CalendarControl.Schedule item = new CalendarControl.Schedule(); item.Start = calendar1.SelectedDate; if (schedule.Count() == 0) { item.Item = "×"; calendar1.RemoveSchedule(calendar1.SelectedDate); calendar1.AddSchedule(item); } else if (schedule[0].Item.ToString() == "×") { item.Item = "当直"; calendar1.RemoveSchedule(calendar1.SelectedDate); calendar1.AddSchedule(item); } else if (schedule[0].Item.ToString() == "当直") { item.Item = "△"; calendar1.RemoveSchedule(calendar1.SelectedDate); calendar1.AddSchedule(item); } else { calendar1.RemoveSchedule(calendar1.SelectedDate); } }
private void DeleteFromCalendar(RepeatRule target) { // dgvRuleで選択中のRowとそれに対応するRuleを削除する dgvRule.Rows.Remove(dgvRule.SelectedRows[0]); // 現在表示中のカレンダーの不都合日表示のみ削除する。(実際に削除するのはダイアログがOKされた時) var pdays = target.GetDays(Year, Month); pdays.AddRange(getBAMonthsAffairDays(Year, Month, target)); pdays.Where(pday => pday > 0 && pday <= DateTime.DaysInMonth(Year, Month)).ToList().ForEach(pday => { var targetdate = new DateTime(Year, Month, pday); if (!CheckTargetDate(Year, Month, pday)) { // 指定した日にちを対象とするルールが存在しなければカレンダーから削除 var schedule = calendar1.GetSchedule(targetdate); CalendarControl.Schedule item = new CalendarControl.Schedule(); item.Start = targetdate; calendar1.RemoveSchedule(item.Start); } }); }
private void setRule(RepeatRule rule) { // ルールに則ってカレンダーに不都合日を設定する var days = rule.GetDays(Year, Month); days.AddRange(getBAMonthsAffairDays(Year, Month, rule)); days.Where(day => day > 0 && day <= DateTime.DaysInMonth(Year, Month)).ToList().ForEach(day => { DateTime target = new DateTime(Year, Month, day); var schedule = calendar1.GetSchedule(target); CalendarControl.Schedule item = new CalendarControl.Schedule(); item.Start = target; if (schedule.Count() == 0) { item.Item = "×"; item.Alignment = StringAlignment.Center; calendar1.RemoveSchedule(item.Start); calendar1.AddSchedule(item); } }); AddedRule.Add(rule); }
private void FormSetting_Load(object sender, EventArgs e) { menu = new ContextMenuStrip(); this.Text = "個人設定"; SortStandbyLists(); txtName.Text = Person.Name; calendar1.ScheduleLabelSpace = 2; calendar1.LabelHeight = 30; if (Person != null) { num1st.Value = Person.Requirement.PossibleTimes; numHoliday.Value = Person.Requirement.HolidayPossibleTimes; numInterval.Value = Person.Requirement.Interval; numHolidayInterval.Value = Person.Requirement.HolidayInterval; calendar1.SetDrawDate(Year, Month); cmbAttr.Items.Add("医員"); cmbAttr.Items.Add("助教"); switch (Person.Attre) { case StandbyList.Person.Attributes.医員: cmbAttr.Text = "医員"; break; case StandbyList.Person.Attributes.助教: cmbAttr.Text = "助教"; break; } PossibleDays.Status status; for (int i = 0; i < DateTime.DaysInMonth(Year, Month); i++) { status = Person[new DateTime(Year, Month, i + 1)]; CalendarControl.Schedule item; DateTime date = new DateTime(Year, Month, i + 1); switch (status) { case PossibleDays.Status.Affair: item = new CalendarControl.Schedule(); item.Start = date; item.BackColor = Color.LightPink; item.LineAlignment = StringAlignment.Center; item.Alignment = StringAlignment.Center; item.Item = "×"; calendar1.AddSchedule(item); break; case PossibleDays.Status.Limited: item = new CalendarControl.Schedule(); item.Start = date; item.BackColor = Color.LightPink; item.LineAlignment = StringAlignment.Center; item.Alignment = StringAlignment.Center; item.Item = "△"; calendar1.AddSchedule(item); break; default: break; } } // dgvRuleの初期化 dgvRule.Columns.Add("期限", "期限"); dgvRule.Columns[(int)RuleIndex.Limit].Width = 130; dgvRule.Columns.Add("ルール", "ルール"); dgvRule.Columns[(int)RuleIndex.Rule].Width = 130; dgvRule.Columns.Add("理由", "理由"); dgvRule.Columns.Add("追加の不都合日", "追加の不都合日"); dgvRule.Columns[(int)RuleIndex.AddedAffair].Width = 100; Person.Requirement.RepeatRule.ForEach(t => setDgv(t)); // 新しく追加されたルール、削除されたルールを一時的に格納する変数を初期化 AddedRule = new List <RepeatRule>(); DeletedRule = new List <RepeatRule>(); } }
private void FormSetting_Load(object sender, EventArgs e) { this.Text = "個人設定"; txtName.Text = Person.Name; if (Person != null) { num1st.Value = Person.Requirement.FirstCallPossibleTimes; num2nd.Value = Person.Requirement.SecondCallPossibleTimes; num3rd.Value = Person.Requirement.ThirdCallPossibleTimes; numPCI.Value = Person.Requirement.PCIPossibleTimes; numHoliday.Value = Person.Requirement.HolidayPossibleTimes; num2ndHoliday.Value = Person.Requirement.SecondHolidayPossibleTimes; num3rdHoliday.Value = Person.Requirement.ThirdHolidayPossibleTimes; numPCIHoliday.Value = Person.Requirement.PCIHolidayPossibleTimes; numInterval.Value = Person.Requirement.Interval; num2ndInterval.Value = Person.Requirement.SecondInterval; num3rdInterval.Value = Person.Requirement.ThirdInterval; numPCIInterval.Value = Person.Requirement.PCIInterval; calendar1.SetDrawDate(Year, Month); cmbAttr.Items.Add("指導医"); cmbAttr.Items.Add("レジデント"); cmbAttr.Items.Add("PCI術者"); switch (Person.Attre) { case StandbyList.Person.Attributes.SeniorPhysician: cmbAttr.Text = "指導医"; break; case StandbyList.Person.Attributes.Resident: cmbAttr.Text = "レジデント"; break; case StandbyList.Person.Attributes.PCIOperator: cmbAttr.Text = "PCI術者"; break; } PossibleDays.Status status; for (int i = 0; i < DateTime.DaysInMonth(Year, Month); i++) { status = Person[new DateTime(Year, Month, i + 1)]; CalendarControl.Schedule item; DateTime date = new DateTime(Year, Month, i + 1); switch (status) { case PossibleDays.Status.Affair: item = new CalendarControl.Schedule(); item.Start = date; item.Item = "×"; calendar1.AddSchedule(item); break; case PossibleDays.Status.Duty: item = new CalendarControl.Schedule(); item.Start = date; item.Item = "当直"; calendar1.AddSchedule(item); break; case PossibleDays.Status.Limited: item = new CalendarControl.Schedule(); item.Start = date; item.Item = "△"; calendar1.AddSchedule(item); break; default: break; } } } }