Пример #1
0
        private void cboRegion_SelectedIndexChanged(object sender, EventArgs e)
        {
            CADASTRAL_REGION region = cboRegion.SelectedItem as CADASTRAL_REGION;

            if (region != null && !string.IsNullOrEmpty(region.CODE))
            {
                List <MUNICIPALITY> municipalities = _basicService.LoadAllMUNICIPALITY(_businessParam).Where(c => c.ID_CADASTRAL_REGION == region.ID_CADASTRAL_REGION).OrderBy(c => c.NAME).ToList();
                municipalities.Insert(0, new MUNICIPALITY {
                    NAME = "---", CODE = "", ID_MUNICIPALITY = -1
                });

                cboMunicipality.DataSource    = municipalities;
                cboMunicipality.DisplayMember = "NAME";
                cboMunicipality.ValueMember   = "ID_MUNICIPALITY";

                CADASTRAL_ZONE cadastreZone   = cboRegionZone.SelectedItem as CADASTRAL_ZONE;
                int            prevCodeLength = cadastreZone.CODE.Length;
                txtCodeRegion.Text = region.CODE.Substring(prevCodeLength, region.CODE.Length - prevCodeLength);

                if (municipalities == null || municipalities.Count == 0)
                {
                    txtCodeMunicipality.Text    = "";
                    txtCodeTerriturialUnit.Text = "";

                    cboMunicipality.DataSource    = null;
                    cboTerritorialUnit.DataSource = null;
                }

                txtCodeRegion.ReadOnly = true;
            }
            else
            {
                cboMunicipality.DataSource = null;
                txtCodeRegion.Text         = "";
                txtCodeRegion.ReadOnly     = false;
            }
        }
Пример #2
0
        private void cboRegionZone_SelectedIndexChanged(object sender, EventArgs e)
        {
            CADASTRAL_ZONE cadastreZone = cboRegionZone.SelectedItem as CADASTRAL_ZONE;

            if (cadastreZone != null && cadastreZone.ID_CADASTRAL_ZONE != -1)
            {
                List <CADASTRAL_REGION> regions = _basicService.LoadAllCADASTRAL_REGION(_businessParam).Where(c => c.ID_CADASTRAL_ZONE == cadastreZone.ID_CADASTRAL_ZONE).OrderBy(c => c.NAME).ToList();
                regions.Insert(0, new CADASTRAL_REGION {
                    NAME = "---", CODE = "", ID_CADASTRAL_REGION = -1
                });

                cboRegion.DataSource    = regions;
                cboRegion.DisplayMember = "NAME";
                cboRegion.ValueMember   = "ID_CADASTRAL_REGION";

                txtCodeRegionZone.Text = cadastreZone.CODE;

                if (regions == null || regions.Count == 0)
                {
                    txtCodeRegion.Text          = "";
                    txtCodeMunicipality.Text    = "";
                    txtCodeTerriturialUnit.Text = "";

                    cboRegion.DataSource          = null;
                    cboMunicipality.DataSource    = null;
                    cboTerritorialUnit.DataSource = null;
                }

                txtCodeRegionZone.ReadOnly = true;
            }
            else
            {
                cboRegion.DataSource       = null;
                txtCodeRegionZone.ReadOnly = false;
                txtCodeRegionZone.Text     = "";
            }
        }