<%@ Page Language="JScript" %> <%@ Register TagPrefix="IBuySpy" TagName="Header" Src="_Header.ascx" %> <%@ Register TagPrefix="IBuySpy" TagName="Menu" Src="_Menu.ascx" %> <%@ Import Namespace="System.Data.SqlClient" %> <script runat="server"> //******************************************************* // // The Page_Load event on this page is used to load the // ShoppingCart DataGrid *the first time* the page is // accessed. // // Note that subsequent postbacks to the page *do not* // reload the Datagrid. Instead, we rely on the control's // built-in viewstate management to rebuild the control // on the server. // //******************************************************* function Page_Load(sender: Object, e: EventArgs) : void { if (Page.IsPostBack == false) { // Calculate end-user's shopping cart ID var cart : IBuySpy.ShoppingCartDB = new IBuySpy.ShoppingCartDB(); var cartId : String = cart.GetShoppingCartId(); // Populate datagrid with shopping cart data MyDataGrid.DataSource = cart.GetItems(cartId); MyDataGrid.DataBind(); // Update total price label TotalLbl.Text = String.Format( "{0:c}", cart.GetTotal(cartId)); } } //******************************************************* // // The SubmitBtn_Click event handle is used to order the // items within the current shopping cart. It then // displays the orderid and order status to the screen // (hiding the "SubmitBtn" button to ensure that the // user can't click it twice). // //******************************************************* function SubmitBtn_Click(sender : Object, e: ImageClickEventArgs) : void { var cart : IBuySpy.ShoppingCartDB = new IBuySpy.ShoppingCartDB(); // Calculate end-user's shopping cart ID var cartId : String = cart.GetShoppingCartId(); // Calculate end-user's customerID var customerId : String = User.Identity.Name; if ((cartId != null) && (customerId != null)) { // Place the order var ordersDatabase : IBuySpy.OrdersDB = new IBuySpy.OrdersDB(); var orderId : int = ordersDatabase.PlaceOrder(customerId, cartId); //Update labels to reflect the fact that the order has taken place Header.Text="Check Out Complete!"; Message.Text = "Your Order Number Is: " + orderId; SubmitBtn.Visible = false; } }
</script> <html> <head> <link rel="stylesheet" type="text/css" href="IBuySpy.css"> </head> <body background="images/sitebkgrd.gif" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginheight="0" marginwidth="0"> <table cellspacing="0" cellpadding="0" width="100%" border="0"> <tr> <td colspan="2"> <IBuySpy:Header ID="Header1" runat="server" /> </td> </tr> <tr> <td valign="top"> <IBuySpy:Menu id="Menu1" runat="server" /> <img height="1" src="images/1x1.gif" width="145"> </td> <td align="left" valign="top" width="100%" nowrap> <table height="100%" align="left" cellspacing="0" cellpadding="0" width="100%" border="0"> <tr valign="top"> <td nowrap> <br> <form runat="server"> <img align="left" width="24" src="images/1x1.gif"> <table cellspacing="0" cellpadding="0" width="100%" border="0"> <tr> <td class="ContentHead"> <img align="left" height="32" width="60" src="images/1x1.gif"><asp:Label ID="Header" runat="server">Review and Submit Your Order</asp:Label> <br> </td> </tr> </table> <img align="left" height="1" width="92" src="images/1x1.gif"> <table height="100%" cellspacing="0" cellpadding="0" width="550" border="0"> <tr valign="top"> <td width="100%" class="Normal"> <br> <asp:Label ID="Message" runat="server">Please check all the information below to be sure it's correct.</asp:Label> <br> <br> <asp:DataGrid id="MyDataGrid" width="90%" BorderColor="black" GridLines="Vertical" cellpadding="4" cellspacing="0" Font-Name="Verdana" Font-Size="8pt" ShowFooter="true" HeaderStyle-CssClass="CartListHead" FooterStyle-CssClass="cartlistfooter" ItemStyle-CssClass="CartListItem" AlternatingItemStyle-CssClass="CartListItemAlt" AutoGenerateColumns="false" runat="server"> <Columns> <asp:BoundColumn HeaderText="Product Name" DataField="ModelName" /> <asp:BoundColumn HeaderText="Model Number" DataField="ModelNumber" /> <asp:BoundColumn HeaderText="Quantity" DataField="Quantity" /> <asp:BoundColumn HeaderText="Price" DataField="UnitCost" DataFormatString="{0:c}" /> <asp:BoundColumn HeaderText="Subtotal" DataField="ExtendedAmount" DataFormatString="{0:c}" /> </Columns> </asp:DataGrid> <br> <br> <b>Total: </b> <asp:Label ID="TotalLbl" runat="server" /> <p> <asp:ImageButton id="SubmitBtn" ImageURL="images/submit.gif" OnClick="SubmitBtn_Click" runat="server" /> </p> </td> </tr> </table> </form> </td> </tr> </table> </td> </tr> </table> </body> </html>