public bool add(InventoryDTO m) { try { string query = "insert into Inventory (Name, Quantity, Price, Supplier) values ('" + m.Name + "'," + m.Quantity + "," + m.Price + ",'" + m.Supplier + "')"; c.sqlComm = new SqlCommand(query, c.sqlConn); c.sqlComm.ExecuteNonQuery(); c.sqlConn.Close(); return(true); } catch (Exception e) { return(false); } }
public bool update(InventoryDTO m) { string query = "update Inventory set Quantity=" + m.Quantity + ", Price=" + m.Price + ", Supplier='" + m.Supplier + "' where Name='" + m.Name + "'"; try { c.sqlComm = new SqlCommand(query, c.sqlConn); c.sqlComm.ExecuteNonQuery(); c.sqlConn.Close(); return(true); } catch (Exception e) { c.sqlConn.Close(); return(false); } }