/// <summary> /// Function to update the location of the product /// </summary> /// <param name="Product_Id"></param> /// <param name="NewLocations_Id"></param> /// <param name="NewLocation"></param> public static void UpdateProductLocation(int Product_Id, string CurrLocations_Id, string NewLocations_Id, string NewLocation) { Inventory item = Inventory.Get(Product_Id); item.Product_Location = NewLocation; ProductLocation.ChangeItemAtLocation(NewLocations_Id, NewLocation, item.On_Hand); ProductLocation.RemoveItemAtLocation(CurrLocations_Id); item.Save(); }
private void Add_Product_button_Click(object sender, RoutedEventArgs e) { 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); //Ensure all fields have actually been filled out if (listPrice && unitPrice && reorderLevel && reorderQuant && onHand && product_Code.Length >= 4 && product_Name.Length >= 1 && category_comboBox.SelectedIndex >= 0) { //Create and Add the product to the database string category = category_comboBox.Text.ToString(); Product product = new Product(product_Name, product_Code, category, list_price, unit_price); string location = Location_comboBox.Text.ToString(); Inventory inventoryitem = new Inventory(product_Name, location, product_Code, on_Hand, reorder_level, reorder_quant); ProductLocation pl = (ProductLocation)Location_comboBox.SelectedItem; ProductLocation.ChangeItemAtLocation(pl.Product_Location, product_Code, on_Hand); product.Save(); inventoryitem.Save(); //Reset all Textboxes to blank; ResetBoxesToBlank(); listBox.ItemsSource = Product.GetAll(); //refresh the listbox items List <ProductLocation> locations = ProductLocation.GetAllEmpty(); Location_comboBox.Items.Clear(); foreach (ProductLocation item in locations) { Location_comboBox.Items.Add(item); } } }