예제 #1
0
        public ActionResult ChuyenNhanVienTheoDoi(string CategoryGuid, int?UserId, string MoTaNoiDungChuyen)
        {
            shCategoryService _category = new shCategoryService();
            shCategory        category  = _category.FindByKey(CategoryGuid);

            _category.ThemMoi_HieuChinhCategory(
                category.CategoryGuid,
                null,
                category.CategoryName,
                category.ParentId,
                UserId,
                category.Status,
                category.CreatedDate,
                category.MetaTitle,
                category.Description,
                category.SortOrder,
                category.FileName);


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

            return(RedirectToAction("Index"));
        }
예제 #2
0
        public ActionResult CategoryLeft(bool?IsMenuChild)
        {
            if (!IsMenuChild.HasValue)
            {
                IsMenuChild = false;
            }

            shCategoryService        _category  = new shCategoryService();
            IEnumerable <shCategory> dsCategory = _category.DanhSachCategory()
                                                  .Where(x => string.IsNullOrEmpty(x.ParentId) ||
                                                         string.IsNullOrWhiteSpace(x.ParentId))
                                                  .ToList();

            List <shCategory> dsDanhMuc = dsCategory.ToList();

            if (IsMenuChild.Value)
            {
                foreach (var item in dsCategory)
                {
                    dsDanhMuc.AddRange(_category.DanhSachCategory_ByParentId(item.CategoryGuid));
                }
            }

            return(PartialView("CategoryLeft", dsDanhMuc));
        }
예제 #3
0
        public ActionResult DsProduct(string CategoryGuid, int?page)
        {
            int pageCurrent = 1;

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

            IEnumerable <shCategory> ds = _category.DanhSachCategory_ByParentId(CategoryGuid);

            shProductService _product  = new shProductService();
            List <shProduct> dsProduct = new List <shProduct>();

            foreach (var item in ds)
            {
                dsProduct.AddRange(_product.DanhSachProduct_TheoDanhMuc(item.CategoryGuid));
            }

            dsProduct.AddRange(_product.DanhSachProduct_TheoDanhMuc(CategoryGuid));

            ViewBag.dsProduct    = dsProduct.OrderByDescending(x => x.ProductId).ToPagedList(pageCurrent, Config.PAGE_SIZE_8);
            ViewBag.CategoryGuid = CategoryGuid;
            return(PartialView("dsProduct", ViewBag.dsProduct));
        }
        public ActionResult divProduct()
        {
            shCategoryService _category = new shCategoryService();

            IEnumerable <shCategory> ds = _category.DanhSachCategory();

            return(PartialView("divProduct", ds));
        }
예제 #5
0
        public PartialViewResult Categories(string CategoryGuid)
        {
            shCategoryService        _category  = new shCategoryService();
            IEnumerable <shCategory> dsCategory = _category.FindList().Where(x => x.ParentId == null || x.ParentId == string.Empty).OrderBy(x => x.CategoryId);

            SelectList select = new SelectList(dsCategory, "CategoryGuid", "CategoryName", CategoryGuid);

            return(PartialView("Categories", select));
        }
예제 #6
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()));
        }
예제 #7
0
        public ActionResult Create(string DanhMucGuid, int?DanhMucId, string CategoryName, string CategoryGuid, bool?Status, string Description, int?SortOrder, string FileName)
        {
            shCategory category = new shCategory();

            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        // Insert- update Category
                        shCategoryService _category = new shCategoryService();
                        category = _category.ThemMoi_HieuChinhCategory(
                            DanhMucGuid,
                            null,
                            CategoryName,
                            CategoryGuid,
                            null,
                            Status,
                            DateTime.Now,
                            null,
                            Description,
                            SortOrder,
                            FileName);

                        // Insesrt Image
                        if (!string.IsNullOrEmpty(FileName) || !string.IsNullOrWhiteSpace(FileName))
                        {
                            shCategoryImageService _categoryImage = new shCategoryImageService();
                            shCategoryImage        categoryImage  = _categoryImage.Insert_UpdateCategoryImage(
                                null,
                                null,
                                category.CategoryGuid,
                                FileName,
                                null,
                                User.Identity.GetUserLogin().Userid,
                                true,
                                DateTime.Now,
                                null
                                );
                        }

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

            int?page = CommonHelper.FindPageCategory(category.CategoryGuid, category.CategoryId);

            return(RedirectToAction("Index", new { page = page }));
        }
예제 #8
0
        public ActionResult ChuyenNhanVienTheoDoi(string CategoryGuid)
        {
            shCategoryService _category = new shCategoryService();
            shCategory        category  = _category.FindByKey(CategoryGuid);

            qtUserService        _user = new qtUserService();
            IEnumerable <qtUser> ds    = _user.DanhSachUser(null, TypeHelper.ToInt32(User.Identity.GetUserLogin().Unitid), null);

            ViewBag.UserId = new SelectList(ds, "UserId", "UserName", category.UserId);

            return(PartialView("ChuyenNhanVienTheoDoi", category));
        }
