private void btnAddSupplier_Click(object sender, EventArgs e) { try { if (!GetConfirmation("Are you sure to add this Supplier?", "Confirm Add!!")) { return; } Supplier supplier = new Supplier(txtSupplierName.Text.Trim(), txtSupplierAddress.Text.Trim(), txtSupplierPhoneNumber.Text.Trim(), checkBoxIsActive.Checked); CustomResult customResult = bus.AddSupplier(supplier); if (customResult.Result == CustomResultType.Succeed) { supplierDataGridView.Refresh(); MessageBox.Show("Supplier Added", "Inform", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearSupplierTextBoxes(); ReloadAddSupplierProductBindingSource_Supplier(); txtSupplierName.Focus(); } else if (customResult.Result == CustomResultType.InvalidModelState) { validator.DisplayModelValidationErrorsAndFocus(supplier.GetType()); } else if (customResult.Result == CustomResultType.InvalidInput) { MessageBox.Show(customResult.ErrorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtSupplierPhoneNumber.Focus(); } else { throw new Exception(customResult.ErrorMessage); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtSupplierName.Focus(); } }