private void btnLockSupplier_Click(object sender, EventArgs e) { try { if (!GetConfirmation("Are you sure to edit this Supplier?", "Confirm Edit!!")) { return; } if ((supplierBindingSource.Current as Supplier) == null) { throw new Exception("Couldn't get this Supplier to Lock/Unlock"); } int id = (supplierBindingSource.Current as Supplier).Id; CustomResult customResult = bus.ChangeLockSupplier(id); if (customResult.Result == CustomResultType.Succeed) { supplierDataGridView.Refresh(); ReloadSuppliersProductsBindingSource_Grid(); ReloadAddSupplierProductBindingSource_Supplier(); ReloadRemoveSupplierProductBindingSource_Supplier(); ReloadRemoveSupplierProductBindingSource_Product(); } else if (customResult.Result == CustomResultType.InvalidModelState) { validator.DisplayModelValidationErrorsAndFocus(typeof(Supplier)); } else { throw new Exception(customResult.ErrorMessage); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }