コード例 #1
0
        public void GridSum(List <Items> wrList)
        {
            DateTime dt  = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            DateTime dt2 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month));

            IEnumerable <ConcertEvent> concert = concertRepository.Get(p => p.EndDate <= dt2 && p.EndDate >= dt);

            //p.BeginningDate
            //(p => dt2 >= p.EndDate)
            for (int row = 0; row < workerRepository.GetAllFromCache().Count(); row++)
            {
                int sum  = 0;
                int wrId = wrList[row].wrk.ID;

                foreach (ConcertEvent cncrt in concert)
                {
                    if (concertMarkRepository.IsExist(p => p.ConcertEventID == cncrt.ID && p.WorkerID == wrId))
                    {
                        sum += concertMarkRepository.Get(p => p.ConcertEventID == cncrt.ID && p.WorkerID == wrId).First().NumOfMarks;
                    }
                }

                sum += lessonMarkRepository.Get(p => p.WorkerID == wrId && p.IsVisited == true).Count();
                DataGridRow r = lessonGrid.GetRow(row);
                TextBlock   s = (TextBlock)lessonGrid.GetCell(r, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month) + 1).Content;
                s.Text = sum.ToString();
            }
        }
コード例 #2
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();
        }