private bool CreateGroup()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                int classroomId = (db.Classrooms.Where(g => g.Name == cmbClassroom.SelectedItem.ToString()).FirstOrDefault()).Id;
                int educationID = (db.Educations.Where(g => g.Name == cmbEducation.SelectedItem.ToString()).FirstOrDefault()).Id;
                int teacherID   = (db.Teachers.Where(g => g.Name + " " + g.Surname == cmbTeacher.SelectedItem.ToString()).FirstOrDefault()).Id;
                int mentorID    = (db.Employees.Where(g => g.Mentor == cmbMentor.SelectedItem.ToString()).FirstOrDefault()).Id;

                Group group = new Group
                {
                    Name               = txtNameGroup.Text,
                    ClassroomId        = classroomId,
                    TeacherId          = teacherID,
                    MentorId           = mentorID,
                    Capacity           = Convert.ToInt32(txtCapacityGroup.Text),
                    EducationProgramId = educationID,
                    Status             = true
                };

                db.Groups.Add(group);

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private bool CreateStudent()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                Student student = new Student
                {
                    Name    = txtNameStudent.Text,
                    Surname = txtSurnameStudent.Text,
                    Email   = txtEmailStudent.Text,
                    Phone   = txtPhoneStudent.Text,
                    Fee     = txtFeeStudent.Text,
                    Status  = true
                };

                db.Students.Add(student);

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        private bool CreateEmployee()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                int positionId = (db.Positions.Where(g => g.Name == cmbPosition.SelectedItem.ToString()).FirstOrDefault()).Id;

                Employee employee = new Employee
                {
                    Name       = txtNameEmploye.Text,
                    Surname    = txtSurnameEmploye.Text,
                    Email      = txtEmailEmployee.Text,
                    Phone      = txtPhoneEmployee.Text,
                    PositionId = positionId,
                    StartTime  = Convert.ToDateTime(txtStartTimeEmp.Text),
                    Salary     = Convert.ToDouble(txtSaalaryEmp.Text),
                    Status     = true
                };

                db.Employees.Add(employee);

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        private bool CreateEducation()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                Education education = new Education
                {
                    Name   = txtNameEducation.Text,
                    Price  = Convert.ToDouble(txtPriceEducation.Text),
                    Status = true
                };

                db.Educations.Add(education);

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #5
0
        private bool UpdateEmployee()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                int positionId = (db.Positions.Where(g => g.Name == cmbPosition.SelectedItem.ToString()).FirstOrDefault()).Id;

                Employee newemp = db.Employees.Where(s => s.Id == empGlobal.Id).FirstOrDefault();

                newemp.Name       = txtNameEmploye.Text;
                newemp.Surname    = txtSurnameEmploye.Text;
                newemp.Email      = txtEmailEmployee.Text;
                newemp.PositionId = positionId;
                newemp.StartTime  = Convert.ToDateTime(txtStartTimeEmp.Text);
                newemp.Salary     = Convert.ToDouble(txtSaalaryEmp.Text);

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #6
0
        private bool CreateClassroom()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                Classroom classroom = new Classroom
                {
                    Name   = txtNameClassroom.Text,
                    Status = true
                };

                db.Classrooms.Add(classroom);

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #7
0
        private bool CreatePosition()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                Position position = new Position
                {
                    Name   = txtNamePosition.Text,
                    Status = true
                };

                db.Positions.Add(position);

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private bool CreateTeacher()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                Teacher teacher = new Teacher
                {
                    Name       = txtNameTeacher.Text,
                    Surname    = txtSurnameTeacher.Text,
                    Speciality = txtSpecStudent.Text,
                    Email      = txtEmailTeacher.Text,
                    Phone      = txtPhoneTeacher.Text,
                    Status     = true
                };

                db.Teachers.Add(teacher);

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #9
0
        private bool CreateTaskMarks()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                int studentId = (db.Students.Where(g => g.Name == cmbStudent.SelectedItem.ToString()).FirstOrDefault()).Id;
                int taskId    = (db.Tasks.Where(g => g.Name == cmbTask.SelectedItem.ToString()).FirstOrDefault()).Id;

                Models.StudentsMark studentsMark = new Models.StudentsMark
                {
                    StudentId = studentId,
                    TaskId    = taskId,
                    Mark      = Convert.ToInt32(txtMark.Text),
                };



                db.StudentsMarks.Add(studentsMark);

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private bool UpdateGroup()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                int classroomId = (db.Classrooms.Where(g => g.Name == cmbClassroom.SelectedItem.ToString()).FirstOrDefault()).Id;
                int educationID = (db.Educations.Where(g => g.Name == cmbEducation.SelectedItem.ToString()).FirstOrDefault()).Id;
                int teacherID   = (db.Teachers.Where(g => g.Name + " " + g.Surname == cmbTeacher.SelectedItem.ToString()).FirstOrDefault()).Id;
                int mentorID    = (db.Employees.Where(g => g.Mentor == cmbMentor.SelectedItem.ToString()).FirstOrDefault()).Id;

                Group newgru = db.Groups.Where(s => s.Id == groupGlobal.Id).FirstOrDefault();

                newgru.Name        = txtNameGroup.Text;
                newgru.ClassroomId = classroomId;
                newgru.TeacherId   = teacherID;
                newgru.MentorId    = mentorID;
                newgru.Capacity    = Convert.ToInt32(txtCapacityGroup.Text);
                newgru.ClassroomId = classroomId;

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #11
0
        private bool UpdateStudentMarks()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                int studentId = (db.Students.Where(g => g.Name == cmbStudent.SelectedItem.ToString()).FirstOrDefault()).Id;
                int taskId    = (db.Tasks.Where(g => g.Name == cmbTask.SelectedItem.ToString()).FirstOrDefault()).Id;


                Models.Task newtask = db.Tasks.Where(s => s.Id == studentsMarkGlobal.Id).FirstOrDefault();

                studentsMarkGlobal.StudentId = studentId;
                studentsMarkGlobal.TaskId    = taskId;
                studentsMarkGlobal.Mark      = Convert.ToInt32(txtMark.Text);

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private bool UpdateStudent()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                Student nwstu = db.Students.Where(s => s.Id == studentGlobal.Id).FirstOrDefault();

                nwstu.Name    = txtNameStudent.Text;
                nwstu.Surname = txtSurnameStudent.Text;
                nwstu.Email   = txtEmailStudent.Text;
                nwstu.Phone   = txtPhoneStudent.Text;
                nwstu.Fee     = txtFeeStudent.Text;


                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private bool CreateTask()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                int groupId = (db.Groups.Where(g => g.Name == cmbGroupTask.SelectedItem.ToString()).FirstOrDefault()).Id;

                Models.Task task = new Models.Task
                {
                    Name     = txtNameTask.Text,
                    Deadline = Convert.ToDateTime(dtpDeadline.Text),
                    GroupId  = groupId,
                    Status   = true
                };



                db.Tasks.Add(task);

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private bool UpdateTask()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                int groupId = (db.Groups.Where(g => g.Name == cmbGroupTask.SelectedItem.ToString()).FirstOrDefault()).Id;


                Models.Task newtask = db.Tasks.Where(s => s.Id == taskGlobal.Id).FirstOrDefault();

                newtask.Name     = txtNameTask.Text;
                newtask.Deadline = Convert.ToDateTime(dtpDeadline.Text);


                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private bool UpdateTeacher()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                Teacher newteac = db.Teachers.Where(s => s.Id == teacherGlobal.Id).FirstOrDefault();

                newteac.Name       = txtNameTeacher.Text;
                newteac.Surname    = txtSurnameTeacher.Text;
                newteac.Speciality = txtSpecStudent.Text;
                newteac.Email      = txtEmailTeacher.Text;
                newteac.Phone      = txtPhoneTeacher.Text;

                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #16