예제 #9
0
        public static MvcHtmlString DanhMucCha(this HtmlHelper helper, string CategoryGuid, string CategoryName)
        {
            string html = string.Empty;

            shCategoryService _category = new shCategoryService();

            html += CommonHelper.LamDanhMucHienThiView(CategoryGuid);

            html += "<a href='/DanhMuc/Category/Create/" + CategoryGuid + "'  class='category-parent'>" + CategoryName + "</a>";

            return(new MvcHtmlString(html));
        }
예제 #10
0
        public PartialViewResult ListCategory(int?page)
        {
            int pageCurrent = 1;

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

            shCategoryService _category = new shCategoryService();

            IPagedList <shCategory> dsCategory = _category.DanhSachCategory_PhanTrang(pageCurrent, Config.PAGE_SIZE_10);

            ViewBag.ListCategory = dsCategory;
            return(PartialView("ListCategory", dsCategory));
        }
예제 #11
0
        public ActionResult Index(int?id)
        {
            shCategoryService _category = new shCategoryService();

            if (!id.HasValue)
            {
                // Nếu link truyền vào không có id ( ví dụ link tổng quát: san-pham thì mặc định lấy trang danh mục đầu tiên)
                id = _category.DanhSachCategory().FirstOrDefault().CategoryId;
            }

            shCategory category = _category.FindList().Where(x => x.CategoryId == id).FirstOrDefault();

            ViewBag.CategoryGuid = category.CategoryGuid;
            DsProduct(category.CategoryGuid, 1);
            return(View(category));
        }
예제 #12
0
        public ActionResult Product()
        {
            shCategoryService _category = new shCategoryService();

            IEnumerable <shCategory> model = _category.DanhSachCategory_TopHot();

            int max_ = 4;
            IEnumerable <shCategory> dsC = (new shCategoryService()).DanhSachCategory().Where(x => x.ParentId == "abbce1a1efc649eabbd6949f40f83c60").Take(max_);

            int socconlai = 4 - dsC.Count();

            IEnumerable <shProduct> dsP = (new shProductService()).DanhSachProduct_TheoDanhMuc("abbce1a1efc649eabbd6949f40f83c60").Take(socconlai);


            return(PartialView("Product", model));
        }
예제 #13
0
        public static string LamDanhMucHienThiView(string CategoryGuid)
        {
            string html = string.Empty;

            shCategoryService _category = new shCategoryService();

            shCategory category = _category.FindByKey(CategoryGuid);

            while (!string.IsNullOrWhiteSpace(category.ParentId) || !string.IsNullOrEmpty(category.ParentId))
            {
                category = _category.FindByKey(category.ParentId);

                //html += StringHelper.ConvertToTitleCase(category.CategoryName) + " » ";
                html += category.CategoryName + " » ";
            }

            return(html);
        }
예제 #14
0
        public static MvcHtmlString NhanVienXuLyDanhMuChinh(this HtmlHelper helper, shCategory category)
        {
            qtUserService _user = new qtUserService();
            string UserName = string.Empty;

            if (!string.IsNullOrEmpty(category.ParentId) || !string.IsNullOrWhiteSpace(category.ParentId))
            {
                shCategoryService _category = new shCategoryService();
                shCategory parent = _category.FindByKey(category.ParentId);
                if (parent != null)
                {
                    UserName = "******" + _user.UserName(parent.UserId) + " » </span>";
                }
            }

            UserName += "<span data-toggle='tooltip' title='Theo dõi chính' data-original-title='Theo dõi chính' style='font-weight: 600; color: #72afd2;'>" + _user.UserName(category.UserId) + "</span>";

            return new MvcHtmlString(UserName);
        }
예제 #15
0
        public static int?FindPageCategory(string CategoryGuid, int?CategoryId)
        {
            try
            {
                shCategoryService _category = new shCategoryService();

                List <shCategory> dsCategory = _category.DanhSachCategory().ToList();

                int index = dsCategory.FindIndex(x => x.CategoryGuid == CategoryGuid);

                index = (int)index / Config.PAGE_SIZE_10;

                index++;

                return(index);
            }
            catch (Exception)
            {
                return(1);
            }
        }
예제 #16
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());
        }
예제 #17
0
        public ActionResult Create(string DanhMucGuid, int?DanhMucId, string CategoryName, string CategoryGuid, bool?Status, string Description, int?SortOrder, string FileName)
        {
            // Insert Category
            shCategoryService _category = new shCategoryService();
            shCategory        category  = _category.ThemMoi_HieuChinhCategory(
                DanhMucGuid,
                null,
                CategoryName,
                CategoryGuid,
                HttpContext.User.Identity.GetUserLogin().Userid,
                Status,
                DateTime.Now,
                null,
                Description,
                SortOrder,
                FileName);

            // Insesrt Image
            if (!string.IsNullOrEmpty(FileName) || !string.IsNullOrWhiteSpace(FileName))
            {
                shCategoryImageService _categoryImage = new shCategoryImageService();
                shCategoryImage        categoryImage  = _categoryImage.Insert_UpdateCategoryImage(
                    null,
                    null,
                    category.CategoryGuid,
                    FileName,
                    null,
                    User.Identity.GetUserLogin().Userid,
                    true,
                    DateTime.Now,
                    null
                    );
            }

            int?page = CommonHelper.FindPageCategory(category.CategoryGuid, category.CategoryId);

            return(RedirectToAction("Index", new { page = page }));
        }
