protected void btSave_Click(object sender, EventArgs e) { CityClass obj = new CityClass(); obj.CityName = tbCityName.Text; obj.IsActive = cbIsActive.Checked; obj.PinCode = tbPinCode.Text; Int64 StateIDF = 0; Int64.TryParse(ddlState.SelectedValue, out StateIDF); obj.StateIDF = StateIDF; MEMBERS.SQLReturnValue mRes; if (hfID.Value == string.Empty) { obj.Flag = "ADD"; mRes = CityClass.Insert_Update_City(obj); } else { obj.Flag = "EDIT"; obj.CityIDP = Int64.Parse(hfID.Value); mRes = CityClass.Insert_Update_City(obj); } ScriptManager.RegisterStartupScript(this, this.GetType(), "noti", "setMessage('<b>" + mRes.MessageFromSQL + "</b>',1);", true); ClearControls(); BindData(); pnC.Visible = false; pnG.Visible = true; btAddNew.Visible = true; }
/// <summary> /// Classify the city based on its population. /// </summary> /// <param name="cityPopulation">Number of people in the city.</param> /// <returns>City classification.</returns> private CityClass getCityClass(long cityPopulation) { CityClass cityClassification = CityClass.CC_VILLAGE; if (cityPopulation > 2000) { cityClassification = CityClass.CC_TOWN; } if (cityPopulation > 10000) { cityClassification = CityClass.CC_CITY; } if (cityPopulation > 50000) { cityClassification = CityClass.CC_CAPITAL; } if (cityPopulation > 100000) { cityClassification = CityClass.CC_METROPOLIS; } if (cityPopulation > 500000) { cityClassification = CityClass.CC_MEGALOPOLIS; } return(cityClassification); }
public ActionResult Create(string name, string lengthOfStay, string whoWith) { CityClass myCity = new CityClass(lengthOfStay, whoWith); Place myPlace = new Place(name, myCity); return(View("Index", myPlace)); }
protected void rptData_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandArgument != null) { Int64 CityIDP = Int64.Parse(e.CommandArgument.ToString()); switch (e.CommandName) { case "cEdit": hfID.Value = CityIDP.ToString(); DataTable dtGetCity = CityClass.GetCity_ByCityIDP(CityIDP); if (dtGetCity.Rows.Count > 0) { tbCityName.Text = dtGetCity.Rows[0]["CityName"].ToString(); cbIsActive.Checked = bool.Parse(dtGetCity.Rows[0]["IsActive"].ToString()); tbPinCode.Text = dtGetCity.Rows[0]["PinCode"].ToString(); ddlState.SelectedValue = (!string.IsNullOrEmpty(dtGetCity.Rows[0]["StateIDF"].ToString()) ? dtGetCity.Rows[0]["StateIDF"].ToString() : "-1"); pnC.Visible = true; pnG.Visible = false; btAddNew.Visible = false; } break; case "cDelete": MEMBERS.SQLReturnValue mRes = CityClass.DeleteCity_ByCityID(CityIDP); ScriptManager.RegisterStartupScript(this, this.GetType(), "noti", "setMessage('<b>" + mRes.MessageFromSQL + "</b>',1);", true); ClearControls(); BindData(); break; } } }
public ActionResult SaveCity(string cityName, string state) { CityClass city = new CityClass(cityName, state); city.CitySave(); return(RedirectToAction("NewCity")); }
public void BindDDL() { DataTable dtState = StateClass.GetAllState(); if (dtState.Rows.Count > 0) { ddlState.DataTextField = "StateName"; ddlState.DataValueField = "StateIDP"; ddlState.DataSource = dtState; ddlState.DataBind(); ddlState.Items.Insert(0, new ListItem("--Select State--", "-1")); ddlState.SelectedIndex = 0; } DataTable dtCity = CityClass.GetAllCity(); if (dtCity.Rows.Count > 0) { ddlCity.DataTextField = "CityName"; ddlCity.DataValueField = "CityIDP"; ddlCity.DataSource = dtCity; ddlCity.DataBind(); ddlCity.Items.Insert(0, new ListItem("--Select City--", "-1")); ddlCity.SelectedIndex = 0; } }
/// <summary> /// Detect a change in city class, and produce a message if the player has /// reached the next class. /// TODO This code is very closely related to Micropolis::doPopNum(). /// Maybe merge both in some way? /// (This function gets called much more often however then doPopNum(). /// Also, at the first call, the difference between thisCityPop and /// cityPop is huge.) /// </summary> public void checkGrowth() { if ((cityTime & 3) == 0) { short category = 0; long thisCityPop = getPopulation(); if (cityPopLast > 0) { CityClass lastClass = getCityClass(cityPopLast); CityClass newClass = getCityClass(thisCityPop); if (lastClass != newClass) { // Switched class, find appropiate message. switch (newClass) { case CityClass.CC_VILLAGE: // Don't mention it. break; case CityClass.CC_TOWN: category = (short)MessageNumber.MESSAGE_REACHED_TOWN; break; case CityClass.CC_CITY: category = (short)MessageNumber.MESSAGE_REACHED_CITY; break; case CityClass.CC_CAPITAL: category = (short)MessageNumber.MESSAGE_REACHED_CAPITAL; break; case CityClass.CC_METROPOLIS: category = (short)MessageNumber.MESSAGE_REACHED_METROPOLIS; break; case CityClass.CC_MEGALOPOLIS: category = (short)MessageNumber.MESSAGE_REACHED_MEGALOPOLIS; break; default: throw new ArgumentOutOfRangeException(); } } } if (category > 0 && category != categoryLast) { sendMessage(category, NOWHERE, NOWHERE, true); categoryLast = category; } cityPopLast = thisCityPop; } }
public ActionResult NewFlight() { List <CityClass> allCities = CityClass.GetAll(); List <FlightClass> allFlights = FlightClass.GetAll(); Dictionary <string, object> model = new Dictionary <string, object> { }; model.Add("cities", allCities); model.Add("flights", allFlights); return(View(model)); }
public void GetAll_ReturnsEmptyListFromDatabase_CityClassList() { //Arrange List <CityClass> newList = new List <CityClass> { }; //Act List <CityClass> result = CityClass.GetAll(); //Assert CollectionAssert.AreEqual(newList, result); }
public ActionResult EditCity(int cityId) { foreach (var data in Bc.GetCityListByCityId(cityId)) { CityClass cc = new CityClass() { CityId = data.CityID, City = data.City1 }; CityClassList.Add(cc); } return(RedirectToAction("CityForm")); }
public void BindCity(Int64 StateIDF) { DataTable dtCity = CityClass.GetAllCityBy_StateIDF(StateIDF); if (dtCity.Rows.Count > 0) { ddlCity.DataTextField = "CityName"; ddlCity.DataValueField = "CityIDP"; ddlCity.DataSource = dtCity; ddlCity.DataBind(); ddlCity.Items.Insert(0, new ListItem("--Select City--", "-1")); ddlCity.SelectedIndex = 0; } }
public void Save_SavesToDatabase_CityList() { //Arrange string name = "Washington"; string state = "WA"; CityClass city = new CityClass(name, state); //Act city.CitySave(); List <CityClass> result = CityClass.GetAll(); List <CityClass> testList = new List <CityClass> { city }; //Assert CollectionAssert.AreEqual(testList, result); }
public ActionResult Show(string code) { Dictionary <object, object> model = new Dictionary <object, object>(); List <CountryClass> newList = CountryClass.GetAll(); List <CityClass> newCityList = CityClass.GetAll(); string currentName = ""; string currentContinent = ""; int currentPopulation = 0; string currentGov = ""; string currentCode = ""; CountryClass currentCountry = new CountryClass(currentName, currentContinent, currentPopulation, currentGov, currentCode); foreach (CountryClass country in newList) { if (country.GetCode() == code) { currentCountry.SetName(country.GetName()); currentCountry.SetContinent(country.GetContinent()); currentCountry.SetPopulation(country.GetPopulation()); currentCountry.SetGovernment(country.GetGovernment()); currentCountry.SetCode(country.GetCode()); model.Add("country", currentCountry); } } List <CityClass> totalCityList = new List <CityClass>() { }; foreach (CityClass city in newCityList) { if (city.GetCode() == code) { string cityName = city.GetName(); string cityCode = city.GetCode(); string cityDistrict = city.GetDistrict(); int cityPopulation = city.GetPopulation(); CityClass currentCity = new CityClass(cityName, cityCode, cityDistrict, cityPopulation); totalCityList.Add(currentCity); } } model.Add("cities", totalCityList); return(View(model)); }
private void BindCity(long mStateIDF) { DataTable dtCity = CityClass.GetAllCityBy_StateIDF(mStateIDF); if (dtCity.Rows.Count > 0) { ddcity.DataTextField = "CityName"; ddcity.DataValueField = "CityIDP"; ddcity.DataSource = dtCity; ddcity.DataBind(); ddcity.Items.Insert(0, new ListItem("--SELECT CITY--", "-1")); ddcity.SelectedIndex = 0; } else { ddcity.Items.Clear(); } }
/// <summary> /// Generate list of neighborhoods from JSON object /// </summary> /// <param name="jObject">jObject</param> /// <returns>List of neighborhood objects</returns> public static List <CityClass> HandleJSON(JObject jObject) { var list = jObject["features"]; List <CityClass> neighborhoods = new List <CityClass>(); foreach (var item in list) { CityClass city = new CityClass() { Address = (string)item["properties"]["address"], City = (string)item["properties"]["city"], State = (string)item["properties"]["state"], Zip = (int)item["properties"]["zip"], Borough = (string)item["properties"]["borough"], Neighborhood = (string)item["properties"]["neighborhood"], County = (string)item["properties"]["county"] }; neighborhoods.Add(city); } return(neighborhoods); }
public ActionResult City(string name) { List <CityClass> newCityList = CityClass.GetAll(); string cityName = ""; string cityCode = ""; string cityDistrict = ""; int cityPopulation = 0; CityClass currentCity = new CityClass(cityName, cityCode, cityDistrict, cityPopulation); foreach (CityClass city in newCityList) { if (city.GetName() == name) { currentCity.SetName(city.GetName()); currentCity.SetCode(city.GetCode()); currentCity.SetDistrict(city.GetDistrict()); currentCity.SetPopulation(city.GetPopulation()); } } return(View(currentCity)); }
public void Dispose() { CityClass.ClearAll(); }
public ActionResult Index() { List <CityClass> cityList = CityClass.GetAll(); return(View(cityList)); }
public void BindData() { rptData.DataSource = CityClass.GetAllCity(); rptData.DataBind(); }
public Place(string name, CityClass city) { _name = name; _city = city; }
/// <summary> /// Initialize simulator variables to a sane default. /// </summary> private void init() { roadTotal = 0; railTotal = 0; firePop = 0; resPop = 0; comPop = 0; indPop = 0; totalPop = 0; totalPopLast = 0; resZonePop = 0; comZonePop = 0; indZonePop = 0; totalZonePop = 0; hospitalPop = 0; churchPop = 0; faith = 0; stadiumPop = 0; policeStationPop = 0; fireStationPop = 0; coalPowerPop = 0; nuclearPowerPop = 0; seaportPop = 0; airportPop = 0; needHospital = 0; needChurch = 0; crimeAverage = 0; pollutionAverage = 0; landValueAverage = 0; cityTime = 0; cityMonth = 0; cityYear = 0; startingYear = 0; resHist10Max = 0; resHist120Max = 0; comHist10Max = 0; comHist120Max = 0; indHist10Max = 0; indHist120Max = 0; censusChanged = false; roadSpend = 0; policeSpend = 0; fireSpend = 0; roadFund = 0; policeFund = 0; fireFund = 0; roadEffect = 0; policeEffect = 0; fireEffect = 0; taxFund = 0; cityTax = 0; taxFlag = false; populationDensityMap.clear(); trafficDensityMap.clear(); populationDensityMap.clear(); landValueMap.clear(); crimeRateMap.clear(); powerGridMap.clear(); terrainDensityMap.clear(); rateOfGrowthMap.clear(); fireStationMap.clear(); fireStationEffectMap.clear(); policeStationMap.clear(); policeStationEffectMap.clear(); comRateMap.clear(); resHist = new short[HISTORY_LENGTH]; comHist = new short[HISTORY_LENGTH]; indHist = new short[HISTORY_LENGTH]; crimeHist = new short[HISTORY_LENGTH]; pollutionHist = new short[HISTORY_LENGTH]; moneyHist = new short[HISTORY_LENGTH]; miscHist = new short[HISTORY_LENGTH]; roadPercent = 0.0f; policePercent = 0.0f; firePercent = 0.0f; roadValue = 0; policeValue = 0; fireValue = 0; mustDrawBudget = 0; floodCount = 0; cityYes = 0; problemVotes = new short[(int)CityVotingProblems.PROBNUM]; problemOrder = new short[(int)CityVotingProblems.CVP_PROBLEM_COMPLAINTS]; cityPop = 0; cityPopDelta = 0; cityAssessedValue = 0; cityClass = CityClass.CC_VILLAGE; cityScore = 0; cityScoreDelta = 0; trafficAverage = 0; terrainTreeLevel = -1; terrainLakeLevel = -1; terrainCurveLevel = -1; terrainCreateIsland = -1; graph10Max = 0; graph120Max = 0; simLoops = 0; simPasses = 0; simPass = 0; simPaused = false; simPausedSpeed = 3; heatSteps = 0; heatFlow = -7; heatRule = 0; heatWrap = 3; cityFileName = ""; tilesAnimated = false; doAnimation = true; doMessages = true; doNotices = true; cityPopLast = 0; categoryLast = 0; autoGoto = false; powerStackPointer = 0; powerStackXY = new Position[POWER_STACK_SIZE]; for (int i = 0; i < POWER_STACK_SIZE; i++) { powerStackXY[i] = new Position(); } curMapStackXY = new Position[MAX_TRAFFIC_DISTANCE + 1]; for (int i = 0; i < MAX_TRAFFIC_DISTANCE + 1; i++) { curMapStackXY[i] = new Position(); } nextRandom = 1; homeDir = ""; resourceDir = ""; newMap = 0; newMapFlags = new short[(int)MapType.MAP_TYPE_COUNT]; cityCenterX = 0; cityCenterY = 0; pollutionMaxX = 0; pollutionMaxY = 0; crimeMaxX = 0; crimeMaxY = 0; donDither = 0; valveFlag = false; crimeRamp = 0; pollutionRamp = 0; resCap = false; // Do not block residential growth comCap = false; // Do not block commercial growth indCap = false; // Do not block industrial growth cashFlow = 0; disasterWait = 0; scoreWait = 0; poweredZoneCount = 0; unpoweredZoneCount = 0; newPower = false; cityTaxAverage = 0; simCycle = 0; phaseCycle = 0; speedCycle = 0; doInitialEval = false; mapSerial = 1; resValve = 0; comValve = 0; indValve = 0; globalSprites = new SimSprite[(int)SpriteType.SPRITE_COUNT]; absDist = 0; spriteCycle = 0; totalFunds = 0; autoBulldoze = true; autoBudget = true; gameLevel = GameLevel.LEVEL_EASY; initSimLoad = 0; simSpeed = 0; simSpeedMeta = 0; enableSound = false; enableDisasters = true; evalChanged = false; blinkFlag = 0; mustUpdateFunds = false; mustUpdateOptions = false; cityTimeLast = 0; cityYearLast = 0; cityMonthLast = 0; totalFundsLast = 0; resLast = 0; comLast = 0; indLast = 0; simInit(); }