protected void btnPlaceOrder_Click(object sender, EventArgs e) { string signedInUser = HttpContext.Current.User.Identity.GetUserId(); //if user is not null, do this if (signedInUser != null) { //get textbox details string shipTo = txtShipTo.Text; string shiptoadd1 = txtShipAddr1.Text; string shiptoadd2 = txtShipAddr2.Text; string shipCity = txtShipCity.Text; string shipSt = txtShipState.Text; string shipZip = txtShipZip.Text; string billAddr1 = txtBillAddr1.Text; string billAddr2 = txtBillAddr2.Text; string billcity = txtBillCity.Text; string billstate = txtBillState.Text; string billzip = txtBillZip.Text; string card = txtPymtNum.Text; string exp = txtPymtExp.Text; string cvv = txtPymtCVV.Text; string pymtName = txtPymtName.Text; //Save to Order object Order curOrder = new Order(cart, shipTo, shiptoadd1, shiptoadd2, shipCity, shipSt, shipZip, billAddr1, billAddr2, billcity, billstate, billzip, card, exp, cvv, pymtName, signedInUser); //calc rest of order details curOrder.Discount = curOrder.CalculateDiscount(); curOrder.Subtotal = curOrder.CalculateSubtotal(); curOrder.Tax = curOrder.CalculateTax(); curOrder.OrderTotal = curOrder.TotalOrder(); try //Place order { //save order to DB curOrder.SaveOrder(curOrder); // update stock on hand in DB -lg cart.UpdateStock(cart); Session["OrderIDReciept"] = curOrder.OrderID; //reset curOrder & clear listbox Order nextOrder = new Order(); curOrder = nextOrder; cart.Clear(); Response.Redirect("~/Cart/Confirmation.aspx", false); } catch (Exception ex) { Exception exc = Server.GetLastError(); // Code that runs when an unhandled error occurs ErrorHandler handler = new ErrorHandler(exc); string result = handler.SendEmail(); Response.Redirect("../ContactUs/ErrorPage.aspx?email=" + result); } } else { lblMessageCO.Text = "Please sign in first."; } }