/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void btnSave_Click(object sender, EventArgs e) { // the current binder's customer to edit CustomerEntity customerToSave = (CustomerEntity)_customersBinder.Current; // there are errors, cancel the save until the user fixes them. if (customerToSave.GetEntityFieldsErrors() != string.Empty) { MessageBox.Show("There are errors in the entity. Please fix them prior to save.", "Please fix the errors.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } // there are not field errors else { // save the current customer try { customerToSave.Save(); DisableEditControls(); } // there are entity errors. Show them to the user catch (ORMEntityValidationException ex) { MessageBox.Show(ex.Message); } } }