private void btnAddProduct_Click(object sender, EventArgs e) { string ProductName, Description; int CategoryID = 0, VendorID = 0, ProfitRate; bool ValidSubmission = true; if (String.IsNullOrWhiteSpace(cmbCategory.Text)) { ValidSubmission = false; MessageBox.Show("Please select a category for the product!", "Error"); } else if (String.IsNullOrWhiteSpace(cmbVendor.Text)) { ValidSubmission = false; MessageBox.Show("Please select a vendor for the product!", "Error"); } else if (String.IsNullOrWhiteSpace(txtName.Text)) { ValidSubmission = false; MessageBox.Show("Please enter a name for the product!", "Error"); } else if (String.IsNullOrWhiteSpace(txtProfit.Text)) { ValidSubmission = false; MessageBox.Show("Please enter a profit rate for the product!", "Error"); } else if (!(Int32.TryParse(txtProfit.Text, out ProfitRate))) { ValidSubmission = false; MessageBox.Show("Please enter a valid profit rate!", "Error"); } if (!(GeneralMethods.CheckCategory(cmbCategory.Text))) { if (MessageBox.Show("Are you sure you want to add a new category?", "Add New Category", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { GeneralMethods.AddCategory(cmbCategory.Text); MessageBox.Show("Category added successfuly!", "Success"); } CategoryID = GeneralMethods.GetCategory(cmbCategory.Text); } else if (GeneralMethods.CheckCategory(cmbCategory.Text)) { CategoryID = GeneralMethods.GetCategory(cmbCategory.Text); } if (!(GeneralMethods.CheckVendor(cmbVendor.Text))) { if (MessageBox.Show("Are you sure you want to add a new vendor?", "Add New Vendor", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { GeneralMethods.AddVendor(cmbVendor.Text); MessageBox.Show("Vendor added successfuly!", "Success"); } VendorID = GeneralMethods.GetVendor(cmbVendor.Text); } else if (GeneralMethods.CheckVendor(cmbVendor.Text)) { VendorID = GeneralMethods.GetVendor(cmbVendor.Text); } if (ValidSubmission) { ProductName = txtName.Text; ProfitRate = Convert.ToInt32(txtProfit.Text); Description = rtxtDescription.Text; GeneralMethods.AddProduct(CategoryID, VendorID, ProductName, ProfitRate, Description); GeneralMethods.CreatePurchaseOrderMethod(); MessageBox.Show("Product added successfully!", "Success"); //int id = GeneralMethods.GetPurchaseOrderID(); //GeneralMethods.CreatePurchaseOrderTransaction(id, VendorID, GeneralMethods.GetProductID(), 10); } }