Ejemplo n.º 1
0
 public Boolean UpdateTimeslot(ref Timeslot timeslot, ref string message)
 {
     message = String.Empty;
     TimeslotBDO tBDO = new TimeslotBDO();
     TranslateTimeslotDTOToTimeslotBDo(timeslot, tBDO);
     return timeslotLogic.UpdateTimeslot(ref tBDO, ref message);
 }
Ejemplo n.º 2
0
 public Boolean CreateTimeslot(ref Timeslot timeslot, ref string message)
 {
     message = String.Empty;
     TimeslotBDO tbdo = new TimeslotBDO();
     TranslateTimeslotDTOToTimeslotBDo(timeslot, tbdo);
     return timeslotLogic.CreateTimeslot(ref tbdo, ref message);
 }
Ejemplo n.º 3
0
 public void TranslateTimeslotDTOToTimeslotBDo(Timeslot timeslot, TimeslotBDO tBDO)
 {
     tBDO.TimeSlotCode = timeslot.TimeSlotCode;
     tBDO.TimeStart = timeslot.TimeStart;
     tBDO.TimeEnd = timeslot.TimeEnd;
     tBDO.Days = timeslot.Days;
     tBDO.TotalMins = timeslot.TotalMins;
 }
Ejemplo n.º 4
0
 public void TranslateTimeslotBDOToTimeslotDTo(TimeslotBDO tBDO, Timeslot timeslot)
 {
     timeslot.TimeSlotCode = tBDO.TimeSlotCode;
     timeslot.TimeStart = tBDO.TimeStart;
     timeslot.TimeEnd = tBDO.TimeEnd;
     timeslot.Days = tBDO.Days;
     timeslot.TotalMins = tBDO.TotalMins;
     timeslot.TimeSlotInfo = tBDO.Days + " " + tBDO.TimeStart + "-" + tBDO.TimeEnd;
 }
Ejemplo n.º 5
0
        public Timeslot GetTimeslot(string timeslotCode)
        {
            TimeslotBDO tbdo = new TimeslotBDO();
            tbdo = timeslotLogic.GetTimeslot(timeslotCode);
            Timeslot t = new Timeslot();
            TranslateTimeslotBDOToTimeslotDTo(tbdo, t);

            return t;
        }
Ejemplo n.º 6
0
 public List<Timeslot> GetAllTimeslots()
 {
     List<TimeslotBDO> tBDOList = timeslotLogic.GetAllTimeslots();
     List<Timeslot> allTimeslot = new List<Timeslot>();
     foreach (TimeslotBDO tBDO in tBDOList)
     {
         Timeslot t = new Timeslot();
         TranslateTimeslotBDOToTimeslotDTo(tBDO, t);
         allTimeslot.Add(t);
     }
     return allTimeslot;
 }
Ejemplo n.º 7
0
        private void gvTimeSlot_SelectionChanged(object sender, EventArgs e)
        {
            int selectedIndex = gvTimeSlot.CurrentRow.Index;


            if (selectedIndex >= 0)
            {
                string tCode = gvTimeSlot.Rows[selectedIndex].Cells["TimeslotCode"].Value.ToString();
                List<Timeslot> item = new List<Timeslot>();
                item = timeslotList.FindAll(x => x.TimeSlotCode.ToString() == tCode);

                timeslotSelected = new Timeslot();
                timeslotSelected = (Timeslot)item[0];

            }
        }
