public int CancelBothOrder(int orderId)
 {
     try
     {
         CusManageBusiness cmb = new CusManageBusiness();
         var orderCheck = cmb.GetOrderDetail(orderId);
         if (orderCheck.CustomerUserId != Convert.ToInt32(Session["UserId"]))
         {
             return -2;
         }
         OrderBusiness ob = new OrderBusiness();
         int userId = Convert.ToInt32(Session["UserId"]);
         if (orderCheck.OrderStatus != 0)
         {
             string dependencyCheckSql = string.Format("{0}{1}", "SELECT OrderId FROM dbo.[Orders] WHERE CustomerUserId = ", userId);
             MvcApplication.lowQuantityNotifer.Dispose();
             MvcApplication.cancelOrderNotifier.Start("BMAChangeDB", dependencyCheckSql);
             MvcApplication.cancelOrderNotifier.Change += this.CancelOnChange;
         }
         ob.Cancel(orderId, 0, 0, userId);
         //MvcApplication.lowQuantityNotifer.Start("BMAChangeDB", "SELECT ProductMaterialId,CurrentQuantity,StandardQuantity FROM dbo.[ProductMaterial] WHERE (CurrentQuantity < StandardQuantity AND IsActive = 'True')");
         //MvcApplication.lowQuantityNotifer.Change += this.OnChange2;
         return 1;
     }
     catch (DataException)
     {
         return -1;
     }
 }
        public int AcceptEditedOrder(int orderId)
        {
            try
            {
                CusManageBusiness cmb = new CusManageBusiness();
                var orderCheck = cmb.GetOrderDetail(orderId);
                if (orderCheck.CustomerUserId != Convert.ToInt32(Session["UserId"]))
                {
                    return -2;
                }

                MvcApplication.changeToConfirmNotifier.Start("BMAChangeDB", "SELECT OrderId FROM dbo.[Orders] WHERE OrderStatus = 2");
                MvcApplication.changeToConfirmNotifier.Change += this.ConfirmOnChange;
                cmb.AcceptEditedOrder(orderId);
                return 1;
            }
            catch (Exception)
            {
                return -1;
            }
        }
Example #3
0
 public ActionResult GetOrderToCart(int orderId)
 {
     try
     {
         MvcApplication.changeStatusNotifer.Dispose();
         CusManageBusiness cmb = new CusManageBusiness();
         var order = cmb.GetOrderDetail(orderId);
         if (order.CustomerUserId != Convert.ToInt32(Session["UserId"]))
         {
             return RedirectToAction("Index", "Home");
         }
         CustomerOrderBusiness cob = new CustomerOrderBusiness();
         cob.TurnFlagOn(orderId);
         List<CustomerCartViewModel> lstCart = new List<CustomerCartViewModel>();
         lstCart = cob.GetOrderToCart(orderId);
         if (lstCart != null)
         {
             Session["Cart"] = lstCart;
             Session["BeEdited"] = orderId;
             Session["DeliveryDate"] = order.PlanDeliveryTime;
             Session["Note"] = order.OrderNote;
         }
         return RedirectToAction("Cart");
     }
     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 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 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");
     }
 }
 public ActionResult CancelOrderConfirm(int orderId, string strURL)
 {
     try
     {
         CusManageBusiness cmb = new CusManageBusiness();
         var orderCheck = cmb.GetOrderDetail(orderId);
         if (orderCheck.CustomerUserId != Convert.ToInt32(Session["UserId"]))
         {
             return RedirectToAction("Index", "Home");
         }
         OrderBusiness ob = new OrderBusiness();
         int userId = Convert.ToInt32(Session["UserId"]);
         if (orderCheck.OrderStatus != 0)
         {
             string dependencyCheckSql = string.Format("{0}{1}", "SELECT OrderId FROM dbo.[Orders] WHERE CustomerUserId = ", userId);
             MvcApplication.lowQuantityNotifer.Dispose();
             MvcApplication.cancelOrderNotifier.Start("BMAChangeDB", dependencyCheckSql);
             MvcApplication.cancelOrderNotifier.Change += this.CancelOnChange;
         }
         ob.Cancel(orderId, 0, 0, userId);
         return Redirect(strURL);
     }
     catch (DataException)
     {
         return RedirectToAction("Index");
     }
 }
 public ActionResult CancelOrder(int? orderId)
 {
     try
     {
         CusManageBusiness cmb = new CusManageBusiness();
         var orderCheck = cmb.GetOrderDetail(orderId);
         if (orderCheck.CustomerUserId != Convert.ToInt32(Session["UserId"]))
         {
             return RedirectToAction("Index", "Home");
         }
         if (orderId == null)
         {
             return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
         }
         Order order = db.Orders.Find(orderId);
         List<OrderItem> orderItems = db.OrderItems.Where(n => n.OrderId == orderId).ToList();
         ViewBag.orderItems = orderItems;
         if (order == null)
         {
             return HttpNotFound();
         }
         return View(order);
     }
     catch (Exception)
     {
         return RedirectToAction("Index", "Error");
     }
 }