protected void CartInfoGridView_RowUpdating(object sender, GridViewUpdateEventArgs e) { var controller = new SalesController(); var data = controller.GetCartInfo(User.Identity.Name); var totalPrice = 0.0; var totalQutity = 0; string updatedOn = ""; CartInfoGridView.DataSource = data; CartInfoGridView.DataBind(); foreach (GridViewRow row in CartInfoGridView.Rows) { if (int.Parse((row.FindControl("QOH") as HiddenField).Value) - int.Parse((row.FindControl("Quantity") as Label).Text) < 0) { (row.FindControl("OutOfStockLabel") as Label).Text = "Out of Stock. We only have " + int.Parse((row.FindControl("QOH") as HiddenField).Value) + " in stock."; //have to change //totalQutity = totalQutity + int.Parse((row.FindControl("QOH") as HiddenField).Value); } //else //{ // totalQutity = totalQutity + int.Parse((row.FindControl("Quantity") as Label).Text); //} totalQutity++; totalPrice = totalPrice + double.Parse((row.FindControl("TotalPrice") as Label).Text.Substring(1)); updatedOn = (row.FindControl("UpdatedOn") as HiddenField).Value; } TotalPrice.Text = "" + totalPrice.ToString("C"); ItemAmountUpdateOn.Text = totalQutity + " items in your cart( last updated on " + updatedOn + " )"; }
protected void CheckOut_Click(object sender, EventArgs e) { PartCatelogPanel.Visible = false; ViewCartPanel.Visible = true; NavigationPanel.Visible = true; PurchaseInfoPanel.Visible = false; PlaceOrderPanel.Visible = false; var controller = new SalesController(); var data = controller.GetCartInfo(User.Identity.Name); var totalPrice = 0.0; var totalQutity = 0; string updatedOn = ""; CartInfoGridView.DataSource = data; CartInfoGridView.DataBind(); foreach (GridViewRow row in CartInfoGridView.Rows) { if (int.Parse((row.FindControl("QOH") as HiddenField).Value) - int.Parse((row.FindControl("Quantity") as Label).Text) < 0) { (row.FindControl("OutOfStockLabel") as Label).Text = "Out of Stock. We only have " + int.Parse((row.FindControl("QOH") as HiddenField).Value) + " in stock."; //have to change //totalQutity = totalQutity + int.Parse((row.FindControl("QOH") as HiddenField).Value); } //else //{ // totalQutity = totalQutity + int.Parse((row.FindControl("Quantity") as Label).Text); //} totalQutity++; totalPrice = totalPrice + double.Parse((row.FindControl("TotalPrice") as Label).Text.Substring(1)); updatedOn = (row.FindControl("UpdatedOn") as HiddenField).Value; //updatedOn = String.Format("{0:MM/d/yyyy}", (row.FindControl("UpdatedOn") as HiddenField).Value); } TotalPrice.Text = "" + totalPrice.ToString("C"); ItemAmountUpdateOn.Text = totalQutity + " items in your cart( last updated on " + updatedOn + " )"; }