Exemplo 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;
        }
Exemplo 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);
        }
Exemplo 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;
        }
Exemplo n.º 4
0
 public static void UpdateCountry(Country country)
 {
     CountryDB.UpdateCountry(country);
 }
Exemplo n.º 5
0
 public static Country InsertCountry(Country country)
 {
     return CountryDB.InsertCountry(country);
 }