예제 #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtName.Text == "")
            {
                MessageBox.Show("名前を入力して下さい");
                return;
            }
            Person.Name = txtName.Text;
            switch (cmbAttr.Text)
            {
            case "医員":
                Person.Attre = StandbyList.Person.Attributes.医員;
                break;

            case "助教":
                Person.Attre = StandbyList.Person.Attributes.助教;
                break;
            }
            Person.Requirement.PossibleTimes        = (int)num1st.Value;
            Person.Requirement.HolidayPossibleTimes = (int)numHoliday.Value;
            Person.Requirement.Interval             = (int)numInterval.Value;
            Person.Requirement.HolidayInterval      = (int)numHolidayInterval.Value;
            if (!Person.Possible.Any(t => t.Year == Year && t.Month == Month))
            {
                Person.Possible.Add(new PossibleDays(Year, Month));
            }
            for (int i = 0; i < DateTime.DaysInMonth(Year, Month); i++)
            {
                DateTime dt = new DateTime(Year, Month, i + 1);
                CalendarControl.Schedule[] schedule = calendar1.GetSchedule(dt);
                if (schedule.Count() != 0 && schedule[0].Item.ToString() == "×")
                {
                    Person[new DateTime(Year, Month, i + 1)] = StandbyList.PossibleDays.Status.Affair;
                }
                else if (schedule.Count() != 0 && schedule[0].Item.ToString() == "△")
                {
                    Person[new DateTime(Year, Month, i + 1)] = PossibleDays.Status.Limited;
                }
                else
                {
                    Person[new DateTime(Year, Month, i + 1)] = StandbyList.PossibleDays.Status.None;
                }
            }
            // RepeatRuleによる他の月における不都合日の設定
            AddedRule.ForEach(t => SetOtherMonthsAffair(t));
            Person.Requirement.RepeatRule.AddRange(AddedRule);
            DeletedRule.ForEach(t => DeleteOtherMonthsRules(t));
            DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }