Esempio n. 1
0
        private void Btnsave_Click(object sender, EventArgs e)
        {
            Group grp = new Group();

            Model.Classroom cls   = comboBox1.SelectedItem as Model.Classroom;
            Employee        empl1 = comboBox2.SelectedItem as Employee;
            Employee        empl2 = comboBox3.SelectedItem as Employee;

            Model.Program pr = comboBox4.SelectedItem as Model.Program;

            grp.Name        = textBox1.Text;
            grp.ClassroomID = cls.id;
            grp.TeacherID   = empl1.id;
            grp.MentorID    = empl2.id;
            grp.Capacity    = Convert.ToInt32(textBox2.Text);
            grp.ProgramID   = pr.id;

            grp.Deleted = false;
            using (var db = new AcademyDB())
            {
                db.Groups.Add(grp);
                if (db.SaveChanges() != 0)
                {
                    MessageBox.Show("Group added");
                    FormRefresh();
                }
                else
                {
                    MessageBox.Show("Group didn't add.Fill all inputs!");
                }
            }
        }
Esempio n. 2
0
        private void Btnupdate_Click(object sender, EventArgs e)
        {
            using (var db = new AcademyDB())
            {
                Group           group = db.Groups.Where(std => std.id == selectgrpId).FirstOrDefault();
                Group           st    = new Group();
                Model.Classroom cls   = comboBox1.SelectedItem as Model.Classroom;
                Employee        empl1 = comboBox2.SelectedItem as Employee;
                Employee        empl2 = comboBox3.SelectedItem as Employee;
                Model.Program   pr    = comboBox4.SelectedItem as Model.Program;

                group.Name        = textBox1.Text;
                group.ClassroomID = cls.id;
                group.TeacherID   = empl1.id;
                group.MentorID    = empl2.id;
                group.Capacity    = Convert.ToInt32(textBox2.Text);
                group.ProgramID   = pr.id;


                if (db.SaveChanges() != 0)
                {
                    MessageBox.Show("Group updated");
                    FormRefresh();
                }
                else
                {
                    MessageBox.Show("Group didn't update!");
                }
            }
        }