protected void btnDeleteAll_Click(object sender, EventArgs e) { string cart_id = Request.Cookies["cart_id"].Value; OrderAccess oa = new OrderAccess(); try { oa.DeleteCart(cart_id); Response.Cookies["cart_id"].Expires = DateTime.MinValue; Response.Cookies["itemQuantity"].Expires = DateTime.MinValue; ClientScript.RegisterClientScriptBlock(this.GetType(), "{delete Success}", "alert('Everything in Cart was deleted! heading back to home');window.location.href='Default.aspx' ", true); } catch { oa.DeleteCart(cart_id); ClientScript.RegisterClientScriptBlock(this.GetType(), "{error}", "alert('database connect error');window.location.href='Default.aspx' ", true); } }
protected void linkLogin_Click(object sender, EventArgs e) { try { if (loginStatus()) //logout; clear all cookies { Response.Cookies["name"].Expires = DateTime.MinValue; //delete user cookies Response.Cookies["user_id"].Expires = DateTime.MinValue; Response.Cookies["date"].Expires = DateTime.MinValue; Response.Cookies["roles"].Expires = DateTime.MinValue; linkLogin.Text = "Login"; //set link to "Login" again try { if (cartStatus()) //if cart item is still there { OrderAccess oa = new OrderAccess(); oa.DeleteCart(Request.Cookies["cart_id"].Value); //delete all cart orders from the database Response.Cookies["cart_id"].Expires = DateTime.MinValue; Response.Cookies["itemQuantity"].Expires = DateTime.MinValue; //and delete cart cookie } } catch { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "{error}", "alert('{Master page logout error}');window.location.href='Login.aspx' ", true); } Response.Redirect("Login.aspx"); } else { Response.Redirect("Login.aspx"); } } catch { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "{error}", "alert('{Master logout error}');window.location.href='Login.aspx' ", true); } }