示例#1
0
        void dgContents_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var styleInfo = (TableStyleInfo)e.Item.DataItem;
                if (_attributeNames.Contains(styleInfo.AttributeName))
                {
                    e.Item.Visible = false;
                    return;
                }

                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 ltlIsVisible     = (Literal)e.Item.FindControl("ltlIsVisible");
                var ltlValidate      = (Literal)e.Item.FindControl("ltlValidate");
                var ltlEditStyle     = (Literal)e.Item.FindControl("ltlEditStyle");
                var ltlEditValidate  = (Literal)e.Item.FindControl("ltlEditValidate");
                var upLinkButton     = (HyperLink)e.Item.FindControl("UpLinkButton");
                var downLinkButton   = (HyperLink)e.Item.FindControl("DownLinkButton");

                var showPopWinString = ModalTableMetadataView.GetOpenWindowString(_tableType, _tableName, styleInfo.AttributeName);
                ltlAttributeName.Text = $"<a href=\"javascript:void 0;\" onClick=\"{showPopWinString}\">{styleInfo.AttributeName}</a>";

                ltlDisplayName.Text = styleInfo.DisplayName;
                ltlInputType.Text   = EInputTypeUtils.GetText(EInputTypeUtils.GetEnumType(styleInfo.InputType));
                ltlFieldType.Text   = TableManager.IsAttributeNameExists(_tableStyle, _tableName, styleInfo.AttributeName) ? $"真实 {TableManager.GetTableMetadataDataType(_tableName, styleInfo.AttributeName)}" : "虚拟字段";

                ltlIsVisible.Text = StringUtils.GetTrueOrFalseImageHtml(styleInfo.IsVisible.ToString());
                ltlValidate.Text  = EInputValidateTypeUtils.GetValidateInfo(styleInfo);

                showPopWinString = ModalTableStyleAdd.GetOpenWindowString(styleInfo.TableStyleId, _tableName, styleInfo.AttributeName, _tableStyle, _redirectUrl);
                var editText = "添加";
                if (styleInfo.TableStyleId != 0)//数据库中有样式
                {
                    editText = "修改";
                }
                ltlEditStyle.Text = $"<a href=\"javascript:void 0;\" onClick=\"{showPopWinString}\">{editText}</a>";

                showPopWinString     = ModalTableStyleValidateAdd.GetOpenWindowString(styleInfo.TableStyleId, _tableName, styleInfo.AttributeName, _tableStyle, _redirectUrl);
                ltlEditValidate.Text = $"<a href=\"javascript:void 0;\" onClick=\"{showPopWinString}\">设置</a>";

                if (styleInfo.TableStyleId != 0)//数据库中有样式
                {
                    var urlStyle = PageUtils.GetSysUrl(nameof(PageTableStyle), new NameValueCollection
                    {
                        { "tableName", _tableName },
                        { "tableType", EAuxiliaryTableTypeUtils.GetValue(_tableType) },
                        { "DeleteStyle", true.ToString() },
                        { "AttributeName", styleInfo.AttributeName }
                    });
                    ltlEditStyle.Text +=
                        $@"&nbsp;&nbsp;<a href=""{urlStyle}"" onClick=""javascript:return confirm('此操作将删除对应显示样式,确认吗?');"">删除</a>";
                }

                //if (TableStyleManager.IsMetadata(this.tableStyle, styleInfo.AttributeName) || styleInfo.RelatedIdentity != this.nodeInfo.NodeID)
                //{
                //    isTaxisVisible = false;
                //}
                //else
                //{
                var isTaxisVisible = !TableStyleManager.IsExistsInParents(new List <int> {
                    0
                }, _tableName, styleInfo.AttributeName);
                //}

                if (!isTaxisVisible)
                {
                    upLinkButton.Visible = downLinkButton.Visible = false;
                }
                else
                {
                    var tableMetadataId = BaiRongDataProvider.TableMetadataDao.GetTableMetadataId(styleInfo.TableName, styleInfo.AttributeName);
                    upLinkButton.NavigateUrl = PageUtils.GetSysUrl(nameof(PageTableStyle), new NameValueCollection
                    {
                        { "tableName", _tableName },
                        { "tableType", EAuxiliaryTableTypeUtils.GetValue(_tableType) },
                        { "SetTaxis", true.ToString() },
                        { "TableStyleID", styleInfo.TableStyleId.ToString() },
                        { "Direction", "UP" },
                        { "TableMetadataId", tableMetadataId.ToString() }
                    });
                    downLinkButton.NavigateUrl = PageUtils.GetSysUrl(nameof(PageTableStyle), new NameValueCollection
                    {
                        { "tableName", _tableName },
                        { "tableType", EAuxiliaryTableTypeUtils.GetValue(_tableType) },
                        { "SetTaxis", true.ToString() },
                        { "TableStyleID", styleInfo.TableStyleId.ToString() },
                        { "Direction", "DOWN" },
                        { "TableMetadataId", tableMetadataId.ToString() }
                    });
                }
            }
        }
