Esempio n. 1
0
        public string Save()
        {
            string error = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    if ((this.Student == null || this.Speciality == null) && this.ID > 0)
                    {
                        var cc = (from sc in db.StudentCourses where sc.ID == this.ID select sc).FirstOrDefault();
                        db.StudentCourses.DeleteOnSubmit(cc);
                        db.SubmitChanges();
                        return(string.Empty);
                    }
                    if ((this.Student == null || this.Speciality == null))
                    {
                        return(string.Empty);
                    }

                    StudentCourse studentCourse = new StudentCourse();
                    if (this.ID > 0 && this.Selected == true)
                    {
                        return(error);
                    }
                    else if (this.ID > 0 && this.Selected == false)
                    {
                        studentCourse = (from sc in db.StudentCourses where sc.ID == this.ID select sc).FirstOrDefault();
                        db.StudentCourses.DeleteOnSubmit(studentCourse);
                    }
                    else if (this.ID == 0 && this.Selected == true)
                    {
                        db.StudentCourses.InsertOnSubmit(studentCourse);
                        studentCourse.SpecialityID = this.SpecialityID;
                        studentCourse.StudentsID   = this.StudentsID;
                        studentCourse.CourseID     = this.CourseID;
                        studentCourse.SubjectsID   = this.SubjectsID;
                    }



                    if (this.ID == 0)
                    {
                        db.StudentCourses.InsertOnSubmit(studentCourse);
                    }
                    db.SubmitChanges();
                }
            }

            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
