Beispiel #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;
        }
Beispiel #2
0
        public GradeSectionBDO GetGradeSectionBDO(int gradesectioncode)
        {
            GradeSection    gsec  = new GradeSection();
            GradeSectionBDO gsBDO = new GradeSectionBDO();

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    gsec = (from gs in DCEnt.GradeSections
                            where gs.GradeSectionCode == gradesectioncode
                            select gs).FirstOrDefault <GradeSection>();

                    ConvertGradeSectionToGradeSectionBDO(gsec, gsBDO);
                }
            }
            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(gsBDO);
        }
Beispiel #3
0
        public void ConvertGradeSectionToGradeSectionBDO(GradeSection gs, GradeSectionBDO gsBDO)
        {
            RoomDAO r = new RoomDAO();
            RoomBDO room = new RoomBDO();
            TeacherDAO t = new TeacherDAO();
            TeacherBDO teach = new TeacherBDO();
            SchoolYearDAO s = new SchoolYearDAO();
            SchoolYearBDO sy = new SchoolYearBDO();

            s.ConvertSYToSYBDO(gs.SchoolYear, sy);
            t.ConvertTeacherToTeacherBDO(gs.Teacher, teach);
            r.ConvertRoomToRoomBDO(gs.Room, room);

            gsBDO.Deactivated = gs.Deactivated;
            gsBDO.GradeLevel = gs.GradeLevel;
            gsBDO.GradeSectionCode = gs.GradeSectionCode;
            gsBDO.HomeRoomNumber = (int)gs.HomeRoomNumber;
            gsBDO.HomeRoomTeacherId = gs.HomeRoomTeacherId;
            gsBDO.Section = gs.Section;
            gsBDO.SY = gs.SY;
            gsBDO.Class = gs.Class;

            gsBDO.HomeRoom = room;
            gsBDO.HomeRoomTeacher = teach;
            gsBDO.SchoolYear = sy;
        }
Beispiel #4
0
        public GradeSectionBDO GetGradeSectionBDO(int gradesectioncode)
        {
            GradeSection gsec = new GradeSection();
            GradeSectionBDO gsBDO = new GradeSectionBDO();
            try { 
            using (var DCEnt = new DCFIEntities())
            {
                gsec = (from gs in DCEnt.GradeSections
                                        where gs.GradeSectionCode == gradesectioncode
                                        select gs).FirstOrDefault<GradeSection>();

                 ConvertGradeSectionToGradeSectionBDO(gsec, gsBDO);
             }
            }
            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 gsBDO;
        }
Beispiel #5
0
        public void ConvertGradeSectionToGradeSectionBDO(GradeSection gs, GradeSectionBDO gsBDO)
        {
            RoomDAO       r     = new RoomDAO();
            RoomBDO       room  = new RoomBDO();
            TeacherDAO    t     = new TeacherDAO();
            TeacherBDO    teach = new TeacherBDO();
            SchoolYearDAO s     = new SchoolYearDAO();
            SchoolYearBDO sy    = new SchoolYearBDO();

            s.ConvertSYToSYBDO(gs.SchoolYear, sy);
            t.ConvertTeacherToTeacherBDO(gs.Teacher, teach);
            r.ConvertRoomToRoomBDO(gs.Room, room);

            gsBDO.Deactivated       = gs.Deactivated;
            gsBDO.GradeLevel        = gs.GradeLevel;
            gsBDO.GradeSectionCode  = gs.GradeSectionCode;
            gsBDO.HomeRoomNumber    = (int)gs.HomeRoomNumber;
            gsBDO.HomeRoomTeacherId = gs.HomeRoomTeacherId;
            gsBDO.Section           = gs.Section;
            gsBDO.SY    = gs.SY;
            gsBDO.Class = gs.Class;

            gsBDO.HomeRoom        = room;
            gsBDO.HomeRoomTeacher = teach;
            gsBDO.SchoolYear      = sy;
        }
Beispiel #6
0
 private void ConvertGradeSectionToGradeSectionBDO(GradeSection gs, GradeSectionBDO gsBDO)
 {
     gsBDO.Deactivated       = gs.Deactivated;
     gsBDO.GradeLevel        = gs.GradeLevel;
     gsBDO.GradeSectionCode  = gs.GradeSectionCode;
     gsBDO.HomeRoomNumber    = gs.HomeRoomNumber;
     gsBDO.HomeRoomTeacherId = gs.HomeRoomTeacherId;
     gsBDO.Section           = gs.Section;
     gsBDO.SY = gs.SY;
 }
Beispiel #7
0
 public void ConvertGradeSectionBDOToGradeSection(GradeSectionBDO gsBDO, GradeSection gs)
 {
     gs.Deactivated = gsBDO.Deactivated;
     gs.GradeLevel = gsBDO.GradeLevel;
     gs.GradeSectionCode = gsBDO.GradeSectionCode;
     gs.HomeRoomNumber = gsBDO.HomeRoomNumber;
     gs.HomeRoomTeacherId = gsBDO.HomeRoomTeacherId;
     gs.Section = gsBDO.Section;
     gs.SY = gsBDO.SY;
     gs.Class = gsBDO.Class;
 }
Beispiel #8
0
 public void ConvertGradeSectionBDOToGradeSection(GradeSectionBDO gsBDO, GradeSection gs)
 {
     gs.Deactivated       = gsBDO.Deactivated;
     gs.GradeLevel        = gsBDO.GradeLevel;
     gs.GradeSectionCode  = gsBDO.GradeSectionCode;
     gs.HomeRoomNumber    = gsBDO.HomeRoomNumber;
     gs.HomeRoomTeacherId = gsBDO.HomeRoomTeacherId;
     gs.Section           = gsBDO.Section;
     gs.SY    = gsBDO.SY;
     gs.Class = gsBDO.Class;
 }
Beispiel #9
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);
        }
Beispiel #10
0
        public Boolean CreateGradeSection(ref GradeSectionBDO gsBDO, ref string message)
        {
            message = "Grade Section Added Successfully";
            bool ret = true;

            GradeSection gs = new GradeSection();
            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";
                }
            }
            return ret;
        }
Beispiel #11
0
        public Boolean CreateGradeSection(ref GradeSectionBDO gsBDO, ref string message)
        {
            message = "Grade Section Added Successfully";
            bool ret = true;

            GradeSection gs = new GradeSection();

            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";
                }
            }
            return(ret);
        }
Beispiel #12
0
        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);
        }
Beispiel #13
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);
        }
Beispiel #14
0
 private void ConvertGradeSectionToGradeSectionBDO(GradeSection gs, GradeSectionBDO gsBDO)
 {
     gsBDO.Deactivated = gs.Deactivated;
     gsBDO.GradeLevel = gs.GradeLevel;
     gsBDO.GradeSectionCode = gs.GradeSectionCode;
     gsBDO.HomeRoomNumber = gs.HomeRoomNumber;
     gsBDO.HomeRoomTeacherId = gs.HomeRoomTeacherId;
     gsBDO.Section = gs.Section;
     gsBDO.SY = gs.SY;
 }