Beispiel #1
0
        public void saveProduct(Product Pro)
        {
            cmd.CommandText = "INSERT INTO product(name, quantity, price)" +
                        " values(@name, @quantity, @price)";
            cmd.Parameters.AddWithValue("@name", Pro.getName());
            cmd.Parameters.AddWithValue("@quantity", Pro.getQuantity());
            cmd.Parameters.AddWithValue("@price", Pro.getPrice());

            cmd.ExecuteNonQuery();
            conn.Close();
        }
Beispiel #2
0
        public void updateProduct(Product Pro)
        {
            cmd.CommandText = " UPDATE product SET name = @name, quantity = @quantity, " +
                              " price = @price " +
                              " where id = @id ";
            cmd.Parameters.AddWithValue("@name", Pro.getName());
            cmd.Parameters.AddWithValue("@quantity", Pro.getQuantity());
            cmd.Parameters.AddWithValue("@price", Pro.getPrice());
            cmd.Parameters.AddWithValue("@id", Pro.getId());

            cmd.ExecuteNonQuery();
            conn.Close();
        }