Example #1
0
        private void SetCityByRegion()
        {
            ObjectNode region = null;

            cbRegion.Invoke((MethodInvoker)(() => region = cbRegion.SelectedItem as ObjectNode));

            if (region == null)
            {
                return;
            }

            cbCity.Invoke((MethodInvoker)(() => cbCity.Items.Clear()));
            cbCity.Invoke((MethodInvoker)(() => cbCity.SelectedIndex = -1));

            lblLoading.Invoke((MethodInvoker)(() => lblLoading.Visible = true));
            lblLoading.Invoke((MethodInvoker)(() => lblLoading.Text = "Загрузка всех городов в " + region.ToString() + "."));


            var finded = new List <ObjectNode>();

            foreach (var f in GetObjectsByParent(region.Guid))
            {
                if (f.AOLevel == 3)
                {
                    foreach (var city in GetObjectsByParent(f.Guid))
                    {
                        finded.Add(city);
                    }
                }
                else
                {
                    finded.Add(f);
                }
            }

            if (CITIES_LIKE_REGION.Contains(region.ToString()))
            {
                for (int i = 0; i < finded.Count; i++)
                {
                    var cur = finded[i] as ObjectNode;

                    if (cur?.AOLevel == 4 || cur?.AOLevel == 3)
                    {
                        cbCity.Invoke((MethodInvoker)(() => cbCity.Items.Add(cur)));
                    }
                }

                cbCity.Invoke((MethodInvoker)(() => cbCity.Items.Add(region)));
            }
            else
            {
                foreach (var item in finded)
                {
                    cbCity.Invoke((MethodInvoker)(() => cbCity.Items.Add(item)));
                }
            }
            lblLoading.Invoke((MethodInvoker)(() => lblLoading.Visible = false));
        }
Example #2
0
        private void SetHousesByStreet()
        {
            try
            {
                ObjectNode street = null;
                cbStreet.Invoke((MethodInvoker)(() => street = cbStreet.SelectedItem as ObjectNode));

                if (street == null)
                {
                    return;
                }

                cbHouse.Invoke((MethodInvoker)(() => cbHouse.Items.Clear()));
                cbHouse.Invoke((MethodInvoker)(() => cbHouse.SelectedIndex = -1));

                lblLoading.Invoke((MethodInvoker)(() => lblLoading.Visible = true));
                lblLoading.Invoke((MethodInvoker)(() => lblLoading.Text = "Загрузка всех домов на " + street.ToString() + "."));

                var houses = (from h in parser.DataContext.House
                              where h.AOGUID == street.Guid
                              select new ObjectNode(h.HOUSEGUID, h.HOUSENUM, TableType.House, street.Guid, street)
                              ).ToList().Distinct(new ObjectNode.ByNameComparer());

                foreach (var h in houses)
                {
                    cbHouse.Invoke((MethodInvoker)(() => cbHouse.Items.Add(h)));
                }


                lblLoading.Invoke((MethodInvoker)(() => lblLoading.Visible = false));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " [MainForm.cs, method: SetHousesByStreet]");
            }
        }
Example #3
0
        private void SetStreetsByCity()
        {
            ObjectNode city = null;

            cbCity.Invoke((MethodInvoker)(() => city = cbCity.SelectedItem as ObjectNode));

            if (city == null)
            {
                return;
            }

            cbStreet.Invoke((MethodInvoker)(() => cbStreet.Items.Clear()));
            cbStreet.Invoke((MethodInvoker)(() => cbStreet.SelectedIndex = -1));

            lblLoading.Invoke((MethodInvoker)(() => lblLoading.Visible = true));
            lblLoading.Invoke((MethodInvoker)(() => lblLoading.Text = "Загрузка всех улиц в " + city.ToString() + "."));

            foreach (var f in GetObjectsByParent(city.Guid))
            {
                if (f.AOLevel > 6)
                {
                    cbStreet.Invoke((MethodInvoker)(() => cbStreet.Items.Add(f)));
                }
            }

            lblLoading.Invoke((MethodInvoker)(() => lblLoading.Visible = false));
        }