public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _relatedFieldId = AuthRequest.GetQueryInt("RelatedFieldID");
            _parentId       = AuthRequest.GetQueryInt("ParentID");
            _level          = AuthRequest.GetQueryInt("Level");
            _totalLevel     = DataProvider.RelatedFieldDao.GetRelatedFieldInfo(_relatedFieldId).TotalLevel;

            if (AuthRequest.IsQueryExists("Delete") && AuthRequest.IsQueryExists("ID"))
            {
                var id = AuthRequest.GetQueryInt("ID");
                DataProvider.RelatedFieldItemDao.Delete(id);
                if (_level != _totalLevel)
                {
                    AddScript($@"parent.location.href = '{PageRelatedFieldMain.GetRedirectUrl(SiteId, _relatedFieldId, _totalLevel)}';");
                }
            }
            else if ((AuthRequest.IsQueryExists("Up") || AuthRequest.IsQueryExists("Down")) && AuthRequest.IsQueryExists("ID"))
            {
                var id     = AuthRequest.GetQueryInt("ID");
                var isDown = AuthRequest.IsQueryExists("Down");
                if (isDown)
                {
                    DataProvider.RelatedFieldItemDao.UpdateTaxisToUp(id, _parentId);
                }
                else
                {
                    DataProvider.RelatedFieldItemDao.UpdateTaxisToDown(id, _parentId);
                }
            }
            else if (_level != _totalLevel)
            {
                InfoMessage("点击字段项名可以管理下级字段项");
            }

            if (IsPostBack)
            {
                return;
            }

            VerifySitePermissions(ConfigManager.WebSitePermissions.Configration);

            //if (_totalLevel >= 5)
            //{
            //    RptContents.Columns[1].Visible = false;
            //}

            RptContents.DataSource     = DataProvider.RelatedFieldItemDao.GetRelatedFieldItemInfoList(_relatedFieldId, _parentId);
            RptContents.ItemDataBound += RptContents_ItemDataBound;
            RptContents.DataBind();

            BtnAdd.Attributes.Add("onclick", ModalRelatedFieldItemAdd.GetOpenWindowString(SiteId, _relatedFieldId, _parentId, _level));

            if (_level == 1)
            {
                var urlReturn = PageRelatedField.GetRedirectUrl(SiteId);
                BtnReturn.Attributes.Add("onclick", $"parent.location.href = '{urlReturn}';return false;");
            }
            else
            {
                BtnReturn.Visible = false;
            }
        }
Esempio n. 2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _relatedFieldId = Body.GetQueryInt("RelatedFieldID");
            _parentId       = Body.GetQueryInt("ParentID");
            _level          = Body.GetQueryInt("Level");
            _totalLevel     = DataProvider.RelatedFieldDao.GetRelatedFieldInfo(_relatedFieldId).TotalLevel;

            if (Body.IsQueryExists("Delete") && Body.IsQueryExists("ID"))
            {
                var id = Body.GetQueryInt("ID");
                try
                {
                    DataProvider.RelatedFieldItemDao.Delete(id);
                    if (_level != _totalLevel)
                    {
                        AddScript($@"parent.location.href = '{PageRelatedFieldMain.GetRedirectUrl(PublishmentSystemId, _relatedFieldId, _totalLevel)}';");
                    }
                }
                catch (Exception ex)
                {
                    FailMessage($"删除字段项失败,{ex.Message}");
                }
            }
            else if ((Body.IsQueryExists("Up") || Body.IsQueryExists("Down")) && Body.IsQueryExists("ID"))
            {
                var id     = Body.GetQueryInt("ID");
                var isDown = Body.IsQueryExists("Down");
                if (isDown)
                {
                    DataProvider.RelatedFieldItemDao.UpdateTaxisToUp(id, _parentId);
                }
                else
                {
                    DataProvider.RelatedFieldItemDao.UpdateTaxisToDown(id, _parentId);
                }
            }
            else if (_level != _totalLevel)
            {
                InfoMessage("点击字段项名可以管理下级字段项");
            }

            if (!IsPostBack)
            {
                string level;
                if (_level == 1)
                {
                    level = "一级";
                }
                else
                {
                    var itemInfo    = DataProvider.RelatedFieldItemDao.GetRelatedFieldItemInfo(_parentId);
                    var levelString = "二";
                    if (_level == 3)
                    {
                        levelString = "三";
                    }
                    else if (_level == 4)
                    {
                        levelString = "四";
                    }
                    else if (_level == 5)
                    {
                        levelString = "五";
                    }

                    level = $"{levelString}级({itemInfo.ItemName})";
                }

                BreadCrumbWithItemTitle(AppManager.Cms.LeftMenu.IdConfigration, AppManager.Cms.LeftMenu.Configuration.IdConfigurationContentModel, "联动字段管理", level, AppManager.Cms.Permission.WebSite.Configration);

                BindGrid();

                AddButton.Attributes.Add("onclick", ModalRelatedFieldItemAdd.GetOpenWindowString(PublishmentSystemId, _relatedFieldId, _parentId, _level));

                if (_level == 1)
                {
                    var urlReturn = PageRelatedField.GetRedirectUrl(PublishmentSystemId);
                    ReturnButton.Attributes.Add("onclick", $"parent.location.href = '{urlReturn}';return false;");
                }
                else
                {
                    ReturnButton.Visible = false;
                }
            }
        }