예제 #1
0
        public ActionResult DeleteSection(string SectionGuid, string ProductGuid)
        {
            shSectionService _section = new shSectionService();
            shProductSet     section  = _section.FindByKey(SectionGuid);

            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        if (section != null)
                        {
                            section.Status = false;
                            _section.Update(section);
                        }

                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }


            if (Request.IsAjaxRequest())
            {
                return(Json("OK", JsonRequestBehavior.AllowGet));
            }

            return(RedirectToAction("Index"));
        }
예제 #2
0
        public ActionResult SizeGuid(string ProductGuid, string SectionGuid, string SizeGuid)
        {
            if (string.IsNullOrWhiteSpace(SectionGuid) || string.IsNullOrEmpty(SectionGuid))
            {
                shSectionService _section = new shSectionService();

                IEnumerable <shProductSet> ds = _section.DanhSachSection_TheoProductGuid_ParentNull(ProductGuid);

                if (ds != null && ds.Count() > 0)
                {
                    SectionGuid = ds.FirstOrDefault().SectionGuid;
                }
            }

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

            foreach (var size in dsSize)
            {
                size.SizeName += " - " + Format.FormatDecimalToString(size.PriceCurrent.GetValueOrDefault(0)).Replace(',', '.');
            }
            SelectList select = new SelectList(dsSize, "SizeGuid", "SizeName", SizeGuid);

            return(PartialView("SizeGuid", select));
        }
예제 #3
0
        public PartialViewResult EditSize(string SizeGuid, string SectionGuid, string ProductGuid)
        {
            shSizeService _size = new shSizeService();
            shSetSize     size  = _size.FindByKey(SizeGuid);

            if (size == null)
            {
                size = new shSetSize();
            }

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

            ViewBag.SectionGuid = new SelectList(dsSection, "SectionGuid", "SectionName", SectionGuid);

            IEnumerable <shSetSize> dsSize = _size.DanhSachSize_BySectionGuid(null, ProductGuid, null)
                                             .Where(x => string.IsNullOrWhiteSpace(x.ParentId) ||
                                                    string.IsNullOrEmpty(x.ParentId));

            foreach (var item in dsSize)
            {
                item.SizeName = _section.SectionName(item.SectionGuid) + " - " + item.SizeName;
            }
            ViewBag.Parent = new SelectList(dsSize, "SizeGuid", "SizeName", size.ParentId);
            //size.PriceCurrent = Format.SubStringDotInDecimal(size.PriceCurrent.Value);

            return(PartialView("EditSize", size));
        }
예제 #4
0
        public static MvcHtmlString ChatLieu_KichThuoc(this HtmlHelper helper, string SizeGuid, string SizeName, string Stuff, string ParentId, string SectionGuid)
        {
            string html = string.Empty;

            if (!string.IsNullOrWhiteSpace(SizeName))
            {
                html += SizeName;
            }

            if (!string.IsNullOrWhiteSpace(Stuff))
            {
                html += " - " + Stuff;
            }
            string title = string.Empty;
            string style = string.Empty;

            if (!string.IsNullOrWhiteSpace(ParentId))
            {
                shSectionService _section = new shSectionService();
                shSizeService    _size    = new shSizeService();
                shSetSize        size     = _size.FindByKey(ParentId);
                if (size != null)
                {
                    title = "Thuộc bộ sản phẩm: " + _section.SectionName(SectionGuid) + " [" + size.SizeName + "]";
                }
            }
            else
            {
                style = "font-weight:bold; cursor: pointer";
            }
            string span = "<span title='" + title + "' style='" + style + "' class='parent-size'>" + html + "</span>";

            return(new MvcHtmlString(span));
        }
예제 #5
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));
        }
예제 #6
0
        public PartialViewResult DsChildSection(string SectionGuid)
        {
            shSectionService _section = new shSectionService();

            IEnumerable <shProductSet> dsSection = _section.DanhSachSection_TheoParentId(SectionGuid);

            return(PartialView("DsChildSection", dsSection));
        }
