Example #1
0
        protected void grvCuentas_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            //int fila =Convert.ToInt32( e.CommandArgument);
            //GridView gridPadre = (GridView)sender;
            GridViewRow row = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);

            if (e.CommandName == "EditarCuenta")
            {
                hdnId.Value   = row.Cells[0].Text;
                TxtBanco.Text = row.Cells[5].Text;

                System.Data.DataSet ds = new System.Data.DataSet();
                using (BancoDAO db = new BancoDAO())
                {
                    CuentaDAO dtadb = new CuentaDAO();
                    Cuenta    cta   = dtadb.BuscarCuenta(Convert.ToInt32(hdnId.Value));
                    hdnIdBanco.Value                    = row.Cells[4].Text;
                    ddlMoneda.SelectedValue             = Convert.ToString(cta.TipoMonedaID);
                    ddlEmpresaRecaudadora.SelectedValue = Convert.ToString(cta.CodigoCIASeguro);
                    txtNumero.Text = cta.Numero;
                    rbtPrederminado.SelectedItem.Value = Convert.ToString(cta.Predeterminado == true ? 1 : 0);

                    ds = db.ListaPropiedadesBanco(Convert.ToInt32(cta.BancoID), Convert.ToInt32(cta.TipoMonedaID));
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        lblParametro1.Text = Convert.ToString(ds.Tables[0].Rows[0][1]);
                        txtParametro1.Text = Convert.ToString(ds.Tables[0].Rows[0][2]);

                        lblParametro2.Text = Convert.ToString(ds.Tables[0].Rows[1][1]);
                        txtParametro2.Text = Convert.ToString(ds.Tables[0].Rows[1][2]);

                        lblParametro3.Text = Convert.ToString(ds.Tables[0].Rows[2][1]);
                        txtParametro3.Text = Convert.ToString(ds.Tables[0].Rows[2][2]);

                        lblParametro4.Text = Convert.ToString(ds.Tables[0].Rows[3][1]);
                        txtParametro4.Text = Convert.ToString(ds.Tables[0].Rows[3][2]);

                        string jss2 = "openModalCuentas()";
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", jss2, true);
                    }
                }
            }
            if (e.CommandName == "AnularCuenta")
            {
                using (CuentaDAO db = new CuentaDAO())
                {
                    try
                    {
                        hdnId.Value = row.Cells[0].Text;
                        db.AnularCuenta(Convert.ToInt32(hdnId.Value));
                        CargarBancos();
                        txtmensaje.Text = "Cuenta eliminada con exito";
                        string jss2 = "openModal()";
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", jss2, true);
                    }
                    catch (Exception ex)
                    {
                        txtmensaje.Text = ex.Message;
                        string jss2 = "openModal()";
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", jss2, true);
                    }
                }
            }
        }