Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            var    W     = new WorkLoad();
            string item1 = comboBox1.GetItemText(comboBox1.SelectedItem);
            string item2 = comboBox3.GetItemText(comboBox3.SelectedItem);
            bool   k     = W.AddLoad(item1, item2);

            if (k == false)
            {
                MessageBox.Show("Нагрузка НЕ добавлена!");
            }
            Form1 sf = new Form1();

            this.Hide();
            sf.ShowDialog();
            this.Close();
        }
Example #2
0
        public bool AddLoad(string Name, string Discipline)
        {
            var Work = new WorkLoad();

            if (NewNameLoad(Name) && NewDisciplineLoad(Discipline))
            {
                con.Open();
                OleDbCommand da     = new OleDbCommand("select hour from discipline where discipline = '" + Discipline + "' ", con);
                int          result = Convert.ToInt32(da.ExecuteScalar());
                var          L      = new Lecturer();
                if (L.FindLecturerHours(Name, result))
                {
                    con.Close();
                    con.Open();
                    OleDbCommand da1             = new OleDbCommand("select id from discipline where discipline = '" + Discipline + "' ", con);
                    int          idDiscipline    = Convert.ToInt32(da1.ExecuteScalar());
                    string       ListDisciplines = "Update ListDisciplines SET WorcLoad = '" + 0 + "' WHERE DisciplineID = '" + idDiscipline + "'";
                    OleDbCommand command1        = new OleDbCommand(ListDisciplines, con);
                    command1.ExecuteReader();
                    con.Close();
                    con.Open();
                    string       createWorkLoad = "INSERT INTO WorkLoad VALUES('" + Name + "','" + Discipline + "');";
                    OleDbCommand command        = new OleDbCommand(createWorkLoad, con);
                    command.ExecuteScalar();
                    con.Close();
                    MessageBox.Show("Нагрузка добавлена!");
                    return(true);
                }
                else
                {
                    con.Close();
                    MessageBox.Show("Нагрузка НЕ добавлена!");
                    return(false);
                }
            }

            return(false);
        }