コード例 #1
0
        /// <summary>
        /// Binds the properties control.
        /// </summary>
        /// <param name="type">The type.</param>
        private void BindPropertiesControl(string type)
        {
            Control control = null;

            switch (type)
            {
            case FormController.MetaPrimitiveControlType:
                _propertyPath = "~/Apps/MetaDataBase/MetaUI/Modules/MetaFormControls/SmartTableLayoutItemProperties.ascx";
                control       = this.Page.LoadControl(_propertyPath);
                control.ID    = "propCtrl";
                phProperties.Controls.Clear();
                phProperties.Controls.Add(control);
                SmartTableLayoutItemProperties sp = (SmartTableLayoutItemProperties)control;
                if (!_add && FormItemData != null && FormItemData.Control != null)
                {
                    MetaClass temp = MetaDataWrapper.GetMetaClassByName(FormDocumentData.MetaClassName);
                    if (!temp.Fields.Contains(FormItemData.Control.Source))
                    {
                        temp = temp.CardOwner;
                    }

                    sp.Source   = CHelper.GetResFileString(temp.Fields[FormItemData.Control.Source].FriendlyName);
                    sp.ReadOnly = FormItemData.Control.ReadOnly;
                }
                if (_add && FormSectionData != null)
                {
                    sp.MetaClassName = FormDocumentData.MetaClassName;
                }
                break;

            default:
                //CUSTOM
                //FormSectionData.Control.Property
                //FormControlProperty fcp = new FormControlProperty();
                //fcp.Data = string
                break;
            }
            if (control == null)
            {
                divProperties.Visible = false;
            }
        }
コード例 #2
0
        protected void btnSave_ServerClick(object sender, EventArgs e)
        {
            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }

            FormController fc = new FormController(FormDocumentData);

            if (!_add && FormItemData != null)             //edit
            {
                FormItemData = fc.GetSTLItemByUid(new Guid(itemUid));

                FormItemData.ShowLabel = !rbNone.Checked;

                FormLabel lbl = null;
                foreach (FormLabel temp in FormItemData.Labels)
                {
                    if (temp.Code.ToLower().Equals(Thread.CurrentThread.CurrentUICulture.Name.ToLower()))
                    {
                        lbl = temp;
                    }
                }
                if (lbl == null)
                {
                    lbl      = new FormLabel();
                    lbl.Code = Thread.CurrentThread.CurrentUICulture.Name.ToLower();
                    FormItemData.Labels.Add(lbl);
                }
                if (rbDefault.Checked)
                {
                    lbl.Title = FormController.DefaultLabelValue;
                }
                else
                {
                    lbl.Title = txtTitle.Text;
                }

                if (!String.IsNullOrEmpty(txtLabelWidth.Text))
                {
                    FormItemData.LabelWidth = Unit.Pixel(int.Parse(txtLabelWidth.Text)).ToString();
                }

                short tabIndex = 0;
                if (!String.IsNullOrEmpty(TabIndexText.Text.Trim()))
                {
                    tabIndex = short.Parse(TabIndexText.Text.Trim());
                }
                FormItemData.TabIndex = tabIndex;

                FormItemData.RowSpan = int.Parse(ddRows.SelectedValue);
                if (!rb1.Disabled && rb1.Checked)
                {
                    FormItemData.ColSpan = 1;
                }
                if (!rb2.Disabled && rb2.Checked)
                {
                    FormItemData.ColSpan = 2;
                }

                foreach (Control c in phProperties.Controls)
                {
                    if (c is SmartTableLayoutItemProperties)
                    {
                        SmartTableLayoutItemProperties sp = (SmartTableLayoutItemProperties)c;
                        //FormItemData.Control.Source = sp.Source;
                        FormItemData.Control.ReadOnly = sp.ReadOnly;
                    }
                }
            }
            else if (_add && FormSectionData != null)
            {
                FormSectionData = fc.GetSectionByUid(new Guid(FormSectionData.Uid));

                if (ddControl.SelectedValue.Equals(FormController.MetaPrimitiveControlType))
                {
                    string source   = String.Empty;
                    bool   readOnly = false;
                    foreach (Control c in phProperties.Controls)
                    {
                        if (c is SmartTableLayoutItemProperties)
                        {
                            SmartTableLayoutItemProperties sp = (SmartTableLayoutItemProperties)c;
                            source   = sp.Source;
                            readOnly = sp.ReadOnly;
                        }
                    }
                    int colSpan = 1;
                    if (!rb1.Disabled && rb1.Checked)
                    {
                        colSpan = 1;
                    }
                    if (!rb2.Disabled && rb2.Checked)
                    {
                        colSpan = 2;
                    }

                    string label = String.Empty;
                    if (rbDefault.Checked)
                    {
                        label = FormController.DefaultLabelValue;
                    }
                    else if (rbCustom.Checked)
                    {
                        label = txtTitle.Text;
                    }

                    short tabIndex = 0;
                    if (!String.IsNullOrEmpty(TabIndexText.Text.Trim()))
                    {
                        tabIndex = short.Parse(TabIndexText.Text.Trim());
                    }

                    FormItem newItem = FormController.CreateFormItemPrimitive(-1, -1,
                                                                              int.Parse(ddRows.SelectedValue), colSpan, !rbNone.Checked,
                                                                              label, Unit.Pixel(int.Parse(txtLabelWidth.Text)), tabIndex, source, readOnly);

                    fc.AddFormItem(newItem, new Guid(FormSectionData.Uid));
                }
            }

            string newUid = Guid.NewGuid().ToString("N");

            Session[newUid] = FormDocumentData;
            CloseAndRefresh(newUid);
        }
