public void EditProgram(Program Program)
        {
            pbDB = new ProgramBuilderEntities();

            Program Prog = pbDB.Programs.First(x => x.ID == Program.ID);

            Prog.Name                    = Program.Name;
            Prog.TrainingLevel           = Program.TrainingLevel;
            Prog.BranchName              = Program.BranchName;
            Prog.EducationType           = Program.EducationType;
            Prog.TrainingPurpose         = Program.TrainingPurpose;
            Prog.EntranceStudent         = Program.EntranceStudent;
            Prog.TrainingTimeDetail      = Program.TrainingTimeDetail;
            Prog.KnowledgeTotal          = Program.KnowledgeTotal;
            Prog.GraduateCondition       = Program.GraduateCondition;
            Prog.PointLadder             = Program.PointLadder;
            Prog.TrainingSupport         = Program.TrainingSupport;
            Prog.Content                 = Program.Content;
            Prog.TrainingPlan            = Program.TrainingPlan;
            Prog.Status                  = Program.Status;
            Prog.ShortContentDescription = Program.ShortContentDescription;
            Prog.LecturerList            = Program.LecturerList;
            Prog.FacultyID               = Program.FacultyID;
            Prog.CreationTime            = DateTime.Now;

            pbDB.SaveChanges();
        }
Esempio n. 2
0
        public void AddFacility(Facility Faci)
        {
            pbDB = new ProgramBuilderEntities();

            pbDB.Facilities.Add(Faci);

            pbDB.SaveChanges();
        }
Esempio n. 3
0
        public void AddClassroom(Classroom Clasro)
        {
            pbDB = new ProgramBuilderEntities();
            Clasro.CreationTime = DateTime.Now;

            pbDB.Classrooms.Add(Clasro);
            pbDB.SaveChanges();
        }
        public void AddProgram(Program Prog)
        {
            pbDB = new ProgramBuilderEntities();

            Prog.CreationTime = DateTime.Now;
            pbDB.Programs.Add(Prog);

            pbDB.SaveChanges();
        }
Esempio n. 5
0
        public void AddFaculty(Faculty Facu)
        {
            pbDB = new ProgramBuilderEntities();

            Facu.CreationTime = DateTime.Now;

            pbDB.Faculties.Add(Facu);

            pbDB.SaveChanges();
        }
        public void AddSyllabus(Syllabus Sylla)
        {
            pbDB = new ProgramBuilderEntities();

            Sylla.CreationTime = DateTime.Now;

            pbDB.Syllabuses.Add(Sylla);

            pbDB.SaveChanges();
        }
Esempio n. 7
0
        public void DeleteAccount(int ID)
        {
            pbDB = new ProgramBuilderEntities();
            Account AccReslut = pbDB.Accounts.Where(x => x.ID == ID).FirstOrDefault();

            pbDB.Accounts.Remove(AccReslut);

            pbDB.Roles.RemoveRange(AccReslut.Roles);

            pbDB.SaveChanges();
        }
Esempio n. 8
0
        public void AddAccount(Account Acc, List <int> RoleIDs)
        {
            pbDB             = new ProgramBuilderEntities();
            Acc.CreationTime = DateTime.Now;

            pbDB.Accounts.Add(Acc);

            pbDB.SaveChanges();

            int CurrentAccID = Acc.ID;

            Account acc = pbDB.Accounts.FirstOrDefault(x => x.ID == CurrentAccID);

            foreach (int RoleID in RoleIDs)
            {
                Role role = pbDB.Roles.FirstOrDefault(x => x.ID == RoleID);
                acc.Roles.Add(role);
            }

            pbDB.SaveChanges();
        }
Esempio n. 9
0
        public void EditClassroom(Classroom Clasro)
        {
            pbDB = new ProgramBuilderEntities();

            Classroom clasroResult = pbDB.Classrooms.Where(x => x.ID == Clasro.ID).FirstOrDefault();

            clasroResult.Name             = Clasro.Name;
            clasroResult.IsOfficeFacility = Clasro.IsOfficeFacility;
            clasroResult.FacilityID       = Clasro.FacilityID;

            pbDB.SaveChanges();
        }
