Example #1
0
        public ActionResult AddOrder(OrderAgencyModel data)
        {
            var order = new Shop_Orders {
                AgencyId = AgencyId
            };

            var datenow = DateTime.Now.TotalSeconds();

            var lst       = _da.GetListImportProductBarcode(data.BarCodes, AgencyId);
            var lstDetail = lst.Select(item => new Shop_Order_Details
            {
                Barcode          = item.BarCode,
                Quantity         = 1,
                QuantityOld      = 0,
                Price            = item.Price,
                TotalPrice       = item.PriceNew,
                Total            = item.PriceNew,
                Discount         = 0,
                DateCreated      = datenow,
                Status           = (int)FDI.CORE.OrderStatus.Complete,
                Value            = item.Value,
                GID              = Guid.NewGuid(),
                ImportProductGID = item.GID,
                ProductID        = item.ProductValueID
            }).ToList();

            if (!lstDetail.Any())
            {
                return(Json(new JsonMessage(true, "Không tồn tại mã sản phẩm"), JsonRequestBehavior.AllowGet));
            }

            var total      = lstDetail.Sum(c => c.Total);
            var totalprice = lstDetail.Sum(c => c.TotalPrice);

            order.Shop_Order_Details = lstDetail;
            order.TotalSaleSP        = 0;
            order.DateCreated        = datenow;
            order.Status             = (int)FDI.CORE.OrderStatus.Complete;
            order.IsDelete           = false;
            order.StartDate          = datenow;
            order.Total          = total;
            order.TotalPrice     = totalprice;
            order.CustomerID     = data.CustomerId;
            order.Payments       = order.TotalPrice;
            order.PriceReceipt   = order.Payments;
            order.Type           = (int)TypeOrder.Banle;
            order.ContactOrderID = data.OrderId;
            order.ReceiveDate    = DateTime.Now.TotalSeconds();


            _ordersDa.Add(order);
            _ordersDa.Save();
            if (data.OrderId > 0)
            {
                var contact = _cusAppSaleDa.GetByID(data.OrderId.Value);
                contact.Status = (int)FDI.CORE.OrderStatus.Complete;
            }
            return(Json(new JsonMessage(false, ""), JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public ActionResult Actions()
        {
            var msg   = new JsonMessage();
            var order = new Shop_Orders();

            switch (DoAction)
            {
            case ActionType.Edit:
                order = _orderDa.GetById(ArrId.FirstOrDefault());
                UpdateModel(order);
                _orderDa.Save();
                msg = new JsonMessage
                {
                    Erros   = false,
                    ID      = order.CustomerName,
                    Message = string.Format("Đã xử lý đơn hàng số: <b>#{0}</b>", Server.HtmlEncode(order.CustomerName))
                };
                break;

            case ActionType.Delete:
                var ltsOrder   = _orderDa.GetListByArrId(ArrId);
                var stbMessage = new StringBuilder();
                foreach (var item in ltsOrder)
                {
                    item.IsDelete = true;
                    stbMessage.AppendFormat("Đã xóa đơn hàng <b>{0}</b>.<br />", Server.HtmlEncode(item.CustomerName));
                }
                _orderDa.Save();
                msg.Message = stbMessage.ToString();
                break;
            }

            if (string.IsNullOrEmpty(msg.Message))
            {
                msg.Message = "Không có hành động nào được thực hiện.";
                msg.Erros   = true;
            }

            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
        private void buttonSaveEmployee_Click(object sender, EventArgs e)
        {
            if ((textBoxclientname.Text == "") || (textBoxbooktitle.Text == "") || (textBoxOrderQuantity.Text == "") || (textBoxUnitPrice.Text == "") || (textBoxSubtotal.Text == "") || (textBoxGST.Text == "") || (textBoxPST.Text == "") || (textBoxtotal.Text == ""))
            {
                MessageBox.Show("Please full fill all the fields", "Missing Data");
                ClearAll();
                return;
            }
            else
            {
                Client client = ClientsDA.SearchNM(textBoxclientname.Text);
                Books  book   = BooksDA.SearchTitle(textBoxbooktitle.Text);
                string qtfh   = textBoxclientname.Text;
                string asda   = textBoxbooktitle.Text;
                int    lalala = Convert.ToInt32(textBoxOrderQuantity.Text);
                if (book == null)
                {
                    MessageBox.Show("Wrong Information book, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (client == null)
                {
                    MessageBox.Show("Wrong Information client, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (book.BookQOH < Convert.ToInt32(textBoxOrderQuantity.Text))
                {
                    MessageBox.Show("The inventory does not have that quantity of products", "Missing Product");
                    ClearAll();
                    return;
                }
                else
                {
                    Order Or = new Order();

                    if ((client.Name == textBoxclientname.Text) && (book.Title.ToString() == textBoxbooktitle.Text) && (book.BookQOH < Convert.ToInt32(textBoxOrderQuantity.Text)))
                    {
                        Or.OrdernUmber  = Convert.ToInt32(textBoxOrderNumber.Text);
                        Or.OrderDate    = dateTimePickerOrder.Text;
                        Or.ShippingDate = dateTimePickerShipping.Text;
                        Or.ClientNumber = textBoxclientname.Text;
                        Or.BookName     = textBoxbooktitle.Text;
                        Or.Quantity     = Convert.ToInt32(textBoxOrderQuantity.Text);
                        Or.unit         = Convert.ToInt32(textBoxUnitPrice.Text);
                        Or.Subtotal     = Convert.ToInt32(textBoxSubtotal.Text);
                        Or.Gst          = Convert.ToInt32(textBoxGST.Text);
                        Or.Pst          = Convert.ToInt32(textBoxPST.Text);
                        Or.total        = Convert.ToInt32(textBoxtotal.Text);
                        OrdersDA.Save(Or);
                        ClearAll();
                    }
                }
            }
        }
Example #4
0
        public ActionResult Actions()
        {
            var msg   = new JsonMessage();
            var order = new Shop_Orders();

            switch (DoAction)
            {
            case ActionType.Add:
                var dateCreated = DateTime.Now.TotalSeconds();
                var keyorder    = Request["KeyOrder"];
                var lstOrder    = (List <ModelWholeSaleItem>)Session["WholeSale"] ?? new List <ModelWholeSaleItem>();
                var temp        = _freightWarehouseDa.GetByKey(Guid.Parse(keyorder));
                if (temp.IsOrder == true)
                {
                    msg = new JsonMessage
                    {
                        Erros   = true,
                        Message = "Đơn Yêu cầu này đã được tạo đơn hàng"
                    };
                    return(Json(msg));
                }
                else
                {
                    if (lstOrder.Any())
                    {
                        var model = lstOrder.FirstOrDefault(c => c.Key == Guid.Parse(keyorder));
                        if (model != null)
                        {
                            var lstM      = model.WholeSaleItems;
                            var lstDetail = new List <Shop_Order_Details>();
                            foreach (var saleItem in lstM)
                            {
                                var shopOrderDetails = new Shop_Order_Details
                                {
                                    ProductID   = saleItem.ProductID,
                                    Quantity    = saleItem.Quantity,
                                    Status      = (int)FDI.CORE.OrderStatus.Complete,
                                    QuantityOld = 0,
                                    IsPromotion = false,
                                    Price       = saleItem.Price ?? 0,
                                    Barcode     = saleItem.Barcode,
                                    //DateCreated = dateCreated,
                                    Percent          = saleItem.PercentSale,
                                    Value            = saleItem.Value,
                                    ImportProductGID = saleItem.Idimport,
                                    PriceSale        = saleItem.PriceSale,
                                    Discount         = saleItem.Discount,
                                    TotalPrice       = saleItem.TotalPrice * saleItem.Quantity,
                                    Total            = saleItem.TotalPrice - saleItem.Discount,
                                };
                                lstDetail.Add(shopOrderDetails);
                                if (saleItem.PromotionPs != null)
                                {
                                    lstDetail.AddRange(from shopOrderDetailse in saleItem.PromotionPs
                                                       from orderDetailse in shopOrderDetailse.PromotionSPItems
                                                       select new Shop_Order_Details
                                    {
                                        ProductID   = orderDetailse.ProductID,
                                        Quantity    = orderDetailse.Quantity,
                                        Status      = (int)FDI.CORE.OrderStatus.Complete,
                                        QuantityOld = 0,
                                        Price       = orderDetailse.PriceSp ?? 0,
                                        Percent     = orderDetailse.Percent,
                                        PriceSale   = orderDetailse.Price,
                                        //DateCreated = dateCreated,
                                        IsPromotion        = true,
                                        PromotionProductID = orderDetailse.ID,
                                        Discount           = orderDetailse.Percent * orderDetailse.Quantity * orderDetailse.PriceSp / 100 + orderDetailse.Price,
                                        TotalPrice         = orderDetailse.TotalPrice * orderDetailse.Quantity,
                                        Total            = orderDetailse.TotalPrice * orderDetailse.Quantity - (orderDetailse.Percent * orderDetailse.Quantity * orderDetailse.PriceSp + orderDetailse.Price),
                                        ContentPromotion = orderDetailse.Name
                                    });
                                }
                            }
                            var lstO = model.PromotionOrder;
                            if (lstO != null)
                            {
                                lstDetail.AddRange(from itemP in lstO
                                                   from items in itemP.PromotionSPItems
                                                   select new Shop_Order_Details
                                {
                                    ProductID   = items.ProductID,
                                    Quantity    = items.Quantity,
                                    Status      = (int)FDI.CORE.OrderStatus.Complete,
                                    QuantityOld = 0,
                                    Price       = items.PriceSp ?? 0,
                                    //DateCreated = dateCreated,
                                    IsPromotion        = true,
                                    PromotionProductID = items.ID,
                                    Percent            = items.Percent,
                                    PriceSale          = items.Price,
                                    Discount           = items.PriceSp + (items.PriceSp * items.Percent / 100),
                                    TotalPrice         = items.TotalPrice * items.Quantity,
                                    ContentPromotion   = items.Title,
                                    Total = (items.TotalPrice - items.PriceSp - (items.PriceSp * items.Percent / 100)) * items.Quantity,
                                });
                            }

                            if (lstDetail.Any())
                            {
                                UpdateModel(order);
                                var dateOfSale = Request["DateOfSale_"];
                                order.StartDate          = dateOfSale.StringToDate().TotalSeconds();
                                order.DateCreated        = DateTime.Now.TotalSeconds();
                                order.TotalPrice         = model.Total;
                                order.Total              = model.Total;
                                order.Status             = (int)FDI.CORE.OrderStatus.Complete;
                                order.IsDelete           = false;
                                order.UserId             = UserItem.UserId;
                                order.UserCreate         = UserItem.UserId;
                                order.AgencyId           = UserItem.AgencyID;
                                order.SalePercent        = model.SalePercent;
                                order.SalePrice          = model.SalePrice;
                                order.Shop_Order_Details = lstDetail;
                                order.Discount           = model.Discount ?? 0;
                                var payment = model.Total - (order.PrizeMoney ?? 0) - order.Discount - model.DiscountSale;
                                order.Payments     = payment;
                                order.PriceReceipt = order.Payments;
                                if (!string.IsNullOrEmpty(order.Company) && !string.IsNullOrEmpty(order.CodeCompany))
                                {
                                    order.Isinvoice = true;
                                }
                                order.Type = (int)TypeOrder.Banbuon;
                                _ordersDa.Add(order);
                                _ordersDa.Save();
                                // set trạng thái đơn yêu cầu đã đc đặt hàng
                                temp.IsOrder = true;
                                _freightWarehouseDa.Save();
                                // xóa key tại session
                                lstOrder.Remove(model);
                                Session["WholeSale"] = lstOrder;
                            }
                            else
                            {
                                msg.Erros   = true;
                                msg.Message = "Bạn chưa chọn sản phẩm nào.";
                            }
                        }
                        else
                        {
                            msg.Erros   = true;
                            msg.Message = "Không thể tạo đơn hàng.";
                        }
                    }
                    else
                    {
                        msg.Erros   = true;
                        msg.Message = "Bạn chưa chọn sản phẩm nào.";
                    }
                }

                break;

            default:
                msg.Message = "Bạn không được phần quyển cho chức năng này.";
                msg.Erros   = true;
                break;
            }
            return(Json(msg));
        }
Example #5
0
        public ActionResult Actions()
        {
            var msg   = new JsonMessage();
            var order = new Shop_Orders();

            switch (DoAction)
            {
            case ActionType.Add:
                var dateCreated = DateTime.Now.TotalSeconds();
                var keyorder    = Request["KeyOrder"];
                var lstOrder    = (List <ModelSaleItem>)Session["AddSale"] ?? new List <ModelSaleItem>();
                var model       = lstOrder.FirstOrDefault(c => c.Key == Guid.Parse(keyorder));
                if (model != null)
                {
                    var lstM      = model.SaleItems;
                    var lstDetail = new List <Shop_Order_Details>();
                    foreach (var saleItem in lstM)
                    {
                        var shopOrderDetails = new Shop_Order_Details
                        {
                            ProductID        = saleItem.ProductID,
                            Quantity         = saleItem.Quantity,
                            Status           = (int)FDI.CORE.OrderStatus.Complete,
                            QuantityOld      = 0,
                            IsPromotion      = false,
                            Value            = saleItem.Value,
                            Price            = saleItem.Price,
                            Barcode          = saleItem.Barcode,
                            ImportProductGID = saleItem.Idimport,
                            //DateCreated = dateCreated,
                            Percent    = saleItem.PercentSale,
                            PriceSale  = saleItem.PriceSale,
                            Discount   = saleItem.Discount,
                            TotalPrice = saleItem.TotalPrice * saleItem.Quantity,
                            Total      = saleItem.TotalPrice - saleItem.Discount,
                        };
                        lstDetail.Add(shopOrderDetails);
                        if (saleItem.PromotionPs.Any())
                        {
                            lstDetail.AddRange(from shopOrderDetailse in saleItem.PromotionPs
                                               from orderDetailse in shopOrderDetailse.PromotionSPItems
                                               select new Shop_Order_Details
                            {
                                ProductID   = orderDetailse.ProductID,
                                Quantity    = orderDetailse.Quantity,
                                Status      = (int)FDI.CORE.OrderStatus.Complete,
                                QuantityOld = 0,
                                Price       = orderDetailse.PriceSp ?? 0,
                                Percent     = orderDetailse.Percent,
                                PriceSale   = orderDetailse.Price,
                                //DateCreated = dateCreated,
                                IsPromotion        = true,
                                PromotionProductID = orderDetailse.ID,
                                Discount           = orderDetailse.Percent * orderDetailse.Quantity * orderDetailse.PriceSp / 100 + orderDetailse.Price,
                                TotalPrice         = orderDetailse.TotalPrice * orderDetailse.Quantity,
                                Total            = orderDetailse.TotalPrice * orderDetailse.Quantity - (orderDetailse.Percent * orderDetailse.Quantity * orderDetailse.PriceSp + orderDetailse.Price),
                                ContentPromotion = orderDetailse.Name
                            });
                        }
                    }
                    var lstO = model.PromotionOrder;
                    lstDetail.AddRange(from itemP in lstO
                                       from items in itemP.PromotionSPItems
                                       select new Shop_Order_Details
                    {
                        ProductID   = items.ProductID,
                        Quantity    = items.Quantity,
                        Status      = (int)FDI.CORE.OrderStatus.Complete,
                        QuantityOld = 0,
                        Price       = items.PriceSp ?? 0,
                        //DateCreated = dateCreated,
                        IsPromotion        = true,
                        PromotionProductID = items.ID,
                        Percent            = items.Percent,
                        PriceSale          = items.Price,
                        Discount           = items.PriceSp + (items.PriceSp * items.Percent / 100),
                        TotalPrice         = items.TotalPrice * items.Quantity,
                        ContentPromotion   = items.Title,
                        Total = (items.TotalPrice - items.PriceSp - (items.PriceSp * items.Percent / 100)) * items.Quantity,
                    });
                    if (lstDetail.Any())
                    {
                        UpdateModel(order);
                        var dateOfSale = Request["DateOfSale_"];
                        order.StartDate          = dateOfSale.StringToDate().TotalSeconds();
                        order.DateCreated        = DateTime.Now.TotalSeconds();
                        order.TotalPrice         = model.TotalPrice;
                        order.Total              = model.Total;
                        order.Status             = (int)FDI.CORE.OrderStatus.Complete;
                        order.IsDelete           = false;
                        order.UserId             = UserItem.UserId;
                        order.UserCreate         = UserItem.UserId;
                        order.AgencyId           = UserItem.AgencyID;
                        order.SalePercent        = model.SalePercent;
                        order.SalePrice          = model.SalePrice;
                        order.Shop_Order_Details = lstDetail;
                        decimal?price = 0;
                        if (!string.IsNullOrEmpty(order.SaleCode))
                        {
                            var temp = _dnSalesDa.GetSaleCodebyCode(order.SaleCode);
                            temp.IsUse   = true;
                            temp.DateUse = DateTime.Now.TotalSeconds();
                            price        = (temp.DN_Sale.Price ?? 0) + ((temp.DN_Sale.Percent ?? 0) * order.TotalPrice / 100);
                            _dnSalesDa.Save();
                        }
                        order.Discount = model.Discount;
                        var payment = model.Total - (order.PrizeMoney ?? 0) - order.Discount - price ?? 0;
                        order.Payments     = payment;
                        order.PriceReceipt = order.Payments;
                        if (!string.IsNullOrEmpty(order.Company) && !string.IsNullOrEmpty(order.CodeCompany))
                        {
                            order.Isinvoice = true;
                        }
                        _ordersDa.Add(order);
                        _ordersDa.Save();
                    }
                    else
                    {
                        msg.Erros   = true;
                        msg.Message = "Bạn chưa chọn sản phẩm nào.";
                    }
                }
                else
                {
                    msg.Erros   = true;
                    msg.Message = "Bạn chưa chọn sản phẩm nào.";
                }
                break;

            default:
                msg.Message = "Bạn không được phần quyển cho chức năng này.";
                msg.Erros   = true;
                break;
            }
            return(Json(msg));
        }
Example #6
0
 public ActionResult StopOrder(string key, int bedId, string port)
 {
     if (key == Keyapi)
     {
         var item = _da.GetOrderOrContactByBedId(bedId);
         var date = DateTime.Now.TotalSeconds();
         if (item.ContactOrders.Any())
         {
             var obj = _contactOrderDa.GetById(item.ContactOrders.Select(m => m).FirstOrDefault());
             if (obj != null)
             {
                 if (date < obj.StartDate)
                 {
                     foreach (var items in obj.Shop_ContactOrder_Details)
                     {
                         items.Status = (int)FDI.CORE.OrderStatus.Cancelled;
                     }
                     obj.Status = (int)FDI.CORE.OrderStatus.Cancelled;
                 }
                 else
                 {
                     obj.Status = (int)FDI.CORE.OrderStatus.Complete;
                 }
                 obj.EndDate = DateTime.Now.TotalSeconds();
                 _contactOrderDa.Save();
                 var url = port + "/updatecontact/" + obj.ID;
                 Node(url);
                 return(Json(1, JsonRequestBehavior.AllowGet));
             }
         }
         else if (item.Shop_Orders.Any())
         {
             var obj = _ordersDa.GetById(item.Shop_Orders.Select(m => m).FirstOrDefault());
             if (obj != null)
             {
                 if (date < obj.StartDate)
                 {
                     foreach (var items in obj.Shop_Order_Details)
                     {
                         items.Status = (int)FDI.CORE.OrderStatus.Cancelled;
                     }
                     foreach (var itemOrder in obj.WalletOrder_History)
                     {
                         itemOrder.IsDelete = true;
                     }
                     foreach (var item1 in obj.RewardHistories)
                     {
                         item1.IsDeleted = true;
                     }
                     foreach (var item2 in obj.ReceiveHistories)
                     {
                         item2.IsDeleted = true;
                     }
                     obj.Status = (int)FDI.CORE.OrderStatus.Cancelled;
                 }
                 else
                 {
                     obj.Status = (int)FDI.CORE.OrderStatus.Complete;
                 }
                 obj.EndDate = DateTime.Now.TotalSeconds();
                 _ordersDa.Save();
                 var url = port + "/updateorder/" + obj.ID;
                 Node(url);
                 return(Json(2, JsonRequestBehavior.AllowGet));
             }
         }
         return(Json(3, JsonRequestBehavior.AllowGet));
     }
     return(Json(0, JsonRequestBehavior.AllowGet));
 }
Example #7
0
        public ActionResult Actions()
        {
            var msg   = new JsonMessage();
            var order = new Shop_Orders();

            switch (DoAction)
            {
            case ActionType.Add:
                var dateCreated = DateTime.Now.TotalSeconds();
                var keyorder    = Request["KeyOrder"];
                var lstOrder    = (List <ModelWholeSaleOItem>)Session["WholeSaleO"] ?? new List <ModelWholeSaleOItem>();
                var temp        = _storageWareHouseDa.GetByKey(Guid.Parse(keyorder));

                if (lstOrder.Any())
                {
                    var model = lstOrder.FirstOrDefault(c => c.Key == Guid.Parse(keyorder));
                    if (model != null)
                    {
                        var lstM      = model.WholeSaleItems;
                        var lstDetail = new List <Shop_Order_Details>();
                        foreach (var saleItem in lstM)
                        {
                            var lstDetail1 = saleItem.ListDnImportItems.Select(item => new Shop_Order_Details
                            {
                                ProductID      = item.ProductID,
                                ProductValueID = item.ProductValueID,
                                Quantity       = item.Quantity,
                                Status         = (int)FDI.CORE.OrderStatus.Complete,
                                QuantityOld    = 0,
                                IsPromotion    = false,
                                CateValueID    = saleItem.CateValueID,
                                Price          = item.Price ?? 0,
                                Barcode        = item.Barcode,
                                //DateCreated = dateCreated,
                                Percent          = item.PercentSale,
                                Value            = item.Value,
                                ImportProductGID = item.Idimport,
                                PriceSale        = item.PriceSale,
                                Discount         = item.Discount,
                                TotalPrice       = item.TotalPrice * item.Quantity,
                                Total            = item.Price * item.Quantity * item.Value,
                            }).ToList();
                            lstDetail.AddRange(lstDetail1);
                        }
                        if (lstDetail.Any())
                        {
                            UpdateModel(order);
                            var dateOfSale = Request["DateOfSale_"];
                            order.StartDate          = dateOfSale.StringToDate().TotalSeconds();
                            order.DateCreated        = DateTime.Now.TotalSeconds();
                            order.TotalPrice         = model.Total;
                            order.Total              = model.Total;
                            order.Status             = (int)FDI.CORE.OrderStatus.Complete;
                            order.IsDelete           = false;
                            order.UserId             = UserItem.UserId;
                            order.UserCreate         = UserItem.UserId;
                            order.AgencyId           = UserItem.AgencyID;
                            order.SalePercent        = model.SalePercent;
                            order.SalePrice          = model.SalePrice;
                            order.Shop_Order_Details = lstDetail;
                            order.Discount           = model.Discount ?? 0;
                            var payment = model.Total - (order.PrizeMoney ?? 0) - order.Discount -
                                          model.DiscountSale;
                            order.Payments     = payment;
                            order.PriceReceipt = order.Payments;
                            if (!string.IsNullOrEmpty(order.Company) && !string.IsNullOrEmpty(order.CodeCompany))
                            {
                                order.Isinvoice = true;
                            }
                            order.Type = (int)TypeOrder.Banbuon;
                            _ordersDa.Add(order);
                            _ordersDa.Save();
                            // set trạng thái đơn yêu cầu đã đc đặt hàng

                            _storageWareHouseDa.Save();
                            // xóa key tại session
                            lstOrder.Remove(model);
                            Session["WholeSaleO"] = lstOrder;
                        }
                    }
                }

                break;

            default:
                msg.Message = "Bạn không được phần quyển cho chức năng này.";
                msg.Erros   = true;
                break;
            }
            return(Json(msg));
        }
Example #8
0
        public ActionResult SendOrder()
        {
            var msg = new JsonMessage
            {
                Erros   = false,
                Message = "Cảm ơn bạn đã đặt hàng, Chúng tôi sẽ liện hệ với bạn sớm nhất.!"
            };

            try
            {
                var codeCookie = HttpContext.Request.Cookies["addtocart"];
                if (codeCookie != null)
                {
                    var temp  = codeCookie.Value;
                    var lst   = new JavaScriptSerializer().Deserialize <List <ShopProductDetailCartItem> >(temp);
                    var order = new Shop_Orders();
                    if (lst.Any())
                    {
                        var listDetail = (from item in lst
                                          let product = _productDa.GetProductItem(item.ShopID ?? 0)
                                                        select new Shop_Order_Details
                        {
                            ProductID = item.ShopID,
                            Quantity = item.Quantity,
                            DateCreated = DateTime.Now.TotalSeconds(),
                            Status = 2,
                            Price = product.PriceNew,
                        }).ToList();
                        if (listDetail.Any())
                        {
                            var total = listDetail.Sum(c => c.Price);
                            order.AgencyId           = 2010;
                            order.CustomerName       = Request["fullname"];
                            order.Mobile             = Request["phone"];
                            order.Address            = Request["address"];
                            order.Note               = Request["ordernote"];
                            order.DateCreated        = DateTime.Now.TotalSeconds();
                            order.Status             = 2;
                            order.Shop_Order_Details = listDetail;
                            order.TotalPrice         = total;
                            order.Payments           = total;
                            order.IsDelete           = false;
                            _ordersDa.Add(order);
                            _ordersDa.Save();
                            Response.Cookies["addtocart"].Expires = DateTime.Now.AddDays(-1);
                        }
                        else
                        {
                            msg = new JsonMessage
                            {
                                Erros   = true,
                                Message = "Giỏ hàng của bạn chưa có sản phẩm nào.!"
                            };
                        }
                    }
                    else
                    {
                        msg = new JsonMessage
                        {
                            Erros   = true,
                            Message = "Giỏ hàng của bạn chưa có sản phẩm nào.!"
                        };
                    }
                }
                else
                {
                    msg = new JsonMessage
                    {
                        Erros   = true,
                        Message = "Giỏ hàng của bạn chưa có sản phẩm nào.!"
                    };
                }
            }
            catch (Exception)
            {
                msg = new JsonMessage
                {
                    Erros   = true,
                    Message = "Có lỗi xảy ra.!"
                };
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }