private void Update_Product_button_Click(object sender, RoutedEventArgs e) { int productID = (int)Convert.ToInt32(Product_Id_Textbox.Text); double listPrice = (double)Convert.ToDouble(List_Price_textBox.Text); Product.UpdateListPrice(productID, listPrice); //Product.ChangeProductCategory(productID, comboBox.SelectedValue.ToString()); // comboBox xaml must have SelectedValuePath = "Content" in order to work }
//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(); } }