Esempio n. 1
0
        private static Country GetCountryFromReader(IDataReader dataReader)
        {
            Country country = new Country();
            country.CountryID = DBHelper.GetInt(dataReader, "CountryID");
            country.Name = DBHelper.GetString(dataReader, "Name");

            return country;
        }
Esempio n. 2
0
        public static void UpdateCountry(Country country)
        {
            string sqlQuery = "UPDATE Country SET Name=@Name WHERE CountryID=" + country.CountryID;

            Database db = new SqlDatabase(DBHelper.GetConnectionString());
            DbCommand dbCommand = db.GetSqlStringCommand(sqlQuery);
            db.AddInParameter(dbCommand, "Name", DbType.String, country.Name);

            db.ExecuteNonQuery(dbCommand);
        }
Esempio n. 3
0
        public static Country InsertCountry(Country country)
        {
            string sqlQuery = "INSERT INTO Country(Name) " +
                " VALUES(@Name);SELECT @@Identity";

            Database db = new SqlDatabase(DBHelper.GetConnectionString());
            DbCommand dbCommand = db.GetSqlStringCommand(sqlQuery);
            db.AddInParameter(dbCommand, "Name", DbType.String, country.Name);
            country.CountryID = Convert.ToInt32(db.ExecuteScalar(dbCommand));

            return country;
        }
Esempio n. 4
0
 public static void UpdateCountry(Country country)
 {
     CountryDB.UpdateCountry(country);
 }
Esempio n. 5
0
 public static Country InsertCountry(Country country)
 {
     return CountryDB.InsertCountry(country);
 }