예제 #1
0
        public TimesheetEntryViewModel(TimesheetTemplateViewModel timesheetViewModel)
        {
            // Each instance aggregates a TimesheetEntry object and references its timesheet.
            TimesheetEntry           = new TimesheetEntry();
            TSTemplateModel          = timesheetViewModel;
            TimesheetEntry.timesheet = TSTemplateModel.Timesheet;

            // HoursTextBox is generated with default values on construction.
            UpdateHoursTextbox();

            foreach (string typeName in ShellViewModel.Singleton.TypesOfRatesList)
            {
                if (typeName != "Andet" && typeName != "Hidden")
                {
                    TypeNamesCombobox.Add(new ComboBoxItem()
                    {
                        Content = typeName
                    });
                }
            }
            // Default selection for the type ComboBox is "Arbejde" (Work).
            SelectedTypeComboBoxItem = TypeNamesCombobox.Where(type => (string)type.Content == "Arbejde").First();

            // The ComboBox with employee routes is generated from the routes list on the TimesheetTemplateViewModel.
            TSTemplateModel.EmployeeRoutes.ForEach(route => RouteNamesCombobox.Add(new ComboBoxItem {
                Content = route.LinkedWorkplace.Abbreviation
            }));
            RouteNamesCombobox.Add(new ComboBoxItem()
            {
                Content = ""
            });
        }
        public TimesheetConfirmationViewModel(TimesheetTemplateViewModel timesheet)
        {
            Timesheet = timesheet;
            #region Add Timesheet entry view models to their collections
            foreach (TimesheetEntryViewModel entry in Timesheet.MondayEntries)
            {
                MondayEntries.Add(new TimesheetEntryConfirmationViewModel(entry.TimesheetEntry, this));
            }

            foreach (TimesheetEntryViewModel entry in Timesheet.TuesdayEntries)
            {
                TuesdayEntries.Add(new TimesheetEntryConfirmationViewModel(entry.TimesheetEntry, this));
            }

            foreach (TimesheetEntryViewModel entry in Timesheet.WednesdayEntries)
            {
                WednesdayEntries.Add(new TimesheetEntryConfirmationViewModel(entry.TimesheetEntry, this));
            }

            foreach (TimesheetEntryViewModel entry in Timesheet.ThursdayEntries)
            {
                ThursdayEntries.Add(new TimesheetEntryConfirmationViewModel(entry.TimesheetEntry, this));
            }

            foreach (TimesheetEntryViewModel entry in Timesheet.FridayEntries)
            {
                FridayEntries.Add(new TimesheetEntryConfirmationViewModel(entry.TimesheetEntry, this));
            }

            foreach (TimesheetEntryViewModel entry in Timesheet.SaturdayEntries)
            {
                SaturdayEntries.Add(new TimesheetEntryConfirmationViewModel(entry.TimesheetEntry, this));
            }

            foreach (TimesheetEntryViewModel entry in Timesheet.SundayEntries)
            {
                SundayEntries.Add(new TimesheetEntryConfirmationViewModel(entry.TimesheetEntry, this));
            }
            #endregion
            PageTitle   = "Bekræft Timeseddel - " + timesheet.EmployeeName;
            WeekBox     = timesheet.Timesheet.WeekNumber.ToString();
            YearBox     = timesheet.Timesheet.Year.ToString();
            SalaryIDBox = timesheet.Timesheet.EmployeeID.ToString();

            //Calls the sum event that updates the sum of all the visma entries.
            SumVismaEntries();
        }