예제 #7
0
        public PartialViewResult DsChildSize(string SizeGuid)
        {
            shSizeService    _size    = new shSizeService();
            shSectionService _section = new shSectionService();

            IEnumerable <shSetSize> ListSize = _size.DanhSachSize_ByParent(SizeGuid);

            return(PartialView("DsChildSize", ListSize));
        }
예제 #8
0
        public ActionResult SectionGuid(string ProductGuid, string SectionGuid)
        {
            shSectionService _section = new shSectionService();

            //IEnumerable<shSection> ds = _section.DanhSachSection_TheoProductGuid(ProductGuid);
            IEnumerable <shProductSet> ds = _section.DanhSachSection_TheoProductGuid_ParentNull(ProductGuid);

            SelectList select = new SelectList(ds, "SectionGuid", "SectionName", SectionGuid);

            return(PartialView("SectionGuid", select));
        }
예제 #9
0
        public static MvcHtmlString SectionName(this HtmlHelper helper, string SectionGuid)
        {
            shSectionService _section = new shSectionService();

            shProductSet section = _section.FindByKey(SectionGuid);

            if (section == null)
            {
                section = new shProductSet();
            }

            return(new MvcHtmlString(section.SectionName));
        }
예제 #10
0
        public void LoadDuLieu()
        {
            shOrderService _order = new shOrderService();

            @ViewBag.DonHang          = _order.SoDonHangTrongNgay(DateTime.Now);
            @ViewBag.DoanhThuTheoNgay = Format.FormatDecimalToString(_order.DoanhThuTheoNgay(DateTime.Now));

            shMemberService _member = new shMemberService();

            @ViewBag.NewMember = _member.DanhSachMemberDangKyMoi();

            shProductService _product = new shProductService();
            shSectionService _section = new shSectionService();
            shSizeService    _size    = new shSizeService();

            @ViewBag.SoLuongTon = _size.SoLuongTonSetSize();
        }
예제 #11
0
        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));
        }
예제 #12
0
        public PartialViewResult ListSize(string ProductGuid, string SectionGuid, int?page, string SizeGuid, int?p)
        {
            int pageCurrent = 1;

            if (page.HasValue)
            {
                pageCurrent = page.Value;
            }

            shSizeService    _size    = new shSizeService();
            shSectionService _section = new shSectionService();

            IEnumerable <shSetSize> ListSize = _size.DanhSachSize_BySectionGuid_ParentNull(SectionGuid, ProductGuid, SizeGuid);

            IPagedList <shSetSize> dsSize = ListSize.OrderBy(x => x.SizeId).ToPagedList(pageCurrent, Config.PAGE_SIZE_20);

            ViewBag.ListSize = dsSize;
            ViewBag.p        = p;
            return(PartialView("ListSize", dsSize));
        }
예제 #13
0
        public static MvcHtmlString SectionName_SizeName(this HtmlHelper helper, string SectionGuid, string SizeGuid)
        {
            string           html     = string.Empty;
            shSectionService _section = new shSectionService();
            shProductSet     section  = _section.FindByKey(SectionGuid);

            if (section != null)
            {
                html += section.SectionName;
            }

            shSizeService _size = new shSizeService();
            shSetSize     size  = _size.FindByKey(SizeGuid);

            if (size != null)
            {
                html += "    " + size.SizeName + "    " + size.Stuff;
            }
            return(new MvcHtmlString(html));
        }
