protected void btnAgregar_Click(object sender, EventArgs e) { try { if (txtNombreTipoInfo.Text.Equals("")) { lblmensaje.Text = "Ingrese nombre tipo información"; return; } TipoInfoDTO tipo = new TipoInfoDTO(); tipo.Nombre = txtNombreTipoInfo.Text; if (TipoInfoNegocio.CrearTipoInfo(tipo)) { lblmensaje.Text = "Ingresado Correctamente"; limpiar(); cargarGrilla(); } else { lblmensaje.Text = "Error, no se pudo ingresar"; } } catch (Exception ex) { lblmensaje.Text = ex.Message; } }
protected void btnActualizar_Click(object sender, EventArgs e) { try { TipoInfoDTO tipo = new TipoInfoDTO(); tipo.Id = int.Parse(hdId.Value); tipo.Nombre = txtNombreTipoInfo.Text; if (TipoInfoNegocio.ActualizarTipoInfo(tipo)) { lblmensaje.Text = "Actualizado correctamente"; hdId.Value = ""; limpiar(); btnActualizar.Visible = false; btnAgregar.Visible = true; cargarGrilla(); } else { lblmensaje.Text = "Error, no se pudo actualizar"; } } catch (Exception ex) { lblmensaje.Text = ex.Message; } }
public static TipoInfoDTO ObtenerTipoInfoFiltroID(int tipo) { TipoInfoDTO tipoInfo = new TipoInfoDTO(); using (DB_A5AC51_micosporeEntities db = new DB_A5AC51_micosporeEntities()) { TIPO_INFO tipoData = db.TIPO_INFO.Where(p => p.ID == tipo).First(); tipoInfo.Id = tipoData.ID; tipoInfo.Nombre = tipoData.NOMBRE; } return(tipoInfo); }
protected void btnEditar_Click(object sender, EventArgs e) { try { TipoInfoDTO tipo = null; int id = 0; for (int i = 0; i <= GvTipoInfo.Rows.Count - 1; i++) { bool bChequeado = ((HtmlInputRadioButton)GvTipoInfo.Rows[i].FindControl("RadioButton1")).Checked; if (bChequeado) { id = Convert.ToInt32(GvTipoInfo.DataKeys[GvTipoInfo.Rows[i].RowIndex][0].ToString()); break; } } if (id == 0) { lblmensaje.Text = "Seleccione un valor"; return; } tipo = TipoInfoNegocio.ObtenerTipoInfoFiltroID(id); if (tipo == null) { lblmensaje.Text = "No se encuentran datos"; } else { txtNombreTipoInfo.Text = tipo.Nombre; hdId.Value = tipo.Id.ToString(); btnActualizar.Visible = true; btnAgregar.Visible = false; } } catch (Exception ex) { lblmensaje.Text = ex.Message; } }
protected void btnEliminar_Click(object sender, EventArgs e) { try { int id = 0; for (int i = 0; i <= GvTipoInfo.Rows.Count - 1; i++) { bool bChequeado = ((HtmlInputRadioButton)GvTipoInfo.Rows[i].FindControl("RadioButton1")).Checked; if (bChequeado) { id = Convert.ToInt32(GvTipoInfo.DataKeys[GvTipoInfo.Rows[i].RowIndex][0].ToString()); break; } } if (id == 0) { lblmensaje.Text = "Seleccione un valor"; return; } TipoInfoDTO tipo = new TipoInfoDTO(); tipo.Id = id; if (TipoInfoNegocio.EliminarTipoInfo(tipo)) { lblmensaje.Text = "Eliminado correctamente"; cargarGrilla(); } else { lblmensaje.Text = "Error, no se pudo eliminar"; } } catch (Exception ex) { lblmensaje.Text = ex.Message; } }
public static bool EliminarTipoInfo(TipoInfoDTO tipo) { return(TipoInfoData.MantenedorTipoInfo(tipo, 3)); }
public static bool ActualizarTipoInfo(TipoInfoDTO tipo) { return(TipoInfoData.MantenedorTipoInfo(tipo, 2)); }
public static bool CrearTipoInfo(TipoInfoDTO tipo) { return(TipoInfoData.MantenedorTipoInfo(tipo, 1)); }