Exemple #1
0
        public Boolean CreateGradeSection(ref GradeSectionBDO gsBDO, ref string message)
        {
            message = "Grade Section Added Successfully";
            bool ret = true;

            GradeSection gs = new GradeSection();
            try{
            ConvertGradeSectionBDOToGradeSection(gsBDO, gs);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.GradeSections.Attach(gs);
                DCEnt.Entry(gs).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Grade Section failed";
                }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
                }
            }
            return ret;
        }
Exemple #2
0
        public Boolean ActivateUser(int userId, ref string message)
        {
            message = "User Activated successfully.";
            Boolean ret = true;

            using (var DCEnt = new DCFIEntities())
            {
                User userInDB = (from u in DCEnt.Users
                                 where u.UserId == userId
                                 select u).FirstOrDefault();

                if (userInDB == null)
                {
                    throw new Exception("No user with ID " + userId);
                }

                DCEnt.Users.Remove(userInDB);

                userInDB.Deactivated = false;

                DCEnt.Users.Attach(userInDB);
                DCEnt.Entry(userInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();
                if (num != 1)
                {
                    ret = false;
                    message = "Activation Failed.";
                }
            }
            return ret;
        }
Exemple #3
0
        public Boolean CreateLearningArea(ref LearningAreaBDO laBDO, ref string message)
        {
            message = "Learning Area Added Successfully";
            bool ret = true;

            LearningArea la = new LearningArea();
            try {
            ConvertLearningAreaBDOToLearningArea(laBDO, la);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.LearningAreas.Add(la);
                DCEnt.Entry(la).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num == 0)
                {
                    ret = false;
                    message = "Adding of Learning Area failed";
                }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
                }
            }
            return ret;
        }