예제 #14
0
        public static string NoiDungDonHang(shOrder order, List <CartItem> cart)
        {
            shSectionService _section = new shSectionService();
            shSizeService    _size    = new shSizeService();
            string           noidung  = string.Empty;

            noidung += "<p content-attach> <i>Thông tin người nhận hàng: " + "</i> ";
            noidung += order.FullName;
            if (string.IsNullOrWhiteSpace(order.Phone))
            {
                noidung += " / " + order.Phone;
            }
            if (string.IsNullOrWhiteSpace(order.Email))
            {
                noidung += " / " + order.Email;
            }
            if (string.IsNullOrWhiteSpace(order.Address))
            {
                noidung += " / " + order.Address;
            }
            noidung += " </p>";

            noidung += "<p content-attach><i>Giá trị đơn hàng: " + Format.FormatDecimalToString(order.Total.GetValueOrDefault(0)) + "</i></p>";
            noidung += "<p content-attach><i>Phí ship: " + Format.FormatDecimalToString(order.FeeShip.GetValueOrDefault(0)) + "</i></p>";
            noidung += "<p content-attach><i>Ngày đặt: " + order.NgayDat.GetValueOrDefault(DateTime.Now).ToString("dd/MM/yyyy") + "</i></p>";

            noidung += "<p content-attach><i>Thông tin đơn hàng: ";

            foreach (var item in cart)
            {
                noidung += "<p>" + item.Product.ProductName;
                noidung += _section.SectionName(item.SectionGuid);
                noidung += _size.SizeName(item.SizeGuid) + "</p>";
            }

            noidung += "</i></p>";

            return(noidung);
        }
예제 #15
0
        public ActionResult Create(string ProductGuid, string SectionGuid, string SectionName, string ProductName, int?SortOrder, string ParentId, string parent)
        {
            if (parent == "0")
            {
                ParentId = null;
            }
            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        shSectionService _section = new shSectionService();
                        shProductSet     section  = _section.Insert_UpdateSection(
                            SectionGuid,
                            null,
                            ProductGuid,
                            SectionName,
                            SortOrder,
                            null,
                            true,
                            DateTime.Now,
                            ParentId);
                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }



            return(RedirectToAction("Index", new { id = ProductGuid }));
        }
예제 #16
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()));
        }
예제 #17
0
        public List <TreeView> GetProductTreeview(bool isSection, string ProductGuid)
        {
            shSectionService _section = new shSectionService();
            shSizeService    _size    = new shSizeService();

            IEnumerable <shProductSet> dsSection = _section.DanhSachSection().Where(x => x.ProductGuid == ProductGuid && string.IsNullOrWhiteSpace(x.ParentId));

            List <TreeView> dsTreeview = new List <TreeView>();
            TreeView        zTree      = null;
            TreeView        childZtree = null;

            foreach (var section in dsSection)
            {
                // cấp sản phẩm nhỏ
                zTree          = new TreeView();
                zTree.isParent = true;
                zTree.id       = section.SectionGuid;
                zTree.pId      = section.ProductGuid;

                List <TreeView> dsChildTreeview = null;

                //IEnumerable<shSize> dsChildSize = _size.DanhSachSize_BySectionGuid(section.SectionGuid, null, null);

                IEnumerable <shProductSet> dsChildSection = _section.DanhSachSection().Where(x => x.ParentId == section.SectionGuid).OrderBy(x => x.SortOrder);

                if (dsChildSection.Count() > 0)
                {
                    dsChildTreeview = new List <TreeView>();

                    foreach (var childSection in dsChildSection)
                    {
                        // Cấp kích thước + Giá tiền
                        childZtree      = new TreeView();
                        childZtree.id   = childSection.SectionGuid;
                        childZtree.pId  = childSection.ParentId;
                        childZtree.name = childSection.SectionName;

                        childZtree.isParent = false;
                        childZtree.children = null;
                        childZtree.click    = "shProduct('' , '" + childSection.SectionGuid + "', '', '1')";

                        dsChildTreeview.Add(childZtree);
                    }

                    zTree.children = dsChildTreeview;
                    zTree.open     = true;
                    zTree.click    = "shProduct('', '" + section.SectionGuid + "', '', '1')";
                    zTree.name     = section.SectionName + "[" + dsChildSection.Count() + "]";
                }
                else
                {
                    // Chưa có Kích Thước
                    zTree.click = "shProduct('' , '" + section.SectionGuid + "', '', '1')";
                    zTree.open  = false;
                    zTree.name  = section.SectionName;
                }
                //zTree.name += "<a href='javascript:void(0)' onclick='Edit()'>" +
                //              "<span class='fa fa-pencil-square-o' style='transform: scale(1.3, 1.3);' title='Sửa'>" +
                //              "</span></a>";
                dsTreeview.Add(zTree);
            }

            return(dsTreeview);
        }
예제 #18
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);
        }