Exemple #1
0
        /**
         * Method calls on saving controller method based on validation
         *
         * @param errors list of errors
         * @param user user model
         */
        private void save(List <string> errors, UserModel user)
        {
            UserController controller = new UserController();
            FeedbackWindow feedback   = new FeedbackWindow();

            if (errors.Count != 0)
            {
                feedback.setMessageForInvalidFieldsValues(errors);
            }
            else if (!controller.save(user))
            {
                feedback.setMessageForSavingError();
            }
            else
            {
                feedback.setMessageForSuccessfullOperation();
            }
            feedback.Show();
        }
Exemple #2
0
 /** Method initiaties processed for saving staffSchedule model */
 private void saveScheduleButton_Click(object sender, EventArgs e)
 {
     this.errors = new List <string>();
     this.validateSelection();
     if (errors.Count == 0)
     {
         List <DateTime> selectedMonths    = getCheckedMonths();
         int             staffId           = getSelectedStaffId();
         List <string>   daysToBeScheduled = getDaysToBeScheduled();
         Dictionary <string, Dictionary <string, string> > timesPerDay = getTimesPerDay();
         List <int> scheduledDays = getScheduleIdsPerPeriod(selectedMonths, daysToBeScheduled, timesPerDay);
         if (this.saveStaffSchedules(staffId, scheduledDays))
         {
             clearAllTheFields();
         }
     }
     else
     {
         feedback.setMessageForInvalidFieldsValues(errors);
         feedback.Show();
     }
 }
        /** Method initializes a process of saving and absance model to the database */
        private void saveButton_Click(object sender, EventArgs e)
        {
            if (!this.isDateTimeValid())
            {
                feedbackWindow.setCustomizedMessage(validationMessage);
                feedbackWindow.ShowDialog();
                validationMessage = "";
                return;
            }
            AbsenceModel absence = this.getAbsenceModelFromPresenterForm();

            List <string>     invalidFields = new List <string>();
            AbsenceController controller    = new AbsenceController();

            if (allTheDoctors.Enabled)
            {
                invalidFields = controller.isDataValid(startDatePicker, endDatePicker, startTimePicker, endTimePicker, invalidFields, allTheDoctors);
            }
            else
            {
                invalidFields = controller.isDataValid(startDatePicker, endDatePicker, startTimePicker, endTimePicker, invalidFields);
            }
            if (invalidFields == null || invalidFields.Count == 0)
            {
                if (!controller.save(absence))
                {
                    this.feedbackWindow.setMessageForAbsencesProblems();
                }
                else
                {
                    this.feedbackWindow.setMessageForSuccessfullOperation();
                }
            }
            else
            {
                feedbackWindow.setMessageForInvalidFieldsValues(invalidFields);
            }
            feedbackWindow.ShowDialog();
        }
Exemple #4
0
        /** Method calls on controller method for saving staff member */
        private void saveButton_Click(object sender, EventArgs e)
        {
            StaffController controller  = new StaffController();
            StaffModel      staffMember = this.getStaffModelFromForm();
            List <string>   errors      = Validator.validateStaffMember(staffMember, (int)staffTypes.SelectedValue);

            if (errors.Count == 0)
            {
                bool result = controller.addStaffMember(staffMember);
                if (!result)
                {
                    feedback.setMessageForSavingError();
                }
                else
                {
                    feedback.setMessageForSuccessfullOperation();
                }
            }
            else
            {
                feedback.setMessageForInvalidFieldsValues(errors);
            }
            feedback.Show();
        }
        /** Method performs actions preparing data for saving and the firing the process */
        private void saveButton_Click(object sender, EventArgs e)
        {
            List <string> validationErrors = Validator.validateScheduleEntry(workStartTime.Value, workEndTime.Value, breakStartTime.Value, breakEndTime.Value);

            if (validationErrors.Count != 0)
            {
                feedback.setMessageForInvalidFieldsValues(validationErrors);
                feedback.Show();
                workStartTime.Value = new DateTime(2012, 12, 12, 9, 0, 0);
                workEndTime.Value   = new DateTime(2012, 12, 12, 17, 0, 0);
                return;
            }
            ScheduleModel      schedule   = new ScheduleModel();
            ScheduleController controller = new ScheduleController();
            int staffId = ((ListItem)allTheStaffMembers.SelectedItem).id;

            if (staffId == 0)
            {
                feedback.setMessageForInvalidFieldsValues(new List <string>()
                {
                    "staff member"
                });
                feedback.Show();
                return;
            }
            schedule.setDate(dateToBeScheduled.Value.Date.ToString("yyyy-MM-dd"));
            List <int> scheduleIdList = new List <int>();

            if (!noBreakCheckBox.Checked)
            {
                schedule.setStartTime(workStartTime.Value.TimeOfDay.ToString());
                schedule.setEndTime(breakStartTime.Value.TimeOfDay.ToString());
                if (controller.saveSchedule(schedule))
                {
                    scheduleIdList.Add(controller.getScheduleIdBasedOnOtherScheduleInformation(schedule));
                }
                schedule.setStartTime(breakEndTime.Value.TimeOfDay.ToString());
                schedule.setEndTime(workEndTime.Value.TimeOfDay.ToString());
                if (controller.saveSchedule(schedule))
                {
                    scheduleIdList.Add(controller.getScheduleIdBasedOnOtherScheduleInformation(schedule));
                }
            }
            else
            {
                schedule.setStartTime(workStartTime.Value.TimeOfDay.ToString());
                schedule.setEndTime(workEndTime.Value.TimeOfDay.ToString());
                controller.saveSchedule(schedule);
                scheduleIdList.Add(controller.getScheduleIdBasedOnOtherScheduleInformation(schedule));
            }

            List <bool> errors = controller.saveStaffSchedules(staffId, scheduleIdList);

            if (errors.Count == 0)
            {
                feedback.setMessageForSuccessfullOperation();
            }
            else
            {
                feedback.setMessageForSavingError();
            }
            feedback.Show();
        }