Exemplo n.º 1
0
        public SubjectAssignmentBDO GetScheduleInfo(int sAi)
        {
            SchoolYearDAO syd = new SchoolYearDAO();

            currentSY = syd.CurrentSY();
            SubjectAssignment    schedInfo = new SubjectAssignment();
            SubjectAssignmentBDO saBDO     = new SubjectAssignmentBDO();

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    schedInfo = (from sched in DCEnt.SubjectAssignments
                                 where sched.Deactivated == false && sched.SY.Equals(currentSY) && sched.SubjectAssignmentsID == sAi
                                 select sched).FirstOrDefault <SubjectAssignment>();

                    ConvertSubjectAssignmentToSubjectAssignmentBDO(schedInfo, saBDO);
                }
            }
            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(saBDO);
        }
Exemplo n.º 2
0
        public void ConvertSubjectAssignmentToSubjectAssignmentBDO(SubjectAssignment sa, SubjectAssignmentBDO sabdo)
        {
            sabdo.Deactivated = (bool)sa.Deactivated;
            GradeSectionDAO gd = new GradeSectionDAO();
            GradeSectionBDO g = new GradeSectionBDO();
            g = gd.GetGradeSectionBDO((int)sa.GradeSectionCode);
            sabdo.GradeSection = g;
            sabdo.GradeSectionCode = g.GradeSectionCode;
            RoomBDO r = new RoomBDO();
            RoomDAO rd = new RoomDAO();
            rd.ConvertRoomToRoomBDO(sa.Room, r);
            sabdo.Room = r;
            sabdo.RoomId = r.RoomId;
            SubjectDAO sd = new SubjectDAO();
            SubjectBDO sb = new SubjectBDO();
            sd.ConvertSubjectToSubjectBDO(sa.Subject, sb);
            sabdo.Subject = sb;
            sabdo.SubjectAssignmentsID = sa.SubjectAssignmentsID;
            sabdo.SubjectCode = sa.SubjectCode;
            sabdo.SY = sa.SY;
            TeacherDAO td = new TeacherDAO();
            TeacherBDO tb = new TeacherBDO();
            td.ConvertTeacherToTeacherBDO(sa.Teacher, tb);
            sabdo.Teacher = tb;
            sabdo.TeacherId = tb.TeacherId;
            TimeslotDAO tid = new TimeslotDAO();
            TimeslotBDO tib = new TimeslotBDO();
            tid.ConvertTimeslotToTimeslotBDO(sa.Timeslot, tib);
            sabdo.Timeslot = tib;
            sabdo.TimeSlotCode = tib.TimeSlotCode;

            sabdo.GradeLevel = g.GradeLevel;
        }
Exemplo n.º 3
0
 public void ConvertSubjectAssignmentBDOToSubjectAssignment(SubjectAssignmentBDO sa, SubjectAssignment sabdo)
 {
     sabdo.Deactivated = (bool)sa.Deactivated;
     sabdo.GradeSectionCode = sa.GradeSectionCode;
     sabdo.RoomId = sa.RoomId;
     sabdo.SubjectAssignmentsID = sa.SubjectAssignmentsID;
     sabdo.SubjectCode = sa.SubjectCode;
     sabdo.SY = sa.SY;
     sabdo.TeacherId = sa.TeacherId;
     sabdo.TimeSlotCode = sa.TimeSlotCode;
 }
