コード例 #1
0
        public void addProduct(Product product)
        {
            using (var connection = new SQLiteConnection(connString)){
                connection.Open();
                string addProductQuerry = String.Format(@"INSERT INTO PRODUCTS
                                                        (PRODUCT_NAME, PRODUCT_PRICE) VALUES
                                                        ('{0}', '{1}')", product.Name, product.Price);

                SQLiteCommand addProductCommand = new SQLiteCommand(addProductQuerry, connection);
                addProductCommand.ExecuteNonQuery();
            }
        }
コード例 #2
0
 private void Button_Product_Add_Click(object sender, RoutedEventArgs e)
 {
     if (nameOfProduct.Text.Equals("") || priceOfProduct.Text.Equals(""))
     {
         MessageBox.Show("Not all fields are filled!");
     }
     else
     {
         Product product = new Product(nameOfProduct.Text, Convert.ToDouble(priceOfProduct.Text), false);
         WorkWithDatabase work = new WorkWithDatabase();
         work.addProduct(product);
         nameOfProduct.Text = "";
         priceOfProduct.Text = "";
     }
 }