コード例 #1
0
        /**
         * Controller to read initial data
         */

        public async void init()
        {
            try {
                Cursor.Current = Cursors.WaitCursor;

                // Read reservations from DB and populate table
                List <Models.Reservation> reservations = await this.reservationModel.readReservations();

                this.reservations = reservations;
                this.populateTable(reservations);

                // Read services and populate combo box
                List <Models.Service> services = await serviceModel.readServices();

                this.view.ServiceCBox.comboBox.DisplayMember = "name";
                this.view.ServiceCBox.comboBox.ValueMember   = "id";
                this.view.ServiceCBox.comboBox.DataSource    = services;

                // Read patients and populate combo box
                List <Models.Patient> patients = await patientModel.readPatients();

                this.view.PatientCBox.comboBox.DisplayMember = "fullname";
                this.view.PatientCBox.comboBox.ValueMember   = "id";
                this.view.PatientCBox.comboBox.DataSource    = patients;

                // Read doctors and populate combo box
                this.doctors = await doctorModel.readDoctors();

                this.view.DoctorCBox.comboBox.DisplayMember = "fullname";
                this.view.DoctorCBox.comboBox.ValueMember   = "id";
                this.view.DoctorCBox.comboBox.DataSource    = doctors;

                // Read nurses and populate combo box
                this.nurses = await nurseModel.readNurses();

                this.view.NurseCBox.comboBox.DisplayMember = "fullname";
                this.view.NurseCBox.comboBox.ValueMember   = "id";
                this.view.NurseCBox.comboBox.DataSource    = nurses;

                Cursor.Current = Cursors.Arrow;
            } catch (Exception e) {
                string caption = "Problem në lexim";
                MessageBox.Show(e.Message, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        /**
         * Controller to handle role selection via combobox
         */

        public async void handleRoleSelection()
        {
            try {
                Cursor.Current = Cursors.WaitCursor;

                Models.Role selectedItem = (Models.Role) this.view.CBox.comboBox.SelectedItem;

                switch (selectedItem.Name)
                {
                case Roles.OPERATOR:
                    List <Models.Operator> operators = await operatorModel.readOperators();

                    this.view.Operators                           = operators;
                    this.view.SelectedRole                        = Roles.OPERATOR;
                    this.view.FormRoleLabel.Text                  = Roles.OPERATOR;
                    this.view.FormAddressLabel.Visible            = false;
                    this.view.FormAddressTxtBox.Visible           = false;
                    this.view.FormPhoneNumberLabel.Visible        = false;
                    this.view.FormPhoneNumberTxtBox.Visible       = false;
                    this.view.FormSpecializationLabel.Visible     = false;
                    this.view.SpecializationCBox.comboBox.Visible = false;
                    break;

                case Roles.DOCTOR:
                    List <Models.Doctor> doctors = await doctorModel.readDoctors();

                    this.view.Doctors                             = doctors;
                    this.view.SelectedRole                        = Roles.DOCTOR;
                    this.view.FormRoleLabel.Text                  = Roles.DOCTOR;
                    this.view.FormAddressLabel.Visible            = true;
                    this.view.FormAddressTxtBox.Visible           = true;
                    this.view.FormPhoneNumberLabel.Visible        = true;
                    this.view.FormPhoneNumberTxtBox.Visible       = true;
                    this.view.FormSpecializationLabel.Visible     = true;
                    this.view.SpecializationCBox.comboBox.Visible = true;
                    break;

                case Roles.NURSE:
                    List <Models.Nurse> nurses = await nurseModel.readNurses();

                    this.view.Nurses                              = nurses;
                    this.view.SelectedRole                        = Roles.NURSE;
                    this.view.FormRoleLabel.Text                  = Roles.NURSE;
                    this.view.FormAddressLabel.Visible            = true;
                    this.view.FormAddressTxtBox.Visible           = true;
                    this.view.FormPhoneNumberLabel.Visible        = true;
                    this.view.FormPhoneNumberTxtBox.Visible       = true;
                    this.view.FormSpecializationLabel.Visible     = false;
                    this.view.SpecializationCBox.comboBox.Visible = false;
                    break;

                case Roles.ALL:
                    List <Models.Operator> o = await operatorModel.readOperators();

                    this.view.Operators = o;
                    List <Models.Doctor> d = await doctorModel.readDoctors();

                    this.view.Doctors = d;
                    List <Models.Nurse> n = await nurseModel.readNurses();

                    this.view.Nurses             = n;
                    this.view.SelectedRole       = Roles.ALL;
                    this.view.FormRoleLabel.Text = Roles.ALL;
                    break;

                default:
                    break;
                }

                this.populateUsersTable();

                Cursor.Current = Cursors.Arrow;
            } catch (Exception e) {
                string caption = "Problem në lexim";
                MessageBox.Show(e.Message, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }