Пример #1
0
 private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
 {
     var dateToWorkWith = dateTimePicker1.Value;
     RosterService rservice = new RosterService();
     WorkingRoster = rservice.GetRosterForDate(dateToWorkWith);
     Rebind();
 }
Пример #2
0
        private void BuildButton(int day, RosterDay b)
        {
            var dateToWorkWith = dateTimePicker1.Value;
            RosterService rservice = new RosterService();
            WorkingRoster = rservice.GetRosterForDate(dateToWorkWith);
            if (day > 6)
                day = day % 7;
            b.Label = Enum.GetName(typeof(DayOfWeek), day);
            b.DayOfWeek = day;
            b.BindRoster(WorkingRoster);

            b.btnModify.Tag = day;
        }
Пример #3
0
        private void B_Click(object sender, EventArgs e)
        {
            int day = (int)(((Button)sender).Tag);
            AddEditShiftRoster aeda = new AddEditShiftRoster();
            aeda.User = User;
            var dateToWorkWith = dateTimePicker1.Value;
            RosterService rservice = new RosterService();
            WorkingRoster = rservice.GetRosterForDate(dateToWorkWith);
            aeda.DayOfWeek = day;
            aeda.RosterId = WorkingRoster.Id;
            aeda.ShowDialog();
            if (aeda.DialogResult == DialogResult.OK)
            {

                Rebind();
            }
        }
Пример #4
0
 public Roster GetRosterForDate(DateTime d,string include="")
 {
     CultureInfo cul = CultureInfo.CurrentCulture;
     int weekOfYear = cul.Calendar.GetWeekOfYear(d, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
     int year = d.Year;
     if (weekOfYear > 52)
     {
         weekOfYear = weekOfYear % 52;
         year += 1;
     }
     var unitofWork = new UnitOfWork();
     var roster = unitofWork.RosterRepository.Get(x => x.WeekOfYear == weekOfYear && x.Year == year,includeProperties: include);
     if (roster.FirstOrDefault() != null)
     {
         return roster.FirstOrDefault();
     }
     else
     {
         Roster r = new Roster() { WeekOfYear = weekOfYear, Year = year, Notes = "NOTES", Restaurant = new UnitOfWork().RestaurantRepository.Get().FirstOrDefault() };
         var q = unitofWork.RosterRepository.Insert(r);
         unitofWork.Save();
         return unitofWork.RosterRepository.Get(x => x.WeekOfYear == weekOfYear && x.Year == year, includeProperties:include).FirstOrDefault();
     }
 }
Пример #5
0
 public void BindRoster(Roster workingRoster)
 {
     var unitOfWork = new UnitOfWork();
        UsersOnShift= unitOfWork.ShiftRepository.Get(x => x.DayOfTheWeek == _day && x.RosterId==workingRoster.Id,includeProperties: "EmployeeShifts.EmployeeShiftAssignments").SelectMany(x=> x.EmployeeShifts).ToList();
     dataGridView1.DataSource = UsersOnShift.Select(x => new { Employee = x.Employee==null?"": x.Employee.FullName, ShiftTime = x.StartTime }).ToList();
 }