Пример #1
0
        public IEnumerable<Country> LoadCountries()
        {
            //#region can remove

            //string[] cc = new string[] { "Ukraine", "USA", "Canada", "German", "Spain", "Poland" };

            //#endregion

            var list = new List<Country>();

            var reader = CDatabase.Instance.Execute(modSQL.SelectCountryes());

            Country country = null;
            try
            {
                while(reader.Read())
                {
                    country = new Country();
                    country.Id = reader.GetString(0);
                    country.Name = reader.GetString(1);
                    country.Status = Common.Interfaces.Status.Normal;
                    list.Add(country);
                }
                reader.Close();
            }
            catch
            {
                if (reader != null)
                    reader.Close();
            }

            //#region can remove
            //if (list.Count == 0)
            //{

            //	for (int i = 0; i < cc.Length; i++)
            //	{
            //		list.Add(new Country() { Id = i.ToString(), Name = cc[i] });
            //	}
            //}
            //#endregion

            return list;
        }
Пример #2
0
 public static string UpdateCountry(Country c)
 {
     string query = @"UPDATE Countryes SET City='{0}' WHERE Id='{1}';";
     return string.Format(query, c.Name, c.Id);
 }
Пример #3
0
 public static string InsertCountry(Country c)
 {
     string query = @"INSERT INTO Countryes(Id,CountryName) VALUES('{0}', '{1}');";
     return string.Format(query, c.Id, c.Name);
 }
Пример #4
0
 private bool UpdateCountry(Country country)
 {
     string str = modSQL.UpdateCountry(country);
     return CDatabase.Instance.ExecuteNonQuery(str);
 }