Exemplo n.º 4
0
        public Boolean UpdateSchedule(ref SubjectAssignmentBDO schedBDO, ref string message)
        {
            message = "Schedule updated successfully.";
            Boolean ret = true;

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    var schedID = schedBDO.SubjectAssignmentsID;
                    SubjectAssignment schedInDB = (from s in DCEnt.SubjectAssignments
                                                   where s.SubjectAssignmentsID == schedID
                                                   select s).FirstOrDefault();
                    if (schedInDB == null)
                    {
                        throw new Exception("No schedule with ID " + schedBDO.SubjectAssignmentsID);
                    }
                    DCEnt.SubjectAssignments.Remove(schedInDB);
                    ConvertSubjectAssignmentBDOToSubjectAssignment(schedBDO, schedInDB);

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

                    if (num == 0)
                    {
                        ret     = false;
                        message = "No schedules 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);
        }
Exemplo n.º 5
0
        public Boolean DeleteSchedule(int schedID, ref string message)
        {
            message = "Schedule Deleted successfully.";
            Boolean ret = true;

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    SubjectAssignment schedInDB = (from s in DCEnt.SubjectAssignments
                                                   where s.SubjectAssignmentsID == schedID
                                                   select s).FirstOrDefault();

                    if (schedInDB == null)
                    {
                        throw new Exception("No sched with ID " + schedID);
                    }

                    DCEnt.SubjectAssignments.Remove(schedInDB);
                    DCEnt.Entry(schedInDB).State = System.Data.Entity.EntityState.Deleted;
                    int num = DCEnt.SaveChanges();
                    if (num != 1)
                    {
                        ret     = false;
                        message = "Deletion 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);
        }
Exemplo n.º 6
0
        public void ConvertSubjectAssignmentToSubjectAssignmentBDO(SubjectAssignment sa, SubjectAssignmentBDO sabdo)
        {
            sabdo.Deactivated = (bool)sa.Deactivated;
            GradeSectionDAO gd = new GradeSectionDAO();
            GradeSectionBDO g  = new GradeSectionBDO();

            g = gd.GetGradeSectionBDO((int)sa.GradeSectionCode);
            sabdo.GradeSection     = g;
            sabdo.GradeSectionCode = g.GradeSectionCode;
            RoomBDO r  = new RoomBDO();
            RoomDAO rd = new RoomDAO();

            rd.ConvertRoomToRoomBDO(sa.Room, r);
            sabdo.Room   = r;
            sabdo.RoomId = r.RoomId;
            SubjectDAO sd = new SubjectDAO();
            SubjectBDO sb = new SubjectBDO();

            sd.ConvertSubjectToSubjectBDO(sa.Subject, sb);
            sabdo.Subject = sb;
            sabdo.SubjectAssignmentsID = sa.SubjectAssignmentsID;
            sabdo.SubjectCode          = sa.SubjectCode;
            sabdo.SY = sa.SY;
            TeacherDAO td = new TeacherDAO();
            TeacherBDO tb = new TeacherBDO();

            td.ConvertTeacherToTeacherBDO(sa.Teacher, tb);
            sabdo.Teacher   = tb;
            sabdo.TeacherId = tb.TeacherId;
            TimeslotDAO tid = new TimeslotDAO();
            TimeslotBDO tib = new TimeslotBDO();

            tid.ConvertTimeslotToTimeslotBDO(sa.Timeslot, tib);
            sabdo.Timeslot     = tib;
            sabdo.TimeSlotCode = tib.TimeSlotCode;

            sabdo.GradeLevel = g.GradeLevel;
        }
Exemplo n.º 7
0
        public Boolean CreateSchedule(ref SubjectAssignmentBDO sched, ref string message)
        {
            message = "Schedule Added Successfully";
            bool ret = true;

            SubjectAssignment sa = new SubjectAssignment();

            try {
                ConvertSubjectAssignmentBDOToSubjectAssignment(sched, sa);
                using (var DCEnt = new DCFIEntities())
                {
                    DCEnt.SubjectAssignments.Add(sa);
                    DCEnt.Entry(sa).State = System.Data.Entity.EntityState.Added;
                    int num = DCEnt.SaveChanges();
                    sched.SubjectAssignmentsID = sa.SubjectAssignmentsID;

                    if (num == 0)
                    {
                        ret     = false;
                        message = "Adding of Schedule 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);
        }
Exemplo n.º 8
0
        public Boolean CreateSchedule(ref SubjectAssignmentBDO sched, ref string message)
        {
            message = "Schedule Added Successfully";
            bool ret = true;

            SubjectAssignment sa = new SubjectAssignment();
            try {
            ConvertSubjectAssignmentBDOToSubjectAssignment(sched, sa);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.SubjectAssignments.Add(sa);
                DCEnt.Entry(sa).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();
                sched.SubjectAssignmentsID = sa.SubjectAssignmentsID;

                if (num == 0)
                {
                    ret = false;
                    message = "Adding of Schedule 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;
        }
Exemplo n.º 9
0
 public SubjectAssignmentBDO GetScheduleInfo(int sAi)
 {
     SchoolYearDAO syd = new SchoolYearDAO();
     currentSY = syd.CurrentSY();
     SubjectAssignment schedInfo = new SubjectAssignment();
     SubjectAssignmentBDO saBDO = new SubjectAssignmentBDO();
     try { 
     using (var DCEnt = new DCFIEntities())
     {
         schedInfo = (from sched in DCEnt.SubjectAssignments
                      where sched.Deactivated == false && sched.SY.Equals(currentSY) && sched.SubjectAssignmentsID == sAi
                      select sched).FirstOrDefault<SubjectAssignment>();
             
         ConvertSubjectAssignmentToSubjectAssignmentBDO(schedInfo, saBDO);
     }
     }
     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 saBDO;
 }
Exemplo n.º 10
0
 public void ConvertSubjectAssignmentBDOToSubjectAssignment(SubjectAssignmentBDO sa, SubjectAssignment sabdo)
 {
     sabdo.Deactivated          = (bool)sa.Deactivated;
     sabdo.GradeSectionCode     = sa.GradeSectionCode;
     sabdo.RoomId               = sa.RoomId;
     sabdo.SubjectAssignmentsID = sa.SubjectAssignmentsID;
     sabdo.SubjectCode          = sa.SubjectCode;
     sabdo.SY           = sa.SY;
     sabdo.TeacherId    = sa.TeacherId;
     sabdo.TimeSlotCode = sa.TimeSlotCode;
 }