using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    private Koszyk koszyk = new Koszyk();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
       
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.GridView1.PageSize = System.Convert.ToInt16(DropDownList1.SelectedValue);
        GridView1.SelectedIndex = -1;
    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        DetailsView1.Visible = true;
        DetailsView1.PageIndex = GridView1.SelectedIndex + System.Convert.ToInt16(DropDownList1.SelectedValue) * GridView1.PageIndex;// +GridView1.PageIndex;
        Button1.Visible = true;
        Button2.Visible = true;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        DetailsView1.Visible = false;
        Button1.Visible = false;
        Button2.Visible = false;
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        string wpis = GridView1.SelectedRow.Cells[1].Text;
        float cena = (float)System.Convert.ToDouble(GridView1.SelectedRow.Cells[5].Text);
        koszyk.Dodaj(wpis, cena);
        if (Session["_koszyk"] == null)
            Session.Add("_koszyk", koszyk);
        else
        {
            ((Koszyk)Session["_koszyk"]).Dodaj(wpis, cena);
        }
        Response.Redirect("Default.aspx");
    }
    protected void GridView1_PageIndexChanged(object sender, EventArgs e)
    {
        GridView1.SelectedIndex = -1; 
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        
    }
}