예제 #18
0
        public ActionResult Create(string id)
        {
            if (!string.IsNullOrWhiteSpace(id))
            {
                shCategoryService _category = new shCategoryService();
                shCategory        category  = _category.FindByKey(id);

                if (category != null)
                {
                    ViewBag.DanhMucId   = category.CategoryId;
                    ViewBag.DanhMucGuid = category.CategoryGuid;
                    ViewBag.ParentId    = category.ParentId;
                    return(View(category));
                }
                else
                {
                    return(View(new shCategory()));
                }
            }

            ViewBag.CategoryId = id;
            return(View(new shCategory()));
        }
예제 #19
0
        public ActionResult DeleteHighLight(string[] cbxItem1, int?page)
        {
            shCategoryService _category = new shCategoryService();

            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        _category.UnSubcribeHighLight(cbxItem1);
                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }


            return(RedirectToAction("Index", new { page = page }));
        }
예제 #20
0
        public static string GetUrlTheFirst(string CategoryGuid)
        {
            shCategoryService _category = new shCategoryService();

            shCategory category = new shCategory();

            string controller = CategoryGuid;

            if (!string.IsNullOrWhiteSpace(CategoryGuid) || !string.IsNullOrEmpty(CategoryGuid))
            {
                category = _category.FindByKey(CategoryGuid);

                if (!string.IsNullOrWhiteSpace(category.ParentId) || !string.IsNullOrEmpty(category.ParentId))
                {
                    controller = GetUrlTheFirst(category.ParentId);
                }
                else
                {
                    controller = category.CategoryGuid;
                }
            }

            return(controller);
        }
예제 #21
0
        public List <TreeView> GetCategoryTreeview(bool isProduct)
        {
            shCategoryService _categories = new shCategoryService();

            IEnumerable <shCategory> dsCategory = _categories.DanhSachCategory()
                                                  .Where(x => string.IsNullOrWhiteSpace(x.ParentId))
                                                  .OrderBy(x => x.CategoryId);

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

            foreach (var item in dsCategory)
            {
                zTree = new TreeView();
                //zTree.open = soDem == 0 ? true : false;
                zTree.isParent = true;
                zTree.id       = item.CategoryGuid;
                zTree.pId      = item.ParentId;

                IEnumerable <shCategory> dsChildCategory = _categories.GetCategoryByParentId(item.CategoryGuid).OrderBy(x => x.CategoryId);

                List <TreeView> dsChildTreeview = null;
                if (dsChildCategory.Count() > 0) // Có phần tử con
                {
                    dsChildTreeview = new List <TreeView>();

                    foreach (var childCategory in dsChildCategory)
                    {
                        childZtree      = new TreeView();
                        childZtree.id   = childCategory.CategoryGuid;
                        childZtree.pId  = childCategory.ParentId;
                        childZtree.name = childCategory.CategoryName;
                        if (isProduct)
                        {
                            // TRUE Áp dụng cho hiển thị Danh sách sản phẩm theo danh mục
                            childZtree.isParent = isProduct;
                            childZtree.children = ProductByCategoryGuid(childCategory.CategoryGuid);
                            //childZtree.open = true;
                            childZtree.click = "category('" + childCategory.CategoryId + "')";

                            if (childZtree.children != null && childZtree.children.Count() > 0)
                            {
                                childZtree.name = childCategory.CategoryName + "[" + childZtree.children.Count() + "]";
                            }
                        }
                        else
                        {
                            // FALSE Áp dụng KHÔNG  hiển thị Danh sách sản phẩm theo danh mục
                            childZtree.isParent = isProduct;
                            childZtree.children = null;
                            //childZtree.open = false;
                            childZtree.click = "category('" + childCategory.CategoryId + "')";
                        }

                        dsChildTreeview.Add(childZtree);
                    }

                    zTree.children = dsChildTreeview;
                    zTree.open     = true;
                    zTree.click    = "category('" + item.CategoryId + "')";
                    zTree.name     = item.CategoryName + " (" + dsChildCategory.Count() + ")";
                }
                else
                {
                    zTree.click = "category('" + item.CategoryId + "')";
                    zTree.open  = false; //
                    zTree.name  = item.CategoryName;
                }

                if (isProduct)
                {
                    zTree.children.AddRange(ProductByCategoryGuid(item.CategoryGuid));
                    if (zTree.children.Count() > 0)
                    {
                        zTree.open = true;
                    }
                }
                //zTree.name += "(" +  zTree.children.Count() + ")";
                dsTreeView.Add(zTree);
            }
            return(dsTreeView);
        }
예제 #22
0
        public static MvcHtmlString CategoryName(this HtmlHelper helper, string CategoryGuid)
        {
            shCategoryService _category = new shCategoryService();

            return(new MvcHtmlString(_category.CategoryName(CategoryGuid)));
        }