Ejemplo n.º 1
0
        private void buttonAddGroup_Click(object sender, EventArgs e)
        {
            //додати групу до вивчаємої дисципліни
            FormGroup FG = new FormGroup((Predmet)this.listBoxPredmet.SelectedItem, this.MF.setting);

            FG.ShowDialog();
            if (FG.DialogResult == DialogResult.OK)
            {
                this.CurrentTeacher.AddPredmetInGroup((Group)FG.comboBox1.SelectedItem, this.listBoxPredmet.SelectedIndex);
                FG.Close();
                this.Focus();
                this.listBoxGroup.Items.Clear();

                for (int i = 0; i < this.MF.setting.GetAllGroups().Length; i++)
                {
                    Predmet[] Predmets = this.MF.setting.GetGroup(i).GetAllPredmet();
                    for (int a = 0; a < Predmets.Length; a++)
                    {
                        if (Predmets[a].ToString().Equals(this.listBoxPredmet.SelectedItem.ToString()))
                        {
                            this.listBoxGroup.Items.Add(this.MF.setting.GetGroup(i));
                        }
                    }
                }
                if (this.listBoxGroup.Items.Count > 0)
                {
                    this.listBoxGroup.SelectedIndex = 0;
                    this.buttonDelGroup.Enabled     = this.menuItem15.Enabled = this.toolStripMenuItem5.Enabled = true;
                }
                else
                {
                    this.buttonDelGroup.Enabled = this.menuItem15.Enabled = this.toolStripMenuItem5.Enabled = false;
                }

                this.listBoxTest.Items.Clear();
                Predmet SelectPredmet = new Predmet();
                SelectPredmet = (Predmet)this.listBoxPredmet.SelectedItem;
                if (SelectPredmet != null)
                {
                    this.listBoxTest.Items.AddRange(SelectPredmet.GetTests());
                }

                if (this.listBoxTest.Items.Count > 0)
                {
                    this.listBoxTest.SelectedIndex = 0;
                    this.buttonDelTest.Enabled     = this.buttonIzmNameofTest.Enabled = this.menuItem17.Enabled = this.menuItem18.Enabled = this.toolStripMenuItem8.Enabled = this.toolStripMenuItem9.Enabled = true;
                }
                else
                {
                    this.buttonDelTest.Enabled = this.buttonIzmNameofTest.Enabled = this.menuItem17.Enabled = this.menuItem18.Enabled = this.toolStripMenuItem8.Enabled = this.toolStripMenuItem9.Enabled = false;
                }
            }
        }
Ejemplo n.º 2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (this.WhatEdit == 2)
            {
                FormGroup FG = new FormGroup("Введіть назву нової групи чи класу");
                FG.ShowDialog();
                if (FG.DialogResult == DialogResult.OK)
                {
                    Group [] G      = this.setting.GetAllGroups();
                    bool     IsSame = false;
                    for (int i = 0; i < G.Length; i++)
                    {
                        if (G.GetValue(i).ToString().Equals(FG.textBox1.Text))
                        {
                            IsSame = true;
                        }
                    }

                    if (!IsSame)
                    {
                        this.setting.AddGroup(new Group(FG.textBox1.Text));
                    }
                    else
                    {
                        MessageBox.Show("Група або клас із такою назвою вже існує");
                    }
                }
                FG.Close();
                ReloadListBox();
            }
            else if (this.WhatEdit == 3)
            {
                FormNewAdmin FNA = new FormNewAdmin(this.WhatEdit, this.setting, this.comboBox1.SelectedItem.ToString());
                FNA.ShowDialog();
                this.comboBox1_SelectedIndexChanged(this.comboBox1, new EventArgs());
            }
            else
            {
                FormNewAdmin FNA = new FormNewAdmin(this.WhatEdit, this.setting);
                FNA.ShowDialog();
                ReloadListBox();
            }
        }
Ejemplo n.º 3
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (this.WhatEdit == 0) //редактируем список админов
            {
                if (this.listBox1.SelectedIndex != -1)
                {
                    FormNewAdmin FNA = new FormNewAdmin(this.WhatEdit, this.setting, ((Admin)this.listBox1.SelectedItem).GetID());
                    FNA.ShowDialog();
                    ReloadListBox();
                }
                else
                {
                    MessageBox.Show("Редагуємого адміністратора не виділено");
                }
            }
            if (this.WhatEdit == 1) //редактируем список преподов
            {
                if (this.listBox1.SelectedIndex != -1)
                {
                    FormNewAdmin FNA = new FormNewAdmin(this.WhatEdit, this.setting, ((Teacher)this.listBox1.SelectedItem).GetID());
                    FNA.ShowDialog();
                    ReloadListBox();
                }
                else
                {
                    MessageBox.Show("Редагуємого викладача не виділено");
                }
            }
            if (this.WhatEdit == 2)     //редактируем список груп
            {
                if (this.listBox1.SelectedIndex != -1)
                {
                    FormGroup FG = new FormGroup("Введіть назву групи чи класу", this.listBox1.SelectedItem.ToString());
                    FG.ShowDialog();
                    if (FG.DialogResult == DialogResult.OK)
                    {
                        Group[] G      = this.setting.GetAllGroups();
                        bool    IsSame = false;
                        for (int i = 0; i < G.Length; i++)
                        {
                            if (G.GetValue(i).ToString().Equals(FG.textBox1.Text))
                            {
                                IsSame = true;
                            }
                        }

                        if (!IsSame)
                        {
                            ((Group)this.listBox1.SelectedItem).SetNameOfGroup(FG.textBox1.Text);
                        }
                        else
                        {
                            MessageBox.Show("Група або клас із такою назвою вже існує");
                        }
                    }
                    FG.Close();
                    ReloadListBox();
                }
                else
                {
                    MessageBox.Show("Редагуєму групу або клас не виділено");
                }
            }
            if (this.WhatEdit == 3)     //редактируем список учеников
            {
                if (this.listBox1.SelectedIndex != -1)
                {
                    FormNewAdmin FNA = new FormNewAdmin(this.WhatEdit, this.setting, ((User)this.listBox1.SelectedItem).GetID());
                    FNA.ShowDialog();
                    this.comboBox1_SelectedIndexChanged(this.comboBox1, new EventArgs());
                }
                else
                {
                    MessageBox.Show("Редагуємого учня не виділено");
                }
            }
        }