コード例 #1
0
        public void initializeRequestsList()
        {
            outstandingHolidaysListView.Items.Clear();
            try
            {
                messageLabel.Visible = false;
                using (HBSModel _entity = new HBSModel())
                {
                    var prioritiseReqs = (from el in _entity.HolidayRequests
                                          where el.StatusRequest.Status == GeneralUtils.PENDING
                                          select new PriorityRequest()
                    {
                        Constraints = new BreakingConstraints()
                        {
                            AtLeastPercentage = el.ConstraintsBroken.AtLeastPercentage,
                            ExceedsHolidayEntitlement = el.ConstraintsBroken.ExceedsHolidayEntitlement,
                            HeadOrDeputy = el.ConstraintsBroken.HeadOrDeputy,
                            ManagerOrSenior = el.ConstraintsBroken.ManagerOrSenior
                        },
                        WorkingDays = el.NumberOfDays,
                        DaysPeakTime = el.DaysPeakTime,
                        EndDate = el.EndDate,
                        ID = el.ID,
                        RemainingDays = el.User.RemainingDays,
                        StartDate = el.StartDate,
                        InitialHolidayEntitlement = el.User.InitialHolidayEntitlement,
                        TotalPeakDaysHoliday = el.User.TotalPeakDaysHoliday
                    }).ToList();
                    var ordered = new PrioritiseRequests(prioritiseReqs).getPrioritisedRequests();
                    foreach (var request in ordered)
                    {
                        string[] arr = new string[4];
                        arr[0] = request.ID.ToString();
                        arr[1] = request.StartDate.ToShortDateString();
                        arr[2] = request.EndDate.ToShortDateString();
                        arr[3] = request.WorkingDays.ToString();
                        ListViewItem item = new ListViewItem(arr);
                        if (PriorityRequest.isAnyConstraintBroken(request.Constraints))
                        {
                            item.BackColor = Color.SandyBrown;
                        }
                        else
                        {
                            item.BackColor = Color.Lime;
                        }

                        outstandingHolidaysListView.Items.Add(item);
                    }
                }
            }
            catch (Exception err)
            {
                DesktopAppUtils.popDefaultErrorMessageBox("Could not retrieve Item from DB \n" + err.Message);
            }
        }
コード例 #2
0
        private void searchBookingsButton_Click(object sender, EventArgs e)
        {
            if (employeeDropDown.SelectedIndex == -1)
            {
                DesktopAppUtils.popDefaultErrorMessageBox("No employee selected");
                return;
            }
            ComboItem employee = (ComboItem)employeeDropDown.SelectedItem;

            if (employee.ID == -1)
            {
                DesktopAppUtils.popDefaultErrorMessageBox("No employee selected");
                return;
            }
            if (departmentDropDown.SelectedIndex == -1)
            {
                DesktopAppUtils.popDefaultErrorMessageBox("No department selected");
                return;
            }
            if (monthDropDown.SelectedIndex == -1)
            {
                DesktopAppUtils.popDefaultErrorMessageBox("No month selected");
                return;
            }
            ComboItem month = (ComboItem)monthDropDown.SelectedItem;
            object    year  = yearDropDown.SelectedItem;

            this.Cursor = Cursors.WaitCursor;
            if (currentlySelectedEmployeeId == employee.ID)
            {
                calendarDataVisualization1.ChangeSelection(month.ID, int.Parse(year.ToString()));
            }
            else
            {
                currentlySelectedEmployeeId = employee.ID;
                using (HBSModel model = new HBSModel())
                {
                    var holidayRequests = model.HolidayRequests.Where(x => x.UserID == employee.ID &&
                                                                      x.StatusRequest.Status == GeneralUtils.APPROVED).ToList();
                    List <DateRange> dateRanges = new List <DateRange>();
                    foreach (HolidayRequest holidayRequest in holidayRequests)
                    {
                        dateRanges.Add(new DateRange(holidayRequest.StartDate, holidayRequest.EndDate));
                    }
                    calendarDataVisualization1.ClearDateRanges();
                    calendarDataVisualization1.AddDateRangesList(dateRanges);
                    calendarDataVisualization1.ChangeSelection(month.ID, int.Parse(year.ToString()));
                }
            }
            selectedMonthLabel.Text = "Selected Month: " + month.Text + " " + year.ToString();
            this.Cursor             = Cursors.Default;
        }
コード例 #3
0
 private void suggesstionConfirmedButton_Click(object sender, EventArgs e)
 {
     if (suggestionsListView.SelectedItems.Count > 0)
     {
         int          selIndex     = suggestionsListView.SelectedIndices[0];
         ListViewItem selectedItem = suggestionsListView.Items[selIndex];
         UC_OutstandingHolidays.Instance.ConfirmSuggestion(Convert.ToDateTime(selectedItem.SubItems[0].Text),
                                                           Convert.ToDateTime(selectedItem.SubItems[1].Text));
     }
     else
     {
         DesktopAppUtils.popDefaultErrorMessageBox("No suggestion selected");
     }
 }