Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 3870 Prog5 Shopping Bag.

Similar presentations


Presentation on theme: "CS 3870 Prog5 Shopping Bag."— Presentation transcript:

1 CS 3870 Prog5 Shopping Bag

2 Prog 5 MainMasterPage Prog5MasterPage same as Prog4
Create a new master page

3 Prog 5 New folder Prog5 New pages Default.aspx Updating.aspx
Shoppin.aspx Checkout.aspx Then could copy content from Prog4 Modify as necessary

4 Prog 5 Do them after Shopping Bag is completed Main Web Site folder
Login.aspx CreateUser.aspx UserName: csse Do them after Shopping Bag is completed

5 New Page Checkout Maintain a shopping bag for each session
Add items into the shopping bag when shopping GridView to display all items in the shopping bag on checkout Clear the bag when checkout

6 Shopping Bag Your Choice DataTable ArrayList
New class: in folder App_Code . . .

7 Shopping Bag: Using DataTable
// SQLDataClass using System.Data; public static DataTable NewShoppingBag() { DataTable table = new DataTable(); table.Columns.Add("ProductID"); table.Columns.Add("ProductName"); table.Columns.Add("Quantity"); table.Columns.Add("UnitPrice"); table.Columns.Add("Cost"); table.PrimaryKey = new DataColumn[] { table.Columns[0] }; return table; }

8 Global.vb void Session_Start(object sender, EventArgs e) { //Prog5 Session["Prog5_Bag"] = SQLDataClass.NewShoppingBag(); }

9 Page Shopping //New Button “Add to Shopping Bag” //Adds the last calculated item to the shopping bag. protected void btnAddToBag_Click(object sender, EventArgs e) { DataTable bag = (DataTable) Session["Prog5_Bag"]; DataRow row = bag.NewRow(); row[0] = txtID.Text; row[1] = txtName.Text; row[2] = txtPrice.Text; row[3] = txtQuantity.Text; row[4] = txtSubTotal.Text; DataRow oldRow = bag.Rows.Find(row[0]); if (oldRow != null) bag.Rows.Remove(oldRow); bag.Rows.Add(row); }

10 Page Checkout protected void Page_Load(object sender, EventArgs e) { GridView1.DataSource = (DataTable)Session["Prog5_Bag"]; GridView1.DataBind(); }

11 Page Checkout protected void btnCheckout_Click(. . .) { // End the current session // will clear all session variables Session.Abandon(); // Logout of Membership FormsAuthentication.SignOut() // Go to Login.aspx // Response.Redirect("~/Login.aspx"); Response.Redirect(FormsAuthentication.LoginUrl); }


Download ppt "CS 3870 Prog5 Shopping Bag."

Similar presentations


Ads by Google