Exemple #4
0
        public Boolean AddLog(LogBDO log)
        {
            //string message = "Log Added Successfully";
            bool ret = true;

            try
            {
                Log l = new Log();
                ConvertLogBDOToLog(log, l);
                using (var DCEnt = new DCFIEntities())
                {
                    DCEnt.Logs.Add(l);
                    DCEnt.Entry(l).State = System.Data.Entity.EntityState.Added;
                    int num = DCEnt.SaveChanges();
                    if (num < 1)
                    {
                        ret = false;
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(ret);
        }
Exemple #5
0
        public Boolean DeleteUser(int userId, ref string message)
        {
            message = "User Deleted successfully.";
            Boolean ret = true;

            using (var DCEnt = new DCFIEntities())
            {
                User userInDB = (from u in DCEnt.Users
                                 where u.UserId == userId
                                 select u).FirstOrDefault();

                if (userInDB == null)
                {
                    throw new Exception("No user with ID " + userId);
                }

                DCEnt.Users.Remove(userInDB);
                DCEnt.Entry(userInDB).State = System.Data.Entity.EntityState.Deleted;
                int num = DCEnt.SaveChanges();
                if (num != 1)
                {
                    ret     = false;
                    message = "Deletion of User Failed.";
                }
            }
            return(ret);
        }
Exemple #6
0
        public Boolean DeleteTimeslot(string timeslotCode, ref string message)
        {
            message = "Timeslot Deleted successfully.";
            Boolean ret = true;

            using (var DCEnt = new DCFIEntities())
            {
                Timeslot tInDB = (from t in DCEnt.Timeslots
                                  where t.TimeSlotCode == timeslotCode
                                  select t).FirstOrDefault();

                if (tInDB == null)
                {
                    throw new Exception("No timeslot with code " + tInDB);
                }

                DCEnt.Timeslots.Remove(tInDB);
                DCEnt.Entry(tInDB).State = System.Data.Entity.EntityState.Deleted;
                int num = DCEnt.SaveChanges();
                if (num != 1)
                {
                    ret     = false;
                    message = "Deletion of Timeslot Failed.";
                }
            }
            return(ret);
        }
Exemple #7
0
        public Boolean UpdateTimeslot(ref TimeslotBDO tBDO, ref string message)
        {
            message = "Timeslot updated successfully.";
            Boolean ret = true;

            using (var DCEnt = new DCFIEntities())
            {
                var      timeslotCode = tBDO.TimeSlotCode;
                Timeslot timeslotInDB = (from t in DCEnt.Timeslots
                                         where t.TimeSlotCode == timeslotCode
                                         select t).FirstOrDefault();
                if (timeslotInDB == null)
                {
                    throw new Exception("No timeslot with code " + tBDO.TimeSlotCode);
                }
                DCEnt.Timeslots.Remove(timeslotInDB);

                timeslotInDB.TimeStart = tBDO.TimeStart;
                timeslotInDB.TimeEnd   = tBDO.TimeEnd;
                timeslotInDB.Days      = tBDO.Days;

                DCEnt.Timeslots.Attach(timeslotInDB);
                DCEnt.Entry(timeslotInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret     = false;
                    message = "No timeslot is updated.";
                }
            }
            return(ret);
        }
Exemple #8
0
        public Boolean UpdateSY(ref SchoolYearBDO syBDO, ref string message)
        {
            message = "School Year updated successfully.";
            Boolean ret = true;

            using (var DCEnt = new DCFIEntities())
            {
                var        SY     = syBDO.SY;
                SchoolYear syInDB = (from u in DCEnt.SchoolYears
                                     where u.SY == SY
                                     select u).FirstOrDefault();
                if (syInDB == null)
                {
                    throw new Exception(syBDO.SY + " doesn't exist");
                }
                DCEnt.SchoolYears.Remove(syInDB);

                syInDB.SY        = syBDO.SY;
                syInDB.CurrentSY = syBDO.CurrentSY;

                DCEnt.SchoolYears.Attach(syInDB);
                DCEnt.Entry(syInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret     = false;
                    message = "No SY is updated.";
                }
            }
            return(ret);
        }
Exemple #9
0
        public Boolean CreateTimeslot(ref TimeslotBDO tBDO, ref string message)
        {
            message = "Timeslot Added Successfully";
            bool ret = true;

            Timeslot t = new Timeslot()
            {
                TimeSlotCode = tBDO.TimeSlotCode,
                TimeStart    = tBDO.TimeStart,
                TimeEnd      = tBDO.TimeEnd,
                Days         = tBDO.Days
            };

            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Timeslots.Attach(t);
                DCEnt.Entry(t).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();
                tBDO.TimeSlotCode = t.TimeSlotCode;

                if (num != 1)
                {
                    ret     = false;
                    message = "Adding of Timeslot failed";
                }
            }
            return(ret);
        }
Exemple #10
0
        public Boolean DeleteSY(string schoolyear, ref string message)
        {
            message = "SY " + schoolyear + " Deleted successfully.";
            Boolean ret = true;

            using (var DCEnt = new DCFIEntities())
            {
                SchoolYear SYInDB = (from u in DCEnt.SchoolYears
                                     where u.SY == schoolyear
                                     select u).FirstOrDefault();

                if (SYInDB == null)
                {
                    throw new Exception("No SY " + schoolyear + " existed");
                }

                DCEnt.SchoolYears.Remove(SYInDB);
                DCEnt.Entry(SYInDB).State = System.Data.Entity.EntityState.Deleted;
                int num = DCEnt.SaveChanges();
                if (num != 1)
                {
                    ret     = false;
                    message = "Deletion of SY Failed.";
                }
            }
            return(ret);
        }
Exemple #11
0
        public Boolean DismissStudent(string studentID, ref string message)
        {
            message = "Student dismissed successfully.";
            Boolean ret = true;

            using (var DCEnt = new DCFIEntities())
            {
                Student studentInDB = (from s in DCEnt.Students
                                       where s.StudentId == studentID
                                       select s).FirstOrDefault();
                if (studentInDB == null)
                {
                    throw new Exception("No student with ID " + studentID);
                }

                DCEnt.Students.Remove(studentInDB);

                studentInDB.Dismissed = true;

                DCEnt.Students.Attach(studentInDB);
                DCEnt.Entry(studentInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();
                if (num != 1)
                {
                    ret = false;
                    message = "Fail to Dismiss Student.";
                }
            }
            return ret;
        }
Exemple #12
0
        public Boolean CreateSY(ref SchoolYearBDO syBDO, ref string message)
        {
            message = "School Year Added Successfully";
            bool ret = true;


            SchoolYear u = new SchoolYear()
            {
                SY        = syBDO.SY,
                CurrentSY = syBDO.CurrentSY
            };

            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.SchoolYears.Attach(u);
                DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();
                syBDO.SY = u.SY;

                if (num != 1)
                {
                    ret     = false;
                    message = "Adding of School Year failed";
                }
            }
            return(ret);
        }
Exemple #13
0
        public Boolean CreateUser(ref UserBDO userBDO, ref string message)
        {
            message = "User Added Successfully";
            bool ret = true;

            UserType ut = new UserType()
            {
                UserType1    = userBDO.UserType.UsersType,
                UserTypeCode = userBDO.UserType.UserTypeCode
            };
            User u = new User()
            {
                UserName     = userBDO.UserName,
                Password     = userBDO.Password,
                LastName     = userBDO.LastName,
                FirstName    = userBDO.FirstName,
                MiddleName   = userBDO.MiddleName,
                UserTypeCode = userBDO.UserType.UserTypeCode,
                UserType     = ut
            };

            using (var DCEnt = new DCFIEntities()) {
                DCEnt.Users.Attach(u);
                DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();
                userBDO.UserId = u.UserId;

                if (num != 1)
                {
                    ret     = false;
                    message = "Adding of User failed";
                }
            }
            return(ret);
        }
Exemple #14
0
        public Boolean UpdateCurriculum(ref CurriculumBDO cbdo, ref string message)
        {
            message = "Curriculum updated successfully.";
            Boolean    ret = true;
            Curriculum c   = new Curriculum();

            ConvertCurriculumBDOToCurriculum(cbdo, c);
            using (var DCEnt = new DCFIEntities())
            {
                var        cCode = c.CurriculumCode;
                Curriculum cInDB = (from curri in DCEnt.Curriculums
                                    where curri.CurriculumCode == cCode
                                    select curri).FirstOrDefault();
                if (cInDB == null)
                {
                    throw new Exception("No Curriculum with Code" + c.CurriculumCode);
                }
                DCEnt.Curriculums.Remove(cInDB);
                ConvertCurriculumBDOToCurriculum(cbdo, cInDB);


                DCEnt.Curriculums.Attach(cInDB);
                DCEnt.Entry(cInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();

                if (num == 0)
                {
                    ret     = false;
                    message = "No Curriculum is updated.";
                }
            }
            return(ret);
        }
Exemple #15
0
 public Boolean AddLog(LogBDO log)
 {
     //string message = "Log Added Successfully";
     bool ret = true;
     try
     {
         Log l = new Log();
         ConvertLogBDOToLog(log, l);
         using (var DCEnt = new DCFIEntities())
         {
             DCEnt.Logs.Add(l);
             DCEnt.Entry(l).State = System.Data.Entity.EntityState.Added;
             int num = DCEnt.SaveChanges();
              if (num < 1)
             {
                 ret = false;
                
             }
         }
     }
     catch (DbEntityValidationException dbEx)
     {
         foreach (var validationErrors in dbEx.EntityValidationErrors)
         {
             foreach (var validationError in validationErrors.ValidationErrors)
             {
                 Trace.TraceInformation("Property: {0} Error: {1}",
                                         validationError.PropertyName,
                                         validationError.ErrorMessage);
             }
         }
     }
     return ret;
 }
Exemple #16
0
        public Boolean UpdateTrait(ref TraitBDO tBDO, ref string message)
        {
            message = "Trait updated successfully.";
            Boolean ret = true;

            using (var DCEnt = new DCFIEntities())
            {
                var   traitCode = tBDO.TraitCode;
                Trait tInDB     = (from t in DCEnt.Traits
                                   where t.TraitCode == traitCode
                                   select t).FirstOrDefault();
                if (tInDB == null)
                {
                    throw new Exception("No Trait with TraitCode " + tBDO.TraitCode);
                }
                DCEnt.Traits.Remove(tInDB);

                tInDB.Description = tBDO.Description;
                tInDB.GradeLevel  = tBDO.GradeLevel;
                tInDB.TraitCode   = tBDO.TraitCode;

                DCEnt.Traits.Attach(tInDB);
                DCEnt.Entry(tInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret     = false;
                    message = "No trait is updated.";
                }
            }
            return(ret);
        }
Exemple #17
0
        public Boolean CreateTrait(ref TraitBDO tBDO, ref string message)
        {
            message = "Trait Added Successfully";
            bool ret = true;

            Trait t = new Trait();
            try {
            ConvertTraitBDOToTrait(tBDO, t);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Traits.Attach(t);
                DCEnt.Entry(t).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Trait failed";
                }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
                }
            }
            return ret;
        }
Exemple #18
0
        public Boolean CreateSY(ref SchoolYearBDO syBDO, ref string message)
        {
            message = "School Year Added Successfully";
            bool ret = true;

            SchoolYear u = new SchoolYear()
            {
                SY = syBDO.SY,
                CurrentSY = syBDO.CurrentSY
            };

            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.SchoolYears.Attach(u);
                DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();
                syBDO.SY = u.SY;

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of School Year failed";
                }
            }
            return ret;
        }
        public Boolean UpdateGradeLevel(ref GradeLevelBDO gBDO, ref string message)
        {
            message = "Grade Level updated successfully.";
            Boolean ret = true;
            using (var DCEnt = new DCFIEntities())
            {
                var gCode = gBDO.GradeLev;
                GradeLevel gInDB = (from g in DCEnt.GradeLevels
                                    where g.GradeLevel1 == gCode
                                    select g).FirstOrDefault();
                if (gInDB == null)
                {
                    throw new Exception("No Grade Level " + gBDO.GradeLev);
                }
                DCEnt.GradeLevels.Remove(gInDB);
                gInDB.GradeLevel1 = gBDO.GradeLev;
                gInDB.Description = gBDO.Description;

                DCEnt.GradeLevels.Attach(gInDB);
                DCEnt.Entry(gInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "No grade level is updated.";
                }
            }
            return ret;

        }
