Ejemplo n.º 1
0
    public void DeleteProduct(int id)
    {
        var command = new SqlCommand("delete from products where id=:id");

        command.Parameters.AddWithValue("id", id);
        MsSqlDatabaseHelpers.ExecuteNonQuery(command, ConnectionString);
    }
Ejemplo n.º 2
0
    public void UpdateProduct(Product product)
    {
        var command = new SqlCommand("update products set name=@name, description=@description, price=@price where id=@id");

        command.Parameters.AddWithValue("id", product.Id);
        command.Parameters.AddWithValue("name", product.Name);
        command.Parameters.AddWithValue("description", product.Description);
        command.Parameters.AddWithValue("price", product.Price);
        MsSqlDatabaseHelpers.ExecuteNonQuery(command, ConnectionString);
    }
Ejemplo n.º 3
0
    public void AddNewProduct(Product product)
    {
        var command = new SqlCommand("insert into products (id, name, description, price) values (@id, @name, @description, @price)");

        command.Parameters.AddWithValue("id", product.Id);
        command.Parameters.AddWithValue("name", product.Name);
        command.Parameters.AddWithValue("description", product.Description);
        command.Parameters.AddWithValue("price", product.Price);
        MsSqlDatabaseHelpers.ExecuteNonQuery(command, ConnectionString);
    }