示例#1
0
文件: DataLayer.cs 项目: bobdeus/PTT
 /// <summary>
 /// Updates the sell information for an inventoryItem
 /// </summary>
 /// <param name="inventoryItem">The item that is being sold</param>
 /// <param name="customer">The customer that is purchasing the item</param>
 /// <param name="date">The date it was purchased</param>
 /// <param name="sellPrice">The price the item was sold for</param>
 public static void SellInventory(InventoryItem inventoryItem, Customer customer, DateTime date, double sellPrice)
 {
     if (inventoryItem == null)
         throw new ArgumentNullException("Inventory Item cannot be null");
     using (SqlCeCommand cmd = new SqlCeCommand(@"update Inventory set soldPrice = @soldPrice, dateSold = @dateSold, buyer = @buyer where inventoryId = @inventoryId"))
     {
         cmd.Parameters.AddWithValue("@soldPrice", sellPrice);
         cmd.Parameters.AddWithValue("@dateSold", date.Date);
         cmd.Parameters.AddWithValue("@buyer", customer != null ? (object)customer.CustomerId : DBNull.Value);
         cmd.Parameters.AddWithValue("@inventoryId", inventoryItem.InvnetoryId);
         ExecuteNonQuery(cmd);
     }
 }
示例#2
0
 internal static InventoryItem Load(IDataReader reader)
 {
     int id = (int)reader["inventoryId"];
     if (cachedInventoryItem.ContainsKey(id))
         return cachedInventoryItem[id];
     else
     {
         InventoryItem m = new InventoryItem(reader);
         cachedInventoryItem[id] = m;
         return m;
     }
 }