Ejemplo n.º 8
0
        private void SetTimeSlotCombo() {
           
            //Get timeslot that are already assigned
            List<Timeslot> usedtslot = new List<Timeslot>();
            foreach (SubjectAssignment sch in schedules)
            {
                if (sch.GradeLevel == gradelevel && sch.GradeSectionCode == int.Parse(cmbSection.SelectedValue.ToString()))
                {
                    Timeslot ts = new Timeslot();
                    ts.TimeSlotCode = sch.TimeSlotCode;
                    ts.TimeSlotInfo = sch.TimeslotInfo;
                    ts.TimeStart = sch.Timestart;
                    ts.TimeEnd = sch.TimeEnd;
                    ts.Days = sch.Days;
                    usedtslot.Add(ts);
                }
            }

            //get the list of all timeslots
            availTimeSlot = new List<Timeslot>(timeslots); //timeslots;

            //Remove timeslots that are already been used
            if (usedtslot.Count > 0)
            {
                foreach (Timeslot t in usedtslot) { 
                  string times = t.TimeSlotCode;
                 availTimeSlot.RemoveAll(a => a.TimeSlotCode == times);
                }
            }


            //Remove timeslots that are conflicting to other schedules
            #region ConflictTimeslotsFilter
            List<Timeslot> compareTimeSlot = new List<Timeslot>();
            List<String> tCodelist;

            foreach (Timeslot t in usedtslot)
            {
                string[] dayArray = t.Days.Split(',');
                int t_TimeStart = timeStringToInt(t.TimeStart);
                int t_TimeEnd = timeStringToInt(t.TimeEnd);
                compareTimeSlot = availTimeSlot;
                tCodelist = new List<String>();

                foreach (Timeslot ct in compareTimeSlot)
                {
                    foreach (string sDay in dayArray)
                    {
                        if (ct.Days.Contains(sDay))
                        {
                            int ct_TimeStart = timeStringToInt(ct.TimeStart);
                            int ct_TimeEnd = timeStringToInt(ct.TimeEnd);
                    

                            if ((ct_TimeStart <= t_TimeStart && ct_TimeEnd <= t_TimeEnd && ct_TimeEnd > t_TimeStart) ||
                                    (ct_TimeStart >= t_TimeStart && ct_TimeEnd <= t_TimeEnd) ||
                                    (ct_TimeStart >= t_TimeStart && ct_TimeStart < t_TimeEnd && ct_TimeEnd > t_TimeEnd))
                            {
                                tCodelist.Add(ct.TimeSlotCode);
                            }
                        }
                    }
                   
                }

                //Remove conflicted schedules against the used schedules
                foreach (string code in tCodelist)
                {
                    availTimeSlot.RemoveAll(x => x.TimeSlotCode == code);
                    compareTimeSlot = null;
                }
            }

            #endregion


            //assign new list of Timeslot on the dropdown box
            if (availTimeSlot.Count > 0)
            {
                cmbTimeslot.Enabled = true;
                cmbTimeslot.ValueMember = "TimeslotCode";
                cmbTimeslot.DisplayMember = "TimeslotInfo";
                cmbTimeslot.DataSource = availTimeSlot;
                cmbTimeslot.SelectedIndex = 0;
            }
        }
Ejemplo n.º 9
0
        private void btnAddSchedule_Click(object sender, EventArgs e)
        {
            if (cmbGradeLevel.Text != string.Empty && cmbSection.Text != string.Empty && cmbTimeslot.Text != string.Empty && 
                cmbSubject.Text != string.Empty && cmbTeacher.Text != string.Empty && cmbRoom.Text != string.Empty)
            {
                Timeslot t = new Timeslot();
                t = timeslots.Find(x => x.TimeSlotCode == cmbTimeslot.SelectedValue.ToString());

                GradeSection gs = new GradeSection();
                gs = sections.Find(x => x.GradeSectionCode == sectioncode);

                Subject su = new Subject();
                su = subjects.Find(x => x.SubjectCode == cmbSubject.SelectedValue.ToString());

                Room rm = new Room();
                rm = rooms.Find(x => x.RoomId == Int32.Parse(cmbRoom.SelectedValue.ToString()));

                Teacher tc = new Teacher();
                tc = teachers.Find(x => x.TeacherId == cmbTeacher.SelectedValue.ToString());

                SubjectAssignment sa = new SubjectAssignment();
                sa.GradeLevel = cmbGradeLevel.SelectedValue.ToString() ;
                sa.TeacherName = cmbTeacher.Text;
                sa.SY = currentSY;
                sa.Subject = su;
                sa.SubjectCode = su.SubjectCode;
                sa.SubjectDescription = su.Description;
                sa.TimeslotInfo = t.TimeSlotInfo;
                sa.TimeSlotCode = t.TimeSlotCode;
                sa.Room = rm;
                sa.RoomId = rm.RoomId;
                sa.RoomCode = rm.RoomCode;
                sa.Teacher = tc;
                sa.TeacherId = tc.TeacherId;
                sa.Section = section;
                sa.GradeSection = gs;
                sa.GradeSectionCode = gs.GradeSectionCode;
                sa.Timeslot = t;
                sa.Timestart = t.TimeStart;
                sa.TimeEnd = t.TimeEnd;
                sa.Days = t.Days;
                sa.Deactivated = false;
                createdSchedule.Add(sa);
                schedules.Add(sa);

                
                cmbTimeslot.DataSource = null;
                availTimeSlot.RemoveAll(x => x.TimeSlotCode == t.TimeSlotCode);
                if (availTimeSlot.Count > 0)
                {
                    cmbTimeslot.DataSource = availTimeSlot;
                    cmbTimeslot.SelectedIndex = 0;
                    cmbTimeslot.Refresh();
                }
                else
                    cmbTimeslot.Enabled = false;

                gvSchedule.DataSource = null;
                gvSchedule.DataSource = schedules.FindAll(x => x.GradeSectionCode == sectioncode);
                gvSchedule.Refresh();

                // LoadSchedules();


            }
        }
