예제 #1
0
        void GetUsingClass()
        {
            DateTime targetDate = DateTime.Now;

            // Select all needed info from USINGCLASS that fit selected Date
            var data = (from u in DataProvider.Ins.DB.USINGCLASSes
                        join c in DataProvider.Ins.DB.CLASSes on u.ClassID equals c.ClassID
                        where u.Status_ == (int)Enums.UsingStatus.Approved &&
                        targetDate >= u.StartDate && targetDate <= u.EndDate &&
                        (int)targetDate.DayOfWeek == u.Day_ &&                                   // satisfied the day of week
                        (DbFunctions.DiffDays(targetDate, c.StartDate) / 7) % u.RepeatCycle == 0 // satisfied the repeat cycle
                        select new { u.UsingClassID, u.RoomID, c.ClassName, u.StartPeriod, u.Duration }).ToList();

            data.Sort((a, b) => { return(string.Compare(a.RoomID, b.RoomID)); });

            foreach (var item in data)
            {
                if (IsExistRoom(item.RoomID))
                {
                    var room = GetRoom(item.RoomID);
                    room.Add(item.UsingClassID, item.ClassName, item.StartPeriod, item.Duration);
                }
                else
                {
                    var room = new table();
                    room.Add(item.UsingClassID, item.ClassName, item.StartPeriod, item.Duration);
                    room.roomID = item.RoomID;
                    tb.Add(room);
                }
            }
        }
예제 #2
0
        void GetUsingExam()
        {
            DateTime targetDate = DateTime.Now;

            // Select all needed info from USINGCLASS that fit selected Date
            var data = (from u in DataProvider.Ins.DB.USINGEXAMs
                        join e in DataProvider.Ins.DB.EXAMs on u.ExamID equals e.ExamID
                        join c in DataProvider.Ins.DB.CLASSes on e.ClassID equals c.ClassID
                        where u.Date_ == targetDate &&
                        u.Status_ == (int)Enums.UsingStatus.Approved
                        select new { u.UsingExamID, u.RoomID, c.ClassName, u.StartPeriod, u.Duration }).ToList();

            data.Sort((a, b) => { return(string.Compare(a.RoomID, b.RoomID)); });

            foreach (var item in data)
            {
                if (IsExistRoom(item.RoomID))
                {
                    var room = GetRoom(item.RoomID);
                    room.Add(item.UsingExamID, "Thi: " + item.ClassName, item.StartPeriod, item.Duration);
                }
                else
                {
                    var room = new table();
                    room.Add(item.UsingExamID, "Thi: " + item.ClassName, item.StartPeriod, item.Duration);
                    room.roomID = item.RoomID;
                    tb.Add(room);
                }
            }
        }
예제 #3
0
        void GetUsingEvent()
        {
            DateTime targetDate = new DateTime(selectedYear, selectedMonth.monthValue, selectedDay);

            // Select all needed info from USINGCLASS that fit selected Date
            var data = (from u in DataProvider.Ins.DB.USINGEVENTs
                        join e in DataProvider.Ins.DB.EVENT_ on u.EventID equals e.EventID
                        where u.Date_ == targetDate &&
                        u.Status_ == (int)Enums.UsingStatus.Approved
                        select new { u.UsingEventID, u.RoomID, e.EventName, u.StartPeriod, u.Duration }).ToList();

            data.Sort((a, b) => { return(string.Compare(a.RoomID, b.RoomID)); });

            foreach (var item in data)
            {
                if (IsExistRoom(item.RoomID))
                {
                    var room = GetRoom(item.RoomID);
                    room.Add(item.UsingEventID, item.EventName, item.StartPeriod, item.Duration);
                }
                else
                {
                    var room = new table();
                    room.Add(item.UsingEventID, item.EventName, item.StartPeriod, item.Duration);
                    room.roomID = item.RoomID;
                    tb.Add(room);
                }
            }
        }