Esempio n. 1
0
        private void onFindAbonents()
        {
            Mouse.OverrideCursor = Cursors.Wait;

            //var finder = ServiceLocator.Current.GetInstance<IFinderService>();


            try {
                if (this.LS != null)
                {
                    // find for abonent
                    var rslt = _finder.FindAbonent(this.LS.GetValueOrDefault(0));
                    if (rslt != null)
                    {
                        clearCurrentAbonent();
                        this.Abonents.Add(rslt);
                        this.ResultVisible  = Visibility.Visible;
                        this.AbonentVisible = Visibility.Visible;
                    }
                    else
                    {
                        MessageBox.Show(
                            "Не найден абонент с таким номером лицевого счета.",
                            "Сообщение",
                            MessageBoxButton.OK,
                            MessageBoxImage.Information
                            );
                    }
                }
                else if (this.Family != null && this.Family != "")
                {
                    var rslts = _finder.FindAbonents(this.Family);
                    if (rslts != null)
                    {
                        clearCurrentAbonent();
                        foreach (var item in rslts)
                        {
                            this.Abonents.Add(item);
                        }
                        this.ResultVisible  = Visibility.Visible;
                        this.AbonentVisible = Visibility.Visible;
                    }
                    else
                    {
                        MessageBox.Show(
                            "Не найдены абоненты с такими фамилиями.",
                            "Сообщение",
                            MessageBoxButton.OK,
                            MessageBoxImage.Information
                            );
                    }
                }
                else if (
                    this.CurrentSettlement != null ||
                    this.CurrentHouse != null ||
                    this.CurrentHouse != "" ||
                    this.CurrentStreet != null ||
                    this.CurrentStreet != ""
                    )
                {
                    string settl = null;
                    if (this.CurrentSettlement != null)
                    {
                        settl = this.CurrentSettlement.Name;
                    }

                    var rslt = _finder.FindAbonents(
                        this.Family, settl,
                        this.CurrentStreet,
                        this.CurrentHouse,
                        this.CurrentAppartment
                        );

                    if (rslt != null)
                    {
                        clearCurrentAbonent();
                        foreach (var item in rslt)
                        {
                            this.Abonents.Add(item);
                        }
                        this.ResultVisible  = Visibility.Visible;
                        this.AbonentVisible = Visibility.Visible;
                    }
                    else
                    {
                        MessageBox.Show(
                            "Не найдены абоненты с такими условиями поиска.",
                            "Сообщение",
                            MessageBoxButton.OK,
                            MessageBoxImage.Information
                            );
                    }
                }
            }

            catch (Exception e) {
                MessageBox.Show(
                    e.Message + "\n" + e.InnerException.Message,
                    "Ошибка",
                    MessageBoxButton.OK,
                    MessageBoxImage.Information
                    );;
            }

            finally {
                Mouse.OverrideCursor = null;
            }
        }