Ejemplo n.º 10
0
        private void loadAvailableTeachers()
        {
            List<SubjectAssignment> roomSchedule = new List<SubjectAssignment>(schedules.FindAll(s => s.SY == GlobalClass.currentsy));
            Timeslot selectedTimeslot = new Timeslot();
            string szVal = string.Empty;
            szVal = cmbTimeslot.SelectedValue.ToString();
            selectedTimeslot = timeslots.Find(x => x.TimeSlotCode == szVal);

            string[] dayArray = selectedTimeslot.Days.Split(',');

            int selected_TimeStart = timeStringToInt(selectedTimeslot.TimeStart);
            int selected_TimeEnd = timeStringToInt(selectedTimeslot.TimeEnd);

          
            availTeach = new List<Teacher>(teachers);

            foreach (Teacher tc in teachers)
            {
                foreach (SubjectAssignment rS in roomSchedule)
                {
                    if (rS.TeacherId == tc.TeacherId)
                    {
                        foreach (string sDay in dayArray)
                        {
                            if (rS.Days.Contains(sDay))
                            {
                                int compared_TimeStart = timeStringToInt(rS.Timestart);
                                int compared_TimeEnd = timeStringToInt(rS.TimeEnd);

                                if ((compared_TimeStart <= selected_TimeStart && compared_TimeEnd <= selected_TimeEnd && compared_TimeEnd > selected_TimeStart) ||
                                            (compared_TimeStart >= selected_TimeStart && compared_TimeEnd <= selected_TimeEnd) ||
                                            (compared_TimeStart >= selected_TimeStart && compared_TimeStart < selected_TimeEnd && compared_TimeEnd > selected_TimeEnd))
                                {
                                    availTeach.RemoveAll(x => x.TeacherId == rS.TeacherId);
                                }
                            }
                        }
                    }
                }
            }
     
          

            if (availTeach.Count > 0)
            {
                cmbTeacher.Enabled = true;
                cmbTeacher.ValueMember = "TeacherId";
                cmbTeacher.DisplayMember = "TeacherName";

                if (academicSubject == true)
                {
                    academicTeachers = new List<Teacher>(teachers.FindAll(x => x.Academic == true));
                    cmbTeacher.DataSource = availTeach;
                }
                else
                {
                    cmbTeacher.DataSource = availTeach;
                }
                //cmbTeacher.DataSource = availTeach;
            }

        }
Ejemplo n.º 11
0
        private void loadAvailableRooms()
        {
            List<SubjectAssignment> roomSchedule = new List<SubjectAssignment>(schedules.FindAll(s => s.SY == GlobalClass.currentsy));
            Timeslot selectedTimeslot = new Timeslot();
            string szVal = string.Empty;
            cmbTimeslot.ValueMember = "TimeSlotCode";
            cmbTimeslot.DisplayMember = "TimeSlotInfo";
            szVal = cmbTimeslot.SelectedValue.ToString();
            selectedTimeslot = timeslots.Find(x => x.TimeSlotCode == szVal);

            string[] dayArray = selectedTimeslot.Days.Split(',');

            int selected_TimeStart = timeStringToInt(selectedTimeslot.TimeStart);
            int selected_TimeEnd = timeStringToInt(selectedTimeslot.TimeEnd);

            availRooms = new List<Room>(rooms);

            foreach (Room rm in rooms)
            {
                foreach (SubjectAssignment rS in roomSchedule)
                {
                    if (rS.RoomId == rm.RoomId)
                    {
                        foreach (string sDay in dayArray)
                        {
                            if (rS.Days.Contains(sDay))
                            {
                                int compared_TimeStart = timeStringToInt(rS.Timestart);
                                int compared_TimeEnd = timeStringToInt(rS.TimeEnd);

                                if ((compared_TimeStart <= selected_TimeStart && compared_TimeEnd <= selected_TimeEnd && compared_TimeEnd > selected_TimeStart) ||
                                            (compared_TimeStart >= selected_TimeStart && compared_TimeEnd <= selected_TimeEnd) ||
                                            (compared_TimeStart >= selected_TimeStart && compared_TimeStart < selected_TimeEnd && compared_TimeEnd > selected_TimeEnd))
                                {
                                    availRooms.RemoveAll(x => x.RoomId == rS.RoomId);
                                }
                            }
                        }
                    }
                }
            }

            if (availRooms.Count > 0)
            {
                cmbRoom.Enabled = true;
                cmbRoom.ValueMember = "RoomId";
                cmbRoom.DisplayMember = "RoomCode";
                cmbRoom.DataSource = availRooms;
            }

        }
