Exemple #1
0
        public ActionResult ListItems()
        {
            var lstOrder      = (List <ModelWholeSaleItem>)Session["WholeSale"] ?? new List <ModelWholeSaleItem>();
            var model         = new ModelWholeSaleItem();
            var paymentmethod = _methodApi.GetAll();

            if (lstOrder.Any())
            {
                model = lstOrder.FirstOrDefault();
                if (model != null)
                {
                    model.LstKey             = lstOrder.Where(c => c.Key != model.Key).Select(c => c.Key).ToList();
                    model.PaymentMethodItems = paymentmethod;
                }
            }
            else
            {
                model.Key                = Guid.NewGuid();
                model.AgentSaleItem      = new AgentSaleItem();
                model.WholeSaleItems     = new List <WholeSaleItem>();
                model.LstKey             = new List <Guid>();
                model.TotalPrice         = 0;
                model.PaymentMethodItems = paymentmethod;
                lstOrder.Add(model);
                Session["WholeSale"] = lstOrder;
            }
            return(View(model));
        }
Exemple #2
0
        public ActionResult AddSale(Guid key, int type)
        {
            var lstOrder = (List <ModelWholeSaleItem>)Session["WholeSaleO"] ?? new List <ModelWholeSaleItem>();
            var model    = new ModelWholeSaleItem();

            if (lstOrder.Any())
            {
                model = lstOrder.FirstOrDefault(c => c.Key == key);
            }
            else
            {
                model.Key            = Guid.NewGuid();
                model.AgentSaleItem  = new AgentSaleItem();
                model.WholeSaleItems = new List <WholeSaleItem>();
                model.LstKey         = new List <Guid>();
                model.TotalPrice     = 0;
            }
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
        public ActionResult CreateOder(int id, Guid keyGuid)
        {
            var lstOrder = (List <ModelWholeSaleItem>)Session["WholeSale"] ?? new List <ModelWholeSaleItem>();

            if (lstOrder.Any())
            {
                var temp = _da.GetById(id);
                if (keyGuid == temp.keyreq)
                {
                    var models = lstOrder.Where(c => c.Key == keyGuid);
                    if (!models.Any())
                    {
                        var lst   = temp.FreightWareHouse_Active;
                        var model = new ModelWholeSaleItem {
                            Key = keyGuid
                        };
                        var lsttemp = new List <WholeSaleItem>();
                        foreach (var item in lst)
                        {
                            var saleProducts = _dnSalesDa.GetSaleProduct(item.ProductID ?? 0, UserItem.AgencyID);
                            var pricesale    = saleProducts.Sale.Any() ? saleProducts.Sale.Sum(c => c.Price) : 0;
                            var percent      = saleProducts.Sale.Any() ? saleProducts.Sale.Sum(c => c.PercentSale) : 0;
                            var discount     = pricesale + (item.Price * percent / 100);
                            // var checkpromotion = _dnPromotionDa.GetPromotionProduct(item.ProductID ?? 0, UserItem.AgencyID, item.QuantityActive ?? 1);
                            var urlimg = "/Content/Admin/images/auto-default.jpg";
                            if (item.Shop_Product.Shop_Product_Detail.Gallery_Picture != null)
                            {
                                urlimg = "/Uploads/" + item.Shop_Product.Shop_Product_Detail.Gallery_Picture.Folder +
                                         item.Shop_Product.Shop_Product_Detail.Gallery_Picture.Url;
                            }

                            var a = new WholeSaleItem
                            {
                                Key             = CodeLogin(),
                                PriceSale       = pricesale,
                                PercentSale     = percent,
                                Value           = item.ValueWeight,
                                Discount        = discount,
                                TotalPrice      = (item.Shop_Product.Shop_Product_Detail.Price * (decimal)item.Shop_Product.Product_Size.Value / 1000 * item.Quantity * item.ValueWeight) - discount,
                                Quantity        = item.Quantity,
                                Barcode         = item.BarCode,
                                Price           = item.Shop_Product.Shop_Product_Detail.Price * (decimal)item.Shop_Product.Product_Size.Value / 1000,
                                Code            = item.Shop_Product.CodeSku,
                                ProductID       = item.ProductID ?? 0,
                                Idimport        = item.ImportProductGID,
                                ProductdetailID = item.Shop_Product.Shop_Product_Detail.ID,
                                Title           = item.Shop_Product.Shop_Product_Detail.Name,
                                UrlImg          = urlimg
                            };
                            lsttemp.Add(a);
                        }
                        model.WholeSaleItems = lsttemp;
                        var total = model.WholeSaleItems.Sum(c => c.TotalPrice * c.Quantity);
                        var sale  = _dnSalesDa.GetSaleByTotalOrder((decimal)total, UserItem.AgencyID);
                        model.SaleOrder = sale;
                        var checkdiscount = _dnAgencyDa.GetById(temp.AgencyId ?? 0);
                        var agency        = new AgentSaleItem
                        {
                            Address = checkdiscount.Address,
                            Name    = checkdiscount.Name,
                            Phone   = checkdiscount.Phone,
                            //Bonus = checkdiscount.
                            ID         = checkdiscount.ID,
                            AgentGroup = checkdiscount.DN_GroupAgency.Name
                        };
                        model.AgentSaleItem = agency;
                        var discsl = ((total * sale.Sum(p => p.PercentSale) / 100) + sale.Sum(p => p.Price));
                        var disc   = (total * (checkdiscount.DN_GroupAgency.Discount ?? 0) / 100);
                        model.DiscountSale = discsl;
                        model.Discount     = disc;
                        model.SalePercent  = total * sale.Sum(p => p.PercentSale) / 100;
                        model.SalePrice    = sale.Sum(p => p.Price);
                        model.Total        = total;
                        model.TotalPrice   = total - discsl - disc;
                        lstOrder.Add(model);
                        Session["WholeSale"] = lstOrder;
                    }
                }
            }
            else
            {
                var temp = _da.GetById(id);
                if (keyGuid == temp.keyreq)
                {
                    var lst   = temp.FreightWareHouse_Active;
                    var model = new ModelWholeSaleItem {
                        Key = keyGuid
                    };
                    var lsttemp = new List <WholeSaleItem>();
                    foreach (var item in lst)
                    {
                        var saleProducts = _dnSalesDa.GetSaleProduct(item.ProductID ?? 0, UserItem.AgencyID);
                        var pricesale    = saleProducts.Sale.Any() ? saleProducts.Sale.Sum(c => c.Price) : 0;
                        var percent      = saleProducts.Sale.Any() ? saleProducts.Sale.Sum(c => c.PercentSale) : 0;
                        var discount     = pricesale + (item.Price * percent / 100);
                        // var checkpromotion = _dnPromotionDa.GetPromotionProduct(item.ProductID ?? 0, UserItem.AgencyID, item.QuantityActive ?? 1);
                        var urlimg = "/Content/Admin/images/auto-default.jpg";
                        if (item.Shop_Product.Shop_Product_Detail.Gallery_Picture != null)
                        {
                            urlimg = "/Uploads/" + item.Shop_Product.Shop_Product_Detail.Gallery_Picture.Folder +
                                     item.Shop_Product.Shop_Product_Detail.Gallery_Picture.Url;
                        }

                        var a = new WholeSaleItem
                        {
                            Key             = CodeLogin(),
                            PriceSale       = pricesale,
                            PercentSale     = percent,
                            Value           = item.ValueWeight,
                            Idimport        = item.ImportProductGID,
                            Discount        = discount,
                            TotalPrice      = (item.Shop_Product.Shop_Product_Detail.Price * (decimal)item.Shop_Product.Product_Size.Value / 1000 * item.Quantity * item.ValueWeight) - discount,
                            Quantity        = item.Quantity,
                            Price           = item.Shop_Product.Shop_Product_Detail.Price * (decimal)item.Shop_Product.Product_Size.Value / 1000,
                            Code            = item.Shop_Product.CodeSku,
                            Barcode         = item.BarCode,
                            ProductID       = item.ProductID ?? 0,
                            ProductdetailID = item.Shop_Product.Shop_Product_Detail.ID,
                            Title           = item.Shop_Product.Shop_Product_Detail.Name,
                            UrlImg          = urlimg
                        };
                        lsttemp.Add(a);
                    }
                    model.WholeSaleItems = lsttemp;
                    var total = model.WholeSaleItems.Sum(c => c.TotalPrice);
                    var sale  = _dnSalesDa.GetSaleByTotalOrder((decimal)total, UserItem.AgencyID);
                    model.SaleOrder = sale;
                    var checkdiscount = _dnAgencyDa.GetById(temp.AgencyId ?? 0);
                    var agency        = new AgentSaleItem
                    {
                        Address = checkdiscount.Address,
                        Name    = checkdiscount.Name,
                        Phone   = checkdiscount.Phone,
                        //Bonus = checkdiscount.
                        ID         = checkdiscount.ID,
                        AgentGroup = checkdiscount.DN_GroupAgency.Name
                    };
                    model.AgentSaleItem = agency;
                    var discsl = ((total * sale.Sum(p => p.PercentSale) / 100) + sale.Sum(p => p.Price));
                    var disc   = (total * (checkdiscount.DN_GroupAgency.Discount ?? 0) / 100);
                    model.DiscountSale = discsl;
                    model.Discount     = disc;
                    model.Total        = total;
                    model.TotalPrice   = total - discsl - disc;
                    lstOrder.Add(model);
                    Session["WholeSale"] = lstOrder;
                }
            }

            return(RedirectToAction("Index", "WholeSale"));
        }