/// <summary>
        /// 建構式,傳入事件編號
        /// </summary>
        /// <param name="EventID"></param>
        public frmEventProperty(string EventID)
        {
            InitializeComponent();

            btnCancel.Click += (sender, e) => this.Close();

            cboWhat.SelectionChangeCommitted += (sender, e) =>
            {
                if (bReentrantFlag) return;

                if (!("" + cboWhat.SelectedValue).Equals(evtChange.SubjectID))
                    DisableSplitMergeControl();
            };

            cboWhere.SelectionChangeCommitted += (sender, e) =>
            {
                if (bReentrantFlag) return;

                if (!("" + cboWhere.SelectedValue).Equals(evtChange.ClassroomID))
                    DisableSplitMergeControl();
            };

            cboWho1.SelectionChangeCommitted += (sender, e) =>
            {
                if (bReentrantFlag) return;

                if (!("" + cboWho1.SelectedValue).Equals(evtChange.TeacherID1))
                    DisableSplitMergeControl();
            };

            cboWho2.SelectionChangeCommitted += (sender, e) =>
            {
                if (bReentrantFlag) return;

                if (!("" + cboWho2.SelectedValue).Equals(evtChange.TeacherID1))
                    DisableSplitMergeControl();
            };

            cboWho3.SelectionChangeCommitted += (sender, e) =>
            {
                if (bReentrantFlag) return;

                if (!("" + cboWho3.SelectedValue).Equals(evtChange.TeacherID1))
                    DisableSplitMergeControl();
            };

            cboWhom.SelectionChangeCommitted += (sender, e) =>
            {
                if (bReentrantFlag) return;

                if (!("" + cboWhom.SelectedValue).Equals("" + evtChange.ClassID))
                    DisableSplitMergeControl();
            };

            evtChange = schLocal.CEvents[EventID];

            LoadContent();
        }
        /// <summary>
        /// 確認
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            //dynamic SelectedWho1 = cboWho1.SelectedItem;
            //dynamic SelectedWho2 = cboWho2.SelectedItem;
            //dynamic SelectedWho3 = cboWho3.SelectedItem;
            //dynamic SelectedWhere = cboWhere.SelectedItem;

            string WhoID1 = ""+cboWho1.SelectedItem; //SelectedWho1 != null ? SelectedWho1.WhoID : string.Empty;
            string WhoID2 = "" + cboWho2.SelectedItem; //SelectedWho2 != null ? SelectedWho2.WhoID : string.Empty;
            string WhoID3 = "" + cboWho3.SelectedItem;  //SelectedWho3 != null ? SelectedWho3.WhoID : string.Empty;

            List<string> TeacherNames = new List<string>();

            if (!string.IsNullOrEmpty(WhoID1))
                TeacherNames.Add(WhoID1);

            if (!string.IsNullOrEmpty(WhoID2))
            {
                if (TeacherNames.Contains(WhoID2))
                {
                    MessageBox.Show("授課教師不允許重覆!");
                    return;
                }
                else
                    TeacherNames.Add(WhoID2);
            }

            if (!string.IsNullOrEmpty(WhoID3))
            {
                if (TeacherNames.Contains(WhoID3))
                {
                    MessageBox.Show("授課教師不允許重覆!");
                    return;
                }
            }

            string WhereID = "" + cboWhere.SelectedItem; //SelectedWhere.WhereID;
            byte WeekFlag = (byte)(cboWeekFlag.SelectedIndex + 1);
            bool IsLongBreak = chkLongBreak.Checked ? chkLongBreak.Checked : false;
            bool IsDuplicate = chkDup.Checked ? chkDup.Checked : false;
            string WeekDayCondition = txtWDCondition.Text;
            string PeriodCondition = txtPDCondition.Text;
            string Comment = txtComment.Text;

            schLocal.ChangeEventProperty(evtChange.EventID,
                                         WhoID1,
                                         WhoID2,
                                         WhoID3,
                                         WhereID,
                                         WeekFlag,
                                         WeekDayCondition,
                                         PeriodCondition,
                                         IsLongBreak,
                                         IsDuplicate,
                                         Comment);
            evtChange = null;

            this.Close();
        }
        /// <summary>
        /// 分割
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSplit_Click(object sender, EventArgs e)
        {
            int Length;

            if (int.TryParse(txtLength.Text, out Length))
            {
                frmEventSplit EventSplit = new frmEventSplit(Length);

                EventSplit.SplitEvent += (vsender, ve) =>
                {
                    CEvent evtNew;
                    int nSecCnt;

                    nSecCnt = EventSplit.SectionCount;

                    if (nSecCnt == 1) return;

                    //Change current event length
                    schLocal.ChangeEventLength(evtChange.EventID, EventSplit[1]);

                    txtLength.Text = "" + EventSplit[1];

                    for (int i = 2; i <= nSecCnt; i++)
                    {
                        evtNew = new CEvent();
                        evtNew.EventID = evtChange.EventID;
                        evtNew.TeacherID1 = evtChange.TeacherID1;
                        evtNew.TeacherID2 = evtChange.TeacherID2;
                        evtNew.TeacherID3 = evtChange.TeacherID3;
                        evtNew.ClassID = evtChange.ClassID;
                        evtNew.ClassroomID = evtChange.ClassroomID;
                        evtNew.SubjectID = evtChange.SubjectID;
                        evtNew.Length = EventSplit[i];
                        evtNew.WeekFlag = evtChange.WeekFlag;
                        evtNew.Priority = evtChange.Priority;
                        evtNew.WeekDayCondition = evtChange.WeekDayCondition;
                        evtNew.PeriodCondition = evtChange.PeriodCondition;
                        evtNew.AllowLongBreak = evtChange.AllowLongBreak;
                        evtNew.CourseID = evtChange.CourseID;
                        evtNew.TimeTableID = evtChange.TimeTableID;
                        evtNew.AllowDuplicate = evtChange.AllowDuplicate;
                        evtNew.CourseGroup = evtChange.CourseGroup;
                        evtNew.CourseName = evtChange.CourseName;
                        evtNew.LimitNextDay = evtChange.LimitNextDay;
                        evtNew.SubjectAlias = evtChange.SubjectAlias;
                        evtNew.Comment = evtChange.Comment;

                        schLocal.InsertEvent(evtNew);

                        lstSplit.Items.Add(new
                        {
                            RelatedEvent = evtNew.Length,
                            EventID = evtNew.EventID
                        });
                    }

                    lstSplit.Enabled = true;
                };

                EventSplit.ShowDialog();

                LoadContent();
            }
        }
Exemple #4
0
 public PeriodEventArgs(int weekday, int period, CEvent vo)
 {
     this.Weekday = weekday;
     this.Period = period;
     this.Value = vo;
 }