Ejemplo n.º 12
0
        public void TranslateScheduleBDOToSchedule(SubjectAssignmentBDO sabdo, SubjectAssignment sched)
        {
            GradeSectionService gs = new GradeSectionService();
            GradeSection g = new GradeSection();
            gs.TranslateGradeSectionBDOToGradeSection(sabdo.GradeSection, g);
            sched.GradeSection = g;
            sched.Section = g.Section;
            sched.GradeLevel = g.GradeLevel;
            sched.Class = (int)g.Class;

            RoomService rs = new RoomService();
            Room r = new Room();
            rs.TranslateRoomBDOtoRoomDTO(sabdo.Room, r);
            sched.Room = r;
            sched.RoomCode = r.RoomCode;

            SubjectService ss = new SubjectService();
            Subject s = new Subject();
            ss.TranslateSubjectBDOToSubject(sabdo.Subject, s);
            sched.Subject = s;

            TeacherService ts = new TeacherService();
            Teacher t = new Teacher();
            ts.TranslateTeacherBDOToTeacherDTO(sabdo.Teacher, t);
            sched.Teacher = t;
            if (t.MiddleName == String.Empty)
                sched.TeacherName = t.LastName + ", " + t.FirstName;
            else
                sched.TeacherName = t.LastName + ", " + t.FirstName + " " + t.MiddleName.Substring(0, 1) + ".";

            TimeslotService times = new TimeslotService();
            Timeslot time = new Timeslot();
            times.TranslateTimeslotBDOToTimeslotDTo(sabdo.Timeslot, time);
            sched.Timeslot = time;
            sched.Timestart = time.TimeStart;
            sched.TimeEnd = time.TimeEnd;
            sched.Days = time.Days;

            sched.Deactivated = sabdo.Deactivated;
            sched.GradeSectionCode = sabdo.GradeSectionCode;
            sched.RoomId = sabdo.RoomId;
            sched.SubjectAssignmentsID = sabdo.SubjectAssignmentsID;
            sched.SubjectCode = sabdo.SubjectCode;

            sched.SY = sabdo.SY;
            sched.TeacherId = sabdo.TeacherId;
            sched.TimeSlotCode = sabdo.TimeSlotCode;

            sched.TimeslotInfo = time.Days + " " + time.TimeStart + "-" + time.TimeEnd;
            sched.SubjectInfo = sabdo.SubjectCode + " " + sched.Section + " " + sched.TimeslotInfo;

            sched.SubjectDescription = s.Description;

        }
Ejemplo n.º 13
0
        private void SaveUser()
        {
            try
            {
                Boolean ret = false;
                string message = String.Empty;

                List<String> list = new List<String>();
                if (chkSunday.Checked == true) list.Add("Sun");
                if (chkMonday.Checked == true) list.Add("Mon");
                if (chkTuesday.Checked == true) list.Add("Tue");
                if (chkWednesday.Checked == true) list.Add("Wed");
                if (chkThursday.Checked == true) list.Add("Thu");
                if (chkFriday.Checked == true) list.Add("Fri");
                if (chkSaturday.Checked == true) list.Add("Sat");

                string szDays = string.Empty;
                szDays = string.Join(",", list.ToArray());

                DateTime? dtTimeStart = DateTime.Now;
                DateTime? dtTimeEnd = DateTime.Now;

                dtTimeStart = tPStart.Value;
                dtTimeEnd = tpEnd.Value;

                ITimeslotService tService = new TimeslotService();
                Timeslot timeslot = new Timeslot()
                {
                    TimeSlotCode = txtTimeslotCode.Text,
                    TimeStart = dtTimeStart.Value.ToString("hh:mm tt"),
                    TimeEnd = dtTimeEnd.Value.ToString("hh:mm tt"),
                    Days = szDays
                };

                if (Op.Equals("edit"))
                {
                    timeslot.TimeSlotCode = SelectedTimeslot.TimeSlotCode;
                    ret = tService.UpdateTimeslot(ref timeslot, ref message);
                    Log("U", "Timeslots", timeslot);
                }
                else
                {
                    ret = tService.CreateTimeslot(ref timeslot, ref message);
                    Log("C", "Timeslots", timeslot);
                }

                MessageBox.Show("Saved Successfully!");

                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString());
            }
        }