public void UpdateItem(Inventory itemToUpdate) { var itemInInventoty = db.Inventories.Single(item => item.Id == itemToUpdate.Id); itemInInventoty.Name = itemToUpdate.Name; itemInInventoty.Manufacturer = itemToUpdate.Manufacturer; itemInInventoty.MRP = itemToUpdate.MRP; itemInInventoty.ExpiryDate = itemToUpdate.ExpiryDate; itemInInventoty.Description = itemToUpdate.Description; itemInInventoty.CostPrice = itemToUpdate.CostPrice; itemInInventoty.Quantity = itemToUpdate.Quantity; db.SubmitChanges(); }
public List<Transaction> GetTransactionsForInventoryItem(Inventory inventoryItem) { var transactions = db.Transactions.Where(x => x.InventoryItem == inventoryItem.Id).ToList<Transaction>(); return transactions; }
public void AddItem(Inventory item) { db.Inventories.InsertOnSubmit(item); db.SubmitChanges(); }
partial void DeleteInventory(Inventory instance);
partial void UpdateInventory(Inventory instance);
partial void InsertInventory(Inventory instance);
private void btnSave_Click(object sender, RoutedEventArgs e) { //validate input before using validator class //Add new inventory by invoking a method in inventory manager if(lblNameError.IsVisible || lblManufacturerError.IsVisible||lblExpiryDateError.IsVisible || lblMRPError.IsVisible||lblCostPriceError.IsVisible||lblQuantityError.IsVisible) { //Show a message to correct the imput informationn before saving a inventory item } else { Inventory newItem = new Inventory { Name = txtName.Text, Manufacturer = txtManufacturer.Text, ExpiryDate = Convert.ToDateTime(txtExpiryDate.Text), MRP = Convert.ToDecimal(txtMRP.Text), CostPrice = Convert.ToDecimal(txtCostPrice.Text), PurchaseDate = DateTime.Now, Quantity = Convert.ToInt32(txtQuantity.Text), Description = txtDescription.Text }; InventoryManager manager = new InventoryManager(); manager.AddItem(newItem); ClearinventoryTextBoxes(); LoadlvFullinventory(); } }