// TODO : add reset is_sold_today and number_sold_today public static void addProduct(Product newProduct) { //openConnection(); MySqlCommand command = l_DBConn.CreateCommand(); try { String query = "REPLACE product(barcode,number_in_stock,name,category,price,manufacturer) VALUES('" + newProduct.getBarcode() + "','" + newProduct.getNumberInStock().ToString() + "','" + newProduct.getName() + "','" + newProduct.getCategory() + "','" + newProduct.getPrice().ToString() + "','" + newProduct.getManufacturer() + "')"; command.CommandText = query; command.ExecuteNonQuery(); } catch { }; //closeConnection(); }
public static void modifyProduct(Product changedProduct) { //openConnection(); MySqlCommand command = l_DBConn.CreateCommand(); try { String query = "UPDATE product SET number_in_stock='" + changedProduct.getNumberInStock() + "' ,name='" + changedProduct.getName() + "' ,category='" + changedProduct.getCategory() + "' ,price='" + changedProduct.getPrice() + "' ,manufacturer='" + changedProduct.getManufacturer() + "' WHERE barcode ='" + changedProduct.getBarcode() + "'"; command.CommandText = query; command.ExecuteNonQuery(); } catch { }; //closeConnection(); }