Exemple #20
0
        //    DCEnt.Scholarships.Remove(sInDB);

        //    sInDB.Condition = sBDO.Condition;
        //    sInDB.Deactivated = sBDO.Deactivated;
        //    sInDB.Description = sBDO.Description;
        //    sInDB.Privilege = sBDO.Privilege;
        //    sInDB.ScholarshipCode = sBDO.ScholarshipCode;

        //    DCEnt.Scholarships.Attach(sInDB);
        //    DCEnt.Entry(sInDB).State = System.Data.Entity.EntityState.Modified;
        //    int num = DCEnt.SaveChanges();

        //    if (num != 1)
        //    {
        //        ret = false;
        //        message = "No scholarship is updated.";
        //    }
        //}
        //return ret;


        public Boolean UpdateScholarshipDiscount(ref ScholarshipDiscountBDO sBDO, ref string message)
        {
            message = "Scholarship discount updated successfully.";
            Boolean ret = true;

            using (var DCEnt = new DCFIEntities())
            {
                var scholarshipCode       = sBDO.ScholarshipCode;
                ScholarshipDiscount sInDB = (from s in DCEnt.ScholarshipDiscounts
                                             where s.ScholarshipCode == scholarshipCode
                                             select s).FirstOrDefault();
                if (sInDB == null)
                {
                    throw new Exception("No Scholarship discount with ScholarshipCode " + sBDO.ScholarshipCode);
                }
                DCEnt.ScholarshipDiscounts.Remove(sInDB);

                sInDB.FeeCode         = sBDO.FeeCode;
                sInDB.Deactivated     = sBDO.Deactivated;
                sInDB.Discount        = sBDO.Discount;
                sInDB.ScholarshipCode = sBDO.ScholarshipCode;

                DCEnt.ScholarshipDiscounts.Attach(sInDB);
                DCEnt.Entry(sInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret     = false;
                    message = "No scholarship discount is updated.";
                }
            }
            return(ret);
        }
Exemple #21
0
        public Boolean DeleteScholarshipDiscount(string sdCode, string scholarshipCode)
        {
            //message = "User Deleted successfully.";
            Boolean ret = true;

            using (var DCEnt = new DCFIEntities())
            {
                ScholarshipDiscount sdInDB = (from sd in DCEnt.ScholarshipDiscounts
                                              where sd.ScholarshipCode == scholarshipCode && sd.ScholarshipFeeCode == sdCode
                                              select sd).FirstOrDefault();

                if (sdInDB == null)
                {
                    throw new Exception("No Scholarship Discount with ID " + sdCode);
                }

                DCEnt.ScholarshipDiscounts.Remove(sdInDB);
                DCEnt.Entry(sdInDB).State = System.Data.Entity.EntityState.Deleted;
                int num = DCEnt.SaveChanges();
                if (num != 1)
                {
                    ret = false;
                    //message = "Deletion of User Failed.";
                }
            }
            return(ret);
        }
Exemple #22
0
        public Boolean AddScholarshipDiscount(ScholarshipDiscountBDO discount,int scholarshipCode, ref string message)
        {
            message = "Scholarship Discount Added Successfully";
            Boolean ret = true;

            ScholarshipDiscount sd = new ScholarshipDiscount();
            try {
            ConvertScholarshipDiscountBDOToScholarshipDiscount(discount, sd);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.ScholarshipDiscounts.Add(sd);
                DCEnt.Entry(sd).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Scholarship Discount failed";
                }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
            }
            }
                return ret;
        }
Exemple #23
0
        public Boolean CreateUser(ref UserBDO userBDO, ref string message)
        {
            message = "User Added Successfully";
            bool ret = true;

             UserType ut = new UserType()
                {
                    UserType1 = userBDO.UserType.UsersType,
                    UserTypeCode = userBDO.UserType.UserTypeCode
                };
             User u = new User()
                {

                    UserName = userBDO.UserName,
                    Password = userBDO.Password,
                    LastName = userBDO.LastName,
                    FirstName = userBDO.FirstName,
                    MiddleName = userBDO.MiddleName,
                    UserTypeCode = userBDO.UserType.UserTypeCode,
                    UserType = ut
                };

              using (var DCEnt = new DCFIEntities()) {
                    DCEnt.Users.Attach(u);
                    DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added;
                    int num = DCEnt.SaveChanges();
                    userBDO.UserId = u.UserId;

                    if (num != 1) {
                        ret = false;
                        message = "Adding of User failed";
                    }
            }
            return ret;
        }
Exemple #24
0
        public Boolean CreateFee(ref FeeBDO fBDO, ref string message)
        {
            message = "Fee Added Successfully";
            bool ret = true;

            Fee f = new Fee();
            try {
            ConvertFeeBDOToFee(fBDO, f);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Fees.Attach(f);
                DCEnt.Entry(f).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Fee failed";
                }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
            }
            }
            return ret;
        }
