示例#1
0
        public List <CityView> ViewCity()
        {
            List <CityView> citiesView = new List <CityView>();

            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT * FROM CityView ORDER BY CityName";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader       = command.ExecuteReader();
            CityView      aNewCityView = null;

            while (reader.Read())
            {
                string cityName     = reader["CityName"].ToString();
                string aboutCity    = reader["About"].ToString();
                int    noOfDwellers = Convert.ToInt32(reader["NoOfdwellers"]);
                string location     = reader["Location"].ToString();
                string weather      = reader["Weather"].ToString();
                string country      = reader["Country"].ToString();
                string aboutCountry = reader["AboutCountry"].ToString();
                aNewCityView = new CityView(country, aboutCountry, cityName, aboutCity, noOfDwellers, location, weather);
                citiesView.Add(aNewCityView);
            }
            connection.Close();
            return(citiesView);
        }
示例#2
0
        private void CreateCity(int nameId)
        {
            _city = Game.AddCity(_player, nameId, _x, _y);
            if (_city != null)
            {
                if (_player.IsHuman)
                {
                    // TODO fire-eggs not showing may lose side-effects
                    //if (!Game.Animations)
                    {
                        CityView cityView = new CityView(_city, founded: true);
                        cityView.Closed  += CityFounded;
                        cityView.Skipped += CityViewed;
                        Common.AddScreen(cityView);
                        return;
                    }

                    {
                        CityManager cityManager = new CityManager(_city);
                        cityManager.Closed += CityManagerClosed;
                        Common.AddScreen(cityManager);
                        return;
                    }
                }
                if (_unit != null)
                {
                    Game.DisbandUnit(_unit);
                }
            }
            Game.UpdateResources(_city.Tile);
            EndTask();
        }
示例#3
0
        public List <CityView> GetAllInfoCity()
        {
            List <CityView> cities = new List <CityView>();

            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "Select * from CityView ORDER BY CityName";

            connection.Open();

            SqlCommand command = new SqlCommand(query, connection);

            SqlDataReader reader       = command.ExecuteReader();
            CityView      aNewCityView = null;

            while (reader.Read())
            {
                string cityname     = reader["CityName"].ToString();
                int    noOfDwellers = Convert.ToInt32(reader["NoOfdwellers"]);
                string country      = reader["Country"].ToString();

                aNewCityView              = new CityView();
                aNewCityView.CityName     = cityname;
                aNewCityView.NoOfDwellers = noOfDwellers;
                aNewCityView.CountryName  = country;

                cities.Add(aNewCityView);
            }
            connection.Close();
            return(cities);
        }
示例#4
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
示例#5
0
        public void Edit(CityView view)
        {
            City city = UnitOfWork.To <City>(view);

            UnitOfWork.Update(city);
            UnitOfWork.Commit();
        }
        private void MenuItemCity_Click(object sender, RoutedEventArgs e)
        {
            CityView view = new CityView();

            view.Owner = this;
            view.Show();
        }
        //public IActionResult GetCities(string countryCode)
        //{
        //    CitySqlDAO dao = new CitySqlDAO(connectionString);
        //    IList<City> cities = dao.GetCities(countryCode);

        //    return View(cities);
        //}

        //public IActionResult GetCities(string countryCode, string district)
        //{
        //    CitySqlDAO dao = new CitySqlDAO(connectionString);
        //    IList<City> cities = dao.GetCities(countryCode, district);

        //    return View(cities);
        //}

        public IActionResult GetCities(CityView city)
        {
            CitySqlDAO   dao    = new CitySqlDAO(connectionString);
            IList <City> cities = dao.GetCities(city.CountryCode, city.district);

            return(View(cities));
        }
示例#8
0
        public override void Run()
        {
            if (Human != _city.Owner)
            {
                Console.WriteLine($"{_city.Name} builds {(_improvement as ICivilopedia).Name}.");
                EndTask();
                return;
            }

            IScreen cityView;

            if (!Settings.Animations)
            {
                cityView = new Newspaper(_city, new string[] { $"{_city.Name} builds", $"{(_improvement as ICivilopedia).Name}." }, showGovernment: false);
            }
            else if (_improvement is IBuilding)
            {
                cityView = new CityView(_city, production: (_improvement as IBuilding));
            }
            else if (_improvement is IWonder)
            {
                cityView = new CityView(_city, production: (_improvement as IWonder));
            }
            else
            {
                EndTask();
                return;
            }
            cityView.Closed += ClosedCityView;
            Common.AddScreen(cityView);
        }