0
 private void DeleteStudentsMarks()
 {
     using (MyAcademyEntities2 db = new MyAcademyEntities2())
     {
         for (int i = 0; i < dgvStudentMarks.SelectedRows.Count; i++)
         {
             int          stdmarkId    = (int)dgvStudentMarks.SelectedRows[i].Cells[0].Value;
             StudentsMark studentsMark = db.StudentsMarks.FirstOrDefault(u => u.Id == stdmarkId);
         }
         db.SaveChanges();
     }
     GenerateTasksMarks();
 }
Beispiel #17
0
 private void DeleteClassRoom()
 {
     using (MyAcademyEntities2 db = new MyAcademyEntities2())
     {
         for (int i = 0; i < dgvClassrooms.SelectedRows.Count; i++)
         {
             int       clroomId  = (int)dgvClassrooms.SelectedRows[i].Cells[0].Value;
             Classroom classroom = db.Classrooms.FirstOrDefault(u => u.Id == clroomId);
             classroom.Status = false;
         }
         db.SaveChanges();
     }
     GenerateClassroom();
 }
 private void DeleteGroup()
 {
     using (MyAcademyEntities2 db = new MyAcademyEntities2())
     {
         for (int i = 0; i < dgvGroup.SelectedRows.Count; i++)
         {
             int   groupId = (int)dgvGroup.SelectedRows[i].Cells[0].Value;
             Group group   = db.Groups.FirstOrDefault(u => u.Id == groupId);
             group.Status = false;
         }
         db.SaveChanges();
     }
     GenerateGroups();
 }
