示例#1
0
        public ActionResult dsProduct(string ProductAdd)
        {
            List <shProduct> ds       = new List <shProduct>();
            shProduct        product  = new shProduct();
            shProductService _product = new shProductService();

            if (!string.IsNullOrEmpty(ProductAdd) || !string.IsNullOrWhiteSpace(ProductAdd))
            {
                string[] dsProduct = ProductAdd.Split(';');
                if (dsProduct != null)
                {
                    foreach (var child in dsProduct)
                    {
                        product = _product.FindByKey(child);
                        if (product != null)
                        {
                            ds.Add(product);
                        }
                    }
                }
            }

            ViewBag.ProductAdd = ProductAdd;

            return(PartialView("dsProduct", ds));
        }
示例#2
0
        public JsonResult ProductTreeview(bool?IsSection, string ProductGuid)
        {
            shProductService _product = new shProductService();
            shProduct        product  = _product.FindByKey(ProductGuid);

            if (!IsSection.HasValue)
            {
                IsSection = false;
            }

            if (product == null)
            {
                product = new shProduct();
            }

            TreeView tongthe = new TreeView();

            tongthe.name     = product.ProductName;
            tongthe.id       = product.ProductGuid;
            tongthe.pId      = null;
            tongthe.open     = true;
            tongthe.isParent = true;
            tongthe.click    = "shProduct('" + product.ProductGuid + "', '', '', '0')";
            tongthe.children = GetProductTreeview(IsSection.Value, ProductGuid);

            return(Json(tongthe, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public ActionResult Create(string id)
        {
            Session[Config.DesignImage]   = new List <ProductMultiUpload>();
            Session[Config.MaterialImage] = new List <ProductMultiUpload>();

            if (!string.IsNullOrWhiteSpace(id))
            {
                shProductService _product = new shProductService();
                shProduct        product  = _product.FindByKey(id);

                if (product != null)
                {
                    shCategoryService _category = new shCategoryService();

                    ViewBag.citySel     = _category.CategoryName(product.CategoryGuid);
                    ViewBag.ProductGuid = product.ProductGuid;

                    #region Image
                    shProductImageService        _productImage   = new shProductImageService();
                    IEnumerable <shProductImage> DsDesignImage   = _productImage.DanhSachProductImage_ByCategory(product.ProductGuid, Config.ProductImageCategory_Design);
                    IEnumerable <shProductImage> DsMaterialImage = _productImage.DanhSachProductImage_ByCategory(product.ProductGuid, Config.ProductImageCategory_Material);
                    ViewBag.DsDesignImage   = DsDesignImage;
                    ViewBag.DsMaterialImage = DsMaterialImage;
                    #endregion

                    return(View(product));
                }
                else
                {
                    return(View(new shProduct()));
                }
            }

            if (TempData["ERROR"] != null)
            {
                ModelState.AddModelError("", TempData["ERROR"].ToString());

                shCategoryService _category = new shCategoryService();

                if (TempData["CategoryGuid"] != null)
                {
                    ViewBag.citySel = _category.CategoryName(TempData["CategoryGuid"].ToString());
                }

                ViewBag.CategoryGuid = TempData["CategoryGuid"];
                ViewBag.ProductGuid  = TempData["ProductGuid"];
                ViewBag.ProductName  = TempData["ProductName"];
                ViewBag.Description  = TempData["Description"];
                ViewBag.Details      = TempData["Details"];

                TempData["ERROR"] = null;
            }

            return(View(new shProduct()));
        }
示例#4
0
        public ActionResult DialogHighLight(string ProductGuid)
        {
            shProductService _product = new shProductService();
            shProduct        product  = _product.FindByKey(ProductGuid);

            if (product == null)
            {
                product = new shProduct();
            }

            return(PartialView("DialogHighLight", product));
        }
示例#5
0
        public static MvcHtmlString ProductLink(this HtmlHelper helper, string ProductGuid)
        {
            string html = string.Empty;

            if (!string.IsNullOrEmpty(ProductGuid) || !string.IsNullOrWhiteSpace(ProductGuid))
            {
                shProductService _product = new shProductService();
                shProduct        product  = _product.FindByKey(ProductGuid);
                html = " <a href='" + product.MetaTitle + "-" + product.ProductId + "' target='_blank'>" + product.ProductName + "</a>";
            }
            return(new MvcHtmlString(html));
        }
示例#6
0
        public static MvcHtmlString ProductName(this HtmlHelper helper, string ProductGuid)
        {
            string html = string.Empty;

            if (!string.IsNullOrEmpty(ProductGuid) || !string.IsNullOrWhiteSpace(ProductGuid))
            {
                shProductService _product = new shProductService();
                shProduct        product  = _product.FindByKey(ProductGuid);
                html = product.ProductName;
            }
            return(new MvcHtmlString(html));
        }
示例#7
0
        public ActionResult AddItem(string ProductGuid, int Quantity, string SectionGuid, string SizeGuid)
        {
            var cart = Session[CartSession];

            shProductService _product = new shProductService();
            shProduct        product  = _product.FindByKey(ProductGuid);

            if (cart != null)
            {
                var list = (List <CartItem>)cart;

                if (list.Exists(x => (x.Product.ProductGuid == ProductGuid) && (x.SectionGuid == SectionGuid) && (x.SizeGuid == SizeGuid)))
                {
                    foreach (var item in list)
                    {
                        if ((item.Product.ProductGuid == ProductGuid) && (item.SectionGuid == SectionGuid) && (item.SizeGuid == SizeGuid))
                        {
                            item.Quantity += Quantity;
                        }
                    }
                }
                else
                {
                    var item = new CartItem();
                    item.Product     = product;
                    item.Quantity    = Quantity;
                    item.SectionGuid = SectionGuid;
                    item.SizeGuid    = SizeGuid;
                    list.Add(item);
                }

                Session[CartSession] = list;
            }
            else
            {
                var item = new CartItem();
                item.Product     = product;
                item.Quantity    = Quantity;
                item.SectionGuid = SectionGuid;
                item.SizeGuid    = SizeGuid;
                var listCart = new List <CartItem>();
                listCart.Add(item);

                Session[CartSession] = listCart;
            }

            if (Request.IsAjaxRequest())
            {
                return(Json("OK", JsonRequestBehavior.AllowGet));
            }
            return(RedirectToAction("trang-chu"));
        }
示例#8
0
        public shSaleDetail KiemTraSanPhamNamTrongChuongTrinhKhuyenMai(DateTime dt, string ProductGuid, string SizeGuid)
        {
            shSale       sale       = ChuongTrinhKhuyenMaiHienTai(dt);
            shSaleDetail saleDetail = new shSaleDetail();

            if (sale == null)
            {
                return(saleDetail);
            }

            shSaleDetailService        _saleService = new shSaleDetailService();
            IEnumerable <shSaleDetail> ds           = _saleService.DanhSachBySaleGuid(sale.SaleGuid);

            if (sale.DieuKienApDung == DieuKienApDungKhuyenMai.TatCaSanPham.GetHashCode())
            {
                saleDetail = ds.FirstOrDefault();
                return(saleDetail);
            }
            else if (sale.DieuKienApDung == DieuKienApDungKhuyenMai.TheoDanhMuc.GetHashCode())
            {
                shProductService _product = new shProductService();
                shProduct        product  = _product.FindByKey(ProductGuid);

                foreach (var item in ds)
                {
                    if (item.CategoryGuidProductGuid == product.CategoryGuid)
                    {
                        saleDetail = item;
                        return(item);
                    }
                }
            }
            else if (sale.DieuKienApDung == DieuKienApDungKhuyenMai.TheoSanPhamRiengBiet.GetHashCode())
            {
                shProductService _product = new shProductService();
                shProduct        product  = _product.FindByKey(ProductGuid);

                foreach (var item in ds)
                {
                    if (item.CategoryGuidProductGuid == product.ProductGuid)
                    {
                        saleDetail = item;
                        return(item);
                    }
                }
            }
            return(saleDetail);
        }
        public ActionResult Details(int?id)
        {
            shProductService _product = new shProductService();

            shProduct product = _product.FindList().Where(x => x.ProductId == id).FirstOrDefault();

            shProductImageService        _productImage = new shProductImageService();
            IEnumerable <shProductImage> dsImage       = _productImage.DanhSachProductImage_ByProductGuid(product.ProductGuid);

            ViewBag.dsImageMauMa    = dsImage.Where(x => x.ProductImageCategory == Config.ProductImageCategory_Design);
            ViewBag.dsImageChatLieu = dsImage.Where(x => x.ProductImageCategory == Config.ProductImageCategory_Material);


            shSectionService           _section  = new shSectionService();
            IEnumerable <shProductSet> dsSection = _section.DanhSachSection_TheoProductGuid_ParentNull(product.ProductGuid);


            shProductSet section = new shProductSet();

            if (dsSection != null && dsSection.Count() > 0)
            {
                section = dsSection.FirstOrDefault();
            }

            shSizeService           _size  = new shSizeService();
            IEnumerable <shSetSize> dsSize = _size.DanhSachSize_BySectionGuid(section.SectionGuid, product.ProductGuid, null);


            ViewBag.ProductSize = section.SectionName + " --- " +
                                  CommonHelper.TinhToanKichThuocMaxMin(dsSize.FirstOrDefault(), dsSize.LastOrDefault());
            ViewBag.ProductPrice = CommonHelper.TinhToanGiaTienMaxMin(dsSize.FirstOrDefault(), dsSize.LastOrDefault());

            // Tính toán số tiền sau khuyến mại
            string productSale = CommonHelper.TinhToanGiaTienSauKhiGiam(dsSize.FirstOrDefault(), dsSize.LastOrDefault());

            if (!string.IsNullOrEmpty(productSale) && !string.IsNullOrWhiteSpace(productSale))
            {
                ViewBag.ProductSale = Format.FormatDecimalToString(Convert.ToDecimal(productSale));
            }


            ViewBag.ListSection = dsSection;

            return(View(product));
        }
示例#10
0
        public ActionResult Section(string id)
        {
            if (!string.IsNullOrWhiteSpace(id))
            {
                shProductService _product = new shProductService();
                shProduct        product  = _product.FindByKey(id);

                if (product != null)
                {
                    shCategoryService _category = new shCategoryService();


                    return(View(product));
                }
                else
                {
                    return(View(new shProduct()));
                }
            }

            return(View());
        }
示例#11
0
        public ActionResult Preview(string ProductGuid)
        {
            shProductService _product = new shProductService();
            shProduct        product  = _product.FindByKey(ProductGuid);

            if (product != null)
            {
                #region Image
                shProductImageService        _productImage   = new shProductImageService();
                IEnumerable <shProductImage> DsDesignImage   = _productImage.DanhSachProductImage_ByCategory(product.ProductGuid, Config.ProductImageCategory_Design);
                IEnumerable <shProductImage> DsMaterialImage = _productImage.DanhSachProductImage_ByCategory(product.ProductGuid, Config.ProductImageCategory_Material);
                ViewBag.DsDesignImage   = DsDesignImage;
                ViewBag.DsMaterialImage = DsMaterialImage;
                #endregion

                shSectionService           _section  = new shSectionService();
                IEnumerable <shProductSet> dsSection = _section.DanhSachSection_TheoProductGuid_ParentNull(product.ProductGuid);
                ViewBag.Section = dsSection;

                return(PartialView("Preview", product));
            }

            return(PartialView("Preview", new shProduct()));
        }
示例#12
0
        public IEnumerable <TimKiemNangCao> TimKiemNangCao(string keyword)
        {
            List <TimKiemNangCao> ds      = new List <TimKiemNangCao>();
            TimKiemNangCao        timkiem = new TimKiemNangCao();

            // 1. Tìm kiếm trong bảng sản phẩm
            shProductService        _product  = new shProductService();
            IEnumerable <shProduct> dsProduct = _product.FindList().Where(x => TypeHelper.CompareString(x.ProductName, keyword));

            foreach (var product in dsProduct)
            {
                timkiem             = new TimKiemNangCao();
                timkiem.CategoryId  = TheLoaiTimKiemNangCao.SanPham.GetHashCode();
                timkiem.Category    = "Sản phẩm";
                timkiem.Name        = product.ProductName;
                timkiem.MetaTitle   = product.MetaTitle + "-" + product.ProductId;
                timkiem.keyword     = keyword;
                timkiem.CreatedDate = product.CreateDate;
                timkiem.Description = " Bộ sản phẩm có kết cấu và giá sản phẩm: &nbsp;&nbsp;&nbsp;&nbsp; Kích ...";
                timkiem.ProductGuid = product.ProductGuid;
                ds.Add(timkiem);
            }


            // 3. Tìm kiếm trong bảng set sản phẩm
            shSectionService           _section = new shSectionService();
            IEnumerable <shProductSet> dsSet    = _section.FindList().Where(x => TypeHelper.CompareString(x.SectionName, keyword));

            foreach (var set in dsSet)
            {
                shProduct product = _product.FindByKey(set.ProductGuid);

                timkiem             = new TimKiemNangCao();
                timkiem.CategoryId  = TheLoaiTimKiemNangCao.SetSanPham.GetHashCode();
                timkiem.Category    = "Sản phẩm";
                timkiem.Name        = product.ProductName + "- Set " + set.SectionName + keyword;
                timkiem.MetaTitle   = product.MetaTitle + "-" + product.ProductId;
                timkiem.keyword     = keyword;
                timkiem.CreatedDate = set.CreateDate;
                timkiem.Description = " Bộ sản phẩm có kết cấu và giá sản phẩm: &nbsp;&nbsp;&nbsp;&nbsp; Kích ...";
                timkiem.ProductGuid = product.ProductGuid;
                ds.Add(timkiem);
            }

            // 4. Tìm kiếm trong bảng kích thước theo set
            shSizeService           _size  = new shSizeService();
            IEnumerable <shSetSize> dsSize = _size.FindList().Where(x => TypeHelper.CompareString(x.SizeName, keyword));

            foreach (var size in dsSize)
            {
                shProduct product = _product.FindByKey(size.ProductGuid);

                timkiem             = new TimKiemNangCao();
                timkiem.CategoryId  = TheLoaiTimKiemNangCao.SetSanPham.GetHashCode();
                timkiem.Category    = "Sản phẩm";
                timkiem.Name        = product.ProductName + " - Kích thước: " + size.SizeName;
                timkiem.MetaTitle   = product.MetaTitle + "-" + product.ProductId;
                timkiem.keyword     = keyword;
                timkiem.CreatedDate = size.CreateDate;
                timkiem.Description = " Bộ sản phẩm có kết cấu và giá sản phẩm: &nbsp;&nbsp;&nbsp;&nbsp; Kích ...";
                timkiem.ProductGuid = product.ProductGuid;
                ds.Add(timkiem);
            }


            // 2. Tìm kiếm trong bảng tin tức
            shNewService        _new  = new shNewService();
            IEnumerable <shNew> dsNew = _new.FindList().Where(x => TypeHelper.CompareString(x.TitleNew, keyword));

            foreach (var news in dsNew)
            {
                timkiem             = new TimKiemNangCao();
                timkiem.CategoryId  = TheLoaiTimKiemNangCao.TinTuc.GetHashCode();
                timkiem.Category    = "Tin Tức";
                timkiem.Name        = news.TitleNew;
                timkiem.MetaTitle   = news.MetaTitle + "-" + news.NewId;
                timkiem.keyword     = keyword;
                timkiem.CreatedDate = news.CreatedDate;
                timkiem.Description = news.Summary;
                ds.Add(timkiem);
            }

            return(ds);
        }
示例#13
0
        public ActionResult Create(string ProductGuid, string CategoryGuid, int?ProductId, string ProductName, string CompleteSetInclude, string Details, int?Number, int?SortOrder, string UserManual, bool?Status, string Description,
                                   string DeleteImage)
        {
            List <ProductMultiUpload> dsDesignImage   = (List <ProductMultiUpload>)Session[Config.DesignImage];
            List <ProductMultiUpload> dsMaterialImage = (List <ProductMultiUpload>)Session[Config.MaterialImage];

            shProductService _product = new shProductService();

            string Image = "";

            if (dsDesignImage.Count() > 0)
            {
                var obj = dsDesignImage.FirstOrDefault();
                if (obj != null)
                {
                    Image = obj.value;
                }
            }
            shProduct product = new shProduct();

            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        // 1. Inser , Upload Product
                        product = _product.Inser_UpdateProduct(
                            ProductGuid,
                            ProductId.Value,
                            CategoryGuid,
                            ProductName,
                            null,
                            CompleteSetInclude,
                            Details,
                            UserManual,
                            null,
                            null,
                            Number,
                            Image,
                            null,
                            null,
                            SortOrder,
                            null,
                            null,
                            Status,
                            DateTime.Now,
                            Description);


                        if (!(product.ProductId > 0))
                        {
                            TempData["ERROR"]        = "Cập nhật dữ liệu bản ghi không thành công. Xin vui lòng thao tác lại";
                            TempData["ProductGuid"]  = ProductGuid;
                            TempData["CategoryGuid"] = CategoryGuid;
                            TempData["ProductName"]  = ProductName;
                            TempData["Description"]  = Description;
                            TempData["Details"]      = Details;

                            return(RedirectToAction("Create", new { id = ProductGuid }));
                        }
                        // 2. nếu người dùng có upload file lưu lại lịch sử trong bảng ProductImage
                        shProductImageService _productImage = new shProductImageService();
                        _productImage.InsertAllImageProduct(product.ProductGuid, User.Identity.GetUserLogin().Userid, dsDesignImage, dsMaterialImage, null, null, true, DateTime.Now);

                        // 3. Delete Image
                        _productImage.DeleteAllImageProduct(DeleteImage);
                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }

            int?page = CommonHelper.FindPageProduct(product.ProductGuid, product.ProductId, Config.PAGE_SIZE_20);

            return(RedirectToAction("Index", new { page }));
        }