示例#9
0
        private void CityFounded(object sender, EventArgs args)
        {
            CityView cityView = new CityView(_city, firstView: true);

            cityView.Closed += CityViewed;
            Common.AddScreen(cityView);
        }
示例#10
0
        public List <CityView> GetAllCity()
        {
            connection.ConnectionString = connectionString;
            string     query   = "SELECT * FROM CityView";
            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader   reader   = command.ExecuteReader();
            List <CityView> cityList = new List <CityView>();

            while (reader.Read())
            {
                CityView cityView = new CityView();
                cityView.CityName  = reader["CityName"].ToString();
                cityView.CityAbout = reader["CityAbout"].ToString();
                if (!reader["NoOfDwellers"].Equals(System.DBNull.Value))
                {
                    cityView.NoOfDwellers = reader.GetInt64(reader.GetOrdinal("NoOfDwellers"));
                }
                else
                {
                    cityView.NoOfDwellers = 0;
                }

                cityView.Location     = reader["Location"].ToString();
                cityView.Weather      = reader["Weather"].ToString();
                cityView.CountryName  = reader["CountryName"].ToString();
                cityView.CountryAbout = reader["CountryAbout"].ToString();
                cityList.Add(cityView);
            }
            reader.Close();
            connection.Close();
            return(cityList);
        }
示例#11
0
        internal List <CityView> SearchByCountryName(string countryName)
        {
            List <CityView> citiesView = new List <CityView>();

            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT * FROM CityView WHERE Country LIKE '%' + @countryName + '%'";
            SqlCommand    command    = new SqlCommand(query, connection);

            command.Parameters.Clear();
            command.Parameters.Add("@countryName", SqlDbType.VarChar);
            command.Parameters["@countryName"].Value = countryName;
            connection.Open();
            SqlDataReader reader       = command.ExecuteReader();
            CityView      aNewCityView = null;

            while (reader.Read())
            {
                string cityName     = reader["CityName"].ToString();
                string aboutCity    = reader["About"].ToString();
                int    noOfDwellers = Convert.ToInt32(reader["NoOfdwellers"]);
                string location     = reader["Location"].ToString();
                string weather      = reader["Weather"].ToString();
                string country      = reader["Country"].ToString();
                string aboutCountry = reader["AboutCountry"].ToString();
                aNewCityView = new CityView(country, aboutCountry, cityName, aboutCity, noOfDwellers, location, weather);
                citiesView.Add(aNewCityView);
            }
            connection.Close();
            return(citiesView);
        }
示例#12
0
        public IActionResult GetForm()
        {
            CityView cityView = new CityView();

            cityView.CountryCode = "USA";

            return(View(cityView));
        }
示例#13
0
    private Dictionary <Vector3, SimpleMapPlaceable> _placedBuildingDictionary; // A dict of all placed Object in the map. Used to avoid collisions.

    #endregion

    #region Constructors

    public BuildingManager()
    {
        _placedBuildingDictionary = new Dictionary <Vector3, SimpleMapPlaceable>();
        _routeCreationView        = Object.FindObjectOfType <TransportRouteCreationView>();
        _productProcessorView     = Object.FindObjectOfType <ProductProcessorView>();
        _cityView                         = Object.FindObjectOfType <CityView>();
        _storageContainerView             = Object.FindObjectOfType <StorageContainerView>();
        SimpleMapPlaceable.OnClickAction += OnPlaceableClick;
    }
示例#14
0
        public void Create(CityView view)
        {
            City city = UnitOfWork.To <City>(view);

            city.StateId = view.StateId;
            city.Name    = view.Name;

            UnitOfWork.Insert(city);
            UnitOfWork.Commit();
        }
示例#15
0
 public IActionResult Calendar(int skip = 0) => _authenticationProvider.SomeIfAdministrator(User).Map(
     administrator =>
 {
     var now      = DateTime.UtcNow;
     var nowMonth = new DateTime(now.Year, now.Month, 1);
     var month    = nowMonth.AddMonths(-skip);
     var talks    = _talkService.List(month, month.AddMonths(1), administrator.City);
     return((IActionResult)View(new TalkCalendarView(month, CityView.FromDomain(administrator.City), talks.Select(TalkView.FromDomain).ToArray())));
 }
     ).ValueOr(() => RedirectToAction("Administrator", "Authentication"));
示例#16
0
        public void SelectValue(object sender, EventArgs e)
        {
            int[] rows = CityView.GetSelectedRows();

            SelectedValue = Convert.ToInt32(CityView.GetRowCellValue(rows[0], "Id"));
            SelectedCode  = CityView.GetRowCellValue(rows[0], "Name").ToString();
            SelectedText  = CityView.GetRowCellValue(rows[0], "Name").ToString();

            Hide();
        }
示例#17
0
        public void Get_ReturnsViewById()
        {
            CityView actual   = service.Get <CityView>(city.Id);
            CityView expected = Mapper.Map <CityView>(city);

            Assert.Equal(expected.CreationDate, actual.CreationDate);
            Assert.Equal(expected.Id, actual.Id);

            Assert.True(false, "Not all properties tested");
        }
示例#18
0
        public ActionResult Edit(CityView city)
        {
            if (!Validator.CanEdit(city))
            {
                return(View(city));
            }

            Service.Edit(city);

            return(RedirectIfAuthorized("Index"));
        }
示例#19
0
        public ActionResult Create([Bind(Exclude = "Id")] CityView city)
        {
            if (!Validator.CanCreate(city))
            {
                return(View(city));
            }

            Service.Create(city);

            return(RedirectIfAuthorized("Index"));
        }
示例#20
0
        private void CityView_Click(object sender, EventArgs e)
        {
            City     city     = (player.availableActions.First(a => a is InteractCity) as InteractCity).city;
            CityView cityView = new CityView(city, player, this);

            controller.Stop();
            cityView.ShowDialog();
            if (running)
            {
                controller.Start();
            }
        }
示例#21
0
        public CitiesControllerTests()
        {
            validator = Substitute.For <ICityValidator>();
            service   = Substitute.For <ICityService>();

            city = ObjectFactory.CreateCityView();

            controller = Substitute.ForPartsOf <CitiesController>(validator, service);
            controller.ControllerContext = new ControllerContext {
                RouteData = new RouteData()
            };
        }
示例#22
0
 private void GetFocusedRowData(int index)
 {
     if (index >= 0 && CityView.RowCount > 0)
     {
         CityView.FocusedRowHandle = index;
         btnSave.Enabled           = false;
         btnAddNew.Enabled         = btnModify.Enabled = true;
         txtCityCode.Text          = CityView.GetRowCellValue(index, CityManager.CityDetails.CityCode.ToString()).ToString();
         txtCityName.Text          = CityView.GetRowCellValue(index, CityManager.CityDetails.CityName.ToString()).ToString();
         cmbCountry.Text           = CityView.GetRowCellValue(index, CityManager.CityDetails.CountryName.ToString()).ToString();
     }
 }
示例#23
0
 public CityController(CityDatabase cityDatabase,
                       CityView cityView,
                       DayCounterController dayCounterController,
                       HourController hourController,
                       BuildingInfoBuyPanelPresenter buildingInfoBuyPanelPresenter)
 {
     _cityDatabase                  = cityDatabase;
     _cityView                      = cityView;
     _dayCounterController          = dayCounterController;
     _hourController                = hourController;
     _buildingInfoBuyPanelPresenter = buildingInfoBuyPanelPresenter;
 }
示例#24
0
        public void Create_City()
        {
            CityView view = ObjectFactory.CreateCityView(1);

            service.Create(view);

            City     actual   = context.Set <City>().AsNoTracking().Single(model => model.Id != city.Id);
            CityView expected = view;

            Assert.Equal(expected.CreationDate, actual.CreationDate);

            Assert.True(false, "Not all properties tested");
        }
示例#25
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Request.QueryString["action"] != null)
     {
         string shortSpelling = string.Empty;
         string spelling      = string.Empty;
         int    hotlevel      = 0;
         if (!string.IsNullOrEmpty(this.txtShortSpelling.Text.Trim()))
         {
             shortSpelling = this.txtShortSpelling.Text.Trim();
         }
         if (!string.IsNullOrEmpty(this.txtSpelling.Text.Trim()))
         {
             spelling = this.txtSpelling.Text.Trim();
         }
         if (!string.IsNullOrEmpty(this.txtHotLevel.Text.Trim()))
         {
             hotlevel = int.Parse(this.txtHotLevel.Text.Trim());
         }
         CityView cityView = new CityView()
         {
             Code          = this.txtCityCode.Text.Trim(),
             Name          = this.txtCityName.Text.Trim(),
             ProvinceCode  = this.ddlProvinceName.SelectedValue,
             ShortSpelling = shortSpelling,
             Spelling      = spelling,
             HotLevel      = hotlevel
         };
         if (Request.QueryString["action"].ToString() == "add")
         {
             try
             {
                 FoundationService.AddCity(cityView, "");
                 RegisterScript("alert('添加成功!'); window.location.href='City.aspx'");
             } catch (Exception ex) {
                 ShowExceptionMessage(ex, "添加");
             }
         }
         else
         {
             try
             {
                 FoundationService.UpdateCity(cityView, "");
                 RegisterScript("alert('修改成功!'); window.location.href='City.aspx?Search=Back'");
             } catch (Exception ex) {
                 ShowExceptionMessage(ex, "修改");
             }
         }
     }
 }
