예제 #1
0
    private DataSet ugTransformations_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        //Set filters
        int    level   = ValidationHelper.GetInteger(txtLevel.Text, -1);
        string docType = txtDocTypes.Text;

        //Set new info to XML collection
        HierarchicalTransformations transf = LoadTransformation();

        int pageSize = ValidationHelper.GetInteger(ugTransformations.PageSizeDropdown.SelectedValue, 0);
        int count    = transf.ItemsCount;

        // Hide filter when no pager used for grid or if all items count is larger then page size
        if ((pageSize == TreeProvider.ALL_LEVELS) || (count < pageSize))
        {
            pnlFilter.Visible = false;
        }
        else
        {
            pnlFilter.Visible = true;
        }

        DataSet ds = transf.GetDataSet(level, HierarchicalTransformations.StringToUniViewItemType(TemplateType), docType);

        return(ds);
    }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //Validate data
        string errorMessage = new Validator().NotEmpty(ucTransformations.Value, GetString("transformationedit.erroremptytransformation")).Result;

        if ((errorMessage == "") && (txtLevel.Text.Trim() != String.Empty) && (!ValidationHelper.IsInteger(txtLevel.Text)))
        {
            errorMessage = GetString("development.invalidtransformationlevel");
        }

        if (String.IsNullOrEmpty(txtLevel.Text))
        {
            txtLevel.Text = "-1";
        }

        int level = ValidationHelper.GetInteger(txtLevel.Text, -1);

        if (level < -1)
        {
            errorMessage = GetString("development.invalidtransformationlevel");
        }

        if (errorMessage != String.Empty)
        {
            lblError.Text    = errorMessage;
            lblError.Visible = true;
            return;
        }

        //Fill the info
        if (mHierInfo == null)
        {
            mHierInfo        = new HierarchicalTransformationInfo();
            mHierInfo.ItemID = Guid.NewGuid();
        }


        mHierInfo.ItemLevel          = ValidationHelper.GetInteger(txtLevel.Text, 0);
        mHierInfo.TransformationName = ucTransformations.Value.ToString();
        mHierInfo.Value    = ucClassSelector.Value.ToString();
        mHierInfo.ItemType = HierarchicalTransformations.StringToUniViewItemType(drpTemplateType.SelectedValue);

        if ((mTransformations != null) && (TransInfo != null))
        {
            mTransformations.SetTransformation(mHierInfo);
            TransInfo.TransformationHierarchicalXML = mTransformations.GetXML();
            TransformationInfoProvider.SetTransformation(TransInfo);
            HierarchicalID = mHierInfo.ItemID;

            RaiseOnSaved();
        }

        lblInfo.Visible  = true;
        lblError.Visible = false;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string templateType = QueryHelper.GetString("templatetype", String.Empty);

        // If not in site manager - filter class selector for only site documents
        if (!IsSiteManager)
        {
            ucClassSelector.SiteID = CMSContext.CurrentSiteID;
        }

        if (!RequestHelper.IsPostBack())
        {
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.item"), "item"));
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.alternatingitem"), "alternatingitem"));
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.firstitem"), "firstitem"));
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.lastitem"), "lastitem"));
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.header"), "header"));
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.footer"), "footer"));
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.singleitem"), "singleitem"));
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.separator"), "separator"));
            drpTemplateType.Items.Add(new ListItem(GetString("hiertransf.currentitem"), "currentitem"));

            //If new template type set via url
            if (!String.IsNullOrEmpty(templateType))
            {
                //lblTemplateType.Text = ConvertTemplateTypeToString(templateType);
                if (templateType != "all")
                {
                    drpTemplateType.SelectedValue = templateType;
                }
                else
                {
                    drpTemplateType.SelectedValue = "item";
                }
            }
        }

        //Info and error messages
        lblInfo.Text = GetString("general.changessaved");

        //First edit after save ... show info message
        if (ShowInfoLabel)
        {
            lblInfo.Visible = true;
        }

        if (!String.IsNullOrEmpty(templateType))
        {
            mTemplateType = HierarchicalTransformations.StringToUniViewItemType(templateType);
        }

        //Load transformations xml
        mTransformations = new HierarchicalTransformations("ClassName");
        if (TransInfo != null)
        {
            if (!String.IsNullOrEmpty(TransInfo.TransformationHierarchicalXML))
            {
                mTransformations.LoadFromXML(TransInfo.TransformationHierarchicalXML);
            }
        }

        //Edit
        if (HierarchicalID != Guid.Empty)
        {
            mHierInfo = mTransformations.GetTransformation(HierarchicalID);
            //Load Transformation values
            if (!RequestHelper.IsPostBack())
            {
                txtLevel.Text                 = mHierInfo.ItemLevel.ToString();
                ucTransformations.Value       = mHierInfo.TransformationName;
                ucClassSelector.Value         = mHierInfo.Value;
                templateType                  = HierarchicalTransformations.UniViewItemTypeToString(mHierInfo.ItemType);
                drpTemplateType.SelectedValue = templateType;
                mTemplateType                 = mHierInfo.ItemType;
            }
        }
    }