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

            _tableStyleId      = AuthRequest.GetQueryInt("TableStyleID");
            _relatedIdentities = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("RelatedIdentities"));
            if (_relatedIdentities.Count == 0)
            {
                _relatedIdentities.Add(0);
            }
            _tableName     = AuthRequest.GetQueryString("TableName");
            _attributeName = AuthRequest.GetQueryString("AttributeName");
            _redirectUrl   = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("RedirectUrl"));

            _styleInfo = _tableStyleId != 0 ? DataProvider.TableStyleDao.GetTableStyleInfo(_tableStyleId) : TableStyleManager.GetTableStyleInfo(_tableName, _attributeName, _relatedIdentities);

            if (IsPostBack)
            {
                return;
            }

            InputTypeUtils.AddListItems(DdlInputType);

            var relatedFieldInfoList = DataProvider.RelatedFieldDao.GetRelatedFieldInfoList(SiteId);

            foreach (var rfInfo in relatedFieldInfoList)
            {
                var listItem = new ListItem(rfInfo.Title, rfInfo.Id.ToString());
                DdlRelatedFieldId.Items.Add(listItem);
            }

            ERelatedFieldStyleUtils.AddListItems(DdlRelatedFieldStyle);

            ControlUtils.SelectSingleItem(DdlIsRapid, _styleInfo.Id != 0 ? false.ToString() : true.ToString());

            TbAttributeName.Text = _styleInfo.AttributeName;
            TbDisplayName.Text   = _styleInfo.DisplayName;
            TbHelpText.Text      = _styleInfo.HelpText;
            ControlUtils.SelectSingleItem(DdlInputType, _styleInfo.InputType.Value);
            TbTaxis.Text = _styleInfo.Taxis.ToString();
            ControlUtils.SelectSingleItem(DdlIsFormatString, _styleInfo.Additional.IsFormatString.ToString());
            TbDefaultValue.Text           = _styleInfo.DefaultValue;
            DdlIsHorizontal.SelectedValue = _styleInfo.IsHorizontal.ToString();
            TbColumns.Text = _styleInfo.Additional.Columns.ToString();

            ControlUtils.SelectSingleItem(DdlRelatedFieldId, _styleInfo.Additional.RelatedFieldId.ToString());
            ControlUtils.SelectSingleItem(DdlRelatedFieldStyle, _styleInfo.Additional.RelatedFieldStyle);

            TbHeight.Text = _styleInfo.Additional.Height == 0 ? string.Empty : _styleInfo.Additional.Height.ToString();
            TbWidth.Text  = _styleInfo.Additional.Width;

            var styleItems = _styleInfo.StyleItems ?? DataProvider.TableStyleItemDao.GetStyleItemInfoList(_styleInfo.Id);

            TbItemCount.Text        = styleItems.Count.ToString();
            RptItems.DataSource     = GetDataSource(styleItems.Count, styleItems);
            RptItems.ItemDataBound += RptItems_ItemDataBound;
            RptItems.DataBind();

            var isSelected  = false;
            var isNotEquals = false;
            var list        = new List <string>();

            foreach (var item in styleItems)
            {
                list.Add(item.ItemValue);
                if (item.IsSelected)
                {
                    isSelected = true;
                }
                if (item.ItemValue != item.ItemTitle)
                {
                    isNotEquals = true;
                }
            }

            DdlIsRapid.SelectedValue = (!isSelected && !isNotEquals).ToString();
            TbRapidValues.Text       = string.Join(",", list);

            TbCustomizeLeft.Text  = _styleInfo.Additional.CustomizeLeft;
            TbCustomizeRight.Text = _styleInfo.Additional.CustomizeRight;

            ReFresh(null, EventArgs.Empty);
        }