Esempio n. 10
0
        public void EditFaculty(Faculty Facu)
        {
            pbDB = new ProgramBuilderEntities();

            Faculty facuResult = pbDB.Faculties.Where(x => x.ID == Facu.ID).FirstOrDefault();

            facuResult.VietNameseName = Facu.VietNameseName;
            facuResult.EnglishName    = Facu.EnglishName;
            facuResult.PhoneNumber    = Facu.PhoneNumber;
            facuResult.TrainingTime   = Facu.TrainingTime;
            facuResult.ClassroomID    = Facu.ClassroomID;

            pbDB.SaveChanges();
        }
Esempio n. 11
0
        public void DeleteClassroom(int ID)
        {
            pbDB = new ProgramBuilderEntities();

            Classroom clasro = pbDB.Classrooms.Where(x => x.ID == ID).FirstOrDefault();

            pbDB.Classrooms.Remove(clasro);

            Classroom DefaultClassro = pbDB.Classrooms.First();

            if (DefaultClassro != null)
            {
                DefaultClassro.IsOfficeFacility = false;

                EditClassroom(DefaultClassro);
            }

            pbDB.SaveChanges();
        }
Esempio n. 12
0
        public void EditAccount(Account Acc, List <int> RoleIDs)
        {
            pbDB = new ProgramBuilderEntities();
            Account AccReslut = pbDB.Accounts.FirstOrDefault(x => x.ID == Acc.ID);

            AccReslut.UserName    = Acc.UserName;
            AccReslut.Password    = Acc.Password;
            AccReslut.FullName    = Acc.FullName;
            AccReslut.Degree      = Acc.Degree;
            AccReslut.PhoneNumber = Acc.PhoneNumber;
            AccReslut.Email       = Acc.Email;
            AccReslut.FacultyID   = Acc.FacultyID;

            AccReslut.Roles.Clear();

            foreach (int RoleID in RoleIDs)
            {
                Role role = pbDB.Roles.FirstOrDefault(x => x.ID == RoleID);

                AccReslut.Roles.Add(role);
            }

            pbDB.SaveChanges();
        }
        public void EditSyllabus(Syllabus sylla)
        {
            pbDB = new ProgramBuilderEntities();

            Syllabus CurrentSylla = pbDB.Syllabuses.Single(x => x.ID == sylla.ID);

            CurrentSylla.VietnameseName            = sylla.VietnameseName;
            CurrentSylla.EnglishName               = sylla.EnglishName;
            CurrentSylla.KnowldgeType              = sylla.KnowldgeType;
            CurrentSylla.LearningTimeDetail        = sylla.LearningTimeDetail;
            CurrentSylla.Requirement               = sylla.Requirement;
            CurrentSylla.Planning                  = sylla.Planning;
            CurrentSylla.DocumentReference         = sylla.DocumentReference;
            CurrentSylla.LearningOutcomeEvaluate   = sylla.LearningOutcomeEvaluate;
            CurrentSylla.LecturerContact           = sylla.LecturerContact;
            CurrentSylla.ShortDescription          = sylla.ShortDescription;
            CurrentSylla.OutcomeContent            = sylla.OutcomeContent;
            CurrentSylla.OutcomeMaxtrixMapping     = sylla.OutcomeMaxtrixMapping;
            CurrentSylla.OutcomeMappingDescription = sylla.OutcomeMappingDescription;
            CurrentSylla.ClassroomID               = sylla.ClassroomID;
            CurrentSylla.CreationTime              = DateTime.Now;

            pbDB.SaveChanges();
        }
