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

            var styleInfo = (TableStyleInfo)e.Item.DataItem;

            var ltlAttributeName = (Literal)e.Item.FindControl("ltlAttributeName");
            var ltlDisplayName   = (Literal)e.Item.FindControl("ltlDisplayName");
            var ltlInputType     = (Literal)e.Item.FindControl("ltlInputType");
            var ltlFieldType     = (Literal)e.Item.FindControl("ltlFieldType");
            var ltlValidate      = (Literal)e.Item.FindControl("ltlValidate");
            var ltlTaxis         = (Literal)e.Item.FindControl("ltlTaxis");
            var ltlEditStyle     = (Literal)e.Item.FindControl("ltlEditStyle");
            var ltlEditValidate  = (Literal)e.Item.FindControl("ltlEditValidate");

            ltlAttributeName.Text = styleInfo.AttributeName;

            ltlDisplayName.Text = styleInfo.DisplayName;
            ltlInputType.Text   = InputTypeUtils.GetText(styleInfo.InputType);

            var columnInfo = TableColumnManager.GetTableColumnInfo(_tableName, styleInfo.AttributeName);

            ltlFieldType.Text = columnInfo != null ? $"真实 {DataTypeUtils.GetText(columnInfo.DataType)}" : "虚拟字段";

            ltlValidate.Text = TableStyleManager.GetValidateInfo(styleInfo);

            var showPopWinString = ModalTableStyleAdd.GetOpenWindowString(0, styleInfo.Id, new List <int> {
                0
            }, _tableName, styleInfo.AttributeName, _redirectUrl);
            var editText = styleInfo.Id != 0 ? "修改" : "添加";

            ltlEditStyle.Text = $@"<a href=""javascript:;"" onclick=""{showPopWinString}"">{editText}</a>";

            showPopWinString = ModalTableStyleValidateAdd.GetOpenWindowString(0, styleInfo.Id, new List <int> {
                0
            }, _tableName, styleInfo.AttributeName, _redirectUrl);
            ltlEditValidate.Text = $@"<a href=""javascript:;"" onclick=""{showPopWinString}"">设置</a>";

            ltlTaxis.Text = styleInfo.Taxis.ToString();

            if (styleInfo.Id == 0)
            {
                return;
            }

            ltlEditStyle.Text +=
                $@"&nbsp;&nbsp;<a href=""{PageUtils.GetSettingsUrl(nameof(PageSiteTableStyle), new NameValueCollection
                {
                    {"tableName", _tableName},
                    {"DeleteStyle", true.ToString()},
                    {"AttributeName", styleInfo.AttributeName}
                })}"" onClick=""javascript:return confirm('此操作将删除对应显示样式,确认吗?');"">删除</a>";
        }
示例#2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _tableName   = Body.GetQueryString("tableName");
            _redirectUrl = GetRedirectUrl(_tableName);

            if (IsPostBack)
            {
                return;
            }

            VerifyAdministratorPermissions(ConfigManager.Permissions.Settings.Site);

            if (Body.IsQueryExists("DeleteStyle"))
            {
                var attributeName = Body.GetQueryString("AttributeName");
                if (TableStyleManager.IsExists(0, _tableName, attributeName))
                {
                    TableStyleManager.Delete(0, _tableName, attributeName);
                    Body.AddAdminLog("删除数据表单样式", $"表单:{_tableName},字段:{attributeName}");
                    SuccessDeleteMessage();
                }
            }

            var styleInfoList = TableStyleManager.GetTableStyleInfoList(_tableName, new List <int> {
                0
            });

            RptContents.DataSource     = styleInfoList;
            RptContents.ItemDataBound += RptContents_ItemDataBound;
            RptContents.DataBind();

            BtnAddStyle.Attributes.Add("onclick", ModalTableStyleAdd.GetOpenWindowString(0, 0, new List <int> {
                0
            }, _tableName, string.Empty, _redirectUrl));
            BtnAddStyles.Attributes.Add("onclick",
                                        ModalTableStylesAdd.GetOpenWindowString(0, new List <int> {
                0
            }, _tableName, _redirectUrl));
            BtnImport.Attributes.Add("onclick", ModalTableStyleImport.GetOpenWindowString(_tableName, 0, 0));
            BtnExport.Attributes.Add("onclick", ModalExportMessage.GetOpenWindowStringToSingleTableStyle(_tableName));
        }