public void SetValue(bool clear = true) { List <Items> wrList = (List <Items>)lessonGrid.ItemsSource; for (int column = 1; column < DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month) + 1; column++) { DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, column); LessonEvent lsnEvent = new LessonEvent(); if (lessonRepository.IsExist(p => p.Date == dt)) { lsnEvent = lessonRepository.GetAllFromCache().Where(d => d.Date == dt).First(); } else { lsnEvent.Date = dt; lessonRepository.Insert(lsnEvent); lessonRepository.AddToCache(lsnEvent, lsnEvent.ID); } for (int row = 0; row < workerRepository.GetAllFromCache(1).Count(); row++) { Worker wr = wrList[row].wrk; DataGridRow r = lessonGrid.GetRow(row); var s = lessonGrid.GetCell(r, column).Content; CheckBox ch = (CheckBox)s; if (lessonMarkRepository.IsExist(p => p.LessonEventID == lsnEvent.ID && p.WorkerID == wr.ID)) { //if (lessonRepository.IsExist(p => p.Date == dt)) ch.IsChecked = clear ? lessonMarkRepository.Get(p => p.WorkerID == wr.ID && p.LessonEventID == lsnEvent.ID).First().IsVisited : false; } else { ch.IsChecked = false; } s = ch; lessonGrid.GetCell(r, column).Content = ch; } } GridCount(); }
public void SetValue() { List <Items> wrList = (List <Items>)lessonGrid.ItemsSource; for (int column = 1; column < DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month) + 1; column++) { DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, column); LessonEvent lsnEvent = new LessonEvent(); if (lessonRepository.IsExist(p => p.Date == dt)) { lsnEvent = lessonRepository.GetAllFromCache().Where(d => d.Date == dt).First(); } //lsnEvent = lessonRepository.Get(d => d.Date == dt).First(); ConcertEvent concEvent = new ConcertEvent(); if (concertRepository.IsExist(p => dt >= p.BeginningDate && dt <= p.EndDate)) { concEvent = concertRepository.GetListFromCache().Where(p => dt >= p.BeginningDate && dt <= p.EndDate).First(); //concEvent = concertRepository.Get(p => dt >= p.BeginningDate && dt <= p.EndDate).First(); } for (int row = 0; row < workerRepository.GetAllFromCache(1).Count(); row++) { int wrId = wrList[row].wrk.ID; DataGridRow r = lessonGrid.GetRow(row); if (lessonMarkRepository.IsExist(p => p.LessonEventID == lsnEvent.ID && p.IsVisited == true && p.WorkerID == wrId)) { lessonGrid.GetCell(r, column).Background = new SolidColorBrush(Colors.Red); } if (concertMarkRepository.IsExist(p => p.ConcertEventID == concEvent.ID && p.WorkerID == wrId)) { lessonGrid.GetCell(r, column).Background = new SolidColorBrush(Colors.Green); } } } GridSum(wrList); }
public InfoWorker(Worker worker) { int sum = 0; List <Items> items = new List <Items>(); InitializeComponent(); lessonRepository = new LessonEventRepository(new ApplicationContext()); workerRepository = new WorkerRepository(new ApplicationContext()); lessonMarkRepository = new LessonMarksRepository(new ApplicationContext()); concertRepository = new ConcertEventRepository(new ApplicationContext()); concertMarkRepository = new ConcertMarksRepository(new ApplicationContext()); foreach (ConcertEvent con in concertRepository.Get(p => p.EndDate.Value.Month == DateTime.Now.Month)) { if (concertMarkRepository.IsExist(p => p.ConcertEventID == con.ID && p.WorkerID == worker.ID)) { Items item = new Items() { concert = con, marks = concertMarkRepository.Get(p => p.ConcertEventID == con.ID && p.WorkerID == worker.ID).First().NumOfMarks }; sum += item.marks; items.Add(item); } } concertListView.ItemsSource = items; this.Namelabel.Content = worker.Name; this.Surnamelabel.Content = worker.Surname; int lessonVisited = 0; foreach (LessonEvent lesson in lessonRepository.Get(p => p.Date.Month == DateTime.Now.Month)) { if (lessonMarkRepository.IsExist(p => p.LessonEventID == lesson.ID && p.WorkerID == worker.ID && p.IsVisited == true)) { lessonVisited++; } } sum += lessonVisited; this.numOfMakrslabel.Content = sum.ToString(); this.lessonVisitedNumLabel.Content = lessonVisited.ToString(); }