//update the Item private void button2_Click(object sender, RoutedEventArgs e) { //Get the selected item string product_Code = listBox.Items.GetItemAt(1).ToString(); product_Code = product_Code.Remove(0, 15); Inventory item = Inventory.GetWithCode(product_Code); //update the item quantity int newValue; if (Int32.TryParse(textBox.Text, out newValue)) { item.ModifyItemStock(newValue); } //update the listbox listBox.Items.Clear(); listBox.Items.Add("Product : " + item.Product); listBox.Items.Add("Product Code : " + item.Product_Code); listBox.Items.Add("On Hand : " + item.On_Hand); listBox.Items.Add("On Order : " + item.On_Order); listBox.Items.Add("Reorder Level : " + item.Reorder_Level); listBox.Items.Add("Reorder Quantity : " + item.Reorder_Quantity); }
//Update the selected product private void Update_Product_button_Click(object sender, RoutedEventArgs e) { //Check all of the text/combo box fields string product_Code = Product_Code_Textbox.Text.ToString(); string product_Name = Product_Name_textBox.Text.ToString(); double list_price, unit_price; bool listPrice, unitPrice, reorderLevel, reorderQuant, onHand; int reorder_level, reorder_quant, on_Hand; CheckTextBoxes(out list_price, out listPrice, out unit_price, out unitPrice, out reorder_level, out reorderLevel, out reorder_quant, out reorderQuant, out on_Hand, out onHand); if (listPrice && unitPrice && reorderLevel && reorderQuant && onHand && product_Code.Length > 1 && product_Name.Length > 1) { Product product = (Product)listBox.SelectedItem; Inventory inventory = Inventory.GetWithCode(product.Product_Code); string category = category_comboBox.Text.ToString(); Product.ChangeProductCategory(product.Product_Id, category); Product.UpdateListPrice(product.Product_Id, list_price); Inventory.setFiltersToOrder(product.Product_Id, reorder_level, reorder_quant); inventory.ModifyItemStock(on_Hand); //Re-enable the textboxes that can't be updated in case a new product is to be added Product_Code_Textbox.IsEnabled = true; Product_Name_textBox.IsEnabled = true; Unit_Price_textBox.IsEnabled = true; //reset/update all fields listBox.ItemsSource = Product.GetAll(); Disc_Product_button.IsEnabled = false; Update_Product_button.IsEnabled = false; Add_Product_button.IsEnabled = true; Location_comboBox.IsEnabled = true; ResetBoxesToBlank(); } }