Esempio n. 2
0
        public string Save()
        {
            string error = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    User use = new User();
                    if (this.ID > 0)
                    {
                        use = (from us in db.Users where us.ID == this.ID select us).FirstOrDefault();
                    }

                    use.FirstName = this.FirstName;
                    use.LastName  = this.LastName;
                    use.Phone     = this.Phone;
                    use.Email     = this.Email ?? string.Empty;
                    use.Username  = this.Username;
                    use.Password  = this.Password;

                    if (this.ID == 0)
                    {
                        db.Users.InsertOnSubmit(use);
                    }

                    if (this.ID > 0)
                    {
                        var dbRoles = db.UserRoles.Where(i => i.UserID == this.ID).ToList();
                        db.UserRoles.DeleteAllOnSubmit(dbRoles);
                    }

                    db.SubmitChanges();
                    this.ID = use.ID;

                    foreach (var r in this.Roles)
                    {
                        var role = new UserRole();
                        role.UserID = this.ID;
                        role.RoleID = r.RoleID;
                        db.UserRoles.InsertOnSubmit(role);
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
Esempio n. 3
0
        public string Save()
        {
            string error = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    UserRole userRole = new UserRole();
                    if (this.ID > 0)
                    {
                        userRole = (from us in db.UserRoles where us.ID == this.ID select us).FirstOrDefault();
                    }

                    userRole.UserID = this.UserID;
                    userRole.RoleID = this.RoleID;

                    if (this.ID == 0)
                    {
                        db.UserRoles.InsertOnSubmit(userRole);
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
Esempio n. 4
0
        public string Save()
        {
            string error = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    University university = new University();
                    if (this.ID > 0)
                    {
                        university = (from un in db.Universities where un.ID == this.ID select un).FirstOrDefault();
                    }

                    university.City = this.City;
                    university.Name = this.Name;

                    if (this.ID == 0)
                    {
                        db.Universities.InsertOnSubmit(university);
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
Esempio n. 5
0
        public string Save()
        {
            string error = string.Empty;

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    ЕducationaLevel educationLevel = new ЕducationaLevel();

                    if (this.ID > 0)
                    {
                        educationLevel = (from edu in db.ЕducationaLevels where edu.ID == this.ID select edu).FirstOrDefault();
                    }

                    educationLevel.LevelName = this.LevelName;

                    if (this.ID == 0)
                    {
                        db.ЕducationaLevels.InsertOnSubmit(educationLevel);
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
        public string Save()
        {
            string error = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    InterruptedRepeat interruptedRepeat = new InterruptedRepeat();
                    if (this.ID > 0)
                    {
                        interruptedRepeat = (from intr in db.InterruptedRepeats where intr.ID == this.ID select intr).FirstOrDefault();
                    }

                    interruptedRepeat.RepeastYear  = this.RepeastYear;
                    interruptedRepeat.StudentID    = this.StudentID;
                    interruptedRepeat.SpecialityID = this.SpecialityID;
                    interruptedRepeat.CourseID     = this.CourseID;

                    if (this.ID == 0)
                    {
                        db.InterruptedRepeats.InsertOnSubmit(interruptedRepeat);
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
Esempio n. 7
0
        public string Save()
        {
            //List<TCourse>Courses = new List<TCourse>();
            string error = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    Course course = new Course();
                    if (this.ID > 0)
                    {
                        course = (from co in db.Courses where co.ID == this.ID select co).FirstOrDefault();
                    }

                    course.NameCourse = this.NameCourse;

                    if (this.ID == 0)
                    {
                        db.Courses.InsertOnSubmit(course);
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
Esempio n. 8
0
        public string Save()
        {
            string error = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext())
                {
                    Faculty faculty = new Faculty();
                    if (this.ID > 0)
                    {
                        faculty = (from fa in db.Faculties where fa.ID == this.ID select fa).FirstOrDefault();
                    }

                    faculty.FacultyName  = this.FacultyName;
                    faculty.UniversityID = this.UniversityID;
                    //faculty.SpecialityID = this.SpecialityID;

                    if (this.ID == 0)
                    {
                        db.Faculties.InsertOnSubmit(faculty);
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
Esempio n. 9
0
        public string Save()
        {
            string error = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    Role role = new Role();
                    if (this.ID > 0)
                    {
                        role = (from r in db.Roles where r.ID == this.ID select r).FirstOrDefault();
                    }

                    role.Description = this.Description;
                    role.Delete      = this.Delete;

                    if (this.ID == 0)
                    {
                        db.Roles.InsertOnSubmit(role);
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
        public string Save()
        {
            string error = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    SubjectSpeciality subjectSpeciality = new SubjectSpeciality();
                    if (this.ID > 0)
                    {
                        subjectSpeciality = (from sub in db.SubjectSpecialities where sub.ID == this.ID select sub).FirstOrDefault();
                    }

                    subjectSpeciality.SubjectID    = this.SubjectID;
                    subjectSpeciality.SpecialityID = this.SpecialityID;

                    if (this.ID == 0)
                    {
                        db.SubjectSpecialities.InsertOnSubmit(subjectSpeciality);
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
Esempio n. 11
0
        public string Save()
        {
            string error = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    Department department = new Department();
                    if (this.ID > 0)
                    {
                        department = (from dp in db.Departments where dp.ID == this.ID select dp).FirstOrDefault();
                    }

                    department.Txt       = this.Txt;
                    department.Name      = this.Name;
                    department.FacultyID = this.FacultyID;

                    if (this.ID == 0)
                    {
                        db.Departments.InsertOnSubmit(department);
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
Esempio n. 12
0
        public string Save()
        {
            string error = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    SubjectCourse subjectCourse = new SubjectCourse();
                    if (this.ID > 0)
                    {
                        subjectCourse = (from sc in db.SubjectCourses where sc.ID == this.ID select sc).FirstOrDefault();
                    }

                    subjectCourse.SubjectID    = this.SubjectID;
                    subjectCourse.CourseiD     = this.CourseID;
                    subjectCourse.SemesterID   = this.SemesterID;
                    subjectCourse.SpecialityID = this.SpecialityID;

                    if (this.ID == 0)
                    {
                        db.SubjectCourses.InsertOnSubmit(subjectCourse);
                    }
                    db.SubmitChanges();
                }
            }

            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
        public string Save()
        {
            string error = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext())
                {
                    DepartmentLecture departmentLecture = new DepartmentLecture();
                    if (this.ID > 0)
                    {
                        departmentLecture = (from dl in db.DepartmentLectures where dl.ID == this.ID select dl).FirstOrDefault();
                    }
                    departmentLecture.LectureID    = this.LectureID;
                    departmentLecture.DepartmentID = this.DepartmentID;
                    departmentLecture.StartDate    = this.StartDate;
                    departmentLecture.FinishDate   = this.FinishDate;
                    departmentLecture.SubjectID    = this.SubjectID;

                    if (this.ID == 0)
                    {
                        db.DepartmentLectures.InsertOnSubmit(departmentLecture);
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
Esempio n. 14
0
        public string Save()
        {
            string error = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    FormOfEducation formOfEducation = new FormOfEducation();
                    if (this.ID > 0)
                    {
                        formOfEducation = (from foe in db.FormOfEducations where foe.ID == this.ID select foe).FirstOrDefault();
                    }

                    formOfEducation.Name = this.Name;

                    if (this.ID == 0)
                    {
                        db.FormOfEducations.InsertOnSubmit(formOfEducation);
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
Esempio n. 15
0
        public string Save()
        {
            string error = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    Subject subject = new Subject();
                    if (this.ID > 0)
                    {
                        subject = (from su in db.Subjects where su.ID == this.ID select su).FirstOrDefault();
                    }

                    subject.FacultyID             = this.FacultyID;
                    subject.DepartmentsID         = this.DeparmentsID;
                    subject.SubjectName           = this.SubjectName;
                    subject.CompulsoryDiscipline  = this.CompulsoryDiscipline;
                    subject.FacultativeDiscipline = this.FacultativeDiscipline;

                    if (this.ID == 0)
                    {
                        db.Subjects.InsertOnSubmit(subject);
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
Esempio n. 16
0
        public string Save()
        {
            string err = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    Student stu = new Student();
                    if (this.ID > 0)
                    {
                        stu = (from st in db.Students where st.ID == this.ID select st).FirstOrDefault();

                        //if (s.EGN != this.EGN) { err = ""; return err; }
                    }

                    stu.FirstName  = this.FirstName;
                    stu.MiddleName = this.MiddleName;
                    stu.LastName   = this.LastName;
                    stu.EGN        = this.EGN;
                    stu.Phone      = this.Phone;
                    stu.Email      = this.Email;
                    stu.City       = this.City;
                    stu.GraduateSecondarySchool       = this.GraduateSecondarySchool;
                    stu.DateOfEnrollmentInFirstCourse = this.DateOfEnrollmentInFirstCourse;
                    stu.Male      = this.Male;
                    stu.Address   = this.Address;
                    stu.Image     = this.Image;
                    stu.FacultyID = this.FacultyID;


                    if (this.ID == 0)
                    {
                        db.Students.InsertOnSubmit(stu);
                    }
                    db.SubmitChanges();
                    this.ID = stu.ID;

                    //TStudentSpeciality.Save(db, this);
                }
            }

            catch (Exception ex)
            {
                err = ex.Message;
            }
            return(err);
        }
Esempio n. 17
0
        public string Save()
        {
            string error = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    Lecture lecture = new Lecture();
                    if (this.ID > 0)
                    {
                        lecture = (from le in db.Lectures where le.ID == this.ID select le).FirstOrDefault();
                    }

                    lecture.FirstName  = this.FirstName;
                    lecture.LastName   = this.LastName;
                    lecture.MiddleName = this.MiddleName;
                    lecture.Title      = this.Title;
                    lecture.Phone      = this.Phone;
                    lecture.Email      = this.Email;
                    lecture.FacultyID  = this.FacultyID;
                    //  lecture.Departmnet = this.Department;
                    lecture.GraduateUniversity = this.GraduateUniversity;
                    lecture.City  = this.City;
                    lecture.Image = this.Image;

                    if (this.ID == 0)
                    {
                        db.Lectures.InsertOnSubmit(lecture);
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
Esempio n. 18
0
        public string Save()
        {
            string error = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    StudentSpeciality studentSpeciality = new StudentSpeciality();
                    if (this.ID > 0)
                    {
                        studentSpeciality = (from sts in db.StudentSpecialities where sts.ID == this.ID select sts).FirstOrDefault();
                    }

                    studentSpeciality.Credits           = this.Credits;
                    studentSpeciality.SpecialityID      = this.SpecialityID;
                    studentSpeciality.StartYear         = this.StartYear;
                    studentSpeciality.FinishYear        = this.FinishYear;
                    studentSpeciality.CourseID          = this.CourseID;
                    studentSpeciality.FormOfEducationID = this.FormOfEducationID;
                    studentSpeciality.StudentID         = this.StudentID;
                    studentSpeciality.FacultyNumber     = this.FacultyNumber;
                    studentSpeciality.EducationLevelID  = this.EducationLevel.ID;


                    if (this.ID == 0)
                    {
                        db.StudentSpecialities.InsertOnSubmit(studentSpeciality);
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
Esempio n. 19
0
        public string Save()
        {
            string error = "";

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext())
                {
                    Evaluation evaluation = new Evaluation();
                    if (this.ID > 0)
                    {
                        evaluation = (from ev in db.Evaluations where ev.ID == this.ID select ev).FirstOrDefault();
                    }


                    evaluation.SubjectID    = this.SubjectID;
                    evaluation.StudentID    = this.StudentID;
                    evaluation.SpecialityID = this.SpecialityID;
                    evaluation.LectureID    = this.LectureID;
                    evaluation.Number       = this.Number;
                    evaluation.CourseID     = this.CourseID;

                    if (this.ID == 0)
                    {
                        db.Evaluations.InsertOnSubmit(evaluation);
                    }
                    db.SubmitChanges();
                }
            }

            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }