Exemplo n.º 1
0
 protected void gvdatos_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     try
     {
         divMensaje.Attributes.Add("Style", "display:none");
         lblMensaje.Text = string.Empty;
         if (e.CommandName.Equals(CConstantes.Constantes.MODIFICAR))
         {
             TBL_MODELO item = logicaModelo.ItemPorCodigo(Convert.ToInt32(e.CommandArgument));
             hfCodigo.Value          = item.MOD_CODIGO.ToString();
             txtDescripcion.Text     = item.MOD_DESCRIPCION;
             ddlMarcas.SelectedValue = item.MAR_CODIGO.ToString();
         }
         else if (e.CommandName.Equals(CConstantes.Constantes.ELIMINAR))
         {
             logicaModelo.Eliminar(Convert.ToInt32(e.CommandArgument));
             cargarGrid();
         }
     }
     catch (Exception ex)
     {
         divMensaje.Attributes.Add("Style", "display:block");
         lblMensaje.Text = ex.Message;
     }
 }
Exemplo n.º 2
0
 protected void btnGuardar_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtDescripcion.Text))
     {
         try
         {
             TBL_MODELO item = new TBL_MODELO();
             if (hfCodigo.Value.Equals(CConstantes.Constantes.VALOR_POR_DEFECTO))
             {
                 logicaModelo.Guardar(cargaEntidad(item));
             }
             else
             {
                 item = logicaModelo.ItemPorCodigo(Convert.ToInt32(hfCodigo.Value));
                 item = cargaEntidad(item);
                 logicaModelo.Modificar(item);
             }
             limpiarControles();
             cargarGrid();
         }
         catch (Exception ex)
         {
             divMensaje.Attributes.Add("Style", "display:block");
             lblMensaje.Text = ex.Message;
         }
     }
 }
Exemplo n.º 3
0
 public void Modificar(TBL_MODELO item)
 {
     try
     {
         dc.SaveChanges();
     }
     catch (Exception ex)
     {
         throw new ArgumentException(ex.Message);
     }
 }
Exemplo n.º 4
0
 public void Guardar(TBL_MODELO item)
 {
     try
     {
         item.MOD_CODIGO = secuencial();
         dc.TBL_MODELO.Add(item);
         dc.SaveChanges();
     }
     catch (Exception ex)
     {
         throw new ArgumentException(ex.Message);
     }
 }
Exemplo n.º 5
0
 private TBL_MODELO cargaEntidad(TBL_MODELO item)
 {
     item.MOD_DESCRIPCION = txtDescripcion.Text.Trim().ToUpper();
     item.MAR_CODIGO      = Convert.ToInt32(ddlMarcas.SelectedValue);
     return(item);
 }