Beispiel #1
0
        protected void btnAgregar_Click(object sender, EventArgs e)
        {
            if (rfvNombre.IsValid && revPais.IsValid)
            {
                Pais   pais   = new Pais();
                n_Pais n_pais = new n_Pais();
                pais.nombre   = txtPais.Text;
                pais.cod_pais = 0;
                pais.estado   = true;

                if (n_pais.existePais(pais.nombre))
                {
                    pais.cod_pais = int.Parse(n_pais.getTablaPorNombre(pais.nombre));
                    if (n_pais.editarPais(pais))
                    {
                        lblExito.Text      = "Exito al agregar";
                        lblExito.ForeColor = System.Drawing.Color.Green;
                        vaciarTextBox();
                        cargarGrilla();
                    }
                    else
                    {
                        vaciarTextBox();
                        lblExito.Text      = "Error al agregar.";
                        lblExito.ForeColor = System.Drawing.Color.Red;
                    }
                }
                else
                {
                    if (n_pais.agregarPais(pais))
                    {
                        lblExito.Text      = "Exito al agregar";
                        lblExito.ForeColor = System.Drawing.Color.Green;
                        vaciarTextBox();
                        cargarGrilla();
                    }
                    else
                    {
                        vaciarTextBox();
                        lblExito.Text      = "Error al agregar.";
                        lblExito.ForeColor = System.Drawing.Color.Red;
                    }
                }
            }
            else
            {
                lblExito.Text = "";
            }
        }
Beispiel #2
0
        protected void gvPaises_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            String s_Nombre = ((TextBox)gvPaises.Rows[e.RowIndex].FindControl("txtPais_edit")).Text;
            String s_Cod    = ((Label)gvPaises.Rows[e.RowIndex].FindControl("lblCod_edit")).Text;
            Pais   pais     = new Pais();

            pais.nombre   = s_Nombre;
            pais.cod_pais = int.Parse(s_Cod);
            pais.estado   = true;

            n_Pais n_pais = new n_Pais();

            n_pais.editarPais(pais);

            gvPaises.EditIndex = -1;
            cargarGrilla();
            lblExito.Text = "";
        }