protected void Page_Load(object sender, EventArgs e)
    {
        if (StopProcessing)
        {
            // No actions if processing is stopped
        }
        else
        {
            //Check view permission
            if (!CheckViewPermissions(UIContext.EditedObject as BaseInfo))
            {
                editElem.StopProcessing = true;
                editElem.Visible        = false;
                return;
            }

            if (!CheckEditPermissions())
            {
                editElem.Enabled = false;
                editElem.ShowError(GetString("ui.notauthorizemodified"));
            }


            editElem.OnAfterDefinitionUpdate += new EventHandler(editElem_OnAfterDefinitionUpdate);
            if (DisplayedControls != String.Empty)
            {
                editElem.DisplayedControls = DisplayedControls.ToEnum <FieldEditorControlsEnum>();
            }

            if (FieldEditorMode != String.Empty)
            {
                editElem.Mode = FieldEditorMode.ToEnum <FieldEditorModeEnum>();
            }
            editElem.ShowQuickLinks = ShowQuickLinks;

            BaseInfo bi = UIContext.EditedObject as BaseInfo;

            // Set the form defintion to the FieldEditor
            if ((bi != null) && (ParametersColumnName != String.Empty))
            {
                // Set properties for webpart
                switch (editElem.Mode)
                {
                case FieldEditorModeEnum.WebPartProperties:
                case FieldEditorModeEnum.SystemWebPartProperties:
                    editElem.WebPartId = bi.Generalized.ObjectID;
                    break;
                }

                editElem.FormDefinition = ValidationHelper.GetString(bi.GetValue(ParametersColumnName), String.Empty);
            }

            ScriptHelper.HideVerticalTabs(Page);
        }
    }
Esempio n. 2
0
 public FieldDataDescriptor(string CaptionText, DataColumn Column, FieldEditorMode Mode = FieldEditorMode.Auto,
                            EditorDataStyle?Style = null, int?SizeWidth      = null, object NullValue = null, bool IsReadOnly = false,
                            decimal?Minimum       = null, decimal?Maximum    = null,
                            object DataSource     = null, string ValueMember = null, string DisplayMember = null,
                            GetListBoxItemsDelegate GetListBoxItemsMethod = null, FormatValueDelegate FormatValueMethod = null)
 {
     if (Mode == FieldEditorMode.Auto)
     {
         if (DataSource != null && ValueMember != null && DisplayMember != null && GetListBoxItemsMethod != null)
         {
             Mode = FieldEditorMode.ListBox;
         }
         else if (DataSource != null && ValueMember != null && DisplayMember != null)
         {
             Mode = FieldEditorMode.ComboBox;
         }
         else if (DataSource != null)
         {
             Mode = FieldEditorMode.ComboTextBox;
         }
         else if (FormatValueMethod != null)
         {
             Mode = FieldEditorMode.TextBox; this.IsReadOnly = true;
         }
         else if (Column.DataType == typeof(bool))
         {
             Mode = FieldEditorMode.CheckBox;
         }
         else if (Column.DataType == typeof(byte))
         {
             Mode = FieldEditorMode.NumberTextBox; this.Minimum = byte.MinValue; this.Maximum = byte.MaxValue;
         }
         else if (Column.DataType == typeof(short))
         {
             Mode = FieldEditorMode.NumberTextBox; this.Minimum = short.MinValue; this.Maximum = short.MaxValue;
         }
         else if (Column.DataType == typeof(int))
         {
             Mode = FieldEditorMode.NumberTextBox; this.Minimum = int.MinValue; this.Maximum = int.MaxValue;
         }
         else if (Column.DataType == typeof(long))
         {
             Mode = FieldEditorMode.NumberTextBox; this.Minimum = long.MinValue; this.Maximum = long.MaxValue;
         }
         else if (Column.DataType == typeof(ushort))
         {
             Mode = FieldEditorMode.NumberTextBox; this.Minimum = ushort.MinValue; this.Maximum = ushort.MaxValue;
         }
         else if (Column.DataType == typeof(uint))
         {
             Mode = FieldEditorMode.NumberTextBox; this.Minimum = uint.MinValue; this.Maximum = uint.MaxValue;
         }
         else if (Column.DataType == typeof(ulong))
         {
             Mode = FieldEditorMode.NumberTextBox; this.Minimum = ulong.MinValue; this.Maximum = ulong.MaxValue;
         }
         else if (Column.DataType == typeof(DateTime))
         {
             Mode = FieldEditorMode.DateTimeTextBox;
         }
         else if (Column.DataType == typeof(Guid))
         {
             Mode = FieldEditorMode.TextBox; this.IsReadOnly = true;
         }
         else if (Column.MaxLength > 260)
         {
             Mode = FieldEditorMode.MultilineTextBox;
         }
         else
         {
             Mode = FieldEditorMode.TextBox;
         }
     }
     if (Mode == FieldEditorMode.BitMask && (Column.DataType == typeof(long) || Column.DataType == typeof(ulong)))
     {
         Mode = FieldEditorMode.BitMask64;
     }
     this.CaptionText = CaptionText; // Column.Caption;
     this.ColumnName  = Column.ColumnName;
     this.Mode        = Mode;
     this.Style       = Style;
     this.IsNull      = Column.AllowDBNull || Mode == FieldEditorMode.GuidEditor;
     this.NullValue   = NullValue;
     this.IsReadOnly  = this.IsReadOnly || Column.ReadOnly || IsReadOnly || Mode == FieldEditorMode.GuidEditor;
     if (this.IsReadOnly && this.Mode == FieldEditorMode.NumberTextBox)
     {
         this.Mode = FieldEditorMode.TextBox;
     }
     if (Column.MaxLength > 0)
     {
         this.MaxLength = Column.MaxLength;
     }
     if (Minimum.HasValue)
     {
         this.Minimum = Minimum;
     }
     if (Maximum.HasValue)
     {
         this.Maximum = Maximum;
     }
     this.SizeWidth             = SizeWidth;
     this.DataSource            = DataSource;
     this.ValueMember           = ValueMember;
     this.DisplayMember         = DisplayMember;
     this.GetListBoxItemsMethod = GetListBoxItemsMethod;
     this.FormatValueMethod     = FormatValueMethod;
 }