private void checkChangeTeacher(CancelEventArgs e)
        {
            Teacher teacher = (Teacher)_workingObject;
            bool    allowed = true;

            foreach (Label edotlW in _mainPanel.Controls)
            {
                if (edotlW.GetType().FullName == "OpenCTT.EnableDisableOneTermLabel")
                {
                    EnableDisableOneTermLabel edotl = (EnableDisableOneTermLabel)edotlW;
                    if (!edotl.getIsTermEnabled())
                    {
                        foreach (EduProgramGroup epg in AppForm.CURR_OCTT_DOC.CoursesRootNode.Nodes)
                        {
                            foreach (EduProgram ep in epg.Nodes)
                            {
                                ArrayList [,] mytt = ep.getTimetable();
                                ArrayList lessonsInOneTimeSlot = mytt[edotl.getIndexRow(), edotl.getIndexCol()];
                                if (lessonsInOneTimeSlot != null)
                                {
                                    foreach (Object [] puPair in lessonsInOneTimeSlot)
                                    {
                                        Course  course    = (Course)puPair[0];
                                        Teacher teacherFM = course.getTeacher();
                                        if (teacherFM == teacher)
                                        {
                                            allowed = false;
                                            goto raus;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

raus:

            if (!allowed)
            {
                e.Cancel = true;

                string message1 = RES_MANAGER.GetString("checkChangeTeacher.msb.notsuccessfull.message");

                string caption1 = RES_MANAGER.GetString("checkChangeTeacher.msb.notsuccessfull.caption");

                MessageBoxButtons buttons1 = MessageBoxButtons.OK;

                MessageBox.Show(this, message1, caption1, buttons1,
                                MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            else
            {
                e.Cancel = false;
            }
        }
예제 #2
0
        public ChangeAllowedTimeSlotsCmd(Object workingObject, int cmdType, AllowedTimeSlotsForm atsf)
        {
            _atsf          = atsf;
            _cmdType       = cmdType;
            _workingObject = workingObject;

            if (_cmdType == Constants.ATSF_TIME_SLOT_TYPE_TEACHER)
            {
                Teacher teacher = (Teacher)_workingObject;
                _oldAllowedTimeSlots = teacher.getAllowedTimeSlots();
            }
            else if (_cmdType == Constants.ATSF_TIME_SLOT_TYPE_EDU_PROGRAM)
            {
                EduProgram ep = (EduProgram)_workingObject;
                _oldAllowedTimeSlots = ep.getAllowedTimeSlots();
            }
            else if (_cmdType == Constants.ATSF_TIME_SLOT_TYPE_EDU_PROGRAM_GROUP)
            {
                EduProgramGroup epg = (EduProgramGroup)_workingObject;
                _oldAllowedTimeSlots = epg.getAllowedTimeSlots();
            }
            else if (_cmdType == Constants.ATSF_TIME_SLOT_TYPE_ROOM)
            {
                Room room = (Room)_workingObject;
                _oldAllowedTimeSlots = room.getAllowedTimeSlots();
            }

            _newAllowedTimeSlots = (bool [, ])_oldAllowedTimeSlots.Clone();

            foreach (Label edotlW in _atsf.getMainPanel().Controls)
            {
                if (edotlW.GetType().FullName == "OpenCTT.EnableDisableOneTermLabel")
                {
                    EnableDisableOneTermLabel edotl = (EnableDisableOneTermLabel)edotlW;

                    if (edotl.getIsTermEnabled())
                    {
                        _newAllowedTimeSlots[edotl.getIndexRow(), edotl.getIndexCol()] = true;
                    }
                    else
                    {
                        _newAllowedTimeSlots[edotl.getIndexRow(), edotl.getIndexCol()] = false;
                    }
                }
            }
        }
        private void checkChangeEduProgramGroup(CancelEventArgs e)
        {
            EduProgramGroup epg     = (EduProgramGroup)_workingObject;
            bool            allowed = true;

            foreach (Label edotlW in _mainPanel.Controls)
            {
                if (edotlW.GetType().FullName == "OpenCTT.EnableDisableOneTermLabel")
                {
                    EnableDisableOneTermLabel edotl = (EnableDisableOneTermLabel)edotlW;
                    if (!edotl.getIsTermEnabled())
                    {
                        foreach (EduProgram ep in epg.Nodes)
                        {
                            ArrayList [,] mytt = ep.getTimetable();
                            if (!(mytt[edotl.getIndexRow(), edotl.getIndexCol()] == null || mytt[edotl.getIndexRow(), edotl.getIndexCol()].Count == 0))
                            {
                                allowed = false;
                                goto raus;
                            }
                        }
                    }
                }
            }

raus:

            if (!allowed)
            {
                e.Cancel = true;
                string message1 = RES_MANAGER.GetString("checkChangeEduProgramGroup.msb.notsuccessfull.message");

                string caption1 = RES_MANAGER.GetString("checkChangeEduProgramGroup.msb.notsuccessfull.caption");

                MessageBoxButtons buttons1 = MessageBoxButtons.OK;

                MessageBox.Show(this, message1, caption1, buttons1,
                                MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            else
            {
                e.Cancel = false;
            }
        }
        private void RCButton_Click(object sender, System.EventArgs e)
        {
            foreach (Label edotlW in AllowedTimeSlotsForm.MAIN_PANEL.Controls)
            {
                if (edotlW.GetType().FullName == "OpenCTT.EnableDisableOneTermLabel")
                {
                    EnableDisableOneTermLabel edotl = (EnableDisableOneTermLabel)edotlW;

                    if (_isForRow)
                    {
                        if (edotl.getIndexRow() == _row)
                        {
                            if (_isForEnable && !edotl.getIsTermEnabled())
                            {
                                edotl.setIsTermEnabled(true);
                                if (edotl.getIsTermEnabled() == AllowedTimeSlotsForm.getATSForm().getAllowedTimeSlots()[edotl.getIndexRow(), edotl.getIndexCol()])
                                {
                                    AllowedTimeSlotsForm.getATSForm().decrTimeSlotChangeCounter();
                                }
                                else
                                {
                                    AllowedTimeSlotsForm.getATSForm().incrTimeSlotChangeCounter();
                                }
                            }
                            else if (!_isForEnable && edotl.getIsTermEnabled())
                            {
                                edotl.setIsTermEnabled(false);
                                if (edotl.getIsTermEnabled() == AllowedTimeSlotsForm.getATSForm().getAllowedTimeSlots()[edotl.getIndexRow(), edotl.getIndexCol()])
                                {
                                    AllowedTimeSlotsForm.getATSForm().decrTimeSlotChangeCounter();
                                }
                                else
                                {
                                    AllowedTimeSlotsForm.getATSForm().incrTimeSlotChangeCounter();
                                }
                            }
                        }
                    }
                    else
                    {
                        if (edotl.getIndexCol() == _col)
                        {
                            if (_isForEnable && !edotl.getIsTermEnabled())
                            {
                                edotl.setIsTermEnabled(true);
                                if (edotl.getIsTermEnabled() == AllowedTimeSlotsForm.getATSForm().getAllowedTimeSlots()[edotl.getIndexRow(), edotl.getIndexCol()])
                                {
                                    AllowedTimeSlotsForm.getATSForm().decrTimeSlotChangeCounter();
                                }
                                else
                                {
                                    AllowedTimeSlotsForm.getATSForm().incrTimeSlotChangeCounter();
                                }
                            }
                            else if (!_isForEnable && edotl.getIsTermEnabled())
                            {
                                edotl.setIsTermEnabled(false);
                                if (edotl.getIsTermEnabled() == AllowedTimeSlotsForm.getATSForm().getAllowedTimeSlots()[edotl.getIndexRow(), edotl.getIndexCol()])
                                {
                                    AllowedTimeSlotsForm.getATSForm().decrTimeSlotChangeCounter();
                                }
                                else
                                {
                                    AllowedTimeSlotsForm.getATSForm().incrTimeSlotChangeCounter();
                                }
                            }
                        }
                    }
                }
            }

            if (AllowedTimeSlotsForm.getATSForm().getTimeSlotChangeCounter() > 0)
            {
                AllowedTimeSlotsForm.getATSForm().getOKButton().Enabled = true;
            }
            else
            {
                AllowedTimeSlotsForm.getATSForm().getOKButton().Enabled = false;
            }
        }
        private void AllowedTimeSlotsForm_Load(object sender, System.EventArgs e)
        {
            _mainPanel.SuspendLayout();

            int dlStartX        = 15;
            int hlStartY        = 15;
            int dayLabelWidth   = 60;
            int dayLabelHeight  = 20;
            int hourLabelWidth  = 55;
            int hourLabelHeight = 22;

            Label dayHourLabel = new Label();

            dayHourLabel.Text        = RES_MANAGER.GetString("dayHourLabel.text");
            dayHourLabel.Size        = new System.Drawing.Size(hourLabelWidth, dayLabelHeight);
            dayHourLabel.Location    = new System.Drawing.Point(dlStartX, hlStartY);
            dayHourLabel.BorderStyle = BorderStyle.FixedSingle;
            dayHourLabel.TextAlign   = System.Drawing.ContentAlignment.MiddleCenter;
            dayHourLabel.BackColor   = System.Drawing.Color.LightBlue;
            _mainPanel.Controls.Add(dayHourLabel);


            int nn = 0;

            foreach (int[] term in AppForm.CURR_OCTT_DOC.IncludedTerms)
            {
                string [] printTerm = new string[4];
                for (int k = 0; k < 4; k++)
                {
                    if (term[k] < 10)
                    {
                        printTerm[k] = "0" + System.Convert.ToString(term[k]);
                    }
                    else
                    {
                        printTerm[k] = System.Convert.ToString(term[k]);
                    }
                }

                string labelText = printTerm[0] + ":" + printTerm[1] + "-" + printTerm[2] + ":" + printTerm[3];

                Label termLabel = new Label();
                termLabel.Size        = new System.Drawing.Size(hourLabelWidth, hourLabelHeight);
                termLabel.Location    = new System.Drawing.Point(dlStartX, hlStartY + dayLabelHeight + nn * hourLabelHeight);
                termLabel.BorderStyle = BorderStyle.FixedSingle;
                termLabel.TextAlign   = System.Drawing.ContentAlignment.MiddleCenter;
                termLabel.BackColor   = System.Drawing.Color.Ivory;
                termLabel.Font        = new System.Drawing.Font("Microsoft Sans Serif", 5.4F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(238)));
                termLabel.Text        = labelText;
                _mainPanel.Controls.Add(termLabel);
                nn++;
            }

            String[] dayText = new String[7];
            dayText[0] = RES_MANAGER.GetString("dayMonday.text");
            dayText[1] = RES_MANAGER.GetString("dayTuesday.text");
            dayText[2] = RES_MANAGER.GetString("dayWednesday.text");
            dayText[3] = RES_MANAGER.GetString("dayThursday.text");
            dayText[4] = RES_MANAGER.GetString("dayFriday.text");
            dayText[5] = RES_MANAGER.GetString("daySaturday.text");
            dayText[6] = RES_MANAGER.GetString("daySunday.text");

            int goAhead = 0;

            for (int n = 0; n < 7; n++)
            {
                if (AppForm.CURR_OCTT_DOC.getIsDayIncluded(n))
                {
                    Label dayLabel = new Label();
                    dayLabel.Size        = new System.Drawing.Size(dayLabelWidth, dayLabelHeight);
                    dayLabel.Location    = new System.Drawing.Point(hourLabelWidth + dlStartX + goAhead * dayLabelWidth, hlStartY);
                    dayLabel.BorderStyle = BorderStyle.FixedSingle;
                    dayLabel.TextAlign   = System.Drawing.ContentAlignment.MiddleCenter;
                    dayLabel.BackColor   = System.Drawing.Color.Ivory;
                    dayLabel.Text        = dayText[n];
                    _mainPanel.Controls.Add(dayLabel);

                    goAhead++;
                }
            }

            int otlStartX = dlStartX + hourLabelWidth;
            int otlStartY = hlStartY + dayLabelHeight;

            for (int j = 0; j < AppForm.CURR_OCTT_DOC.IncludedTerms.Count; j++)
            {
                for (int k = 0; k < AppForm.CURR_OCTT_DOC.getNumberOfDays(); k++)
                {
                    bool tsState = _allowedTimeSlots[j, k];


                    EnableDisableOneTermLabel edotl = new EnableDisableOneTermLabel(tsState, j, k);

                    edotl.Size     = new System.Drawing.Size(dayLabelWidth, hourLabelHeight);
                    edotl.Location = new Point(otlStartX + k * dayLabelWidth, otlStartY + j * hourLabelHeight);

                    _mainPanel.Controls.Add(edotl);
                }
            }

            int startY = 36;

            for (int n = 0; n < AppForm.CURR_OCTT_DOC.IncludedTerms.Count; n++)
            {
                EnableDisableRCButton edb = new EnableDisableRCButton(10, startY + n * 22, n, 0, true, true);
                _rightPanel.Controls.Add(edb);
            }

            for (int n = 0; n < AppForm.CURR_OCTT_DOC.IncludedTerms.Count; n++)
            {
                EnableDisableRCButton edb = new EnableDisableRCButton(35, startY + n * 22, n, 0, false, true);
                _rightPanel.Controls.Add(edb);
            }

            int startX = otlStartX + 10;

            for (int n = 0; n < AppForm.CURR_OCTT_DOC.getNumberOfDays(); n++)
            {
                EnableDisableRCButton edb = new EnableDisableRCButton(startX + n * dayLabelWidth, 1, 0, n, true, false);
                _bottomPanel.Controls.Add(edb);
            }

            for (int n = 0; n < AppForm.CURR_OCTT_DOC.getNumberOfDays(); n++)
            {
                EnableDisableRCButton edb = new EnableDisableRCButton(startX + n * dayLabelWidth, 26, 0, n, false, false);
                _bottomPanel.Controls.Add(edb);
            }

            int mainPanelWidth = dlStartX + hourLabelWidth + dayLabelWidth * AppForm.CURR_OCTT_DOC.getNumberOfDays() + 5;
            int formHeight     = hlStartY + dayLabelHeight + hourLabelHeight * AppForm.CURR_OCTT_DOC.IncludedTerms.Count + _bottomPanel.Height + 15;
            int formWidth      = mainPanelWidth + 74;

            this.ClientSize = new System.Drawing.Size(formWidth, formHeight);

            this._okButton.Location     = new System.Drawing.Point(formWidth / 2 - 78, 75);
            this._cancelButton.Location = new System.Drawing.Point(_okButton.Location.X + 92, 75);

            _mainPanel.ResumeLayout(false);
        }