public static void UpdateOrderLine(OrderLine orderLine) { if (orderLine.OrderID == Guid.Empty) return; if (orderLine.ProductID == Guid.Empty) return; string sqlQuery = "UPDATE OrderLine SET Quantity=@Quantity, ItemPrice=@ItemPrice, ItemPriceDiscount=@ItemPriceDiscount,Tax=@Tax, Total=@Total WHERE OrderID=@OrderID AND ProductID=@ProductID"; DbCommand dbCommand = DBHelper.GetDBCommand(sqlQuery); DBHelper.AddInParameter(dbCommand, "OrderID", DbType.Guid, orderLine.OrderID); DBHelper.AddInParameter(dbCommand, "ProductID", DbType.Guid, orderLine.ProductID); DBHelper.AddInParameter(dbCommand, "Quantity", DbType.Int32, orderLine.Quantity); DBHelper.AddInParameter(dbCommand, "ItemPrice", DbType.Decimal, orderLine.ItemPrice); DBHelper.AddInParameter(dbCommand, "ItemPriceDiscount", DbType.Decimal, orderLine.ItemPriceDiscount); DBHelper.AddInParameter(dbCommand, "Tax", DbType.Decimal, orderLine.Tax); DBHelper.AddInParameter(dbCommand, "Total", DbType.Decimal, orderLine.Total); DBHelper.ExecuteNonQuery(dbCommand); }
public static OrderLine InsertOrderLine(OrderLine orderLine) { string sqlQuery = "INSERT INTO OrderLine(OrderID,ProductID,Quantity,ItemPrice,ItemPriceDiscount,Tax,Total) " + " VALUES(@OrderID,@ProductID,@Quantity, @ItemPrice,@ItemPriceDiscount,@Tax, @Total)"; if (orderLine.OrderID == Guid.Empty) return null; if (orderLine.ProductID == Guid.Empty) return null; DbCommand dbCommand = DBHelper.GetDBCommand(sqlQuery); DBHelper.AddInParameter(dbCommand, "OrderID", DbType.Guid, orderLine.OrderID); DBHelper.AddInParameter(dbCommand, "ProductID", DbType.Guid, orderLine.ProductID); DBHelper.AddInParameter(dbCommand, "Quantity", DbType.Int32, orderLine.Quantity); DBHelper.AddInParameter(dbCommand, "ItemPrice", DbType.Decimal, orderLine.ItemPrice); DBHelper.AddInParameter(dbCommand, "ItemPriceDiscount", DbType.Decimal, orderLine.ItemPriceDiscount); DBHelper.AddInParameter(dbCommand, "Tax", DbType.Decimal, orderLine.Tax); DBHelper.AddInParameter(dbCommand, "Total", DbType.Decimal, orderLine.Total); DBHelper.ExecuteNonQuery(dbCommand); return orderLine; }
private static OrderLine GetOrderLineFromReader(IDataReader dataReader) { OrderLine orderLine = new OrderLine(); orderLine.OrderID = DBHelper.GetGuid(dataReader, "OrderID"); orderLine.ProductID = DBHelper.GetGuid(dataReader, "ProductID"); orderLine.Quantity = DBHelper.GetInt(dataReader, "Quantity"); orderLine.ItemPrice = DBHelper.GetDecimal(dataReader, "ItemPrice"); orderLine.ItemPriceDiscount = DBHelper.GetDecimal(dataReader, "ItemPriceDiscount"); orderLine.Tax = DBHelper.GetDecimal(dataReader, "Tax"); orderLine.Total = DBHelper.GetDecimal(dataReader, "Total"); return orderLine; }