示例#1
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);
        }
示例#2
0
        public static string CheckValidPassword(string username, string password)
        {
            string error = string.Empty;
            TUsers user  = null;

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    if (string.IsNullOrEmpty(username))
                    {
                        return("Моля въведете правилно потребителско име");
                    }
                    if (string.IsNullOrEmpty(password))
                    {
                        return("Моля въведете правилна парола");
                    }

                    var use = (from us in db.Users where us.Username.Equals(username) && us.Password.Equals(password) select us).FirstOrDefault();
                    if (use == null)
                    {
                        return(" Невалидно потребителско име");
                    }

                    user = new TUsers(use);
                }

                Program.CurrentUser = user;
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(error);
        }
示例#3
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);
        }
        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);
        }
示例#5
0
        public static List <TEvaluationResult> LoadEvaluation(out string error)
        {
            List <TEvaluationResult> Evaluations = new List <TEvaluationResult>();

            error = string.Empty;

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    Evaluations = (
                        from ev in db.Evaluations
                        join stud in db.Students on ev.StudentID equals stud.ID
                        join subj in db.Subjects on ev.SubjectID equals subj.ID
                        join spec in db.Specialities on ev.SpecialityID equals spec.ID
                        join lect in db.Lectures on ev.LectureID equals lect.ID

                        select new TEvaluationResult {
                        StudentId = stud.ID, StudentName = stud.FirstName, NameSpeciality = spec.NameSpeciality, SubjectName = subj.SubjectName, LecturerName = lect.FirstName, Eval = ev.Number
                    }
                        ).ToList();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(Evaluations);
        }
示例#6
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);
        }
示例#7
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);
        }
示例#8
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);
        }
示例#9
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);
        }
示例#10
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);
        }
示例#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);
        }
        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);
        }
        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);
        }
示例#14
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);
        }
示例#15
0
        public static List <TStudentCourse> LoadData(int StudentID, TCourse course, out string error)
        {
            List <TStudentCourse> StudentCourses = new List <TStudentCourse>();
            List <TSubject>       Subjects       = new List <TSubject>();

            error = string.Empty;

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    StudentCourses = (from sc in db.StudentCourses where sc.StudentsID == StudentID select new TStudentCourse(sc)).ToList();
                    Subjects       = (from s in db.Subjects where s.CompulsoryDiscipline == false select new TSubject(s)).ToList();

                    var ls = Subjects.Where(i => StudentCourses.Where(p => p.SubjectsID == i.ID).Count() == 0).ToList();

                    var subjCourse = db.SubjectCourses.Where(i => i.CourseiD == course.ID).ToList();
                    ls = ls.Where(i => subjCourse.Select(p => p.SubjectID).Contains(i.ID)).ToList();

                    var specialities = db.SubjectSpecialities.Where(i => ls.Select(k => k.ID).Contains(i.SubjectID)).ToList();
                    var studSpecs    = db.StudentSpecialities.Where(i => i.CourseID == course.ID).ToList();

                    foreach (var l in ls)
                    {
                        var s = new TStudentCourse(l, course);
                        StudentCourses.Add(s);
                    }
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(StudentCourses);
        }
示例#16
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);
        }
示例#17
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);
        }
示例#18
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);
        }
示例#19
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);
        }
        public static List <TSubjectSpeciality> LoadData(out string error)
        {
            List <TSubjectSpeciality> SubjectSpecialities = new List <TSubjectSpeciality>();

            error = string.Empty;

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    SubjectSpecialities = (from ss in db.SubjectSpecialities select new TSubjectSpeciality(ss)).ToList();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(SubjectSpecialities);
        }
        public static List <TInterruptedRepeat> LoadData(out string error)
        {
            List <TInterruptedRepeat> InterruptedRepeats = new List <TInterruptedRepeat>();

            error = string.Empty;

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    InterruptedRepeats = (from inr in db.InterruptedRepeats select new TInterruptedRepeat(inr)).ToList();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(InterruptedRepeats);
        }
示例#22
0
        public static List <TDepartments> LoadData(out string error)
        {
            List <TDepartments> Departments = new List <TDepartments>();

            error = string.Empty;

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    Departments = (from dep in db.Departments select new TDepartments(dep)).ToList();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(Departments);
        }
示例#23
0
        public static List <TEducationLevel> LoadData(out string error)
        {
            List <TEducationLevel> educationLevels = new List <TEducationLevel>();

            error = string.Empty;

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    educationLevels = (from ed in db.ЕducationaLevels select new TEducationLevel(ed)).ToList();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(educationLevels);
        }
示例#24
0
        public static List <TFormOfEducation> LoadData(out string error)
        {
            List <TFormOfEducation> FormOfEducations = new List <TFormOfEducation>();

            error = string.Empty;

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    FormOfEducations = (from forme in db.FormOfEducations select new TFormOfEducation(forme)).ToList();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(FormOfEducations);
        }
示例#25
0
        public static List <TUniversity> LoadData(out string error)
        {
            List <TUniversity> Universities = new List <TUniversity>();

            error = string.Empty;

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    Universities = (from un in db.Universities select new TUniversity(un)).ToList();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(Universities);
        }
示例#26
0
        public static List <TEvaluation> LoadData(out string error)
        {
            List <TEvaluation> Evaluations = new List <TEvaluation>();

            error = string.Empty;

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    Evaluations = (from ev in db.Evaluations select new TEvaluation(ev)).ToList();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(Evaluations);
        }
示例#27
0
        //public string Save()
        //{
        //    string error = "";

        //    try
        //    {
        //        using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
        //        {
        //            Semester sem = new Semester();
        //            if (this.ID > 0)
        //            {
        //                sem = (from sm in db.Semesters where sm.ID == this.ID select sm).FirstOrDefault();
        //            }

        //            sem.SummerWinter = this.SummerWinter;

        //            if (this.ID == 0) db.Semesters.InsertOnSubmit(sem);
        //            db.SubmitChanges();
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        error = ex.Message;
        //    }
        //    return error;
        //}
        public static List <TSemester> LoadData(out string error)
        {
            List <TSemester> Semester = new List <TSemester>();

            error = string.Empty;

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    Semester = (from sr in db.Semesters select new TSemester(sr)).ToList();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(Semester);
        }
        public static List <TDepartmentLectrure> LoadData(out string error)
        {
            List <TDepartmentLectrure> Dlecture = new List <TDepartmentLectrure>();

            error = string.Empty;

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    Dlecture = (from dl in db.DepartmentLectures select new TDepartmentLectrure(dl)).ToList();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(Dlecture);
        }
示例#29
0
        public static List <TRole> LoadData(out string error)
        {
            List <TRole> Roles = new List <TRole>();

            error = string.Empty;

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    Roles = (from r in db.Roles select new TRole(r)).ToList();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(Roles);
        }
示例#30
0
        public static List <TUsers> LoadData(out string error)
        {
            List <TUsers> Users = new List <TUsers>();

            error = string.Empty;

            try
            {
                using (SQLDatabaseDataContext db = new SQLDatabaseDataContext(Program.Connectionstring))
                {
                    Users = (from us in db.Users select new TUsers(us)).ToList();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(Users);
        }