public void AddStockListItemToDataBase(StockListItem stockListItem) { object[] itemVals = stockListItem.GetStockListItemArray(); foreach (object val in itemVals) { dbConnection.CheckInput(val.ToString()); } if (stockListItem.Discount != null) { AddDiscount(stockListItem.Discount); } AddProductToDatabase(stockListItem.Product); dbConnection.InsertTable("Stock", "StockID, ProductSystemID, quantity, discount, PurchaseWay", new [] { "@idParam", "@productIdParam", "@quantParam", "@discountParam", "@purchParam" }, itemVals); }
public void EditStockInDatabase(StockListItem stockListItem) { string[] columnNames = { "StockID", "ProductSystemID", "quantity", "discount", "PurchaseWay" }; object[] itemVals = stockListItem.GetStockListItemArray(); foreach (object val in itemVals) { dbConnection.CheckInput(val.ToString()); } dbConnection.UpdateTable("Stock", "ProductSystemID = '" + stockListItem.Product.SystemId + "'", columnNames, new[] { "@idParam", "@productIdParam", "@quantParam", "@discountParam", "@purchParam" }, itemVals); }