Esempio n. 14
0
        public void AddSubject(Subject subject, List <int> subjectConditionIDs, List <int> AccountIDs)
        {
            pbDB = new ProgramBuilderEntities();

            subject.CreationTime = DateTime.Now;

            pbDB.Subjects.Add(subject);

            pbDB.SaveChanges();

            int CurrentSubjectID = subject.ID;

            Subject CurrentSub = pbDB.Subjects.SingleOrDefault(x => x.ID == CurrentSubjectID);

            for (int i = 0; i < AccountIDs.Count; i++)
            {
                if (AccountIDs[i] == AccountIDs[AccountIDs.Count - 1])
                {
                    AccountIDs.RemoveAt(i);
                    break;
                }
            }

            for (int i = 0; i < AccountIDs.Count; i++)
            {
                int tempAccID = AccountIDs[i];

                SubjectsAccount SubAcc = new SubjectsAccount();

                var acc = (from Acc2 in pbDB.Accounts
                           where Acc2.ID == tempAccID
                           select Acc2).SingleOrDefault();

                SubAcc.Subject          = CurrentSub;
                SubAcc.Account          = acc;
                SubAcc.IsSyllabusEditor = false;

                if (i == AccountIDs.Count - 1)
                {
                    SubAcc.IsSyllabusEditor = true;
                }

                pbDB.SubjectsAccounts.Add(SubAcc);
            }

            //if (AccountIDs != null)
            //{
            //    foreach (int item in AccountIDs)
            //    {
            //        if (item != AccountID)
            //        {
            //            NewAccountIDs.Add(item);
            //        }
            //    }
            //}

            //NewAccountIDs.Add(AccountID);


            //foreach(int item in NewAccountIDs)
            //{
            //    Account acc = (from Acc2 in pbDB.Accounts
            //                   where Acc2.ID == item
            //                   select Acc2).Single();

            //    SubjectsAccount SubAcc = new SubjectsAccount();
            //    SubAcc.Account = acc;
            //    SubAcc.Subject = CurrentSub;
            //    SubAcc.IsSyllabusEditor = false;

            //    if (item.Equals(AccountID))
            //    {
            //        SubAcc.IsSyllabusEditor = true;
            //    }

            //    pbDB.SubjectsAccounts.Add(SubAcc);
            //}

            if (subjectConditionIDs != null)
            {
                foreach (int subjectConditionID in subjectConditionIDs)
                {
                    Subject relateSub = pbDB.Subjects.SingleOrDefault(x => x.ID == subjectConditionID);

                    CurrentSub.Subjects1.Add(relateSub);
                }
            }

            pbDB.SaveChanges();
        }
Esempio n. 15
0
        public void EditSubject(Subject subject, List <int> AccountIDs, List <int> subjectConditionIDs)
        {
            pbDB = new ProgramBuilderEntities();

            Subject CurrentSubj = pbDB.Subjects.SingleOrDefault(x => x.ID == subject.ID);

            CurrentSubj.Name           = subject.Name;
            CurrentSubj.PartialCode    = subject.PartialCode;
            CurrentSubj.CreditNumber   = subject.CreditNumber;
            CurrentSubj.TheoryNumber   = subject.TheoryNumber;
            CurrentSubj.PracticeNumber = subject.PracticeNumber;
            CurrentSubj.LearningLevel  = subject.LearningLevel;
            CurrentSubj.SemesterNumber = subject.SemesterNumber;
            CurrentSubj.Description    = subject.Description;
            CurrentSubj.Purpose        = subject.Purpose;
            CurrentSubj.SubjectTypeID  = subject.SubjectTypeID;
            CurrentSubj.FacultyID      = subject.FacultyID;
            CurrentSubj.Form           = subject.Form;


            //Remove

            CurrentSubj.SubjectsAccounts.Clear();

            CurrentSubj.Subjects1.Clear();

            // Add
            for (int i = 0; i < AccountIDs.Count; i++)
            {
                if (AccountIDs[i] == AccountIDs[AccountIDs.Count - 1])
                {
                    AccountIDs.RemoveAt(i);
                    break;
                }
            }

            for (int i = 0; i < AccountIDs.Count; i++)
            {
                int tempAccID = AccountIDs[i];

                SubjectsAccount SubAcc = new SubjectsAccount();

                var acc = (from Acc2 in pbDB.Accounts
                           where Acc2.ID == tempAccID
                           select Acc2).SingleOrDefault();

                SubAcc.Subject          = CurrentSubj;
                SubAcc.Account          = acc;
                SubAcc.IsSyllabusEditor = false;

                if (i == AccountIDs.Count - 1)
                {
                    SubAcc.IsSyllabusEditor = true;
                }

                pbDB.SubjectsAccounts.Add(SubAcc);
            }

            if (subjectConditionIDs != null)
            {
                foreach (int subjectConditionID in subjectConditionIDs)
                {
                    Subject relateSub = pbDB.Subjects.SingleOrDefault(x => x.ID == subjectConditionID);

                    CurrentSubj.Subjects1.Add(relateSub);
                }
            }


            pbDB.SaveChanges();
        }