public ActionResult OrderDetail(int orderId) { try { CusManageBusiness cmb = new CusManageBusiness(); CustomerOrderBusiness cob = new CustomerOrderBusiness(); int quantity = 0; var order = cmb.GetOrderDetail(orderId); if (order.CustomerUserId != Convert.ToInt32(Session["UserId"])) { return RedirectToAction("Index", "Home"); } var orderItems = cmb.GetOrderItem(orderId); ViewBag.taxRate = cob.GetTaxRate(); ViewBag.orderItems = orderItems; foreach (var item in orderItems) { quantity += item.Quantity; } ViewBag.Discount = cob.checkDiscount(quantity); return View(order); } catch (Exception) { return RedirectToAction("Index", "Error"); } }
public ActionResult OrderList(int? page, string orderStatus, string fromDate, string toDate) { try { MvcApplication.cancelOrderNotifier.Dispose(); if (!MvcApplication.lowQuantityNotifer.CheckConnection()) { MvcApplication.lowQuantityNotifer.Start("BMAChangeDB", "SELECT ProductMaterialId,CurrentQuantity,StandardQuantity FROM dbo.[ProductMaterial] WHERE (CurrentQuantity < StandardQuantity AND IsActive = 'True')"); MvcApplication.lowQuantityNotifer.Change += this.OnChange2; } CusManageBusiness cmb = new CusManageBusiness(); //string orderStatus = f["searchStatus"]; //string fromDate = f["searchFromDate"]; //string toDate = f["searchToDate"]; int pageSize = 10; int pageNumber = (page ?? 1); if (Session["User"] != null) { int cusId = Convert.ToInt32(Session["UserId"]); List<OrderItem> orderItemList = new List<OrderItem>(); var orderList = cmb.GetOrder(cusId).OrderBy(n => n.OrderStatus).ToPagedList(pageNumber, pageSize); if (fromDate != null & toDate != null) { //orderStatus = orderStatus.Value; //fromDate = fromDate.Value; //toDate = toDate.Value; orderList = cmb.SearchOrder(cusId, orderStatus, fromDate, toDate).OrderBy(n => n.OrderStatus).ToPagedList(pageNumber, pageSize); ViewBag.FromDate = fromDate; ViewBag.ToDate = toDate; ViewBag.Status = orderStatus; TempData["Search"] = 1; } foreach (var item in orderList) { orderItemList = orderItemList.Union(cmb.GetOrderItem(item.OrderId)).ToList(); } ViewBag.orderItemList = orderItemList; return View(orderList); } return RedirectToAction("Index", "Home"); } catch (Exception) { return RedirectToAction("Index", "Error"); } }
public ActionResult ConfirmOrder(int orderId) { try { CusManageBusiness cmb = new CusManageBusiness(); CustomerOrderBusiness cob = new CustomerOrderBusiness(); int quantityConfirm = 0; int quantityOld = 0; var orderCheck = cmb.GetOrderDetail(orderId); if (orderCheck.CustomerUserId != Convert.ToInt32(Session["UserId"])) { return RedirectToAction("Index", "Home"); } Order confirmedOrder = cmb.GetOrderDetail(orderId); List<OrderItem> orderItems = cmb.GetOrderItem(orderId); int? previousId = confirmedOrder.PreviousOrderId; Order oldOrder = cmb.GetOrderDetail(previousId); List<OrderItem> oldOrderItems = cmb.GetOrderItem(previousId); foreach (var item in orderItems) { quantityConfirm += item.Quantity; } ViewBag.DiscountConfirm = cob.checkDiscount(quantityConfirm); foreach (var item in oldOrderItems) { quantityOld += item.Quantity; } ViewBag.DiscountOld = cob.checkDiscount(quantityOld); ViewBag.taxRate = cob.GetTaxRate(); ViewBag.oldOrder = oldOrder; ViewBag.orderItems = orderItems; ViewBag.oldOrderItems = oldOrderItems; return View(confirmedOrder); } catch (Exception) { return RedirectToAction("Index", "Error"); } }