<%@ page language="VB" %>

<script runat="server">


    Sub cmdSet_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Profile.FullName = "Jan Milioner"
    End Sub

    Sub cmdGet_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Label1.Text = Profile.FullName & " " & DateTime.Now.ToShortDateString
    End Sub

    
    Sub cmdAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Profile.Basket.Items.Add(New BasketItem(txtItemName.Text))
    End Sub

    Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs)
        lstItems.DataSource = Profile.Basket.Items
        lstItems.DataTextField = "Name"
        lstItems.DataValueField = "ID"
        lstItems.DataBind()
    End Sub

    Sub cmdRemove_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        For Each Item As BasketItem In Profile.Basket.Items
            If Item.ID = lstItems.SelectedItem.Value Then
                Profile.Basket.Items.Remove(Item)
                Return
            End If
        Next
    End Sub

    Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        If Profile.Basket Is Nothing Then Profile.Basket = New Basket()
    End Sub
</script>

<html>
<head id="Head1" runat="server">
    <title>Strona testowa</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    
    </div>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Label ID="Label1" Runat="server" Width="162px">
        </asp:Label>
        <br />
        <br />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="cmdSet" Runat="server" Text="Ustaw profil" OnClick="cmdSet_Click" />
        <asp:Button ID="cmdGet" Runat="server" Text="Pobierz profil" OnClick="cmdGet_Click" /><br />
        <br />
        <br />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<asp:ListBox ID="lstItems" Runat="server" Width="278px"
            Height="106px">
        </asp:ListBox>&nbsp;<br />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:TextBox ID="txtItemName" Runat="server"
            Width="278px"></asp:TextBox>&nbsp;<br />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="cmdAdd" Runat="server" Width="106px" Text="Dodaj produkt" OnClick="cmdAdd_Click" />
        <asp:Button ID="cmdRemove" Runat="server" Width="169px" Text="Usuń zaznaczony produkt" OnClick="cmdRemove_Click" />
    </form>
</body>
</html>
