private void saveButtonAddProductWindow_Click(object sender, RoutedEventArgs e) { try { var productName = (from pn in jackyDigitalXDBEntities.Products where pn.ProductName == textBoxProductNameAddProductWindow.Text select pn); if (productName.Count() != 0) { MessageBox.Show("Specified Product Name already exists, please choose another name."); } else { while (textBoxRetailerIDEditProductWindow.Text == "0") { MessageBox.Show("Invalid Retailer ID, plese re-select a Retailer ID"); RetailerInfo.RetailerInformation retailerInformaiton = new RetailerInfo.RetailerInformation(); retailerInformaiton.ShowDialog(); textBoxRetailerIDEditProductWindow.Text = RetailerInfo.RetailerInformation.retailerID.ToString(); } ProductsPage.Product.ProductID = Convert.ToInt32(textBlockProductIDAddProductWindow.Text); ProductsPage.Product.RetailerID = Convert.ToInt32(textBoxRetailerIDEditProductWindow.Text); ProductsPage.Product.SubCategoryID = Convert.ToInt32(textBoxSubCategoryIDAddProductWindow.Text); ProductsPage.Product.ProductName = textBoxProductNameAddProductWindow.Text; ProductsPage.Product.ProductDescription = textBoxProductDescriptionAddProductWindow.Text; ProductsPage.Product.Price = Convert.ToInt32(textBoxPriceAddProductWindow.Text); ProductsPage.Product.UnitsInStock = Convert.ToInt32(textBoxUnitsInStockAddProductWindow.Text); SaveButtonPressed = true; this.Close(); } } catch (Exception) { MessageBox.Show(@"Invalid characters detected. Please verify all fields and try again. For instance, some fields (e.g., prices, units in stocks) allow only numbers; apart from product description, product photo and 'IsDiscountinued' options, all other fields cannot be empty."); } }
private void button_Click(object sender, RoutedEventArgs e) { RetailerInfo.RetailerInformation retailerInformaiton = new RetailerInfo.RetailerInformation(); retailerInformaiton.ShowDialog(); textBoxRetailerIDEditProductWindow.Text = RetailerInfo.RetailerInformation.retailerID.ToString(); }