Exemple #25
0
        public Boolean UpdateGradeLevel(ref GradeLevelBDO gBDO, ref string message)
        {
            message = "Grade Level updated successfully.";
            Boolean ret = true;

            using (var DCEnt = new DCFIEntities())
            {
                var        gCode = gBDO.GradeLev;
                GradeLevel gInDB = (from g in DCEnt.GradeLevels
                                    where g.GradeLevel1 == gCode
                                    select g).FirstOrDefault();
                if (gInDB == null)
                {
                    throw new Exception("No Grade Level " + gBDO.GradeLev);
                }
                DCEnt.GradeLevels.Remove(gInDB);
                gInDB.GradeLevel1 = gBDO.GradeLev;
                gInDB.Description = gBDO.Description;

                DCEnt.GradeLevels.Attach(gInDB);
                DCEnt.Entry(gInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret     = false;
                    message = "No grade level is updated.";
                }
            }
            return(ret);
        }
Exemple #26
0
        public Boolean CreateCurriculum(ref CurriculumBDO cbdo, ref string message)
        {
            message = "Curriculum Added Successfully";
            bool ret = true;
            Curriculum cur = new Curriculum();
            try {
                ConvertCurriculumBDOToCurriculum(cbdo, cur);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Curriculums.Add(cur);
                DCEnt.Entry(cur).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                    if (num == 0)
                    {
                        ret = false;
                        message = "Adding of Curriculum failed";
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
            }
            }
            return ret;
        }
Exemple #27
0
        public Boolean UpdateSubject(ref SubjectBDO subjectBDO, ref string message)
        {
            message = "Subject updated successfully.";
            Boolean ret = true;

            using (var DCEnt = new DCFIEntities())
            {
                var     subjectCode = subjectBDO.SubjectCode;
                Subject subjectInDB = (from s in DCEnt.Subjects
                                       where s.SubjectCode == subjectCode
                                       select s).FirstOrDefault();
                if (subjectInDB == null)
                {
                    throw new Exception("No Subject with SubjectCode " + subjectBDO.SubjectCode);
                }
                DCEnt.Subjects.Remove(subjectInDB);

                subjectInDB.SubjectID        = subjectBDO.SubjectID;
                subjectInDB.Description      = subjectBDO.Description;
                subjectInDB.GradeLevel       = subjectBDO.GradeLevel;
                subjectInDB.LearningAreaCode = subjectBDO.LearningAreaCode;
                subjectInDB.SubjectCode      = subjectBDO.SubjectCode;

                DCEnt.Subjects.Attach(subjectInDB);
                DCEnt.Entry(subjectInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret     = false;
                    message = "No subject is updated.";
                }
            }
            return(ret);
        }
Exemple #28
0
        public Boolean GraduateStudent(string studentID, ref string message)
        {
            message = "User Retained successfully.";
            Boolean ret = true;

            using (var DCEnt = new DCFIEntities())
            {
                Student studentInDB = (from s in DCEnt.Students
                                       where s.StudentId == studentID
                                       select s).FirstOrDefault();

                if (studentInDB == null)
                {
                    throw new Exception("No student with ID " + studentID);
                }

                DCEnt.Students.Remove(studentInDB);

                studentInDB.Graduated = false;

                DCEnt.Students.Attach(studentInDB);
                DCEnt.Entry(studentInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();
                if (num != 1)
                {
                    ret     = false;
                    message = "Changing Graduate Status Failed.";
                }
            }
            return(ret);
        }
Exemple #29
0
        public Boolean CreateBuilding(ref BuildingBDO buildBDO, ref string message)
        {
            message = "Building Added Successfully";
            bool ret = true;
            try {
            Building b = new Building();
            ConvertBuildingBDOToBuilding(buildBDO,b);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Buildings.Add(b);
                DCEnt.Entry(b).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();
                buildBDO.BuildingCode = b.BuildingCode;

                if (num < 1)
                {
                    ret = false;
                    message = "Adding of Building failed";
                }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
            }
            }
            return ret;
        }
Exemple #30
0
        public Boolean DeleteSY(string schoolyear, ref string message)
        {
            message = "SY " + schoolyear + " Deleted successfully.";
            Boolean ret = true;

            using (var DCEnt = new DCFIEntities())
            {
                SchoolYear SYInDB = (from u in DCEnt.SchoolYears
                                 where u.SY == schoolyear
                                 select u).FirstOrDefault();

                if (SYInDB == null)
                {
                    throw new Exception("No SY " + schoolyear + " existed");
                }

                DCEnt.SchoolYears.Remove(SYInDB);
                DCEnt.Entry(SYInDB).State = System.Data.Entity.EntityState.Deleted;
                int num = DCEnt.SaveChanges();
                if (num != 1)
                {
                    ret = false;
                    message = "Deletion of SY Failed.";
                }
            }
            return ret;
        }