Beispiel #19
0
 private void DeleteEmployee()
 {
     using (MyAcademyEntities2 db = new MyAcademyEntities2())
     {
         for (int i = 0; i < dgvEmployee.SelectedRows.Count; i++)
         {
             int      empId    = (int)dgvEmployee.SelectedRows[i].Cells[0].Value;
             Employee employee = db.Employees.FirstOrDefault(u => u.Id == empId);
             employee.Status = false;
         }
         db.SaveChanges();
     }
     GenerateEmployee();
 }
 private void DeleteTeacher()
 {
     using (MyAcademyEntities2 db = new MyAcademyEntities2())
     {
         for (int i = 0; i < dgvTeacher.SelectedRows.Count; i++)
         {
             int     teacherId = (int)dgvTeacher.SelectedRows[i].Cells[0].Value;
             Teacher teacher   = db.Teachers.FirstOrDefault(u => u.Id == teacherId);
             teacher.Status = false;
         }
         db.SaveChanges();
     }
     GenerateTeacher();
 }
 private void DeleteStudent()
 {
     using (MyAcademyEntities2 db = new MyAcademyEntities2())
     {
         for (int i = 0; i < dgvStudents.SelectedRows.Count; i++)
         {
             int     studentId = (int)dgvStudents.SelectedRows[i].Cells[0].Value;
             Student student   = db.Students.FirstOrDefault(u => u.Id == studentId);
             student.Status = false;
         }
         db.SaveChanges();
     }
     GenerateStudent();
 }
 private void DeleteTask()
 {
     using (MyAcademyEntities2 db = new MyAcademyEntities2())
     {
         for (int i = 0; i < dgvTasks.SelectedRows.Count; i++)
         {
             int         taskId = (int)dgvTasks.SelectedRows[i].Cells[0].Value;
             Models.Task task   = db.Tasks.FirstOrDefault(u => u.Id == taskId);
             task.Status = false;
         }
         db.SaveChanges();
     }
     GenerateTasks();
 }
Beispiel #23
0
 private void DeleteEducation()
 {
     using (MyAcademyEntities2 db = new MyAcademyEntities2())
     {
         for (int i = 0; i < dgvEducation.SelectedRows.Count; i++)
         {
             int       eduId     = (int)dgvEducation.SelectedRows[i].Cells[0].Value;
             Education education = db.Educations.FirstOrDefault(u => u.Id == eduId);
             education.Status = false;
         }
         db.SaveChanges();
     }
     GenerateEducation();
 }
Beispiel #24
0
        private bool UpdateClassroom()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                Classroom newclassroom = db.Classrooms.Where(s => s.Id == globalPos.Id).FirstOrDefault();

                newclassroom.Name = txtNameClassroom.Text;


                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #25
0
        private bool UpdatePosition()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                Position newpos = db.Positions.Where(s => s.Id == posGlobal.Id).FirstOrDefault();

                newpos.Name = txtNamePosition.Text;


                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #26
0
        private bool UpdateEducation()
        {
            int affectedRows = 0;

            using (MyAcademyEntities2 db = new MyAcademyEntities2())
            {
                Education newedu = db.Educations.Where(s => s.Id == edGlobal.Id).FirstOrDefault();

                newedu.Name  = txtNameEducation.Text;
                newedu.Price = Convert.ToDouble(txtPriceEducation.Text);


                affectedRows = db.SaveChanges();
            }
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }