Exemplo n.º 1
0
        private void frmGroups_Load(object sender, EventArgs e)
        {
            try {
                DistricController  districController  = new DistricController();
                LocalityController localityController = new LocalityController();

                Operation <Distrito>   getDistrictOperation   = districController.getRecords();
                Operation <Localidade> getLocalitiesOperation = localityController.getRecords();
                bool dataIsRetrieved = getLocalitiesOperation.State && getDistrictOperation.State;

                if (dataIsRetrieved)
                {
                    // set data
                    districts  = getDistrictOperation.Data;
                    localities = getLocalitiesOperation.Data;
                    // load data
                    cmbDistricts.DataSource = districts;
                    cmbLocations.DataSource = localities;

                    loadTable(this.getGroups());

                    cmbDistricts.SelectedIndex = -1;
                    cmbLocations.SelectedIndex = -1;
                }
                else
                {
                    MessageBox.Show(getDistrictOperation.Error);
                }

                chbStatus.Checked       = true;
                chbRegistration.Checked = true;

                setReadOnly();
            }
            catch (Exception ex)
            {
                FormUtils.defaultErrorMessage(ex);
            }
        }