Exemplo n.º 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();
            }
        }
 public AddWorkersToConcertWindow()
 {
     InitializeComponent();
     worker               = new Worker();
     workerRepositoty     = new WorkerRepository(new ApplicationContext());
     listView.ItemsSource = workerRepositoty.GetAllFromCache();
 }
Exemplo n.º 3
0
 public void GridCount()
 {
     for (int row = 0; row < workerRepository.GetAllFromCache(1).Count(); row++)
     {
         int         num = 0;
         DataGridRow r   = lessonGrid.GetRow(row);
         for (int column = 1; column < DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month) + 1; column++)
         {
             var      sd = lessonGrid.GetCell(r, column).Content;
             CheckBox ch = (CheckBox)sd;
             if (ch.IsChecked == true)
             {
                 num++;
             }
         }
         TextBlock s = (TextBlock)lessonGrid.GetCell(r, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month) + 1).Content;
         s.Text = num.ToString();
     }
 }
Exemplo n.º 4
0
        public LessonWindow()
        {
            InitializeComponent();

            List <Items> items = new List <Items>();

            lessonRepository     = new LessonEventRepository(new ApplicationContext());
            workerRepository     = new WorkerRepository(new ApplicationContext());
            lessonMarkRepository = new LessonMarksRepository(new ApplicationContext());

            foreach (Worker wr in workerRepository.GetAllFromCache(1))
            {
                Items item = new Items()
                {
                    wrk = wr
                };
                items.Add(item);
            }

            for (int i = 1; i <= DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month); i++)
            {
                DataGridCheckBoxColumn chekColumn = new DataGridCheckBoxColumn();
                chekColumn.Header     = i.ToString();
                chekColumn.Binding    = new Binding(i.ToString());
                chekColumn.IsReadOnly = true;

                chekColumn.CellStyle = new Style(typeof(DataGridCell));
                chekColumn.CellStyle.Setters.Add(new Setter(DataGridCell.BackgroundProperty, new SolidColorBrush(Colors.LightGray)));

                lessonGrid.Columns.Add(chekColumn);
            }
            DataGridTextColumn num = new DataGridTextColumn();

            num.Header  = "Sum";
            num.Binding = new Binding("Sum");

            num.CellStyle = new Style(typeof(DataGridCell));
            num.CellStyle.Setters.Add(new Setter(DataGridCell.BackgroundProperty, new SolidColorBrush(Colors.LightGray)));
            lessonGrid.Columns.Add(num);

            lessonGrid.ItemsSource = items;


            //SetValue();
        }