コード例 #3
0
        private void BindPropertiesControl(string type)
        {
            Control control = null;

            switch (type)
            {
            case FormController.MetaPrimitiveControlType:
                _propertyPath = "~/Apps/MetaUI/Modules/MetaFormControls/SmartTableLayoutItemProperties.ascx";
                control       = this.Page.LoadControl(_propertyPath);
                control.ID    = "propCtrl";
                phProperties.Controls.Clear();
                phProperties.Controls.Add(control);
                SmartTableLayoutItemProperties sp = (SmartTableLayoutItemProperties)control;
                if (!_add && FormItemData != null && FormItemData.Control != null)
                {
                    #region Define Classes & Fields
                    string    ownName   = FormItemData.Control.Source;
                    string    aggrName  = String.Empty;
                    MetaField fieldOwn  = null;
                    MetaClass classOwn  = MetaDataWrapper.GetMetaClassByName(FormDocumentData.MetaClassName);
                    MetaField fieldAggr = null;
                    MetaClass classAggr = null;
                    if (ownName.Contains("."))                                  //aggregation
                    {
                        string[] mas = ownName.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
                        ownName  = mas[0];
                        aggrName = mas[1];
                        if (!classOwn.Fields.Contains(ownName))
                        {
                            classOwn = classOwn.CardOwner;
                        }
                        fieldOwn = classOwn.Fields[ownName];
                        if (fieldOwn.IsAggregation)
                        {
                            string aggrClassName = fieldOwn.Attributes[McDataTypeAttribute.AggregationMetaClassName].ToString();
                            classAggr = MetaDataWrapper.GetMetaClassByName(aggrClassName);
                            if (!classAggr.Fields.Contains(aggrName))
                            {
                                classAggr = classAggr.CardOwner;
                            }
                            fieldAggr = classAggr.Fields[aggrName];
                        }
                    }
                    else
                    {
                        if (!classOwn.Fields.Contains(ownName))
                        {
                            classOwn = classOwn.CardOwner;
                        }
                        fieldOwn = classOwn.Fields[ownName];
                    }
                    #endregion

                    string text = String.Empty;
                    if (fieldAggr != null)
                    {
                        text = String.Format("{0} - {1}",
                                             CHelper.GetResFileString(fieldOwn.FriendlyName),
                                             CHelper.GetResFileString(fieldAggr.FriendlyName)
                                             );
                    }
                    else
                    {
                        text = CHelper.GetResFileString(fieldOwn.FriendlyName);
                    }
                    sp.Source   = text;
                    sp.ReadOnly = FormItemData.Control.ReadOnly;
                }
                if (_add && FormSectionData != null)
                {
                    sp.MetaClassName = FormDocumentData.MetaClassName;
                }
                break;

            default:
                //CUSTOM
                //FormSectionData.Control.Property
                //FormControlProperty fcp = new FormControlProperty();
                //fcp.Data = string
                break;
            }
            if (control == null)
            {
                divProperties.Visible = false;
            }
        }