Пример #1
0
        /**
         * Controller to read initial data
         */

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

                // Populate months combobox
                this.view.MonthCBox.comboBox.DisplayMember = "name";
                this.view.MonthCBox.comboBox.ValueMember   = "value";
                this.view.MonthCBox.comboBox.DataSource    = new List <Models.Month> {
                    Months.JANUARY,
                    Months.FEBRUARY,
                    Months.MARCH,
                    Months.APRIL,
                    Months.MAY,
                    Months.JUNE,
                    Months.JULY,
                    Months.AUGUST,
                    Months.SEPTEMBER,
                    Months.OCTOBER,
                    Months.NOVEMBER,
                    Months.DECEMBER
                };

                // Read sectors from DB and populate combobox
                List <Models.Sector> sectors = await sectorModel.readSectors();

                this.view.SectorsCBox.comboBox.DisplayMember = "name";
                this.view.SectorsCBox.comboBox.ValueMember   = "id";
                this.view.SectorsCBox.comboBox.DataSource    = sectors;

                Cursor.Current = Cursors.Arrow;

                // Read data from DB and populate table
                List <Models.EmergencyDoctor> data = await this.emergencyDoctorModel.readEmergencyDoctors(
                    (int)this.view.SectorsCBox.comboBox.SelectedValue,
                    this.view.MonthCBox.comboBox.SelectedValue.ToString(),
                    DateTime.Now.Year.ToString()
                    );

                this.populateTable(data);

                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 initial data
         */

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

                // Read roles from DB and populate combobox
                List <Models.Role> roles = await roleModel.readRoles();

                List <Models.Role> filteredRoles = new List <Models.Role>();

                roles.Add(new Models.Role(
                              -1,
                              Roles.ALL
                              ));

                roles.ForEach((role) => {
                    if (role.Name != Roles.MANAGER)
                    {
                        filteredRoles.Add(role);
                    }
                });

                this.view.CBox.comboBox.DisplayMember = "name";
                this.view.CBox.comboBox.ValueMember   = "id";
                this.view.CBox.comboBox.DataSource    = filteredRoles;

                // Read sectors from DB and populate combobox
                List <Models.Sector> sectors = await sectorModel.readSectors();

                this.view.SpecializationCBox.comboBox.DisplayMember = "name";
                this.view.SpecializationCBox.comboBox.ValueMember   = "id";
                this.view.SpecializationCBox.comboBox.DataSource    = sectors;

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