private void BtnGuardar_Click(object sender, EventArgs e) { if (id == null) { entity = new Entities.Producto(); } CargarEntity(entity); var validation = new Helps.DataValidations(entity).Validate(); bool valid = validation.Item1; if (valid == true) { if (id == null) { try { entity = bll.Insert(entity); InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Insert, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Producto: " + entity.codigo, "", "")); Notifications.FrmSuccess.SuccessForm(Helps.Language.SearchValue("guardadoOK")); this.Close(); } catch (Exception ex) { if (ex.Message == EValidaciones.existe) { Notifications.FrmInformation.InformationForm(Helps.Language.SearchValue("errorExiste")); } else { InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.InsertError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Producto: " + entity.codigo, ex.StackTrace, ex.Message)); Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("guardadoError") + "\n" + ex.Message); } } } else { try { bll.Update(entity); InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Update, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Producto: " + entity.codigo, "", "")); Notifications.FrmSuccess.SuccessForm(Helps.Language.SearchValue("editadoOK")); this.Close(); } catch (Exception ex) { if (ex.Message == EValidaciones.existe) { Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("errorExiste")); } else { InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.UpdateError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Producto: " + entity.codigo, ex.StackTrace, ex.Message)); Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("editadoError") + "\n" + ex.Message); } } } } else { string messageValid = validation.Item2; Notifications.FrmInformation.InformationForm(messageValid); } }