Example #1
0
        public void Page_Load(object sender, EventArgs e)
        {
            var classCode = Request.QueryString["classCode"];

            _categoryClassInfo = Main.CategoryClassRepository.GetCategoryClassInfo(SiteId, classCode);

            if (Request.QueryString["Delete"] != null && Request.QueryString["CategoryIDCollection"] != null)
            {
                var categoryIdList = Request.QueryString["CategoryIDCollection"].Split(',');
                foreach (var categoryId in categoryIdList)
                {
                    Main.CategoryRepository.Delete(TranslateUtils.ToInt(categoryId));
                }
                LtlMessage.Text = Utils.GetMessageHtml("成功删除所选节点", true);
            }
            else if (Request.QueryString["categoryId"] != null && (Request.QueryString["subtract"] != null || Request.QueryString["add"] != null))
            {
                var categoryId = TranslateUtils.ToInt(Request.QueryString["categoryId"]);
                var isSubtract = Request.QueryString["subtract"] != null;
                Main.CategoryRepository.UpdateTaxis(SiteId, _categoryClassInfo.ClassCode, categoryId, isSubtract);

                Response.Redirect(GetRedirectUrl(SiteId, _categoryClassInfo.ClassCode, categoryId));
                return;
            }

            if (IsPostBack)
            {
                return;
            }

            LtlScripts.Text += CategoryTreeItem.GetScript(SiteId, _categoryClassInfo.ClassCode, ECategoryLoadingType.List);

            if (Request.QueryString["CurrentCategoryID"] != null)
            {
                _currentCategoryId = TranslateUtils.ToInt(Request.QueryString["CurrentCategoryID"]);
                var onLoadScript = GetScriptOnLoad(_currentCategoryId);
                if (!string.IsNullOrEmpty(onLoadScript))
                {
                    LtlScripts.Text += onLoadScript;
                }
            }

            BtnAdd.Attributes.Add("onclick", ModalCategoryAdd.GetOpenWindowStringToAdd(SiteId, _categoryClassInfo.ClassCode));

            //BtnDelete.Attributes.Add("onclick",
            //    PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(
            //        PageUtils.GetWcmUrl(nameof(PageCategory), new NameValueCollection
            //        {
            //            {"SiteId", SiteId.ToString()},
            //            {"ClassCode", _categoryClassInfo.ClassCode},
            //            {"Delete", true.ToString()},
            //        }), "CategoryIDCollection", "CategoryIDCollection", "请选择需要删除的节点!", "此操作将删除对应节点以及所有下级节点,确认删除吗?"));

            RptContents.DataSource     = Main.CategoryRepository.GetCategoryIdListByParentId(SiteId, _categoryClassInfo.ClassCode, 0);
            RptContents.ItemDataBound += RptContents_ItemDataBound;
            RptContents.DataBind();
        }
Example #2
0
        public static string GetCategoryRowHtml(int siteId, CategoryInfo categoryInfo, bool enabled, ECategoryLoadingType loadingType)
        {
            var treeItem = CategoryTreeItem.CreateInstance(categoryInfo, enabled);
            var title    = treeItem.GetItemHtml(loadingType);

            var rowHtml = string.Empty;

            if (loadingType == ECategoryLoadingType.Tree || loadingType == ECategoryLoadingType.Select)
            {
                rowHtml = $@"
<tr treeItemLevel=""{categoryInfo.ParentsCount + 1}"">
	<td nowrap>
		{title}
	</td>
</tr>
";
            }
            else if (loadingType == ECategoryLoadingType.List)
            {
                var editUrl      = string.Empty;
                var upLink       = string.Empty;
                var downLink     = string.Empty;
                var checkBoxHtml = string.Empty;

                if (enabled)
                {
                    editUrl =
                        $@"<a href=""javascript:;"" onclick=""{ModalCategoryAdd.GetOpenWindowStringToEdit(siteId, categoryInfo.ClassCode, categoryInfo.Id)}"">编辑</a>";

                    upLink = $@"<a href=""{GetRedirectUrl(siteId, categoryInfo.ClassCode)}&subtract={true}&categoryId={categoryInfo.Id}"">上升</a>";

                    downLink =
                        $@"<a href=""{GetRedirectUrl(siteId, categoryInfo.ClassCode)}&add={true}&categoryId={categoryInfo.Id}"">下降</a>";

                    checkBoxHtml =
                        $"<input type='checkbox' name='CategoryIDCollection' value='{categoryInfo.Id}' />";
                }

                rowHtml = $@"
<tr treeItemLevel=""{categoryInfo.ParentsCount + 1}"">
    <td>{title}</td>
    <td>{categoryInfo.CategoryCode}</td>
    <td class=""center"">{upLink}</td>
    <td class=""center"">{downLink}</td>
    <td class=""center"">{editUrl}</td>
    <td class=""center"">{checkBoxHtml}</td>
</tr>
";
            }
            return(rowHtml);
        }
