public static bool Validate(T entity) { EntityValidationResult result = DataValidation.ValidateEntity(entity); if (result.HasError) { throw new Exception(result.MensagemErro()); } return(true); }
private void Save() { BeforeOperation(); try { if (Form == null) { return; } EntityValidationResult valid = Form.Validate(); if (valid.HasError) { throw new Exception(valid.MensagemErro()); } Form.Save(); Form.Form.DialogResult = DialogResult.OK; Form.Form.Close(); } catch (Exception ex) { ExibeErro("Erro ao salvar dados.\n" + ex.Message); } AfterOperation(); }