protected void Button_FinCompra(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["damncookie"]; if (check_caducidad()) { ENUser user = new ENUser(0, "", "", cookie["username"], new DateTime(), "", "", ""); if (user.ReadID()) { ENCart cart = new ENCart(0, user.userID, 0.0F, 0); DataTable table = cart.ReadCart(); ENOrder order = new ENOrder(user.userID, "Preparando", paga, DateTime.Now); if (order.CreateOrder()) { for (int i = 0; i < table.Rows.Count; i++) { ENProduct p = new ENProduct(Convert.ToInt32(table.Rows[i][0].ToString()), "", 0.0F, 0, "", "", "", ""); if (p.ReadProductFromCatalog()) { p.stock -= Convert.ToInt32(table.Rows[i][3].ToString()); } p.UpdateProduct(); } cart.DeleteCart(); } } Response.Redirect("Default.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["damncookie"]; if (cookie != null) { ENUser user = new ENUser(0, "", "", cookie["username"], new DateTime(), "", "", ""); if (user.ReadUserPerfil()) { Direccion.Text = user.address; } ENCart cart = new ENCart(0, 0, 0.0F, 0); DataTable table = cart.ReadCart(); for (int i = 0; i < table.Rows.Count; i++) { paga = float.Parse(table.Rows[i][3].ToString()) * float.Parse(table.Rows[i][4].ToString()) + paga; } TotalPrice.Text = Convert.ToString(paga) + "€"; } }