Ejemplo n.º 1
0
        /**
         * Method analyzes validation and based on result shows appropriate message to the user
         *
         * @param staffId
         * @param scheduleDays list of days to be scheduled
         *
         * @return result of saving
         */
        private bool saveStaffSchedules(int staffId, List <int> scheduledDays)
        {
            List <bool> errors = scheduleController.saveStaffSchedules(staffId, scheduledDays);

            if (errors.Count != 0)
            {
                feedback.setMessageForSavingError();
                feedback.Show();
                return(false);
            }
            feedback.setMessageForSuccessfullOperation();
            feedback.Show();
            return(true);
        }
Ejemplo n.º 2
0
        /** Method initiaties the process of updating the attendance process */
        private void saveButton_Click(object sender, System.EventArgs e)
        {
            FeedbackWindow message = new FeedbackWindow();

            if (attendanceOptions.SelectedIndex != 0)
            {
                BookingController        controller     = new BookingController();
                string                   selectedOption = (attendanceOptions.SelectedItem as ListItem).text;
                Dictionary <string, int> options        = controller.getAttendanceOptions()[selectedOption];
                booking.setAttendance(options["attendance"]);
                booking.setConfirmation(options["confirmation"]);
                booking.setLackOfCancellation(options["lackOfCancellation"]);
                if (controller.updateAttendanceStatus(booking))
                {
                    message.setMessageForSuccessfullOperation();
                }
                else
                {
                    message.setMessageForSavingError();
                }
                parent.getAppointmentBoxes();
                this.Hide();
            }
            else
            {
                message.setCustomizedMessage(ATTENDANCE_OPTION_NOT_SELECTED);
            }
            message.Show();
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
0
        /** Method is responsible for initiation of the process of saving the settings */
        private void saveUserSettings_Click(object sender, EventArgs e)
        {
            List <string> notification = new List <string>();
            List <string> verification = new List <string>();
            List <string> confirmation = new List <string>();

            if (onThePhoneVerification.Enabled && onThePhoneVerification.Checked)
            {
                verification.Add(settingsPanel.verificationOptions.call.ToString());
            }
            if (emailVerification.Enabled && emailVerification.Checked)
            {
                verification.Add(settingsPanel.verificationOptions.email.ToString());
            }
            if (printableConfirmation.Enabled && printableConfirmation.Checked)
            {
                confirmation.Add(settingsPanel.confirmationOptions.print.ToString());
            }
            if (emailConfirmation.Enabled && emailConfirmation.Checked)
            {
                confirmation.Add(settingsPanel.confirmationOptions.email.ToString());
            }

            FeedbackWindow feedback = new FeedbackWindow();

            if (!controller.saveSettings(notification, verification, confirmation))
            {
                feedback.setMessageForSavingError();
            }
            else
            {
                feedback.setMessageForSuccessfullOperation();
            }
            feedback.Show();
            fillInSettingsBasedOnUserData();
        }
Ejemplo n.º 5
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();
        }