예제 #1
0
        public ActionResult Create(string id, string s, string p)
        {
            shSectionService _section = new shSectionService();
            shProductService _product = new shProductService();
            shProductSet     section  = new shProductSet();

            if (!string.IsNullOrWhiteSpace(s))
            {
                section = _section.FindByKey(s);

                ViewBag.parent = string.IsNullOrWhiteSpace(section.ParentId) ? 0 : 1;
            }

            section.ProductGuid = id;
            ViewBag.ProductName = _product.ProductName(id);
            ViewBag.ProductGuid = id;

            IEnumerable <shProductSet> dsSection = _section.DanhSachSection()
                                                   .Where(x => x.ProductGuid == id &&
                                                          x.ParentId == null &&
                                                          x.SectionGuid != s)
                                                   .OrderBy(x => x.SectionId);

            ViewBag.dsSection = new SelectList(dsSection, "SectionGuid", "SectionName", null);
            ViewBag.p         = p;
            return(View(section));
        }
예제 #2
0
        public ActionResult TopSanPham(string StartTime, string EndTime, string TheLoai)
        {
            DateTime _tungay = DateTime.Now;

            if (!string.IsNullOrEmpty(StartTime) || !string.IsNullOrWhiteSpace(StartTime))
            {
                _tungay = TypeHelper.ToDate(StartTime);
            }

            DateTime _denngay = DateTime.Now;

            if (!string.IsNullOrEmpty(EndTime) || !string.IsNullOrWhiteSpace(EndTime))
            {
                _denngay = TypeHelper.ToDate(EndTime);
            }

            List <BieuDoTop>     dsBieuDo     = new List <BieuDoTop>();
            BieuDoTop            top          = new BieuDoTop();
            shOrderDetailService _orderDetail = new shOrderDetailService();
            shProductService     _product     = new shProductService();
            ShopOnlineDb         db           = new ShopOnlineDb();

            IEnumerable <shOrderDetail> dsOrderDetail = _orderDetail.DanhSachOrderDetail_TheoThoiGian(_tungay, _denngay);
            int TongSoLuong = TinhTongSoLuong(dsOrderDetail);
            IEnumerable <string> dsDistinct = dsOrderDetail.Select(x => x.ProductGuid).Distinct();

            foreach (var item in dsDistinct)
            {
                IEnumerable <shOrderDetail> dsTheoSanPham = dsOrderDetail.Where(x => x.ProductGuid == item);
                top       = new BieuDoTop();
                top.label = _product.ProductName(item);
                top.y     = TinhTongSoLuong(dsTheoSanPham);

                if (TheLoai == Config.SoLuong)
                {
                    top.indexLabel = top.y.ToString();
                }
                else if (TheLoai == Config.DoanhThu)
                {
                    top.indexLabel = Format.FormatDecimalToString(TinhTongSoTien(dsTheoSanPham));
                }

                dsBieuDo.Add(top);
            }

            dsBieuDo = dsBieuDo.OrderBy(x => x.y).Take(Config.Top_10).ToList();

            if (Request.IsAjaxRequest())
            {
                return(Json(dsBieuDo, JsonRequestBehavior.AllowGet));
            }
            return(PartialView("TopSanPhamTheoSoLuong"));
        }