Пример #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!");
                }
            }
        }
Пример #2
0
        //adding

        private void Btnadd_Click(object sender, EventArgs e)
        {
            Employee employee = new Employee();
            Position posid    = comboBox1.SelectedItem as Position;

            Model.Program program = comboBox2.SelectedItem as Model.Program;

            employee.Name         = textBox1.Text;
            employee.Surname      = textBox2.Text;
            employee.SpecialityID = program.id;
            employee.Email        = textBox4.Text;
            employee.Phone        = textBox5.Text;
            employee.StartTime    = dateTimePicker1.Value;
            employee.Salary       = Convert.ToDouble(textBox6.Text);
            employee.PositionID   = posid.id;
            employee.Deleted      = false;
            using (var db = new AcademyDB())
            {
                db.Employees.Add(employee);
                if (db.SaveChanges() != 0)
                {
                    MessageBox.Show("Employee added");
                    FormRefresh();
                }
                else
                {
                    MessageBox.Show("Employee didn't add.Fill all inputs!");
                }
            }
        }
Пример #3
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!");
                }
            }
        }
Пример #4
0
        private void Button1_Click(object sender, EventArgs e)
        {
            using (var db = new AcademyDB())
            {
                Employee      employee = db.Employees.Where(emp => emp.id == selectedemployerId).FirstOrDefault();
                Model.Program program  = comboBox2.SelectedItem as Model.Program;
                Position      position = comboBox1.SelectedItem as Position;

                employee.Name         = textBox1.Text;
                employee.Surname      = textBox2.Text;
                employee.Email        = textBox4.Text;
                employee.Phone        = textBox5.Text;
                employee.SpecialityID = program.id;
                employee.StartTime    = dateTimePicker1.Value;
                employee.Salary       = Convert.ToDouble(textBox6.Text);
                employee.PositionID   = position.id;


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