/// <summary> /// elimina un registro seleccionado /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnEliminar_Click(object sender, EventArgs e) { if (metroGrid1.SelectedRows.Count > 0) { int idCat = GetId(); Entities.Categoria categoria = bll.GetById(idCat); try { DialogResult confirmation = new Notifications.FrmQuestion(Language.SearchValue("preguntaEliminar")).ShowDialog(); if (confirmation == DialogResult.OK) { bll.Delete(idCat); InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Delete, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Categoria: " + categoria.categoria, "", "")); RefrescarTabla(); Notifications.FrmSuccess.SuccessForm(Language.SearchValue("eliminadoOK")); } } catch (Exception ex) { InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.DeleteError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Categoria: " + categoria.categoria, ex.StackTrace, ex.Message)); RefrescarTabla(); Notifications.FrmError.ErrorForm(Language.SearchValue("eliminadoError") + "\n" + ex.Message); } } else { Notifications.FrmInformation.InformationForm(Language.SearchValue("XinfoSelecEliminar")); } }
/// <summary> /// carga el nombre de la categoría en el form /// </summary> private void CargarDatosEnForm() { try { categoria = bllCat.GetById(id); lblNombreValue.Text = categoria.categoria; } catch (Exception ex) { InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Error, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Error carga de datos", ex.StackTrace, ex.Message)); Notifications.FrmError.ErrorForm(Language.SearchValue("errorBuscarDatos") + "\n" + ex.Message); } }