private void btnDelete_Click(object sender, EventArgs e) { product = new Product(); product.ProductId = Convert.ToInt32(txbProductID.Text); product.ProdName = txbProductName.Text; DialogResult result = MessageBox.Show("Delete Product ID: " + product.ProductId.ToString() + "?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { try { if (!ProductsDB.DeleteProduct(product)) { MessageBox.Show("Another user has updated or deleted " + "that product.", "Database Error"); } else { RefreshList(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } }
// ------------Added by Wei Guang Yan---------------- // Method of inserting product name to database public void AddProduct(string txtAdd) { // Innitialize for messagebox string message; string title = "New Product Insert"; MessageBoxButtons button = MessageBoxButtons.OK; MessageBoxIcon icon; // Add new item to database bool flag = ProductsDB.AddProduct(txtAdd); // Check whether adding excution is successful, and show message if (flag == true) { comboBox2.DataSource = ProductsDB.GetProducts(); comboBox2.DisplayMember = "ProdName"; comboBox2.ValueMember = "ProductId"; comboBox2.SelectedIndex = comboBox2.Items.Count - 1; txtAddItem.Text = ""; message = "The product is added successfully!"; icon = MessageBoxIcon.None; } else { message = "Error: Fail to add new product!\n Please try again or contact IT supports."; icon = MessageBoxIcon.Error; } MessageBox.Show(message, title, button, icon); }
// ------------Added by Wei Guang Yan---------------- // Method of updating product name to database public void UpdateProduct(string txtUpdate) { // Initialization for messagebox string message; string title = "Product Update"; MessageBoxButtons button = MessageBoxButtons.OK; MessageBoxIcon icon = MessageBoxIcon.Warning; // Excute updating int id = ProductsDB.GetProductId(comboBox2.Text); bool flag = ProductsDB.UpdateProduct(id, txtUpdate); // Check whether updating is successful, and show message if (flag == true) { int index = comboBox2.SelectedIndex; comboBox2.DataSource = ProductsDB.GetProducts(); comboBox2.DisplayMember = "ProdName"; comboBox2.ValueMember = "ProductId"; comboBox2.SelectedIndex = index; message = "The product is updated successfully!"; icon = MessageBoxIcon.None; } else { message = "Error: Fail to update product!\n Please try again or contact IT support."; icon = MessageBoxIcon.Error; } MessageBox.Show(message, title, button, icon); }
private void RefreshProducts() { frmMain.productList = null; frmMain.productList = ProductsDB.GetAll(); PopulateTreeNode("rootProducts"); PopulateViewer("rootProducts"); }
private void RadioButton3_CheckedChanged_1(object sender, EventArgs e) { //panelProductSuppliers.Show();20190604 //20190604-- panel25.BringToFront(); //panel25.Visible = true; //--20190604 comboBox3.DataSource = ProductsDB.GetProducts(); comboBox3.DisplayMember = "ProdName"; comboBox3.ValueMember = "ProductId"; int fid; bool parseOK = Int32.TryParse(comboBox3.SelectedValue.ToString(), out fid); comboBox4.DataSource = Products_SuppliersDB.GetSuppliersByProductID(fid); comboBox4.DisplayMember = "SupName"; comboBox4.ValueMember = "SupplierId"; comboBox7.DataSource = ProductsDB.GetProducts(); comboBox7.DisplayMember = "ProdName"; comboBox7.ValueMember = "ProductId"; comboBox6.DataSource = Products_SuppliersDB.GetSuppliersByProductID(fid); comboBox6.DisplayMember = "SupName"; comboBox6.ValueMember = "SupplierId"; }
private void DeleteProduct(Product prd) { DialogResult result = MessageBox.Show("Delete Product: " + prd.ProdName + "?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { try { if (!ProductsDB.DeleteProduct(prd)) { MessageBox.Show("Another user has updated or deleted " + "that product.", "Database Error"); } else { RefreshProducts(); frmMain.DisplayMessage("Product has been deleted successfully."); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } }
private void mainForm_Load(object sender, EventArgs e) { packageList = PackagesDB.GetAll(); productList = ProductsDB.GetAll(); supplierList = SupplierDB.ListSupplier(); suppliersContactList = SupplierContactsDB.listSuppliers(); }
private void cboProdId_SelectedIndexChanged(object sender, EventArgs e) { int selectedID = (int)cboProdId.SelectedValue; prod = ProductsDB.GetProductById(selectedID); lblProdName.Text = prod.ProdName; }
// ------------Added by Wei Guang Yan---------------- // Radio-button-Click event on "Products"----Edit/Add product private void radioButton1_CheckedChanged(object sender, EventArgs e) { //this.panel14.SendToBack(); //Show panel13 //panelProductSuppliers.Hide(); 20190604 this.panel13.BringToFront(); //this.panel13.Visible = true;20190604 // Set combobox's datasource to products table comboBox2.DataSource = ProductsDB.GetProducts(); comboBox2.DisplayMember = "ProdName"; comboBox2.ValueMember = "ProductId"; // Set panel status as "products" for "update" and "add" button checking panelStatus = PanelStatus.Products; // Set desplay of relevant labels and buttons, and clear "Add" textbox lblItemList.Text = "Products"; lblUpdateItem.Text = "Update Product:"; btnUpdate.Text = "Update Product"; lblAddItem.Text = "Add Product:"; btnAdd.Text = "Add Product"; txtAddItem.Clear(); RadioButton rb = sender as RadioButton; if (rb != null) { if (rb.Checked) { // Only one radio button will be checked //Console.WriteLine("Changed: " + rb.Name); //datagridview2.source = DataLayer.ProductsDB.GetProducts(); } } }
private void Form1_Load(object sender, EventArgs e) { productList = ProductsDB.GetAll(); productDGV.MultiSelect = false; productDGV.DataSource = productList; cmbProducts.DataSource = productList; cmbProducts.DisplayMember = "ProdName"; cmbProducts.ValueMember = "ProductId"; }
private void DisplayCurrentProductData() { if (currentProd != null) { txtName.Text = currentProd.ProdName; } else // null this product does not exist - need to refresh combo box { productIds = ProductsDB.GetProductsIds(); } }
// load data if a ProductID is passed from Main form private void loadData() { List <Products> productDetails = new List <Products>(); productDetails = ProductsDB.ProductDetail((int)prodId); txtProductID.Text = productDetails[0].ProductId.ToString(); txtProdName.Text = productDetails[0].ProdName.ToString(); List <Products_Suppliers> productSuppliers = new List <Products_Suppliers>(); productSuppliers = DisplayProductSupplier(); }
private void btnAccept_Click(object sender, EventArgs e) { product = new Product(); if (string.IsNullOrEmpty(txbProductName.Text)) { MessageBox.Show("Please use numeric characters for 'Product ID'", "Input Format Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } product.ProductId = 0; product.ProdName = txbProductName.Text; if (xNewProduct) { try { ProductsDB.AddProduct(product); this.DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } else { Product newProduct = new Product(); newProduct.ProductId = Convert.ToInt32(txbProductID.Text); newProduct.ProdName = txbProductName.Text; product.ProductId = newProduct.ProductId; // The same ID try { if (!ProductsDB.UpdateProduct(product, newProduct)) { MessageBox.Show("Another user has updated or " + "deleted that product.", "Database Error"); this.DialogResult = DialogResult.Retry; } else { product = newProduct; this.DialogResult = DialogResult.OK; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } }
private void Form2_Load(object sender, EventArgs e) { products = ProductsDB.GetProducts(); listBox1.DataSource = products; listBox1.DisplayMember = "ProdName"; int Box1_initialIndex = 0; listBox1.SetSelected(Box1_initialIndex, true); LoadSupplierBox(products[Box1_initialIndex].ProductId); button2.Text = char.ConvertFromUtf32(0x2193); button8.Text = char.ConvertFromUtf32(0x2191); }
// display products after getting list by DB method private void DisplayProducts() { productsList = ProductsDB.GetProducts(); if (productsList != null) // if we have products to display { lstView.Items.Clear(); //start with empty list box foreach (Products prod in productsList) { lstView.Items.Add(prod); } } else // null this product does not exist - need to refresh combo box { MessageBox.Show("There is no product to display."); } }
// method to load the combo box for products private void LoadProductComboBox() { List <Product> cbproducts = new List <Product>(); try { cbproducts = ProductsDB.GetAll(); cmbProductBName.DataSource = cbproducts; cmbProductBName.DisplayMember = "ProdName"; cmbProductBName.ValueMember = "ProductId"; } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } }
// UPDATE button click, visibility and read-only toggle private void btnSupplierEdit_Click(object sender, EventArgs e) { btnAcceptEdit.Visible = true; btnSupplierEdit.Visible = false; pnlUpdate.Visible = true; lstProducts.Enabled = true; //txtSupplierID.ReadOnly = false; //txtSupplierID.Enabled = true; txtSupName.ReadOnly = false; txtSupName.Enabled = true; productsList = ProductsDB.GetProducts(); foreach (Products prod in productsList) { cboProducts.Items.Add(prod); } }
private void btnAddProduct_Click(object sender, EventArgs e) { product = new Products(); this.PutProductData(product); try { product.ProductId = ProductsDB.AddProduct(product); MessageBox.Show("Product added", "Success!"); this.DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show("Another user has updated or " + "deleted that product.", "Database Error"); this.DialogResult = DialogResult.Retry; } this.Close(); }
private void frmAddUpdateProductSupplier_Load(object sender, EventArgs e) { productIds = ProductsDB.GetProductsIds(); cboProdId.DataSource = productIds; supplierIds = SuppliersDB.GetSuppliersIds(); cboSupplierId.DataSource = supplierIds; if (addProductSupplier) { this.Text = "Add Product Supplier"; cboProdId.SelectedIndex = 0; cboSupplierId.SelectedIndex = 0; } else { this.Text = "Update Product Supplier"; this.DisplayCustomer(); } }
private void btnAccept_Click(object sender, EventArgs e) { if (addProduct) { product = new Products(); this.PutProductData(product); try { product.ProductId = ProductsDB.AddProduct(product); this.DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } else { Products newProduct = new Products(); newProduct.ProductId = product.ProductId; this.PutProductData(newProduct); try { if (!ProductsDB.UpdateProduct(product, newProduct)) { MessageBox.Show("Another user has updated or " + "deleted that product.", "Database Error"); this.DialogResult = DialogResult.Retry; } else { product = newProduct; this.DialogResult = DialogResult.OK; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } }
private void DisplayProductData() { productIds = ProductsDB.GetProductsIds(); cboId.DataSource = productIds; if (productIds != null) { txtName.Text = currentProd.ProdName; cboId.SelectedItem = currentProd.ProductId; lstView.Items.Clear();//start with empty list box lstView.Items.Add("Id " + ": " + "Product Name"); foreach (int id in productIds) { Products s = ProductsDB.GetProductById(id); lstView.Items.Add(s); } } else // null this product does not exist - need to refresh combo box { productIds = ProductsDB.GetProductsIds(); } }
private void btnAcceptEdit_Click(object sender, EventArgs e) { Products currentProduct = ProductsDB.GetProductById((int)prodId); Products newProduct = new Products(); newProduct.ProductId = currentProduct.ProductId; this.PutProductData(newProduct); if (currentProduct.ProdName == null) { MessageBox.Show("Fill in name before adding product", "Please check"); this.DialogResult = DialogResult.OK; } else if (Validator.IsPresent(txtProdName)) { try { if (!ProductsDB.UpdateProduct(currentProduct, newProduct)) { MessageBox.Show("Another user has updated or " + "deleted that product.", "Database Error"); this.DialogResult = DialogResult.Retry; } else { product = newProduct; MessageBox.Show("Product updated", "Success!"); this.DialogResult = DialogResult.OK; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } this.Close(); } }
// delete item button based on which radio button and item is selected private void btnDelete_Click(object sender, EventArgs e) { if (radPackages.Checked == false && radProducts.Checked == false && radSuppliers.Checked == false) { MessageBox.Show("Please select a database to delete from.", "Select a Database"); } else if (radPackages.Checked) { string i = lstView.SelectedItem.ToString(); string[] s = i.Split('|'); int packageId = Int32.Parse(s[0].Trim()); string nameSelected = s[1].Trim(); currentPackage = PackagesDB.GetPackageById(packageId); DialogResult result = MessageBox.Show("Delete Packages " + nameSelected + "?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { try { if (!PackagesDB.DeletePackage(currentPackage)) { MessageBox.Show("Another user has updated or deleted " + "that package.", "Database Error"); currentPackage = PackagesDB.GetPackageById(packageId); } else { this.DisplayPackages(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } } else if (radProducts.Checked) { string i = lstView.SelectedItem.ToString(); string[] s = i.Split('|'); int productId = Int32.Parse(s[0].Trim()); string nameSelected = s[1].Trim(); currentProduct = ProductsDB.GetProductById(productId); DialogResult result = MessageBox.Show("Delete Product " + nameSelected + "?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { try { if (!ProductsDB.DeleteProduct(currentProduct)) { MessageBox.Show("Another user has updated or deleted " + "that package.", "Database Error"); currentProduct = ProductsDB.GetProductById(productId); } else { this.DisplayProducts(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } } else if (radSuppliers.Checked) { string i = lstView.SelectedItem.ToString(); string[] s = i.Split('|'); int supplierId = Int32.Parse(s[0].Trim()); string nameSelected = s[1].Trim(); currentSupplier = SuppliersDB.GetSupplierById(supplierId); DialogResult result = MessageBox.Show("Delete Supplier " + nameSelected + "?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { try { if (!SuppliersDB.DeleteSupplier(currentSupplier)) { MessageBox.Show("Another user has updated or deleted " + "that package.", "Database Error"); currentSupplier = SuppliersDB.GetSupplierById(supplierId); } else { this.DisplaySuppliers(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } } }
private void RefreshList() { GC.SuppressFinalize(productList); // remove existing List object productList = ProductsDB.GetAll(); // and get new one RefreshDGV(); // refresh the DataGridView Control }
private void btnDelete_Click(object sender, EventArgs e) { string tableName = cboTableNames.SelectedValue.ToString(); if (tableName == "Products") { DialogResult result = MessageBox.Show("Delete " + currentProd.ProdName + "?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { try { if (!ProductsDB.DeleteProduct(currentProd)) { MessageBox.Show("Another user has updated or deleted " + "that product.", "Database Error"); currentProd = ProductsDB.GetProductById(currentProd.ProductId); if (currentProd != null) { this.DisplayProductData(); } } else { this.DisplayProductData(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } } else if (tableName == "Suppliers") { DialogResult result = MessageBox.Show("Delete " + currentSupplier.SupName + "?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { try { if (!SuppliersDB.DeleteSupplier(currentSupplier)) { MessageBox.Show("Another user has updated or deleted " + "that supplier.", "Database Error"); currentSupplier = SuppliersDB.GetSupplierById(currentSupplier.SupplierId); if (currentSupplier != null) { this.DisplaySupplierData(); } } else { this.DisplaySupplierData(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } } else if (tableName == "Products_Suppliers") { DialogResult result = MessageBox.Show("Delete Product Supplier " + currentProductSupplier.ProductSupplierId + "?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { try { if (!Products_SuppliersDB.DeleteProductSupplier(currentProductSupplier)) { MessageBox.Show("Another user has updated or deleted " + "that product_supplier.", "Database Error"); currentProductSupplier = Products_SuppliersDB.GetProductSupplierById(currentProductSupplier.ProductSupplierId); if (currentProductSupplier != null) { this.DisplayCurrentProductSupplierData(); } this.DisplayProductSupplierData(); } else { this.DisplayCurrentProductSupplierData(); } this.DisplayProductSupplierData(); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } } else if (tableName == "Packages") { DialogResult result = MessageBox.Show("Delete Packages " + currentPackage.PkgName + "?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { try { if (!PackagesDB.DeletePackage(currentPackage)) { MessageBox.Show("Another user has updated or deleted " + "that package.", "Database Error"); currentPackage = PackagesDB.GetPackageById(currentPackage.PackageId); if (currentPackage != null) { //this.DisplayCurrentProductSupplierData(); this.DisplayProductSupplierData(); } } else { //this.DisplayCurrentProductSupplierData(); this.DisplayPackages(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } } }
private void cboTableNames_SelectedIndexChanged(object sender, EventArgs e) { string tableName = cboTableNames.SelectedValue.ToString(); if (tableName == "Products") { pnlName.Visible = true; pnlName2.Visible = false; lblId.Text = "Product Id"; productIds = ProductsDB.GetProductsIds(); if (productIds.Count > 0) // if there are prodcuts { cboId.DataSource = productIds; cboId.SelectedIndex = 0; // triggers SelectedIndexChanged } else // no members { MessageBox.Show("There are no products. " + "Add some products in the database, and restart the application ", "Empty Load"); Application.Exit(); } DisplayProductData(); } else if (tableName == "Suppliers") { lblId.Text = "Supplier Id"; supplierIds = SuppliersDB.GetSuppliersIds(); pnlName.Visible = true; pnlName2.Visible = false; if (supplierIds.Count > 0) // if there are suppliers { cboId.DataSource = supplierIds; cboId.SelectedIndex = 0; // triggers SelectedIndexChanged } else // no members { MessageBox.Show("There are no suppliers. " + "Add some supplier in the database, and restart the application ", "Empty Load"); Application.Exit(); } DisplaySupplierData(); } else if (tableName == "Products_Suppliers") { lblId.Text = "ProductSupplier Id"; lblName.Text = "Product Name"; lblName2.Text = "Supplier Name"; pnlName.Visible = true; pnlName2.Visible = true; productSupplierIds = Products_SuppliersDB.GetProductSupplierIds(); if (productSupplierIds.Count > 0) // if there are suppliers { cboId.DataSource = productSupplierIds; cboId.SelectedIndex = 0; // triggers SelectedIndexChanged } else // no members { MessageBox.Show("There are no product_suppliers. " + "Add some product_supplier in the database, and restart the application ", "Empty Load"); Application.Exit(); } DisplayProductSupplierData(); } else if (tableName == "Packages_Products_Suppliers") { lblId.Text = "Package Id"; packageIds = Packages_Products_SuppliersDB.GetPackageIds(); pnlName.Visible = false; pnlName2.Visible = false; if (packageIds.Count > 0) // if there are packages { cboId.DataSource = packageIds; cboId.SelectedIndex = 0; // triggers SelectedIndexChanged } else // no members { MessageBox.Show("There are no packages with products_suppliers. " + "Add some packages with product_supplier in the database, and restart the application ", "Empty Load"); Application.Exit(); } } else if (tableName == "Packages") { lblId.Text = "Package Id"; pnlName.Visible = true; pnlName2.Visible = false; packageIds = PackagesDB.GetPackageIds(); DisplayPackages(); if (packageIds.Count > 0) // if there are suppliers { cboId.DataSource = packageIds; cboId.SelectedIndex = 0; // triggers SelectedIndexChanged } else // no members { MessageBox.Show("There are no packages. " + "Add some packages in the database, and restart the application ", "Empty Load"); Application.Exit(); } } }
private void btnUpdate_Click(object sender, EventArgs e) { string tableName = cboTableNames.SelectedValue.ToString(); if (tableName == "Products") { frmAddUpdateProducts updateProductForm = new frmAddUpdateProducts(); updateProductForm.addProduct = false; updateProductForm.product = currentProd; DialogResult result = updateProductForm.ShowDialog(); if (result == DialogResult.OK) { currentProd = updateProductForm.product; this.DisplayProductData(); } else if (result == DialogResult.Retry) { currentProd = ProductsDB.GetProductById(currentProd.ProductId); if (currentProd != null) { this.DisplayProductData(); } } } else if (tableName == "Suppliers") { frmAddUpdateSuppliers updateSupplierForm = new frmAddUpdateSuppliers(); updateSupplierForm.addSupplier = false; updateSupplierForm.supplier = currentSupplier; DialogResult result = updateSupplierForm.ShowDialog(); if (result == DialogResult.OK) { currentSupplier = updateSupplierForm.supplier; this.DisplaySupplierData(); } else if (result == DialogResult.Retry) { currentSupplier = SuppliersDB.GetSupplierById(currentSupplier.SupplierId); if (currentSupplier != null) { this.DisplaySupplierData(); } } } else if (tableName == "Products_Suppliers") { frmAddUpdateProductSupplier updateProductSupplierForm = new frmAddUpdateProductSupplier(); updateProductSupplierForm.addProductSupplier = false; updateProductSupplierForm.productSupplier = currentProductSupplier; DialogResult result = updateProductSupplierForm.ShowDialog(); if (result == DialogResult.OK) { this.DisplayCurrentProductSupplierData(); this.DisplayProductSupplierData(); } else if (result == DialogResult.Retry) { currentProductSupplier = Products_SuppliersDB.GetProductSupplierById(currentProductSupplier.ProductSupplierId); if (currentProductSupplier != null) { this.DisplayCurrentProductSupplierData(); } this.DisplayProductSupplierData(); } } else if (tableName == "Packages") { frmAddUpdatePackages updatePackageForm = new frmAddUpdatePackages(); updatePackageForm.addPackage = false; updatePackageForm.package = currentPackage; updatePackageForm.currentProductSupplierIds = Packages_Products_SuppliersDB.GetProductSupplierIds(currentPackage.PackageId); DialogResult result = updatePackageForm.ShowDialog(); if (result == DialogResult.OK) { this.DisplayPackages(); DisplayCurrentPackageProductSupplierData(); } else if (result == DialogResult.Retry) { currentPackage = PackagesDB.GetPackageById(currentPackage.PackageId); if (currentPackage != null) { DisplayCurrentPackageProductSupplierData(); } this.DisplayPackages(); } } }
private void cboId_SelectedIndexChanged(object sender, EventArgs e) { string tableName = cboTableNames.SelectedValue.ToString(); if (tableName == "Products") { int selectedID = (int)cboId.SelectedValue; lblName.Text = "Product Name"; try { currentProd = ProductsDB.GetProductById(selectedID); DisplayCurrentProductData(); } catch (Exception ex) { MessageBox.Show("Error while retrieving product with selected ID: " + ex.Message, ex.GetType().ToString()); } } else if (tableName == "Suppliers") { int selectedID = (int)cboId.SelectedValue; lblName.Text = "Supplier Name"; try { currentSupplier = SuppliersDB.GetSupplierById(selectedID); DisplayCurrentSupplierData(); } catch (Exception ex) { MessageBox.Show("Error while retrieving supplier with selected ID: " + ex.Message, ex.GetType().ToString()); } } else if (tableName == "Products_Suppliers") { int selectedID = (int)cboId.SelectedValue; try { currentProductSupplier = Products_SuppliersDB.GetProductSupplierById(selectedID); DisplayCurrentProductSupplierData(); } catch (Exception ex) { MessageBox.Show("Error while retrieving product supplier with selected ID: " + ex.Message, ex.GetType().ToString()); } } else if (tableName == "Packages_Products_Suppliers") { int selectedID = (int)cboId.SelectedValue; try { productSupplierIds = Packages_Products_SuppliersDB.GetProductSupplierIds(selectedID); DisplayCurrentPackageProductSupplierData(); } catch (Exception ex) { MessageBox.Show("Error while retrieving package product supplier with selected ID: " + ex.Message, ex.GetType().ToString()); } } else if (tableName == "Packages") { int selectedID = (int)cboId.SelectedValue; lblName.Text = "Package Name"; try { productSupplierIds = Packages_Products_SuppliersDB.GetProductSupplierIds(selectedID); DisplayCurrentPackageProductSupplierData(); } catch (Exception ex) { MessageBox.Show("Error while retrieving package product supplier with selected ID: " + ex.Message, ex.GetType().ToString()); } try { currentPackage = PackagesDB.GetPackageById(selectedID); txtName.Text = currentPackage.PkgName; } catch (Exception ex) { MessageBox.Show("Error while retrieving package with selected ID: " + ex.Message, ex.GetType().ToString()); } } }