public List <ViewCountry> SearchACountry(string aCountry) { SqlConnection connection = new SqlConnection(connectionString); string query = "SELECT * FROM ViewCountry WHERE CountryName LIKE '%" + aCountry + "%'"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); List <ViewCountry> countryList = new List <ViewCountry>(); while (reader.Read()) { string countryName = reader["CountryName"].ToString(); string countryAbout = reader["CountryAbout"].ToString(); int noOfCity = Convert.ToInt32(reader["NoOfCity"].ToString()); string noOfCityDwellers = reader["NoOfCityDwellers"].ToString(); ViewCountry country = new ViewCountry(countryName, countryAbout, noOfCity, noOfCityDwellers); country.TotalNoOfCityDwellers = Convert.ToInt32(noOfCityDwellers); countryList.Add(country); } reader.Close(); connection.Close(); return(countryList); }
public List <ViewCountry> ViewCountyGetAll(string searchCountry) { string viewContryGetAllQuery = "SELECT * FROM tb_country WHERE name LIKE '%'+ @name +'%' ORDER BY name"; SqlCommand command = new SqlCommand(viewContryGetAllQuery, connection); command.Parameters.Clear(); command.Parameters.Add("name", SqlDbType.VarChar); command.Parameters["name"].Value = searchCountry; connection.Open(); SqlDataReader reader = command.ExecuteReader(); List <ViewCountry> viewCountryList = new List <ViewCountry>(); while (reader.Read()) { ViewCountry viewCountry = new ViewCountry(); viewCountry.ViewCountryid = Convert.ToInt32(reader["id"]); viewCountry.ViewCountryName = reader["name"].ToString(); viewCountry.ViewCountryAbout = reader["about"].ToString(); viewCountryList.Add(viewCountry); } reader.Close(); connection.Close(); return(viewCountryList); }
public List <ViewCountry> ViewCountyGetAll() { string viewContryGetAllQuery = "SELECT * FROM tb_country"; SqlCommand command = new SqlCommand(viewContryGetAllQuery, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); List <ViewCountry> viewCountryList = new List <ViewCountry>(); while (reader.Read()) { ViewCountry viewCountry = new ViewCountry(); viewCountry.ViewCountryid = Convert.ToInt32(reader["id"]); viewCountry.ViewCountryName = reader["name"].ToString(); viewCountry.ViewCountryAbout = reader["about"].ToString(); viewCountryList.Add(viewCountry); } reader.Close(); connection.Close(); return(viewCountryList); }
internal static void ExecScores() { Console.WriteLine("Scores !"); Console.WriteLine("Pays 1:"); Country ct1 = ViewCountry.NewCountry(false); Console.WriteLine("Pays 2:"); Country ct2 = ViewCountry.NewCountry(false); Scores scores = CalcScores.DoCalcScores(ct1.Pts, ct2.Pts); ct1.Score = scores.Score1; ct2.Score = scores.Score2; ViewScores.DoViewScores(ct1, ct2); }
public List <ViewCountry> ViewCountyGetAll(string searchCountry) { ViewCountryGateway viewCountryGateway = new ViewCountryGateway(); List <ViewCountry> getFullViewCuntryList = new List <ViewCountry>(); if (searchCountry == "") { List <ViewCountry> viewCountryList = viewCountryGateway.ViewCountyGetAll(); foreach (ViewCountry elemnt in viewCountryList) { ViewCountry aViewCountry = new ViewCountry(); aViewCountry.ViewCountryid = elemnt.ViewCountryid; aViewCountry.ViewCountryName = elemnt.ViewCountryName; aViewCountry.ViewCountryAbout = elemnt.ViewCountryAbout; aViewCountry.viewCountryNoOfCitys = viewCountryGateway.NoOfCityGetway(aViewCountry.ViewCountryid); aViewCountry.viewCountryNoOfCityDrewlers = viewCountryGateway.NoOfCityDrewlersGetway(aViewCountry.ViewCountryid); getFullViewCuntryList.Add(aViewCountry); } } else { List <ViewCountry> viewCountryList = viewCountryGateway.ViewCountyGetAll(searchCountry); foreach (ViewCountry elemnt in viewCountryList) { ViewCountry aViewCountry = new ViewCountry(); aViewCountry.ViewCountryid = elemnt.ViewCountryid; aViewCountry.ViewCountryName = elemnt.ViewCountryName; aViewCountry.ViewCountryAbout = elemnt.ViewCountryAbout; aViewCountry.viewCountryNoOfCitys = viewCountryGateway.NoOfCityGetway(aViewCountry.ViewCountryid); aViewCountry.viewCountryNoOfCityDrewlers = viewCountryGateway.NoOfCityDrewlersGetway(aViewCountry.ViewCountryid); getFullViewCuntryList.Add(aViewCountry); } } return(getFullViewCuntryList); }
internal static void ExecPoints() { Console.WriteLine("Points !"); Console.WriteLine("Pays 1:"); Country ct1 = ViewCountry.NewCountry(true); Console.WriteLine("Pays 2:"); Country ct2 = ViewCountry.NewCountry(true); int coeff = ViewPoints.GetCoeff(); int diff = ct1.Score - ct2.Score; Points points = CalcPoints.DoCalcPoints(ct1.Pts, ct2.Pts, coeff, diff); ct1.Pts = points.Pts1; ct2.Pts = points.Pts2; ViewPoints.DoViewPoints(ct1, ct2); }
public int NoOfCityGetway(int ViewCountryid) { string selectQuery = string.Format("SELECT count(name) as count FROM t_city WHERE countryId='{0}'", ViewCountryid); SqlCommand command = new SqlCommand(selectQuery, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); ViewCountry viewCountry = new ViewCountry(); while (reader.Read()) { viewCountry.viewCountryNoOfCitys = Convert.ToInt32(reader["count"]); } reader.Close(); connection.Close(); return(viewCountry.viewCountryNoOfCitys); }
public string NoOfCityDrewlersGetway(int ViewCountryid) { string selectQuery = string.Format("SELECT sum(noOfDwellers) as count FROM t_city WHERE countryId='{0}'", ViewCountryid); SqlCommand command = new SqlCommand(selectQuery, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); ViewCountry viewCountry = new ViewCountry(); while (reader.Read()) { viewCountry.viewCountryNoOfCityDrewlers = reader["count"].ToString(); } reader.Close(); connection.Close(); return(viewCountry.viewCountryNoOfCityDrewlers); }
public bool SearchCountry(ViewCountry aViewCountry) { throw new NotImplementedException(); }