예제 #1
0
        private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var keywordId   = SqlUtils.EvalInt(e.Item.DataItem, nameof(KeywordInfo.Id));
            var keyword     = SqlUtils.EvalString(e.Item.DataItem, nameof(KeywordInfo.Keyword));
            var alternative = SqlUtils.EvalString(e.Item.DataItem, nameof(KeywordInfo.Alternative));
            var grade       = EKeywordGradeUtils.GetEnumType(SqlUtils.EvalString(e.Item.DataItem, nameof(KeywordInfo.Grade)));

            var ltlKeyword     = (Literal)e.Item.FindControl("ltlKeyword");
            var ltlAlternative = (Literal)e.Item.FindControl("ltlAlternative");
            var ltlGrade       = (Literal)e.Item.FindControl("ltlGrade");
            var ltlEdit        = (Literal)e.Item.FindControl("ltlEdit");
            var ltlDelete      = (Literal)e.Item.FindControl("ltlDelete");

            ltlKeyword.Text     = keyword;
            ltlAlternative.Text = alternative;
            ltlGrade.Text       = EKeywordGradeUtils.GetText(grade);
            ltlEdit.Text        =
                $@"<a href='javascript:;' onclick=""{ModalKeywordAdd.GetOpenWindowStringToEdit(keywordId)}"">编辑</a>";

            var urlDelete = PageUtils.GetSettingsUrl(nameof(PageSiteKeyword), new NameValueCollection
            {
                { "Delete", "True" },
                { "KeywordID", keywordId.ToString() }
            });

            ltlDelete.Text =
                $@"<a href=""{urlDelete}"" onClick=""javascript:return confirm('此操作将删除关键字“{keyword}”确认吗?')"";>删除</a>";
        }
예제 #2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            if (Body.IsQueryExists("Delete") && Body.IsQueryExists("KeywordID"))
            {
                var keywordId = Body.GetQueryInt("KeywordID");
                try
                {
                    DataProvider.KeywordDao.Delete(keywordId);
                    SuccessDeleteMessage();
                }
                catch (Exception ex)
                {
                    FailDeleteMessage(ex);
                }
            }

            SpContents.ControlToPaginate = RptContents;
            SpContents.SelectCommand     = DataProvider.KeywordDao.GetSelectCommand();
            RptContents.ItemDataBound   += RptContents_ItemDataBound;
            SpContents.SortField         = nameof(KeywordInfo.Id);
            SpContents.SortMode          = SortMode.DESC; //排序
            SpContents.ItemsPerPage      = 20;

            if (IsPostBack)
            {
                return;
            }

            VerifyAdministratorPermissions(ConfigManager.Permissions.Settings.Site);

            SpContents.DataBind();
            BtnAdd.Attributes.Add("onclick", ModalKeywordAdd.GetOpenWindowStringToAdd());
            BtnImport.Attributes.Add("onclick", ModalKeywordImport.GetOpenWindowString());
        }
예제 #3
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            if (Body.IsQueryExists("Delete") && Body.IsQueryExists("KeywordID"))
            {
                var keywordId = Body.GetQueryInt("KeywordID");
                try
                {
                    DataProvider.KeywordDao.Delete(keywordId);
                    SuccessDeleteMessage();
                }
                catch (Exception ex)
                {
                    FailDeleteMessage(ex);
                }
            }

            spContents.ControlToPaginate = rptContents;
            spContents.SelectCommand     = DataProvider.KeywordDao.GetSelectCommand();
            rptContents.ItemDataBound   += rptContents_ItemDataBound;
            spContents.SortField         = "KeywordID";
            spContents.SortMode          = SortMode.DESC; //排序
            spContents.ItemsPerPage      = 20;

            if (!IsPostBack)
            {
                BreadCrumbSettings(AppManager.Settings.LeftMenu.Config, "敏感词管理", AppManager.Settings.Permission.SettingsConfig);

                spContents.DataBind();
                btnAdd.Attributes.Add("onclick", ModalKeywordAdd.GetOpenWindowStringToAdd());
                btnImport.Attributes.Add("onclick", ModalKeywordImport.GetOpenWindowString());
            }
        }