示例#1
0
        private void search_btn_Click(object sender, RoutedEventArgs e)
        {
            int lecturerId;

            if (isLecFilter && isSubFilter)
            {
                lecturerId = lecturers.Find(l => l.Name == search_lec_val).EmployeeId;
                sessions   = _sessionViewModel.LoadSessionDataByLecturer(lecturerId);
                List <SessionEntity> lecSubFilteredList = new List <SessionEntity>();
                lecSubFilteredList = sessions.FindAll(s => s.SubjectCode == search_combobx.Text);
                sessions           = lecSubFilteredList;
                isLecFilter        = false;
                isSubFilter        = false;
            }
            else if (searchby_combobx.Text == "Subject")
            {
                sessions = _sessionViewModel.LoadSessionDataBySubject(search_combobx.Text);
            }
            else if (searchby_combobx.Text == "Group")
            {
                sessions = _sessionViewModel.LoadSessionDataByGroup(search_combobx.Text);
            }
            else if (searchby_combobx.Text == "Sub Group")
            {
                sessions = _sessionViewModel.LoadSessionDataBySubGroup(search_combobx.Text);
            }
            else if (searchby_combobx.Text == "Tag")
            {
                sessions = _sessionViewModel.LoadSessionDataByTag(search_combobx.Text);
            }
            else if (searchby_combobx.Text == "Lecturer")
            {
                lecturerId = lecturers.Find(l => l.Name == search_combobx.Text).EmployeeId;
                sessions   = _sessionViewModel.LoadSessionDataByLecturer(lecturerId);
            }
            SetDataGrid();
        }
示例#2
0
        private void GenerateLecturerTable_btn_Click(object sender, RoutedEventArgs ev)
        {
            try
            {
                //string lecturername = lec_name_txt.Text;
                //var s = _sessionViewModel.LoadSessionData();

                int workdID            = int.Parse(timeTable_Id_txt.Text);
                List <WorkEntity> list = new List <WorkEntity>();


                _viewModel = new WorkViewModel();

                list = _viewModel.LoadWorkingDaysData(workdID);
                lecturerTable_grid.ItemsSource = list;

                WorkEntity work = lecturerTable_grid.Items[0] as WorkEntity;

                String res  = work.workingDays.ToString();
                int    num  = work.noOfWorkingHours;
                String res1 = work.timeSlotStartTime.ToString();
                String res2 = work.timeSlotEndTime.ToString();


                //data.items = works.Split(',');

                //List<string> list1 = new List<string>();
                //Data data = new Data();

                string[] days;
                string[] start;
                string[] end;

                start = res1.Split(',');
                end   = res2.Split(',');

                //string full;

                //List<Data> datalist = new List<Data>();


                /*for (int i=0; i<start.Length; i++)
                 * {
                 *  full = start[i] + end[i];
                 *  list1.Add(full);
                 *
                 * }
                 *
                 * for (int i = 0; i < list1.Count; i++)
                 * {
                 *  datalist.Add(new Data
                 *  {
                 *      fullTime = list1[i].ToString()
                 *  });
                 * }*/
                //lecturer_timetable.DataContext = datalist;


                //string[] test = list1.ToArray();
                //data.fullTime = list1.ToArray();



                _timeSlotViewModel = new TimeSlotViewModel();



                days = res.Split(',');

                //data.items[0] = "";
                //data.items = res.Split(',');

                //DataContext = data;

                //lecturer_timetable.Items.Add(data);

                //lecturer_timetable.DataContext = data.fullTime;


                int len = (end.Length) - 2;

                string x = end[len];

                string name = lec_name_txt.Text;

                int        lecId      = lecturers.Find(e => e.Name == name).EmployeeId;
                List <int> sessionIds = new List <int>();
                _sessionViewModel.LoadSessionDataByLecturer(lecId).Select(e => { sessionIds.Add(e.SessionId); return(e); }).ToList();
                var c = sessionIds;

                //var f = _sessionViewModel.LoadSessionDataByLecturer(lecId);


                // for(int i; i < )


                //for (int i = 0; i < days.Length; i++)
                //{
                //    days[i] =
                //}


                //For day : - 9 ?
                // # of days : - 5 ?
                // TOT = 9*5 = 45
                _timeSlotEntities = new List <TimeSlotEntity>();
                double startTime = double.Parse(start[0]);
                //int sttime = 8;
                //float st = ++startTime;
                int currentDate = 0;
                //int edtime = 17;
                double endTime = double.Parse(end[len]);
                int    num1    = num * days.Length;
                for (int i = 0; i < num1; i++)
                {
                    if (startTime == endTime)
                    {
                        startTime = double.Parse(start[0]);
                        currentDate++;
                    }

                    if (i >= c.Count)
                    {
                        _timeSlotEntities.Add(
                            new TimeSlotEntity {
                            ID = i, TimeSlots = $"{startTime}-{++startTime}", Days = days[currentDate], SessionId = 0
                        }
                            );
                    }
                    else
                    {
                        _timeSlotEntities.Add(
                            new TimeSlotEntity {
                            ID = i, TimeSlots = $"{startTime}-{++startTime}", Days = days[currentDate], SessionId = c[i]
                        }
                            );
                    }
                }

                //timeSlotEntity = new TimeSlotEntity(2, "8-9", "tue");
                //_timeSlotViewModel.SaveTimeSlotsData(timeSlotEntity);

                foreach (TimeSlotEntity t in _timeSlotEntities)
                {
                    _timeSlotViewModel.SaveTimeSlotsData(t);
                }

                var y = _timeSlotViewModel.LoadTimeSlotData();
                lecturer_timetable.ItemsSource = y;


                _timeSlotViewModel.DeleteTimeData();



                //string name = "Arosha";

                //int lecId = lecturers.Find(e => e.Name == name).EmployeeId;
                //List<int> sessionIds = new List<int>();
                //_sessionViewModel.LoadSessionDataByLecturer(lecId).Select(e => { sessionIds.Add(e.SessionId); return e; });
                //var c = sessionIds;


                /*string[,] daysAndSlots = {
                 *  { "Monday", "8.30-9.30" },
                 *  { "Tuesday", "9.30-10.30" },
                 *  { "Wednesday", "10.30-11.30" },
                 *  { "Thursday", "11.30-12.30" },
                 *  { "Friday", "12.30-13.30" },
                 *  { "Saturday", "13.30-14.30" }
                 * };*/
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }