private void btnRegister_Click(object sender, EventArgs e) { if (ValidateChildren(ValidationConstraints.Enabled)) { if (txtProductName.Text == "") { MessageBox.Show("Please select a product name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtProductName.Focus(); return; } if (txtQuantity.Text == "") { MessageBox.Show("Please enter a quantity", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtQuantity.Focus(); return; } try { BusinessManager BM = new BusinessManager(); BOProduct BOP = new BOProduct(); BOInventory BOI = new BOInventory(); BOP.ConfigID = txtConfigID.Text; BOI.InventoryDate = dtpInventoryDate.Text; auto_generate(); BOI.InventoryID = txtInventoryID.Text; BOI.Quantity = txtQuantity.Text; BOI.TotalPrice = txtTotalPrice.Text; bool res = BM.BALVerifyInventoryName(BOP); if (res == true) { MessageBox.Show("Record already exists!" + "\n" + "Please update the stock of product", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { int rowsAffected = BM.BALInsertIntoInventory(BOP, BOI); if (rowsAffected > 0) { MessageBox.Show("Successfully saved", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information); btnRegister.Enabled = false; getData(); //frmMainMenu frm = new frmMainMenu(); //frm.GetData(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }