示例#1
0
    //Funció per carregar la grid amb les series que segueix l'usuaris
    private void CarregarGridSeries()
    {
        series = _usuari.Series.ToList();

        GridViewSeries.DataSource = series;
        GridViewSeries.DataBind();
    }
示例#2
0
    //Al apretar el botó de actualitzar, actualitzar la bd segons les dades de la grid i recarrega aquesta.
    protected void GridViewSeries_OnRowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        //Update the values.
        GridViewRow row = GridViewSeries.Rows[e.RowIndex];

        int     id    = int.Parse(((TextBox)(row.Cells[0].Controls[0])).Text);
        string  name  = ((TextBox)(row.Cells[1].Controls[0])).Text;
        string  plot  = ((TextBox)(row.Cells[2].Controls[0])).Text;
        decimal score = Decimal.Parse(((TextBox)(row.Cells[3].Controls[0])).Text);

        string msg = ORM.actualitzarSerie(id, name, plot, score);

        if (msg != null)
        {
            CarregarGridSeriesVar();
            ScriptManager.RegisterStartupScript(this, typeof(Page), "script", "alert('Error on editing TV Serie.');", true);
        }
        else
        {
            //Reset the edit index.
            GridViewSeries.EditIndex = -1;

            //Bind data to the GridView control.
            GridViewSeries.DataBind();

            CarregarGridSeriesVar();
            ScriptManager.RegisterStartupScript(this, typeof(Page), "script", "alert('TV Serie has been edited.');", true);
        }
    }
示例#3
0
    private void CarregarGridTotesSeries()
    {
        series = ORM.retornarSeriesSearch("");

        GridViewSeries.Columns[6].Visible = false;
        GridViewSeries.DataSource         = series;
        GridViewSeries.DataBind();
    }
示例#4
0
    //Paginació de la grid
    protected void GridViewSeries_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        int tst = e.NewPageIndex;

        GridViewSeries.PageIndex  = e.NewPageIndex;
        GridViewSeries.DataSource = series;
        GridViewSeries.DataBind();
    }
示例#5
0
 //Al apretar el botó de cancelar edició, recarrega la grid al seu estat original.
 protected void GridViewSeries_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
 {
     GridViewSeries.EditIndex = -1;
     Response.CacheControl    = "no-cache";
     GridViewSeries.DataBind();
     if (!CheckBoxSeries.Checked)
     {
         CarregarGridSeries();
     }
     else
     {
         CarregarGridTotesSeries();
     }
 }
示例#6
0
    //Al apretar el botó d'editar
    protected void GridViewSeries_OnRowEditing(object sender, GridViewEditEventArgs e)
    {
        GridViewSeries.EditIndex = e.NewEditIndex;
        GridViewSeries.DataBind();

        if (!CheckBoxSeries.Checked)
        {
            CarregarGridSeries();
        }
        else
        {
            CarregarGridTotesSeries();
        }
    }
示例#7
0
    //Al apretar el botó de borrar, elimina aquesta de la BD.
    protected void GridViewSeries_OnRowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        GridViewRow row = (GridViewRow)GridViewSeries.Rows[e.RowIndex];

        int id = int.Parse(row.Cells[0].Text);

        string resultat = ORM.borrarSerie(id);

        if (resultat != null)
        {
            ScriptManager.RegisterStartupScript(this, typeof(Page), "script", "alert('Error! TV Serie has not been deleted.');", true);
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, typeof(Page), "script", "alert('TV Serie has been deleted.');", true);
        }

        GridViewSeries.DataBind();
        CarregarGridSeriesVar();
    }