Exemple #31
0
        public Boolean UpdateUser(ref UserBDO userBDO, ref string message)
        {
            message = "User updated successfully.";
            Boolean ret = true;

            try {
                using (var DCEnt = new DCFIEntities()) {
                    var  userID   = userBDO.UserId;
                    User userInDB = (from u in DCEnt.Users
                                     where u.UserId == userID
                                     select u).FirstOrDefault();
                    if (userInDB == null)
                    {
                        throw new Exception("No user with ID " + userBDO.UserId);
                    }
                    DCEnt.Users.Remove(userInDB);
                    UserType ut = new UserType();
                    ut.UserTypeCode = userBDO.UserType.UserTypeCode;
                    ut.UserType1    = userBDO.UserType.UsersType;

                    userInDB.LastName     = userBDO.LastName;
                    userInDB.FirstName    = userBDO.FirstName;
                    userInDB.MiddleName   = userBDO.MiddleName;
                    userInDB.UserName     = userBDO.UserName;
                    userInDB.Password     = userBDO.Password;
                    userInDB.Deactivated  = userBDO.Deactivated;
                    userInDB.UserTypeCode = ut.UserTypeCode;

                    DCEnt.Users.Attach(userInDB);
                    DCEnt.Entry(userInDB).State = System.Data.Entity.EntityState.Modified;
                    int num = DCEnt.SaveChanges();

                    if (num != 1)
                    {
                        ret     = false;
                        message = "No user is updated.";
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(ret);
        }
Exemple #32
0
        public Boolean UpdateGradeSection(ref GradeSectionBDO gsBDO, ref string message)
        {
            message = "Grade Section updated successfully.";
            Boolean ret = true;

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    var          gsCode = gsBDO.GradeSectionCode;
                    GradeSection gsInDB = (from gs in DCEnt.GradeSections
                                           where gs.GradeSectionCode == gsCode
                                           select gs).FirstOrDefault();
                    if (gsInDB == null)
                    {
                        throw new Exception("No Grade Section with Grade Section Code " + gsBDO.GradeSectionCode);
                    }
                    DCEnt.GradeSections.Remove(gsInDB);

                    gsInDB.Deactivated       = gsBDO.Deactivated;
                    gsInDB.GradeLevel        = gsBDO.GradeLevel;
                    gsInDB.GradeSectionCode  = gsBDO.GradeSectionCode;
                    gsInDB.HomeRoomNumber    = gsBDO.HomeRoomNumber;
                    gsInDB.HomeRoomTeacherId = gsBDO.HomeRoomTeacherId;
                    gsInDB.Section           = gsBDO.Section;
                    gsInDB.SY    = gsBDO.SY;
                    gsInDB.Class = gsBDO.Class;
                    DCEnt.GradeSections.Attach(gsInDB);
                    DCEnt.Entry(gsInDB).State = System.Data.Entity.EntityState.Modified;
                    int num = DCEnt.SaveChanges();

                    if (num != 1)
                    {
                        ret     = false;
                        message = "No grade section is updated.";
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(ret);
        }
Exemple #33
0
        public Boolean UpdateRoom(ref RoomBDO roomBDO, ref string message)
        {
            message = "Room updated successfully.";
            Boolean ret = true;

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    var  roomCode = roomBDO.RoomCode;
                    Room roomInDB = (from r in DCEnt.Rooms
                                     where r.RoomCode == roomCode
                                     select r).FirstOrDefault();
                    if (roomInDB == null)
                    {
                        throw new Exception("No room with RoomCode " + roomBDO.RoomCode);
                    }
                    DCEnt.Rooms.Remove(roomInDB);

                    roomInDB.BuildingCode = roomBDO.BuildingCode;
                    roomInDB.Capacity     = roomBDO.Capacity;
                    roomInDB.Deactivated  = roomBDO.Deactivated;
                    roomInDB.Description  = roomBDO.Description;
                    roomInDB.RoomCode     = roomBDO.RoomNumber;
                    roomInDB.RoomNumber   = roomBDO.RoomNumber;
                    roomInDB.RoomId       = roomBDO.RoomId;

                    DCEnt.Rooms.Attach(roomInDB);
                    DCEnt.Entry(roomInDB).State = System.Data.Entity.EntityState.Modified;
                    int num = DCEnt.SaveChanges();

                    if (num != 1)
                    {
                        ret     = false;
                        message = "No room is updated.";
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(ret);
        }
Exemple #34
0
        public Boolean UpdateSubject(ref SubjectBDO subjectBDO, ref string message)
        {
            message = "Subject updated successfully.";
            Boolean ret = true;

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    var     subjectCode = subjectBDO.SubjectCode;
                    Subject subjectInDB = (from s in DCEnt.Subjects
                                           where s.SubjectCode == subjectCode
                                           select s).FirstOrDefault();
                    if (subjectInDB == null)
                    {
                        throw new Exception("No Subject with SubjectCode " + subjectBDO.SubjectCode);
                    }
                    DCEnt.Subjects.Remove(subjectInDB);

                    subjectInDB.SubjectID        = subjectBDO.SubjectID;
                    subjectInDB.Description      = subjectBDO.Description;
                    subjectInDB.GradeLevel       = subjectBDO.GradeLevel;
                    subjectInDB.LearningAreaCode = subjectBDO.LearningAreaCode;
                    subjectInDB.SubjectCode      = subjectBDO.SubjectCode;
                    subjectInDB.MPW = subjectBDO.MPW;

                    DCEnt.Subjects.Attach(subjectInDB);
                    DCEnt.Entry(subjectInDB).State = System.Data.Entity.EntityState.Modified;
                    int num = DCEnt.SaveChanges();

                    if (num != 1)
                    {
                        ret     = false;
                        message = "No subject is updated.";
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(ret);
        }
Exemple #35
0
        public Boolean CreateUser(ref UserBDO userBDO, ref string message)
        {
            message = "User Added Successfully";
            bool ret = true;

            UserType ut = new UserType()
            {
                UserType1    = userBDO.UserType.UsersType,
                UserTypeCode = userBDO.UserType.UserTypeCode
            };
            User u = new User()
            {
                UserName     = userBDO.UserName,
                Password     = userBDO.Password,
                LastName     = userBDO.LastName,
                FirstName    = userBDO.FirstName,
                MiddleName   = userBDO.MiddleName,
                UserTypeCode = userBDO.UserType.UserTypeCode,
                UserType     = ut
            };

            try {
                using (var DCEnt = new DCFIEntities()) {
                    DCEnt.Users.Attach(u);
                    DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added;
                    int num = DCEnt.SaveChanges();
                    userBDO.UserId = u.UserId;

                    if (num != 1)
                    {
                        ret     = false;
                        message = "Adding of User failed";
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(ret);
        }
Exemple #36
0
        public Boolean CreateUser(ref UserBDO userBDO, ref string message)
        {
            message = "User Added Successfully";
            bool ret = true;

             UserType ut = new UserType()
                {
                    UserType1 = userBDO.UserType.UsersType,
                    UserTypeCode = userBDO.UserType.UserTypeCode
                };
             User u = new User()
                {

                    UserName = userBDO.UserName,
                    Password = userBDO.Password,
                    LastName = userBDO.LastName,
                    FirstName = userBDO.FirstName,
                    MiddleName = userBDO.MiddleName,
                    UserTypeCode = userBDO.UserType.UserTypeCode,
                    UserType = ut
                };
            try {
              using (var DCEnt = new DCFIEntities()) {
                    DCEnt.Users.Attach(u);
                    DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added;
                    int num = DCEnt.SaveChanges();
                    userBDO.UserId = u.UserId;

                    if (num != 1) {
                        ret = false;
                        message = "Adding of User failed";
                    }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
                }
            }
            return ret;
        }
Exemple #37
0
        //    DCEnt.Scholarships.Remove(sInDB);

        //    sInDB.Condition = sBDO.Condition;
        //    sInDB.Deactivated = sBDO.Deactivated;
        //    sInDB.Description = sBDO.Description;
        //    sInDB.Privilege = sBDO.Privilege;
        //    sInDB.ScholarshipCode = sBDO.ScholarshipCode;

        //    DCEnt.Scholarships.Attach(sInDB);
        //    DCEnt.Entry(sInDB).State = System.Data.Entity.EntityState.Modified;
        //    int num = DCEnt.SaveChanges();

        //    if (num != 1)
        //    {
        //        ret = false;
        //        message = "No scholarship is updated.";
        //    }
        //}
        //return ret;


        public Boolean UpdateScholarshipDiscount(ref ScholarshipDiscountBDO sBDO, ref string message)
        {
            message = "Scholarship discount updated successfully.";
            Boolean ret = true;

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    var scholarshipCode       = sBDO.ScholarshipDiscountId;
                    ScholarshipDiscount sInDB = (from s in DCEnt.ScholarshipDiscounts
                                                 where s.ScholarshipDiscountId == scholarshipCode
                                                 select s).FirstOrDefault();
                    if (sInDB == null)
                    {
                        throw new Exception("No Scholarship discount with ScholarshipCode " + sBDO.ScholarshipDiscountId);
                    }
                    DCEnt.ScholarshipDiscounts.Remove(sInDB);

                    // sInDB.FeeID= sBDO.FeeID;
                    sInDB.Deactivated           = sBDO.Deactivated;
                    sInDB.Discount              = sBDO.Discount;
                    sInDB.ScholarshipDiscountId = sBDO.ScholarshipDiscountId;

                    DCEnt.ScholarshipDiscounts.Attach(sInDB);
                    DCEnt.Entry(sInDB).State = System.Data.Entity.EntityState.Modified;
                    int num = DCEnt.SaveChanges();

                    if (num != 1)
                    {
                        ret     = false;
                        message = "No scholarship discount is updated.";
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(ret);
        }
Exemple #38
0
        public Boolean UpdateTimeslot(ref TimeslotBDO tBDO, ref string message)
        {
            message = "Timeslot updated successfully.";
            Boolean ret = true;

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    var      timeslotCode = tBDO.TimeSlotCode;
                    Timeslot timeslotInDB = (from t in DCEnt.Timeslots
                                             where t.TimeSlotCode == timeslotCode
                                             select t).FirstOrDefault();
                    if (timeslotInDB == null)
                    {
                        throw new Exception("No timeslot with code " + tBDO.TimeSlotCode);
                    }
                    DCEnt.Timeslots.Remove(timeslotInDB);

                    timeslotInDB.TimeStart = tBDO.TimeStart;
                    timeslotInDB.TimeEnd   = tBDO.TimeEnd;
                    timeslotInDB.Days      = tBDO.Days;
                    timeslotInDB.TotalMins = tBDO.TotalMins;

                    DCEnt.Timeslots.Attach(timeslotInDB);
                    DCEnt.Entry(timeslotInDB).State = System.Data.Entity.EntityState.Modified;
                    int num = DCEnt.SaveChanges();

                    if (num != 1)
                    {
                        ret     = false;
                        message = "No timeslot is updated.";
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(ret);
        }
        public Boolean UpdateStudentSection(String studentSy, int gradeSectionCode)
        {
            try
            {
                using (var DCEnt = new DCFIEntities())
                {
                    var x = (from ss in DCEnt.StudentEnrollments
                             where ss.StudentSY == studentSy
                             select ss).FirstOrDefault();


                    StudentEnrollment s = new StudentEnrollment();
                    s.DiscountId           = x.DiscountId;
                    s.Dismissed            = x.Dismissed;
                    s.GradeLevel           = x.GradeLevel;
                    s.Stat                 = x.Stat;
                    s.StudentEnrollmentsID = x.StudentEnrollmentsID;
                    //s.SY = x.SY;

                    DCEnt.StudentEnrollments.Remove(x);
                    x.StudentId        = studentSy.Substring(0, 8);
                    x.GradeSectionCode = gradeSectionCode;
                    x.SY         = studentSy.Substring(8, 9);
                    x.DiscountId = s.DiscountId;
                    x.GradeLevel = s.GradeLevel;
                    x.Stat       = s.Stat;

                    DCEnt.StudentEnrollments.Attach(x);

                    DCEnt.Entry(x).State = System.Data.Entity.EntityState.Modified;
                    int num = DCEnt.SaveChanges();
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(true);
        }
Exemple #40
0
        public Boolean SaveTraitsGrades(List <StudentTraitBDO> grades)
        {
            Boolean      ret       = true;
            StudentTrait gradeInDB = new StudentTrait();

            try
            {
                using (var DCEnt = new DCFIEntities())
                {
                    foreach (StudentTraitBDO grade in grades)
                    {
                        gradeInDB = (from ss in DCEnt.StudentTraits
                                     where ss.StudentEnrTraitCode == grade.StudentEnrTraitCode
                                     select ss).FirstOrDefault();

                        DCEnt.StudentTraits.Remove(gradeInDB);

                        ConvertStuTraitsBDOToStuTraits(grade, gradeInDB);


                        DCEnt.StudentTraits.Attach(gradeInDB);
                        DCEnt.Entry(gradeInDB).State = System.Data.Entity.EntityState.Modified;
                        int num = DCEnt.SaveChanges();

                        if (num != 1)
                        {
                            ret = false;
                        }
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }

            return(ret);
        }
Exemple #41
0
        public Boolean UpdateSY(ref SchoolYearBDO syBDO, ref string message)
        {
            message = "School Year updated successfully.";
            Boolean ret = true;

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    var        SY     = syBDO.SY;
                    SchoolYear syInDB = (from u in DCEnt.SchoolYears
                                         where u.SY == SY
                                         select u).FirstOrDefault();
                    if (syInDB == null)
                    {
                        throw new Exception(syBDO.SY + " doesn't exist");
                    }
                    DCEnt.SchoolYears.Remove(syInDB);

                    syInDB.SY        = syBDO.SY;
                    syInDB.CurrentSY = syBDO.CurrentSY;

                    DCEnt.SchoolYears.Attach(syInDB);
                    DCEnt.Entry(syInDB).State = System.Data.Entity.EntityState.Modified;
                    int num = DCEnt.SaveChanges();

                    if (num != 1)
                    {
                        ret     = false;
                        message = "No SY is updated.";
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(ret);
        }
Exemple #42
0
        public Boolean UpdateFee(ref FeeBDO fBDO, ref string message)
        {
            message = "Fee updated successfully.";
            Boolean ret = true;

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    var fCode = fBDO.FeeID;
                    Fee fInDB = (from f in DCEnt.Fees
                                 where f.FeeID == fCode
                                 select f).FirstOrDefault();
                    if (fInDB == null)
                    {
                        throw new Exception("No Fee " + fBDO.FeeID);
                    }
                    DCEnt.Fees.Remove(fInDB);
                    ConvertFeeBDOToFee(fBDO, fInDB);


                    DCEnt.Fees.Attach(fInDB);
                    DCEnt.Entry(fInDB).State = System.Data.Entity.EntityState.Modified;
                    int num = DCEnt.SaveChanges();

                    if (num != 1)
                    {
                        ret     = false;
                        message = "No fee is updated.";
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(ret);
        }
Exemple #43
0
        public Boolean GraduateStudent(string studentID, ref string message)
        {
            message = "User Retained successfully.";
            Boolean ret = true;

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    Student studentInDB = (from s in DCEnt.Students
                                           where s.StudentId == studentID
                                           select s).FirstOrDefault();

                    if (studentInDB == null)
                    {
                        throw new Exception("No student with ID " + studentID);
                    }

                    DCEnt.Students.Remove(studentInDB);

                    studentInDB.Graduated = false;

                    DCEnt.Students.Attach(studentInDB);
                    DCEnt.Entry(studentInDB).State = System.Data.Entity.EntityState.Modified;
                    int num = DCEnt.SaveChanges();
                    if (num != 1)
                    {
                        ret     = false;
                        message = "Changing Graduate Status Failed.";
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(ret);
        }
Exemple #44
0
        public Boolean UpdateGradeLevel(ref GradeLevelBDO gBDO, ref string message)
        {
            message = "Grade Level updated successfully.";
            Boolean ret = true;

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    var        gCode = gBDO.GradeLev;
                    GradeLevel gInDB = (from g in DCEnt.GradeLevels
                                        where g.GradeLevel1 == gCode
                                        select g).FirstOrDefault();
                    if (gInDB == null)
                    {
                        throw new Exception("No Grade Level " + gBDO.GradeLev);
                    }
                    DCEnt.GradeLevels.Remove(gInDB);
                    gInDB.GradeLevel1 = gBDO.GradeLev;
                    gInDB.Description = gBDO.Description;

                    DCEnt.GradeLevels.Attach(gInDB);
                    DCEnt.Entry(gInDB).State = System.Data.Entity.EntityState.Modified;
                    int num = DCEnt.SaveChanges();

                    if (num != 1)
                    {
                        ret     = false;
                        message = "No grade level is updated.";
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(ret);
        }
Exemple #45
0
        public Boolean ActivateUser(int userId, ref string message)
        {
            message = "User Activated successfully.";
            Boolean ret = true;

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    User userInDB = (from u in DCEnt.Users
                                     where u.UserId == userId
                                     select u).FirstOrDefault();

                    if (userInDB == null)
                    {
                        throw new Exception("No user with ID " + userId);
                    }

                    DCEnt.Users.Remove(userInDB);

                    userInDB.Deactivated = false;

                    DCEnt.Users.Attach(userInDB);
                    DCEnt.Entry(userInDB).State = System.Data.Entity.EntityState.Modified;
                    int num = DCEnt.SaveChanges();
                    if (num != 1)
                    {
                        ret     = false;
                        message = "Activation Failed.";
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(ret);
        }
Exemple #46
0
        public Boolean ActivateUser(int userId, ref string message)
        {
            message = "User Activated successfully.";
            Boolean ret = true;
            try {
            using (var DCEnt = new DCFIEntities())
            {
                User userInDB = (from u in DCEnt.Users
                                 where u.UserId == userId
                                 select u).FirstOrDefault();

                if (userInDB == null)
                {
                    throw new Exception("No user with ID " + userId);
                }

                DCEnt.Users.Remove(userInDB);

                userInDB.Deactivated = false;

                DCEnt.Users.Attach(userInDB);
                DCEnt.Entry(userInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();
                if (num != 1)
                {
                    ret = false;
                    message = "Activation Failed.";
                }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
                }
            }
            return ret;
        }
Exemple #47
0
        public Boolean ActivateTimeslot(string timeslotCode, ref string message)
        {
            message = "Timeslot Activated successfully.";
            Boolean ret = true;
            try {
            using (var DCEnt = new DCFIEntities())
            {
                Timeslot tInDB = (from t in DCEnt.Timeslots
                                 where t.TimeSlotCode == timeslotCode
                                 select t).FirstOrDefault();

                if (tInDB == null)
                {
                    throw new Exception("No timeslot with code " + tInDB);
                }

                DCEnt.Timeslots.Remove(tInDB);

                tInDB.Deactivated = false;

                DCEnt.Timeslots.Attach(tInDB);
                DCEnt.Entry(tInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();
                if (num != 1)
                {
                    ret = false;
                    message = "Activation Failed.";
                }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
                }
            }
            return ret;
        }
Exemple #48
0
        public Boolean CreateCurriculum(ref CurriculumBDO cbdo, ref string message)
        {
            message = "Curriculum Added Successfully";
            bool ret = true;
            Curriculum cur = new Curriculum();
            ConvertCurriculumBDOToCurriculum(cbdo, cur);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Curriculums.Add(cur);
                DCEnt.Entry(cur).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num == 0)
                {
                    ret = false;
                    message = "Adding of Curriculum failed";
                }
            }
            return ret;
        }
Exemple #49
0
        public Boolean CreateLearningArea(ref LearningAreaBDO laBDO, ref string message)
        {
            message = "Learning Area Added Successfully";
            bool ret = true;

            LearningArea la = new LearningArea();
            ConvertLearningAreaBDOToLearningArea(laBDO, la);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.LearningAreas.Add(la);
                DCEnt.Entry(la).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num == 0)
                {
                    ret = false;
                    message = "Adding of Learning Area failed";
                }
            }
            return ret;
        }
Exemple #50
0
        public Boolean CreateGradeLevel(ref GradeLevelBDO gBDO, ref string message)
        {
            message = "Grade Level Added Successfully";
            bool ret = true;

            GradeLevel g = new GradeLevel();
            ConvertGradeLevelBDOToGradeLevel(gBDO, g);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.GradeLevels.Attach(g);
                DCEnt.Entry(g).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Grade Level failed";
                }
            }
            return ret;
        }
Exemple #51
0
        public Boolean CreateTrait(ref TraitBDO tBDO, ref string message)
        {
            message = "Trait Added Successfully";
            bool ret = true;

            Trait t = new Trait();
            ConvertTraitBDOToTrait(tBDO, t);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Traits.Attach(t);
                DCEnt.Entry(t).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Trait failed";
                }
            }
            return ret;
        }
Exemple #52
0
        public Boolean CreateFee(ref FeeBDO fBDO, ref string message)
        {
            message = "Fee Added Successfully";
            bool ret = true;

            Fee f = new Fee();
            ConvertFeeBDOToFee(fBDO, f);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Fees.Attach(f);
                DCEnt.Entry(f).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Fee failed";
                }
            }
            return ret;
        }
Exemple #53
0
        public Boolean CreateRoom(ref RoomBDO roomBDO, ref string message)
        {
            message = "Room Added Successfully";
            bool ret = true;

            Room room = new Room();
            ConvertRoomBDOToRoom(roomBDO, room);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Rooms.Attach(room);
                DCEnt.Entry(room).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Room failed";
                }

                return ret;
            }
        }
Exemple #54
0
        public Boolean CreateSY(ref SchoolYearBDO syBDO, ref string message)
        {
            message = "School Year Added Successfully";
            bool ret = true;

            SchoolYear u = new SchoolYear()
            {
                SY = syBDO.SY,
                CurrentSY = syBDO.CurrentSY
            };
            try {
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.SchoolYears.Attach(u);
                DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();
                syBDO.SY = u.SY;

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of School Year failed";
                }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
            }
            }
            return ret;
        }
        public Boolean CreateScholarship(ref ScholarshipBDO sBDO, ref string message)
        {
            message = "Scholarship Added Successfully";
            bool ret = true;

            Scholarship s = new Scholarship();
            ConvertScholarshipBDOToScholarship(sBDO, s);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Scholarships.Add(s);
                DCEnt.Entry(s).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();
                sBDO.ScholarshipCode = s.ScholarshipCode;

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Scholarship failed";
                }
            }
            return ret;
        }
Exemple #56
0
        public Boolean CreateBuilding(ref BuildingBDO buildBDO, ref string message)
        {
            message = "Building Added Successfully";
            bool ret = true;

            Building b = new Building();
            ConvertBuildingBDOToBuilding(buildBDO,b);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Buildings.Add(b);
                DCEnt.Entry(b).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();
                buildBDO.BuildingCode = b.BuildingCode;

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Building failed";
                }
            }
            return ret;
        }
Exemple #57
0
        public Boolean CreateSubject(ref SubjectBDO subjectBDO, ref string message)
        {
            message = "Subject Added Successfully";
            bool ret = true;

            Subject s = new Subject();
            ConvertSubjectBDOToSubject(subjectBDO, s);

            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Subjects.Attach(s);
                DCEnt.Entry(s).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Subject failed";
                }
            }
            return ret;
        }
        public Boolean AddScholarshipDiscount(ScholarshipDiscountBDO discount, string scholarshipCode, ref string message)
        {
            message = "Scholarship Discount Added Successfully";
            Boolean ret = true;

            ScholarshipDiscount sd = new ScholarshipDiscount();
            ConvertScholarshipDiscountBDOToScholarshipDiscount(discount, sd, scholarshipCode);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.ScholarshipDiscounts.Attach(sd);
                DCEnt.Entry(sd).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Scholarship Discount failed";
                }

                return ret;
            }
        }