示例#2
0
        void dgContents_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var tableMetadataId = SqlUtils.EvalInt(e.Item.DataItem, "TableMetadataID");
                var attributeName   = SqlUtils.EvalString(e.Item.DataItem, "AttributeName");
                var dataType        = SqlUtils.EvalString(e.Item.DataItem, "DataType");
                var dataLength      = SqlUtils.EvalInt(e.Item.DataItem, "DataLength");
                var isSystem        = SqlUtils.EvalString(e.Item.DataItem, "IsSystem");

                var ltlAttributeName = e.Item.FindControl("ltlAttributeName") as Literal;
                var ltlDisplayName   = e.Item.FindControl("ltlDisplayName") as Literal;
                var ltlIsVisible     = e.Item.FindControl("ltlIsVisible") as Literal;
                var ltlValidate      = e.Item.FindControl("ltlValidate") as Literal;
                var ltlDataType      = e.Item.FindControl("ltlDataType") as Literal;
                var ltlInputType     = e.Item.FindControl("ltlInputType") as Literal;
                var upLinkButton     = e.Item.FindControl("UpLinkButton") as HyperLink;
                var downLinkButton   = e.Item.FindControl("DownLinkButton") as HyperLink;
                var ltlStyle         = e.Item.FindControl("ltlStyle") as Literal;
                var ltlEditValidate  = e.Item.FindControl("ltlEditValidate") as Literal;
                var ltlEditUrl       = e.Item.FindControl("ltlEditUrl") as Literal;
                var ltlDeleteUrl     = e.Item.FindControl("ltlDeleteUrl") as Literal;

                var showPopWinString = ModalTableMetadataView.GetOpenWindowString(_tableType, _tableName, attributeName);
                ltlAttributeName.Text =
                    $"<a href=\"javascript:void 0;\" onClick=\"{showPopWinString}\">{attributeName}</a>";

                var styleInfo = TableStyleManager.GetTableStyleInfo(EAuxiliaryTableTypeUtils.GetTableStyle(_tableType), _tableName, attributeName, null);
                ltlDisplayName.Text = styleInfo.DisplayName;

                ltlIsVisible.Text = StringUtils.GetTrueOrFalseImageHtml(styleInfo.IsVisible.ToString());
                ltlValidate.Text  = EInputValidateTypeUtils.GetValidateInfo(styleInfo);

                ltlDataType.Text  = EDataTypeUtils.GetTextByAuxiliaryTable(EDataTypeUtils.GetEnumType(dataType), dataLength);
                ltlInputType.Text = EInputTypeUtils.GetText(EInputTypeUtils.GetEnumType(styleInfo.InputType));

                if (IsSystem(isSystem))
                {
                    if (upLinkButton != null)
                    {
                        upLinkButton.NavigateUrl = PageUtils.GetSysUrl(nameof(PageTableMetadata),
                                                                       new NameValueCollection
                        {
                            { "PublishmentSystemID", PublishmentSystemId.ToString() },
                            { "SetTaxis", "True" },
                            { "TableStyleID", styleInfo.TableStyleId.ToString() },
                            { "Direction", "UP" },
                            { "TableMetadataId", tableMetadataId.ToString() },
                            { "ENName", _tableName },
                            { "TableType", EAuxiliaryTableTypeUtils.GetValue(_tableType) }
                        });
                    }
                    if (downLinkButton != null)
                    {
                        downLinkButton.NavigateUrl = PageUtils.GetSysUrl(nameof(PageTableMetadata),
                                                                         new NameValueCollection
                        {
                            { "PublishmentSystemID", PublishmentSystemId.ToString() },
                            { "SetTaxis", "True" },
                            { "TableStyleID", styleInfo.TableStyleId.ToString() },
                            { "Direction", "DOWN" },
                            { "TableMetadataId", tableMetadataId.ToString() },
                            { "ENName", _tableName },
                            { "TableType", EAuxiliaryTableTypeUtils.GetValue(_tableType) }
                        });
                    }
                }

                ltlStyle.Text = GetEditStyleHtml(tableMetadataId, attributeName);

                showPopWinString     = ModalTableStyleValidateAdd.GetOpenWindowString(styleInfo.TableStyleId, _tableName, styleInfo.AttributeName, EAuxiliaryTableTypeUtils.GetTableStyle(_tableType), _redirectUrl);
                ltlEditValidate.Text = $"<a href=\"javascript:void 0;\" onClick=\"{showPopWinString}\">设置</a>";

                ltlEditUrl.Text = GetEditHtml(isSystem, tableMetadataId);

                if (!IsSystem(isSystem))
                {
                    var attributes = new NameValueCollection
                    {
                        { "Delete", true.ToString() },
                        { "TableMetadataID", tableMetadataId.ToString() }
                    };
                    var deleteUrl = PageUtils.AddQueryString(_redirectUrl, attributes);
                    ltlDeleteUrl.Text =
                        $@"<a href=""{deleteUrl}"" onClick=""javascript:return confirm('此操作将删除辅助字段“{attributeName}”,确认吗?');"">删除字段</a>";
                }
            }
        }