Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
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();
        }