private void BUC_Products_Click(object sender, EventArgs e) { _hPanel.Controls.Clear(); ProductControl pc = new ProductControl(_vPanel, _hPanel); _hPanel.Controls.Add(pc); pc.Dock = DockStyle.Fill; pc.Show(); }
private void BindInterfaceDataToObject() { _product.Category = TB_PMC_Category.Text; _product.ProductCode = TB_PMC_Code.Text; _product.ItemDescription = TB_PMC_Description.Text; _product.UnitPrice = TB_PMC_UnitPrice.Text; if (_product.Category.Equals("") || _product.ProductCode.Equals("") || _product.ItemDescription.Equals("") || TB_PMC_Stock.Text.Equals("") || TB_PMC_UnitPrice.Text.Equals("")) { MessageBox.Show("Fill up all boxes!!"); } else { _product.StockAvailable = Convert.ToInt32(TB_PMC_Stock.Text); ConfirmChange(); } void ConfirmChange() { DialogResult dialogResult = MessageBox.Show(BPMC_AddOrUpdate.Text + " Dealer? ", "Confirm Change?", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { if (_product != null) { if (BPMC_AddOrUpdate.Text.Equals("Update")) { if (ProductManager.UpdateProduct(_product)) { MessageBox.Show("Product Updated successfully!"); ReloadDealerControl(); } else { MessageBox.Show("Error! Product Code already Exist! Dealer Code must be unique!"); } } else if (BPMC_AddOrUpdate.Text.Equals("Add")) { if (ProductManager.AddProduct(_product)) { MessageBox.Show("Product Added successfully!"); ReloadDealerControl(); } else { MessageBox.Show("Error! Product Code already Exist! Dealer Code must be unique!"); } } } else { } } else if (dialogResult == DialogResult.No) { //do something else } void ReloadDealerControl() { _hPanel.Controls.Clear(); _productControl = new ProductControl(_vPanel, _hPanel); _hPanel.Controls.Add(_productControl); _productControl.Dock = DockStyle.Fill; _productControl.Show(); _popUpForm.Close(); } } }