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 Nocleg : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["osoba"] == null) Response.Redirect("Formularz.aspx");

        if (Session["nocleg"] != null)
        {
            StrukturyDanych.Nocleg nocleg = (StrukturyDanych.Nocleg)Session["nocleg"];
            DropDownList1.SelectedValue = nocleg.Przyjazd.ToString();
            DropDownList2.SelectedValue = nocleg.Wyjazd.ToString();
            CheckBox1.Checked = !nocleg.CzyNocleg;
            CheckBox1_CheckedChanged(sender, e);
            RadioButtonList1.SelectedValue = nocleg.TypPokoju;
            CheckBox2.Checked = nocleg.OsobaTowarzyszaca;
            CheckBox3.Checked = !nocleg.CzyWyzywienie;          
            Session.Add("nocleg", null);
        }
    }
    
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("Index.aspx");
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        StrukturyDanych.Nocleg nocleg = new StrukturyDanych.Nocleg();
        nocleg.Przyjazd = int.Parse(DropDownList1.SelectedValue);
        nocleg.Wyjazd = int.Parse(DropDownList2.SelectedValue);
        nocleg.CzyNocleg = !CheckBox1.Checked;
        nocleg.TypPokoju = RadioButtonList1.SelectedItem.Value;
        nocleg.OsobaTowarzyszaca = CheckBox2.Checked;
        nocleg.CzyWyzywienie = !CheckBox3.Checked;
        Session.Add("nocleg", nocleg);

        Response.Redirect("Podsumowanie.aspx");
    }
    
    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        Label1.Enabled = !CheckBox1.Checked;
        RadioButtonList1.Enabled = !CheckBox1.Checked;
        CheckBox2.Enabled = !CheckBox1.Checked;
    }
}
