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