Exemple #59
0
        public Boolean UpdateFee(ref FeeBDO fBDO, ref string message)
        {
            message = "Fee updated successfully.";
            Boolean ret = true;
            using (var DCEnt = new DCFIEntities())
            {
                var fCode = fBDO.FeeCode;
                Fee fInDB = (from f in DCEnt.Fees
                                    where f.FeeCode == fCode
                                    select f).FirstOrDefault();
                if (fInDB == null)
                {
                    throw new Exception("No Fee " + fBDO.FeeCode);
                }
                DCEnt.Fees.Remove(fInDB);
                fInDB.Deactivated = fBDO.Deactivated;
                fInDB.FeeCode = fBDO.FeeCode;
                fInDB.FeeDescription = fBDO.FeeDescription;
                fInDB.Unit = fBDO.Unit;
                fInDB.Amount = fBDO.Amount;
                fInDB.DateSet = fBDO.DateSet;
                fInDB.GradeLevel = fBDO.GradeLevel;
                fInDB.SYImplemented = fBDO.SYImplemented;

                DCEnt.Fees.Attach(fInDB);
                DCEnt.Entry(fInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "No fee is updated.";
                }
            }
            return ret;

        }
        public Boolean UpdateGradeSection(ref GradeSectionBDO gsBDO, ref string message)
        {
            message = "Grade Section updated successfully.";
            Boolean ret = true;
            using (var DCEnt = new DCFIEntities())
            {
                var gsCode = gsBDO.GradeSectionCode;
                   GradeSection gsInDB = (from gs in DCEnt.GradeSections
                                      where gs.GradeSectionCode== gsCode
                                      select gs).FirstOrDefault();
                if (gsInDB == null)
                {
                    throw new Exception("No Grade Section with Grade Section Code " + gsBDO.GradeSectionCode);
                }
                DCEnt.GradeSections.Remove(gsInDB);

                gsInDB.Deactivated = gsBDO.Deactivated;
                gsInDB.GradeLevel = gsBDO.GradeLevel;
                gsInDB.GradeSectionCode = gsBDO.GradeSectionCode;
                gsInDB.HomeRoomNumber = gsBDO.HomeRoomNumber;
                gsInDB.HomeRoomTeacherId = gsBDO.HomeRoomTeacherId;
                gsInDB.Section = gsBDO.Section;
                gsInDB.SY = gsBDO.SY;

                DCEnt.GradeSections.Attach(gsInDB);
                DCEnt.Entry(gsInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "No grade section is updated.";
                }
            }
            return ret;

        }