private void RemoveSelectedStockButton_AddStockToStoreUC_Click(object sender, RoutedEventArgs e) { StockModel stock = new StockModel(); stock = (StockModel)NewStocksList_AddStockToStoreUC.SelectedItem; if (stock != null) { FProducts.Add(stock.Product); NewStocks.Remove(stock); FProductsList_AddStockToStoreUC.ItemsSource = null; FProductsList_AddStockToStoreUC.ItemsSource = FProducts; NewStocksList_AddStockToStoreUC.ItemsSource = null; NewStocksList_AddStockToStoreUC.ItemsSource = NewStocks; } else { MessageBox.Show("There is no Product selected !"); } }
private void AddToTheCurrentStoreButton_AddStockToStoreUC_Click(object sender, RoutedEventArgs e) { if ((ProductModel)FProductsList_AddStockToStoreUC.SelectedItem != null) { int quantity = new int(); if (int.TryParse(QuantityValue_AddStockToStoreUC.Text, out quantity)) { if (quantity > 0) { StockModel stock = new StockModel(); stock.Product = (ProductModel)FProductsList_AddStockToStoreUC.SelectedItem; stock.Quantity = quantity; stock.Store = Store; NewStocks.Add(stock); FProducts.Remove(stock.Product); QuantityValue_AddStockToStoreUC.Text = "1"; NewStocksList_AddStockToStoreUC.ItemsSource = null; NewStocksList_AddStockToStoreUC.ItemsSource = NewStocks; FProductsList_AddStockToStoreUC.ItemsSource = null; FProductsList_AddStockToStoreUC.ItemsSource = FProducts; } else { MessageBox.Show("Quanitity must be more than 0"); } } else { MessageBox.Show("quantity is not a number"); } } else { MessageBox.Show("Choose product"); } }