Exemplo n.º 1
0
    protected void grvDatos_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Eliminar")
        {
            try
            {
                int         rowIndex = Convert.ToInt32(e.CommandArgument);
                GridViewRow row      = grvDatos.Rows[rowIndex];
                String      strcod   = row.Cells[1].Text;
                if (objVendedorBL.EliminarVendedor(strcod) == true)
                {
                    EnlazarDatos();
                }
                else
                {
                    throw new Exception("No se elimino el registro. Contacte con IT.");
                }
            }
            catch (Exception ex)
            {
                lblMensaje.Text = ex.Message;
                mpeMensaje.Show();
            }
        }

        if (e.CommandName == "Editar")
        {
            try
            {
                int         rowIndex = Convert.ToInt32(e.CommandArgument);
                GridViewRow row      = grvDatos.Rows[rowIndex];
                String      cod      = row.Cells[1].Text;
                String      ape      = row.Cells[2].Text;
                String      nom      = row.Cells[3].Text;
                String      fec      = row.Cells[5].Text;
                String      sue      = row.Cells[4].Text;
                String      tip      = row.Cells[6].Text;

                lblError.Text   = "";
                lblCod2.Text    = cod;
                txtNom2.Text    = ape;
                txtApe2.Text    = nom;
                txtFecIng2.Text = fec;
                txtSue2.Text    = sue;
                cboTipo2.Text   = tip;

                mpActualizar.Show();
            }
            catch (Exception ex)
            {
                lblError2.Text = ex.Message;
                mpActualizar.Show();
            }
        }
    }
Exemplo n.º 2
0
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     try
     {
         //Codifique
         DialogResult vrpta;
         vrpta = MessageBox.Show("Esta seguro de eliminar el registro?", "Confirmar",
                                 MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (vrpta == DialogResult.Yes)
         {
             String strcod = dtgVendedor.CurrentRow.Cells[0].Value.ToString();
             if (objVendedorBL.EliminarVendedor(strcod) == true)
             {
                 CargarDatos();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error : " + ex.Message);
     }
 }