Example #3
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _categoryId = TranslateUtils.ToInt(Request.QueryString["categoryID"]);

            if (!string.IsNullOrEmpty(Request.QueryString["Delete"]) && !string.IsNullOrEmpty(Request.QueryString["CategoryIDCollection"]))
            {
                var categoryIdList = TranslateUtils.StringCollectionToIntList(Request.QueryString["CategoryIDCollection"]);
                foreach (var theCategoryId in categoryIdList)
                {
                    DataProviderWx.StoreCategoryDao.Delete(PublishmentSystemId, theCategoryId);
                }
                SuccessMessage("成功删除所选区域");
            }
            else if (!string.IsNullOrEmpty(Request.QueryString["Subtract"]) || !string.IsNullOrEmpty(Request.QueryString["Add"]))
            {
                var isSubtract = (!string.IsNullOrEmpty(Request.QueryString["Subtract"])) ? true : false;
                DataProviderWx.StoreCategoryDao.UpdateTaxis(PublishmentSystemId, _categoryId, isSubtract);

                PageUtils.Redirect(GetRedirectUrl(PublishmentSystemId, _categoryId));
                return;
            }

            BindGrid();

            if (!IsPostBack)
            {
                BreadCrumb(AppManager.WeiXin.LeftMenu.IdFunction, AppManager.WeiXin.LeftMenu.Function.IdStore, "门店属性管理", AppManager.WeiXin.Permission.WebSite.Store);
                RegisterClientScriptBlock("NodeTreeScript", CategoryTreeItem.GetScript(PublishmentSystemId, ECategoryLoadingType.Category, null));

                if (_categoryId > 0)
                {
                    var onLoadScript = GetScriptOnLoad();
                    if (!string.IsNullOrEmpty(onLoadScript))
                    {
                        Page.RegisterClientScriptBlock("NodeTreeScriptOnLoad", onLoadScript);
                    }
                }

                var arguments        = new NameValueCollection();
                var showPopWinString = string.Empty;

                BtnAdd.Attributes.Add("onclick", ModalStoreCategoryAdd.GetOpenWindowStringToAdd(PublishmentSystemId));

                BtnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(GetRedirectUrlOfDelete(PublishmentSystemId), "CategoryIDCollection", "CategoryIDCollection", "请选择需要删除的门店属性!", "此操作将删除所选门店属性,确认删除吗?"));
            }
        }
Example #4
0
        private static void GetAllCategortTree(List <Category> categoriesList, int?id, CategoryTreeItem categoryTree)
        {
            var childCategories = categoriesList.Where(i => i.parentCategoryId == id).OrderBy(i => i.categoryName).ToList();

            foreach (var category in childCategories)
            {
                var cat = new CategoryTreeItem()
                {
                    id       = category.categoryId,
                    name     = category.categoryName,
                    children = new List <CategoryTreeItem>()
                };
                categoryTree.children.Add(cat);
                GetAllCategortTree(categoriesList, category.categoryId, cat);
            }
        }
Example #5
0
 public string GetScriptOnLoad()
 {
     if (_categoryId > 0)
     {
         var categoryInfo = DataProviderWx.StoreCategoryDao.GetCategoryInfo(_categoryId);
         if (categoryInfo != null)
         {
             var path = string.Empty;
             if (categoryInfo.ParentsCount <= 1)
             {
                 path = _categoryId.ToString();
             }
             else
             {
                 path = categoryInfo.ParentsPath.Substring(categoryInfo.ParentsPath.IndexOf(",") + 1) + "," + _categoryId;
             }
             return(CategoryTreeItem.GetScriptOnLoad(path));
         }
     }
     return(string.Empty);
 }
Example #6
0
        public static string GetCategoryRowHtml(int publishmentSystemId, StoreCategoryInfo categoryInfo, ECategoryLoadingType loadingType, NameValueCollection additional)
        {
            var treeItem = CategoryTreeItem.CreateInstance(categoryInfo);
            var title    = treeItem.GetItemHtml(loadingType, additional, false);

            var rowHtml = string.Empty;

            if (loadingType == ECategoryLoadingType.Category)
            {
                var editUrl      = string.Empty;
                var upLink       = string.Empty;
                var downLink     = string.Empty;
                var checkBoxHtml = string.Empty;


                var urlEdit = ModalStoreCategoryAdd.GetOpenWindowStringToEdit(publishmentSystemId, categoryInfo.Id);
                editUrl = $@"<a href=""javascript:;"" onclick=""{urlEdit}"">编辑</a>";

                var categoryUrl = GetRedirectUrl(publishmentSystemId, categoryInfo.Id);

                string urlUp = $"{categoryUrl}&Subtract=True";
                upLink = $@"<a href=""{urlUp}""><img src=""../Pic/icon/up.gif"" border=""0"" alt=""上升"" /></a>";

                string urlDown = $"{categoryUrl}&Add=True";
                downLink = $@"<a href=""{urlDown}""><img src=""../Pic/icon/down.gif"" border=""0"" alt=""下降"" /></a>";

                checkBoxHtml = $"<input type='checkbox' name='CategoryIDCollection' value='{categoryInfo.Id}' />";

                rowHtml = $@"
<tr treeItemLevel=""{categoryInfo.ParentsCount + 1}"">
    <td>{title}</td>
    <td class=""center"">{upLink}</td>
    <td class=""center"">{downLink}</td>
    <td class=""center"">{editUrl}</td>
    <td class=""center"">{checkBoxHtml}</td>
</tr>
";
            }
            return(rowHtml);
        }
Example #7
0
        public string GetScriptOnLoad(int currentCategoryId)
        {
            if (currentCategoryId == 0)
            {
                return(string.Empty);
            }
            var categoryInfo = Main.CategoryRepository.GetCategoryInfo(currentCategoryId);

            if (categoryInfo == null)
            {
                return(string.Empty);
            }
            string path;

            if (categoryInfo.ParentsCount <= 1)
            {
                path = currentCategoryId.ToString();
            }
            else
            {
                path = categoryInfo.ParentsPath.Substring(categoryInfo.ParentsPath.IndexOf(",", StringComparison.Ordinal) + 1) + "," + currentCategoryId;
            }
            return(CategoryTreeItem.GetScriptOnLoad(path));
        }