Exemplo n.º 1
0
        public int Check(Address address)
        {
            _address = address;

            string curCode = "00";

            if (address.KodReg == "")
            {
                _model.KodReg = "0000000000000";
                curCode = "00";
            }
            else
            {
                _model.KodReg = address.KodReg;
                curCode = address.KodReg;
            }

            if ((address.Raion == "") && (address.Gorod == "") && (address.NasPunkt == "") &&
                (address.Ulica == ""))
            {
                ErrorItem = Address.AddressItems.None;
                return 0;
            }

            // Проверяем район
            if (address.Raion != "")
            {
                _model.Raion = CheckItem(address.Raion, curCode, "KLADR");
                if (_model.Raion != "")
                {
                    _model.Raion = _model.Raion.Remove(5);
                    curCode = _model.Raion;
                }
                else
                {
                    ErrorItem = Address.AddressItems.Raion;
                    return 1;
                }
            }
            else
                _model.Raion = "";

            // Проверяем город
            if (address.Gorod != "")
            {
                _model.Gorod = CheckItem(address.Gorod, curCode, "KLADR");
                if (_model.Gorod != "")
                {
                    _model.Gorod = _model.Gorod.Remove(8);
                    curCode = _model.Gorod;
                }
                else
                {
                    ErrorItem = Address.AddressItems.Gorod;
                    return 1;
                }
            }
            else
                _model.Gorod = "";

            // Проверяем населенный пункт
            if (address.NasPunkt != "")
            {
                _model.NasPunkt = CheckItem(address.NasPunkt, curCode, "KLADR");
                if (_model.NasPunkt != "")
                {
                    _model.NasPunkt = _model.NasPunkt.Remove(11);
                    curCode = _model.NasPunkt;
                }
                else
                {
                    ErrorItem = Address.AddressItems.NasPunkt;
                    return 1;
                }
            }
            else
                _model.NasPunkt = "";

            // Проверяем улицу
            if (address.Ulica != "")
            {
                _model.Ulica = CheckItem(address.Ulica, curCode, "STREET");
                if (_model.Ulica != "")
                {
                    _model.Ulica = _model.Ulica.Remove(13);
                    curCode = _model.Ulica;
                }
                else
                {
                    ErrorItem = Address.AddressItems.Ulica;
                    return 1;
                }
            }
            else
                _model.Ulica = "";

            _model.CurrentCode = curCode;

            AutoUpdateAddress();

            ErrorItem = Address.AddressItems.None;
            return 0;
        }
Exemplo n.º 2
0
 public Worker()
 {
     _address = new Address();
 }