Exemplo n.º 1
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string Accion = Convert.ToString(e.CommandName);

            switch (Accion)
            {
            case "btneliminar":
                int         indexEliminar = Convert.ToInt32(e.CommandArgument);
                GridViewRow rowEliminar   = GridView1.Rows[indexEliminar];
                string      ID            = Server.HtmlDecode(rowEliminar.Cells[3].Text);
                if (ID == "")
                {
                }
                else
                {
                    OBCategorias.ID = int.Parse(ID);
                    if (OBCategoriasDao.DeleteCategorias(OBCategorias) == 1)
                    {
                        LoadCategorias();
                        ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "TRY();", true);
                    }
                }
                break;

            case "btnactualizar":
                int         indexUpdate = Convert.ToInt32(e.CommandArgument);
                GridViewRow rowUpdate   = GridView1.Rows[indexUpdate];
                SelectCategoria();
                OBCategorias.ID = int.Parse(Server.HtmlDecode(rowUpdate.Cells[3].Text));
                OBCategorias.NombreCategoria = txtCategorias.Text;
                OBCategorias.Status          = CategoriaStatus;
                if (OBCategoriasDao.UpdateCategoria(OBCategorias) == 1)
                {
                    LoadCategorias();
                    ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "successalert();", true);
                }



                break;

            case "btnseleccionar":
                int         index = Convert.ToInt32(e.CommandArgument);
                GridViewRow row   = GridView1.Rows[index];
                txtCategorias.Text = Server.HtmlDecode(row.Cells[4].Text);
                switch (Server.HtmlDecode(row.Cells[5].Text))
                {
                case "Activo":
                    DPGeneraSc.Text = "SI";
                    break;

                case "No Activo":
                    DPGeneraSc.Text = "NO";
                    break;

                case "Proximamente":
                    DPGeneraSc.Text = "Proximamente";
                    break;

                default:
                    break;
                }
                //this.DPGeneraSc.Text = Convert.ToString(this.GridView1.Rows[GridView1.SelectedIndex].Cells[4].Text);
                break;

            default:
                break;
            }
        }