/// <summary> /// guarda los cambios /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnGuardar_Click(object sender, EventArgs e) { Entities.Categoria categoria = new Entities.Categoria(); categoria.categoria = TxtNombre.Text; var validation = new Helps.DataValidations(categoria).Validate(); bool valid = validation.Item1; if (valid == true) { if (editarse == false) { try { categoria = bll.Insert(categoria); InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Insert, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Categoria: " + categoria.categoria, "", "")); Notifications.FrmSuccess.SuccessForm(Language.SearchValue("guardadoOK")); RefrescarTabla(); LimpiarTxt(); } catch (Exception ex) { System.Data.SqlClient.SqlException sqlException = ex as System.Data.SqlClient.SqlException; erro = sqlException.Number; InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.InsertError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Categoria: " + categoria.categoria, ex.StackTrace, ex.Message)); Notifications.FrmError.ErrorForm(Language.SearchValue("guardadoError") + "\n" + ex.Message); } } if (editarse == true) { try { categoria.id = id; bll.Update(categoria); InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Update, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Categoria: " + categoria.categoria, "", "")); Notifications.FrmSuccess.SuccessForm(Language.SearchValue("editadoOK")); RefrescarTabla(); LimpiarTxt(); editarse = false; } catch (Exception ex) { InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.UpdateError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Categoria: " + categoria.categoria, ex.StackTrace, ex.Message)); Notifications.FrmError.ErrorForm(Language.SearchValue("editadoError") + "\n" + ex.Message); } } } else { string messageValid = validation.Item2; Notifications.FrmInformation.InformationForm(messageValid); } }