示例#1
0
        protected void UpdateByCountry()
        {
            if (cmbCountries.SelectedItem != null)
            {
                MCountryData mdata     = (MCountryData)cmbCountries.SelectedItem;
                int          IDCountry = mdata.Id;

                StatesHelper sth = new StatesHelper(IDCountry);

                cmbState.ValueMember   = "Id";
                cmbState.DisplayMember = "StateRegion1";
                cmbState.DataSource    = sth.Data;
                int idstate = 0;
                if (sth.Data != null)
                {
                    MStateRegionData sdata = (MStateRegionData)cmbState.SelectedItem;
                    if (sdata != null)
                    {
                        idstate = sdata.Id;
                    }
                }

                UpdateCityData(IDCountry, idstate);
            }
        }
示例#2
0
        protected void GetData(bool withItemselect)
        {
            NostradamusGeoContextFactory factory = new NostradamusGeoContextFactory();

            using (var context = factory.CreateDbContext(new string[] { Constants.ConnectionGeoLocal }))
            {
                try
                {
                    var data = context.StateRegions.Where(x => x.CountryRef == IDCountry).OrderBy(x => x.StateRegion1).ToList();
                    Data = ModelsTransformer.TransferModelList <StateRegion, MStateRegionData>(data);
                    if (withItemselect)
                    {
                        MStateRegionData mdata = new MStateRegionData()
                        {
                            Acronym      = "NO",
                            CountryRef   = 0,
                            Id           = 0,
                            StateRegion1 = "Please select..."
                        };
                        Data.Insert(0, mdata);
                    }
                }
                catch (Exception ex)
                {
                    LogMaster lm = new LogMaster();
                    lm.SetLog(ex.Message);
                }
            }
        }