Exemple #1
0
        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);
        }