public ActionResult DeleteOrder(int?id) { var GetUser = Convert.ToInt32(Session["CustomerID"]); // Get category Categories category = Category.GetCategory(id); // Get Table which foreign key id is GetUser id var checkTable = Table.GetTables().Where(c => c.ID == GetUser).SingleOrDefault(); if (checkTable != null) { // Find which order is related to the category id and tables id OrderCart ordercart = OrderCart.GetOrderCarts().Where(c => c.CategoryID == id && c.TablesID == checkTable.TablesID).SingleOrDefault(); OrderCart.RemoveOrderCart(ordercart); checkTable.TotalQuantity -= ordercart.Quantity; checkTable.TotalAmount -= ordercart.TotalAmount; // After minus the quantity and amount if the quantity become 0 thn will go in this if statement if (checkTable.TotalQuantity == 0) { checkTable.TStatus = TStatus.Empty; checkTable.TotalQuantity = 0; checkTable.TotalAmount = 0; checkTable.ID = null; } Table.UpdateTable(checkTable); } return(RedirectToAction("MyOrder")); }
private void MigrateShoppingCart(string Email) { var cart = OrderCart.GetCart(this.HttpContext); cart.MigrateCart(Email); Session[OrderCart.CartSessionKey] = Email; }
public ActionResult CartSummary() { var cart = OrderCart.GetCart(this.HttpContext); ViewData["CartCount"] = cart.GetCount(); return(PartialView("CartSummary")); }
protected void btnAddItem_Click(object sender, EventArgs e) { dpVendor.Enabled = false; orderCart = new OrderCart(); purchaseData = new PurchaseData(); orderCart.Tokan = hftokanno.Value; orderCart.CreatedBy = GlobalInfo.Userid; orderCart.RequestDetailsId = Convert.ToInt32(dpItem.SelectedItem.Value); orderCart.Quantity = Convert.ToDecimal(hfQuantity.Value); orderCart.VendorId = Convert.ToInt32(dpVendor.SelectedItem.Value); orderCart.Price = Convert.ToDecimal(txtPrice.Text); orderCart.Excise = Convert.ToDouble(txtExcise.Text); orderCart.cst = Convert.ToDouble(txtCST.Text); orderCart.Vat = Convert.ToDouble(txtVat.Text); //orderCart.Insurance = Convert.ToDecimal(txtInsurance.Text); orderCart.Insurance = 0; orderCart.Amt = orderCart.Quantity * (orderCart.Price + (orderCart.Price / 100) * Convert.ToDecimal(orderCart.Excise) + (orderCart.Price / 100) * Convert.ToDecimal(orderCart.cst) + (orderCart.Price / 100) * Convert.ToDecimal(orderCart.Vat) + orderCart.Insurance); orderCart.Flag = 1; //1 for INSERT bool result = purchaseData.OrderCartDML(orderCart); if (result) { clearField(); bindCartList(orderCart); } dpSelect(); }
public ActionResult GioHang() { OrderCart model = new OrderCart(); model.listSanpham = new List <ProductsCart>(); ProductsBLL _getprod = new ProductsBLL(); if (Request.Cookies["shopcard"] != null) { var _list = JsonConvert.DeserializeObject <List <Cart> >(Request.Cookies["shopcard"].Value); List <Products> _listProduct = new List <Products>(); _list.ForEach(p => { var _object = _getprod.ProductById(p.ProductId); if (_object != null) { ProductsCart _cart = new ProductsCart(); _cart.Id = _object.Id; _cart.Name = _object.Name; _cart.Price = _object.Price; _cart.PriceSale = _object.PriceSale; _cart.Url = _object.Url; _cart.Quality = p.Number; _cart.AllPrice = (_object.PriceSale == 0 ? (p.Number * _object.Price) : (p.Number * _object.PriceSale)); model.listSanpham.Add(_cart); } }); model.TamTinh = model.listSanpham.Sum(p => p.AllPrice); model.AllPayment = model.listSanpham.Sum(p => p.AllPrice); } return(View(model)); }
public ActionResult AddOrder(int id) { OrderCart cart = OrderCart.GetCart(this.HttpContext); cart.AddOrder(id); return(RedirectToAction("OrderSummary")); }
/// <summary> /// 添加到购物车 /// </summary> /// <param name="userID"></param> /// <param name="gdsID"></param> /// <param name="count"></param> /// <returns></returns> public bool ADDToCart(int userID, int gdsID, int count) { //找到商品 var goodsData = GetGoodsDataBygoodsID(gdsID); //状态、库存检查 if (goodsData == null) { throw new VerificationException("该商品不存在."); } //若限制库存 判断库存是否足够 if (!String.IsNullOrWhiteSpace(goodsData.stockLimit) && goodsData.stockLimit.Equals("1") && goodsData.stock < count) { throw new VerificationException("库存不足够."); } //添加到购物车 OrderCart orderCart = new OrderCart() { addTime = GetSystemTime(), count = count, gdsID = gdsID, userID = userID }; string sql = $@"IF NOT EXISTS (SELECT 1 FROM order_cart WHERE userID = @userID AND gdsID = @gdsID) INSERT INTO order_cart (userID,gdsID,count,addtime) VALUES(@userID,@gdsID,@count,GETDATE()) ELSE UPDATE order_cart set count = count + @count , addtime = GETDATE() WHERE userID = @userID and gdsid = @gdsID"; return(commonDB.Excute(sql, orderCart) == 1); }
public ActionResult RemoveFromCart(int id) { // Remove the item from the cart var cart = OrderCart.GetCart(this.HttpContext); // Get the name of the product to display confirmation string productName = db.CartItems .Single(item => item.CartItemId == id).Product.Name; // Remove from cart int itemCount = cart.RemoveFromCart(id); // Display the confirmation message var results = new OrderCartRemoveViewModel { Message = Server.HtmlEncode(productName) + " has been removed from your shopping cart.", CartTotal = cart.GetTotal(), CartCount = cart.GetCount(), ItemCount = itemCount, DeleteId = id }; return(Json(results)); }
protected void rpAgentOrderdetails_ItemCommand(object source, RepeaterCommandEventArgs e) { int TempID = 0; TempID = Convert.ToInt32(e.CommandArgument); switch (e.CommandName) { case ("delete"): { orderCart = new OrderCart(); purchaseData = new PurchaseData(); orderCart.OrderCartId = TempID; orderCart.Tokan = hftokanno.Value; orderCart.CreatedBy = GlobalInfo.Userid; orderCart.Flag = 2; //2 for delete purchaseData.OrderCartDML(orderCart); bindCartList(orderCart); //RemoveTempID(TempID); //invocie.TokanId = hftokanno.Value; //invocie.UserID = GlobalInfo.Userid; //BindAgntTempItam(invocie); upMain.Update(); break; } } }
/// <summary> /// Creates a new order for a user, called if a order doesn't already exist for the user in question /// </summary> /// <param name="orderItem">OrderItem information for creation</param> /// <returns>Successful result of OrderItem creation</returns> public async Task <OrderCart> Create(OrderCart order) { _context.Entry(order).State = EntityState.Added; await _context.SaveChangesAsync(); return(order); }
public ActionResult RemoveFromCart(int id) { // Remove the item from the cart var cart = OrderCart.GetCart(this.HttpContext); // Get the name of the album to display confirmation string albumName = unitOfWork.CartRepository.dbSet .Single(item => item.RecordId == id).ProductItem.Name; // Remove from cart int itemCount = cart.RemoveFromCart(id); // Display the confirmation message var results = new ShoppingCartRemoveViewModel { Message = Server.HtmlEncode(albumName) + " has been removed from your shopping cart.", CartTotal = cart.GetTotal(), CartCount = cart.GetCount(), ItemCount = itemCount, DeleteId = id }; return(Json(results)); }
//GET public ActionResult AddToCart(int id) { OrderCart cart = OrderCart.GetCart(this.HttpContext); cart.AddToCart(id); return(RedirectToAction("Index")); }
//order cart public void SaveOrderCarts(OrderCart orderCart) { if (orderCart.OrderCartId == 0) { context.OrderCart.Add(orderCart); } context.SaveChanges(); }
private void MigrateShoppingCart(string UserName) { // Associate shopping cart items with logged-in user var cart = OrderCart.GetCart(this.HttpContext); cart.MigrateCart(UserName); Session[OrderCart.CartSessionKey] = UserName; }
private void bindCartList(OrderCart orderCart) { purchaseData = new PurchaseData(); DS = new DataSet(); orderCart.Flag = 0; //Get Full List rpAgentOrderdetails.DataSource = purchaseData.GetOrderCartList(orderCart); rpAgentOrderdetails.DataBind(); }
// GET: Orders public ActionResult Index() { OrderCart cart = OrderCart.GetCart(this.HttpContext); OrderCartViewModel vm = new OrderCartViewModel() { CartItems = cart.GetCartItems(), }; return(View(vm)); }
public IActionResult Index() { var orderCart = new OrderCart { ProductsInCart = _orderCartService.GetProducts(), TotalPrice = _orderCartService.GetTotalPrice() }; return(View(orderCart)); }
public ActionResult AddToCart(int id) { var addedAlbum = unitOfWork.ProductItemRepository.dbSet .Single(album => album.ID == id); var cart = OrderCart.GetCart(this.HttpContext); cart.AddToCart(addedAlbum); return(RedirectToAction("Index")); }
/// <summary> /// Delete a order from the database, used when the last item in a /// </summary> /// <param name="id">Id of orderItem to be deleted</param> /// <returns>Task of completion for orderItem delete</returns> public async Task Delete(string userId, int orderId) { OrderCart order = await _context.OrderCart.FindAsync(userId, orderId); if (order != null) { _context.Entry(order).State = EntityState.Deleted; await _context.SaveChangesAsync(); } }
public OrdersReport GetOrdersReport(OrderCart cart) { var ordersReport = ComputeOrdersReport(cart); ComputeDiscounts(ordersReport); RecalculateTotal(ordersReport); AddSpeedyShipping(cart.HasFastDeliver, ordersReport); RecalculateTotal(ordersReport); return(ordersReport); }
public IHttpActionResult PutnewProduct([FromUri] int id, [FromBody] OrderCart ordercart) { OrderCartRepository cartrepo = new OrderCartRepository(); ordercart.ID = id; cartrepo.Update(ordercart); return(Ok(ordercart)); }
public ActionResult Index() { var cart = OrderCart.GetCart(this.HttpContext); var viewModel = new ShoppingCartViewModel { CartItems = cart.GetCartItems(), CartTotal = cart.GetTotal() }; return(View(viewModel)); }
public IHttpActionResult Post(OrderCart orderCart) { if (ModelState.IsValid) { orderCartDB.Insert(orderCart); var uri = Url.Link("GetCartByID", new { id = orderCart.ID }); return(Created(uri, orderCart)); } else { return(BadRequest(ModelState)); } }
public Order GetCart(List <OrderCart> orderCarts) { var order = new Order(); try { foreach (var orderCart in orderCarts) { string query = "select * from XXFS_PRODUCT where prod_id = " + orderCart.ProductId; DataSet dataSet = OracleHelper.ExecuteDataset(Constants.Application.DBConnConnectionString, CommandType.Text, query); if (dataSet != null && dataSet.Tables[0].Rows.Count > 0) { foreach (DataRow row in dataSet.Tables[0].Rows) { var cart = new OrderCart { ProductId = row["prod_id"].ToString() != "null" ? Convert.ToInt32(row["prod_id"].ToString()) : 0, ProductName = row["PRODUCT_NAME"].ToString() != "null" ? row["PRODUCT_NAME"].ToString() + " (Id: " + Convert.ToInt32(row["prod_id"].ToString()) + ")" : "", ProductImage = row["Product_Image"].ToString() != "null" ? row["Product_Image"].ToString() : "", Quantity = orderCart.Quantity, ItemQuantity = orderCart.Quantity.ToString(), Price = row["Price"].ToString() != "null" ? Convert.ToDecimal(row["Price"].ToString()) : 0, TotalPrice = orderCart.Quantity * Convert.ToDecimal(row["Price"].ToString()), }; var totalQuantity = row["Quantity"].ToString() != "null" ? Convert.ToInt32(row["Quantity"].ToString()) : 0; var quantities = new List <SelectListItem>(); for (int i = 1; i <= totalQuantity; i++) { quantities.Add(new SelectListItem { Value = i.ToString(), Text = i.ToString() }); } cart.Quantities = quantities; order.OrderCarts.Add(cart); } } } if (order.OrderCarts != null && order.OrderCarts.Count > 0) { order.SubTotal = order.OrderCarts.Sum(x => x.TotalPrice); order.Total = order.OrderCarts.Sum(x => x.TotalPrice); } } catch (Exception ex) { logger.Error(ex); } return(order); }
protected void btnSubmit_Click(object sender, EventArgs e) { Order order = new Order(); purchaseData = new PurchaseData(); orderCart = new OrderCart(); order.VendorId = Convert.ToInt32(dpVendor.SelectedItem.Value); order.CreatedBy = GlobalInfo.Userid; order.TillDate = (Convert.ToDateTime(txtTillDate.Text)).ToString("dd-MM-yyyy"); order.Tokan = hftokanno.Value; order.Frieght = txtFrieght.Text; order.PaymentTerms = txtTerms.Text; order.TransDamage = txtTrDamage.Text; order.Warranty = txtWarranties.Text; order.TotalAmt = Convert.ToDecimal(hftotalAmout.Value); if (order.TotalAmt > 49999) { order.MDApproval = "Pending"; } else { order.MDApproval = "Not Required"; } orderCart.Tokan = hftokanno.Value; bool result = purchaseData.SubmitOrder(order); if (result) { bindCartList(orderCart); clearFields(); divDanger.Visible = false; divwarning.Visible = false; divSusccess.Visible = true; pnlError.Update(); upMain.Update(); } else { divDanger.Visible = false; divwarning.Visible = true; divSusccess.Visible = false; lblwarning.Text = "Please Contact to Site Admin"; pnlError.Update(); } dpSelect(); }
private static OrdersReport ComputeOrdersReport(OrderCart cart) { var result = new List <OrderItem>(); cart.Products.ToList().ForEach(p => ComputeOrdersReportInternal(result, p)); var ordersReport = new OrdersReport { Items = result, Total = result.Sum(r => r.Cost) }; return(ordersReport); }
// // GET: /OrderCart/ public ActionResult Index() { var cart = OrderCart.GetCart(this.HttpContext); // Set up our ViewModel var viewModel = new OrderCartViewModel { CartItems = cart.GetCartItems(), CartTotal = cart.GetTotal() }; // Return the view return(View(viewModel)); }
public IHttpActionResult Post([FromBody] OrderCart ordercart) { OrderCartRepository cartrepo = new OrderCartRepository(); if (ModelState.IsValid) { cartrepo.Insert(ordercart); return(Created("api/sellproducts/" + ordercart.ID, ordercart)); } else { return(BadRequest(ModelState)); } }
// // GET: /Store/AddToCart/5 public ActionResult AddToCart(int id) { // Retrieve the product from the database var addedProduct = db.Products .Single(product => product.Id == id); // Add it to the shopping cart var cart = OrderCart.GetCart(this.HttpContext); cart.AddToCart(addedProduct); // Go back to the main store page for more shopping return(RedirectToAction("Index")); }
/// <summary> /// 获取购物车信息 通过用户ID /// </summary> /// <param name="userID"></param> /// <returns></returns> public IEnumerable <OrderCart> GetCartsDataByUserID(int userID) { OrderCart orderCart = new OrderCart() { userID = userID }; string sqlCondition = SelectSqlGenerate <OrderCart>(orderCart, new List <string>() { nameof(orderCart.userID) }); string sql = $"SELECT * FROM order_cart {sqlCondition} AND count > 0"; return(commonDB.Query <OrderCart>(sql, orderCart)); }