示例#26
0
 internal static City GetCity(CityView cityView)
 {
     if (null == cityView)
     {
         throw new ArgumentNullException("cityView");
     }
     cityView.Validate();
     return(new City(cityView.Code.Trim())
     {
         ProvinceCode = StringUtility.Trim(cityView.ProvinceCode),
         Name = StringUtility.Trim(cityView.Name),
         Spelling = StringUtility.Trim(cityView.Spelling),
         ShortSpelling = StringUtility.Trim(cityView.ShortSpelling),
         HotLevel = cityView.HotLevel
     });
 }
示例#27
0
        public void Edit_City()
        {
            CityView view = ObjectFactory.CreateCityView(city.Id);

            Assert.True(false, "No update made");

            service.Edit(view);

            City actual   = context.Set <City>().AsNoTracking().Single();
            City expected = city;

            Assert.Equal(expected.CreationDate, actual.CreationDate);
            Assert.Equal(expected.Id, actual.Id);

            Assert.True(false, "Not all properties tested");
        }
示例#28
0
    private CityView CreateCityView(Transform parent, MapView mapView, City city, string prefabName)
    {
        var unitPrefab = Resources.Load <CityView>(prefabName);

        if (unitPrefab == null)
        {
            Debug.LogError("Can't load unit " + prefabName);
            return(null);
        }
        CityView cityView = Instantiate(unitPrefab);

        cityView.gameObject.SetActive(true);
        cityView.transform.parent = parent;
        cityView.Init(city, mapView.CellCoordToPosition(city.Coordinate));
        return(cityView);
    }
示例#29
0
        public static void AddCity(CityView cityView, string account)
        {
            var city = City.GetCity(cityView);

            if (QueryCity(city.Code) != null)
            {
                throw new ChinaPay.Core.Exception.KeyRepeatedException("代码[" + city.Code + "]已存在");
            }
            var sameNameCity = QueryCityByName(city.Name);

            if (sameNameCity != null && sameNameCity.ProvinceCode == city.ProvinceCode)
            {
                throw new ChinaPay.Core.Exception.KeyRepeatedException("名称[" + city.Name + "]已存在");
            }
            CityCollection.Instance.Add(city.Code, city);
            saveAddLog("市", city.ToString(), city.Code, account);
        }
示例#30
0
        public List <CityView> GetCityByCountryName(string countrySearchName)
        {
            connection.ConnectionString = connectionString;
            string query = "SELECT * FROM CityView WHERE (CountryName LIKE '%'+@countrySearchName+'%')";


            SqlCommand command = new SqlCommand(query, connection);

            command.Parameters.Add("countrySearchName", SqlDbType.VarChar);
            command.Parameters["countrySearchName"].Value = countrySearchName;

            List <CityView> cityList = new List <CityView>();

            connection.Open();
            SqlDataReader reader   = command.ExecuteReader();
            CityView      cityView = null;

            while (reader.Read())
            {
                cityView           = new CityView();
                cityView.CityName  = reader["CityName"].ToString();
                cityView.CityAbout = reader["CityAbout"].ToString();
                if (!reader["NoOfDwellers"].Equals(System.DBNull.Value))
                {
                    cityView.NoOfDwellers = reader.GetInt64(reader.GetOrdinal("NoOfDwellers"));
                }
                else
                {
                    cityView.NoOfDwellers = 0;
                }


                cityView.Location     = reader["Location"].ToString();
                cityView.Weather      = reader["Weather"].ToString();
                cityView.CountryName  = reader["CountryName"].ToString();
                cityView.CountryAbout = reader["CountryAbout"].ToString();
                cityList.Add(cityView);
            }
            reader.Close();
            connection.Close();
            return(cityList);
        }