コード例 #1
0
        public OptionField Clone()
        {
            OptionField clone = (OptionField)this.MemberwiseClone();

            base.AssignMembers(clone);
            return(clone);
        }
コード例 #2
0
 /// <summary>
 /// Constructor for the class
 /// </summary>
 /// <param name="row">A DataRow containing the option row's data</param>
 /// <param name="parent">the object that contains the row</param>
 public OptionFieldItem(DataRow row, OptionField parent)
 {
     this.id       = (int)row[ColumnNames.OPTION_ID];
     this.val      = row[ColumnNames.NAME].ToString();
     this.text     = row[ColumnNames.TEXT].ToString();
     this.position = (short)row[ColumnNames.POSITION];
     this.parent   = parent;
 }
コード例 #3
0
 /// <summary>
 /// Constructor for the class
 /// </summary>
 /// <param name="row">A DataRow containing the option row's data</param>
 /// <param name="parent">the object that contains the row</param>
 public OptionFieldItem(DataRow row, OptionField parent)
 {
     this.id = (int)row[ColumnNames.OPTION_ID];
     this.val = row[ColumnNames.NAME].ToString();
     this.text = row[ColumnNames.TEXT].ToString();
     this.position = (short) row[ColumnNames.POSITION];
     this.parent = parent;
 }
コード例 #4
0
        /// <summary>
        /// Constructor for the class
        /// </summary>
        /// <param name="frm">The parent form</param>
        /// <param name="field">The fied to be edited</param>
        public OptionFieldDefinition(MainForm frm, OptionField field)
            : base(frm)
        {
            InitializeComponent();
            ScrapeControlLayout();
            this.mode = FormMode.Edit;
            this.field = field;
            this.page = field.Page;

            LoadFormData();
        }
コード例 #5
0
ファイル: ControlFactory.cs プロジェクト: NALSS/epiinfo-82474
        private List<Control> GetControls(OptionField field, Size canvasSize)
        {
            GroupBox groupBox = new GroupBox();
            groupBox.Text = field.PromptText;
            groupBox.Font = field.PromptFont;
            groupBox.FlatStyle = flatStyle;
            groupBox.TabIndex = (int)field.TabIndex;
            groupBox.BackColor = Color.Transparent;
            int groupWidthEstimate;

            if (field.ControlWidthPercentage == 0)
            {
                groupWidthEstimate = groupBox.Width - 40;
            }
            else
            {
                groupBox.Width = (int)(field.ControlWidthPercentage * canvasSize.Width);
                groupWidthEstimate = groupBox.Width - 30;
            }

            Size proposedSize = new Size(groupWidthEstimate, int.MaxValue);
            Bitmap tempImage = new Bitmap(1, 1);
            Graphics graphics = Graphics.FromImage(tempImage);
            SizeF groupPromptSize = graphics.MeasureString(groupBox.Text, groupBox.Font, proposedSize.Width);

            if (field.Options.Count < 1)
            {
                CustomRadioButton rdb = new CustomRadioButton();
                rdb.Text = "Option 1";
                rdb.Left = 5;
                rdb.Top = 20;
                rdb.Enabled = false;
                groupBox.Controls.Add(rdb);
            }
            else
            {
                int tallestControlHeight = 10;
                int widestOptionWidth = 16;
                int leftAlign = 12;

                foreach (string item in field.Options)
                {
                    CustomRadioButton radioButton = new CustomRadioButton();
                    radioButton.Text = item;
                    radioButton.AutoSize = true;

                    radioButton.TabStop = true;

                    radioButton.Enabled = true;
                    radioButton.Visible = false;
                    radioButton.Font = field.ControlFont;
                    groupBox.Controls.Add(radioButton);

                    this._controlFields.Add(radioButton, field);

                    if (radioButton.Width > widestOptionWidth)
                    {
                        widestOptionWidth = (int)radioButton.Width;
                    }

                    if (radioButton.Height > tallestControlHeight)
                    {
                        tallestControlHeight = (int)radioButton.Height;
                    }
                }

                widestOptionWidth += 10;

                double div = (groupBox.Width - (1.2 * leftAlign)) / widestOptionWidth;
                div = div < 1 ? 1 : div;
                int columnCount = (int)Math.Floor(div);
                div = (double)field.Options.Count / (double)columnCount;
                int rowCount = (int)Math.Ceiling(div);

                bool isVertical = ((OptionField)field).Pattern.Contains("Vertical");
                bool startOnLeft = ((OptionField)field).Pattern.Contains("Left");

                int topMargin = (int)groupPromptSize.Height + 10;

                int column = 0;
                int row = 0;

                if (startOnLeft == false)
                {
                    column = columnCount - 1;
                }

                int topOfLastControlDown = 0;

                foreach (Control control in groupBox.Controls)
                {
                    control.Top = row * (tallestControlHeight) + topMargin;

                    if (row == (rowCount - 1) || isVertical == false)
                    {
                        topOfLastControlDown = control.Top;
                    }

                    if (field.ShowTextOnRight)
                    {
                        control.RightToLeft = RightToLeft.No;
                        control.Left = column * (widestOptionWidth) + leftAlign;
                    }
                    else
                    {
                        control.RightToLeft = RightToLeft.Yes;
                        control.Left = column * (widestOptionWidth) + leftAlign + widestOptionWidth - control.Width;
                    }

                    groupBox.AutoSizeMode = AutoSizeMode.GrowOnly;
                    groupBox.AutoSize = false;
                    control.Visible = true;

                    if (isVertical)
                    {
                        row++;
                        if (row >= rowCount)
                        {
                            row = 0;
                            column = startOnLeft ? ++column : --column;
                        }
                    }
                    else
                    {
                        if (startOnLeft)
                        {
                            column++;
                            if (column >= columnCount)
                            {
                                column = 0;
                                row += 1;
                            }
                        }
                        else
                        {
                            column--;
                            if (column < 0)
                            {
                                column = columnCount - 1;
                                row += 1;
                            }
                        }
                    }
                }

                groupBox.Height = topOfLastControlDown + (int)(tallestControlHeight * 1.9);
                field.ControlHeightPercentage = 1.0 * groupBox.Height / canvasSize.Height;
            }

            SetControlProperties(groupBox, field, canvasSize);

            List<Control> controls = new List<Control>();
            controls.Add(groupBox);
            if (!fieldControls.ContainsKey(field))
            {
                fieldControls.Add(field, controls);
            }
            else
            {
                fieldControls.Remove(field);
                fieldControls.Add(field, controls);
            }
            return controls;
        }
コード例 #6
0
 /// <summary>
 /// Constructor for the class
 /// </summary>
 public OptionFieldItem(OptionField parent)
 {
     this.parent = parent;
 }
コード例 #7
0
ファイル: GuiMediator.cs プロジェクト: NALSS/epiinfo-82474
 /// <summary>
 /// Gets data for option fields
 /// </summary>
 /// <param name="field">The field whose data is to be stored</param>
 /// <param name="control">The control associated with the field</param>
 private void GetOptionData(OptionField field, Control control)
 {
     if (Util.IsEmpty(field.CurrentRecordValueObject))
     {   //no data, so clear all radiobuttons
         foreach (var item in control.Controls)
         {
             ((RadioButton)item).Checked = false;
         }
     }
     else
     {
         if (!Util.IsEmpty(field.CurrentRecordValue))
         {
             ((RadioButton)(control.Controls[Convert.ToInt16(field.CurrentRecordValue)])).Checked = true;
         }
     }
 }
コード例 #8
0
        /// <summary>
        /// Update Option field.
        /// </summary>
        /// <param name="field">Option field to update.</param>
        public void UpdateField(OptionField field)
        {
            try
            {
                #region InputValidation
                if (field == null)
                {
                    throw new ArgumentNullException("OptionField");
                }
                #endregion

                Query updateQuery = db.CreateQuery("update metaFields set [CheckCodeAfter] = @CheckCodeAfter, [ControlFontFamily] = @ControlFontFamily, " +
                    "[ControlFontStyle] = @ControlFontStyle, [ControlFontSize] = @ControlFontSize, [ControlHeightPercentage] = @ControlHeightPercentage, " +
                    "[ControlLeftPositionPercentage] = @ControlLeftPositionPercentage, [ControlTopPositionPercentage] = @ControlTopPositionPercentage, [ControlWidthPercentage] = @ControlWidthPercentage, " +
                    "[HasTabStop] = @HasTabStop, [IsReadOnly] = @IsReadOnly, [IsRequired] = @IsRequired, [Name] = @Name, [PageId] = @PageId, " +
                    "[PromptFontFamily] = @PromptFontFamily, [PromptFontStyle] = @PromptFontStyle, [PromptFontSize] = @PromptFontSize, " +
                    "[PromptText] = @PromptText, [List] = @List, [ShouldRepeatLast] = @ShouldRepeatLast, [ShowTextOnRight] = @ShowTextOnRight, [TabIndex] = @TabIndex, [FieldTypeId] = @FieldTypeId " +
                    "where [UniqueId] = @UniqueId");

                if (field.CheckCodeAfter == null)
                    updateQuery.Parameters.Add(new QueryParameter("@CheckCodeAfter", DbType.String, DBNull.Value));
                else
                    updateQuery.Parameters.Add(new QueryParameter("@CheckCodeAfter", DbType.String, field.CheckCodeAfter));

                updateQuery.Parameters.Add(new QueryParameter("@ControlFontFamily", DbType.String, field.ControlFont.Name));
                updateQuery.Parameters.Add(new QueryParameter("@ControlFontStyle", DbType.String, field.ControlFont.Style.ToString()));
                updateQuery.Parameters.Add(new QueryParameter("@ControlFontSize", DbType.Double, field.ControlFont.Size));
                updateQuery.Parameters.Add(new QueryParameter("@ControlHeightPercentage", DbType.Double, field.ControlHeightPercentage));
                updateQuery.Parameters.Add(new QueryParameter("@ControlLeftPositionPercentage", DbType.Double, field.ControlLeftPositionPercentage));
                updateQuery.Parameters.Add(new QueryParameter("@ControlTopPositionPercentage", DbType.Double, field.ControlTopPositionPercentage));
                updateQuery.Parameters.Add(new QueryParameter("@ControlWidthPercentage", DbType.Double, field.ControlWidthPercentage));
                updateQuery.Parameters.Add(new QueryParameter("@HasTabStop", DbType.Boolean, field.HasTabStop));
                updateQuery.Parameters.Add(new QueryParameter("@IsReadOnly", DbType.Boolean, field.IsReadOnly));
                updateQuery.Parameters.Add(new QueryParameter("@IsRequired", DbType.Boolean, field.IsRequired));
                updateQuery.Parameters.Add(new QueryParameter("@Name", DbType.String, field.Name));
                updateQuery.Parameters.Add(new QueryParameter("@PageId", DbType.Int32, field.Page.Id));
                updateQuery.Parameters.Add(new QueryParameter("@PromptFontFamily", DbType.String, field.PromptFont.Name));
                updateQuery.Parameters.Add(new QueryParameter("@PromptFontStyle", DbType.String, field.PromptFont.Style.ToString()));
                updateQuery.Parameters.Add(new QueryParameter("@PromptFontSize", DbType.Double, field.PromptFont.Size));
                updateQuery.Parameters.Add(new QueryParameter("@PromptText", DbType.String, field.PromptText));
                updateQuery.Parameters.Add(new QueryParameter("@List", DbType.String, field.GetOptionsString()));
                updateQuery.Parameters.Add(new QueryParameter("@ShouldRepeatLast", DbType.Boolean, field.ShouldRepeatLast));
                updateQuery.Parameters.Add(new QueryParameter("@ShowTextOnRight", DbType.Boolean, field.ShowTextOnRight));
                updateQuery.Parameters.Add(new QueryParameter("@TabIndex", DbType.Int32, field.TabIndex));
                updateQuery.Parameters.Add(new QueryParameter("@FieldTypeId", DbType.Int32, (int)field.FieldType));
                updateQuery.Parameters.Add(new QueryParameter("@UniqueId", DbType.Guid, field.UniqueId));

                db.ExecuteNonQuery(updateQuery);

            }
            catch (Exception ex)
            {
                throw new GeneralException("Could not update OptionField in the database", ex);
            }
            finally
            {

            }
        }
コード例 #9
0
        /// <summary>
        /// Gets all the fields in a view
        /// </summary>
        /// <param name="view">A view object</param>
        /// <returns>A collection of fields</returns>
        public virtual FieldCollectionMaster GetFields(View view)
        {
            FieldCollectionMaster fields = new FieldCollectionMaster();
            try
            {
                DataTable table = GetFieldsAsDataTable(view);
                foreach (DataRow row in table.Rows)
                {
                    MetaFieldType fieldTypeId = (MetaFieldType)row[ColumnNames.FIELD_TYPE_ID];
                    Field field = null;
                    switch (fieldTypeId)
                    {
                        case MetaFieldType.Text:
                            field = new SingleLineTextField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.LabelTitle:
                            field = new LabelField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.TextUppercase:
                            field = new UpperCaseTextField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Multiline:
                            field = new MultilineTextField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Number:
                            field = new NumberField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.PhoneNumber:
                            field = new PhoneNumberField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Date:
                            field = new DateField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Time:
                            field = new TimeField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.DateTime:
                            field = new DateTimeField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Checkbox:
                            field = new CheckBoxField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.YesNo:
                            field = new YesNoField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Option:
                            field = new OptionField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.CommandButton:
                            field = new CommandButtonField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Image:
                            field = new ImageField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Mirror:
                            field = new MirrorField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Grid:
                            field = new GridField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Group:
                            field = new GroupField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.GUID:
                            field = new GUIDField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.LegalValues:
                            field = new DDLFieldOfLegalValues(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Codes:
                            field = new DDLFieldOfCodes(view);
                            ((DDLFieldOfCodes)field).LoadFromRow(row);  //zack
                            break;
                        case MetaFieldType.List:
                            field = new DDListField(view);
                            ((DDListField)field).LoadFromRow(row);
                            break;
                        case MetaFieldType.CommentLegal:
                            field = new DDLFieldOfCommentLegal(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Relate:
                            field = new RelatedViewField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.RecStatus:
                            field = new RecStatusField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.UniqueKey:
                            field = new UniqueKeyField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.ForeignKey:
                            field = new ForeignKeyField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.GlobalRecordId:
                            field = new GlobalRecordIdField(view);
                            field.LoadFromRow(row);
                            break;
                        default:
                            throw new ApplicationException("Invalid Field Type");
                    }
                    // Note: This check ideally shouldn't be necessary, but Epi 3.5.1 and previous versions actually do allow duplicate field names for group fields.
                    if (fields.Contains(field))
                    {
                        Logger.Log(DateTime.Now + ":  " + string.Format("The {0} field with name \"{1}\" already exists in {2}. This field has not been imported.", field.GetType().ToString(), field.Name, view.Name));
                    }
                    else
                    {
                        fields.Add(field);
                    }
                }

            }
            catch (Exception ex)
            {

            }
            return (fields);
        }
コード例 #10
0
 /// <summary>
 /// Retrieves data for option field from xml metadata.
 /// </summary>
 /// <param name="field">An option field.</param>
 /// <param name="fieldNode">XML node for option field.</param>
 public void GetFieldData(OptionField field, XmlNode fieldNode)
 {
 }
コード例 #11
0
        /// <summary>
        /// Insert a OptionField record into the metaFields table.
        /// </summary>
        /// <param name="field">Option button field.</param>
        /// <returns>Returns the Id of the last OptionField added.</returns>
        public int CreateField(OptionField field)
        {
            try
            {
                #region InputValidation
                if (field == null)
                {
                    throw new ArgumentNullException("OptionField");
                }
                #endregion

                Query insertQuery = db.CreateQuery("insert into metaFields([DataTableName], [ViewId], [UniqueId], [CheckCodeAfter], [ControlFontFamily], [ControlFontStyle], [ControlFontSize], [ControlHeightPercentage], [ControlLeftPositionPercentage], [ControlTopPositionPercentage], [ControlWidthPercentage], [FieldTypeId], [HasTabStop], [IsReadOnly], [IsRequired], [Name], [PageId], [PromptFontFamily], [PromptFontStyle], [PromptFontSize], [PromptText], [List], [ShouldRepeatLast], [ShowTextOnRight], [TabIndex]) " +
                    "values (@DataTableName, @ViewId, @UniqueId, @CheckCodeAfter, @ControlFontFamily, @ControlFontStyle, @ControlFontSize, @ControlHeightPercentage, @ControlLeftPositionPercentage, @ControlTopPositionPercentage, @ControlWidthPercentage, @FieldTypeId, @HasTabStop, @IsReadOnly, @IsRequired, @Name, @PageId, @PromptFontFamily, @PromptFontStyle, @PromptFontSize, @PromptText, @List, @ShouldRepeatLast, @ShowTextOnRight, @TabIndex)");

                insertQuery.Parameters.Add(new QueryParameter("@DataTableName", DbType.String, field.TableName));
                insertQuery.Parameters.Add(new QueryParameter("@ViewId", DbType.Int32, field.GetView().Id));
                insertQuery.Parameters.Add(new QueryParameter("@UniqueId", DbType.Guid, field.UniqueId));
                if (field.CheckCodeAfter == null)
                    insertQuery.Parameters.Add(new QueryParameter("@CheckCodeAfter", DbType.String, DBNull.Value));
                else
                    insertQuery.Parameters.Add(new QueryParameter("@CheckCodeAfter", DbType.String, field.CheckCodeAfter));

                insertQuery.Parameters.Add(new QueryParameter("@ControlFontFamily", DbType.String, field.ControlFont.Name));
                insertQuery.Parameters.Add(new QueryParameter("@ControlFontStyle", DbType.String, field.ControlFont.Style.ToString()));
                insertQuery.Parameters.Add(new QueryParameter("@ControlFontSize", DbType.Double, field.ControlFont.Size));
                insertQuery.Parameters.Add(new QueryParameter("@ControlHeightPercentage", DbType.Double, field.ControlHeightPercentage));
                insertQuery.Parameters.Add(new QueryParameter("@ControlLeftPositionPercentage", DbType.Double, field.ControlLeftPositionPercentage));
                insertQuery.Parameters.Add(new QueryParameter("@ControlTopPositionPercentage", DbType.Double, field.ControlTopPositionPercentage));
                insertQuery.Parameters.Add(new QueryParameter("@ControlWidthPercentage", DbType.Double, field.ControlWidthPercentage));
                insertQuery.Parameters.Add(new QueryParameter("@FieldTypeId", DbType.Int32, (int)field.FieldType));
                insertQuery.Parameters.Add(new QueryParameter("@HasTabStop", DbType.Boolean, field.HasTabStop));
                insertQuery.Parameters.Add(new QueryParameter("@IsReadOnly", DbType.Boolean, field.IsReadOnly));
                insertQuery.Parameters.Add(new QueryParameter("@IsRequired", DbType.Boolean, field.IsRequired));
                insertQuery.Parameters.Add(new QueryParameter("@Name", DbType.String, field.Name));
                insertQuery.Parameters.Add(new QueryParameter("@PageId", DbType.Int32, field.Page.Id));
                insertQuery.Parameters.Add(new QueryParameter("@PromptFontFamily", DbType.String, field.PromptFont.Name));
                insertQuery.Parameters.Add(new QueryParameter("@PromptFontStyle", DbType.String, field.PromptFont.Style.ToString()));
                insertQuery.Parameters.Add(new QueryParameter("@PromptFontSize", DbType.Double, field.PromptFont.Size));
                insertQuery.Parameters.Add(new QueryParameter("@PromptText", DbType.String, field.PromptText));
                insertQuery.Parameters.Add(new QueryParameter("@List", DbType.String, field.GetOptionsString()));
                insertQuery.Parameters.Add(new QueryParameter("@ShouldRepeatLast", DbType.Boolean, field.ShouldRepeatLast));
                insertQuery.Parameters.Add(new QueryParameter("@ShowTextOnRight", DbType.Boolean, field.ShowTextOnRight));
                insertQuery.Parameters.Add(new QueryParameter("@TabIndex", DbType.Int32, field.TabIndex));

                db.ExecuteNonQuery(insertQuery);
                return GetMaxFieldId(field.GetView().Id);
            }
            catch (Exception ex)
            {
                throw new GeneralException("Could not create field in the database", ex);
            }
        }
コード例 #12
0
        /// <summary>
        /// Gets all the fields in a view
        /// </summary>
        /// <param name="view">the view object</param>
        /// <returns>A collection of fields</returns>
        public virtual FieldCollectionMaster GetFields(View view)
        {
            try
            {
                FieldCollectionMaster fields = new FieldCollectionMaster();

                //DataTable table = GetFieldsAsDataTable(view);
                //foreach (DataRow row in table.Rows)
                //{
                //    MetaFieldType fieldTypeId = (MetaFieldType)row[ColumnNames.FIELD_TYPE_ID];
                //    Field field = null;

                XmlNode fieldsNode = view.ViewElement.SelectSingleNode("Fields");
                foreach (XmlNode fieldNode in fieldsNode.ChildNodes)
                {
                    //MetaFieldType fieldTypeId = (MetaFieldType)(int.Parse(fieldNode.Attributes["FieldTypeId"].Value.ToString()));
                    MetaFieldType fieldTypeId = (MetaFieldType)Enum.Parse(typeof(MetaFieldType), fieldNode.Attributes["FieldTypeId"].Value.ToString());

                    Field field = null;
                    switch (fieldTypeId)
                    {
                        case MetaFieldType.Text:
                            field = new SingleLineTextField(view, fieldNode);
                            break;
                        case MetaFieldType.LabelTitle:
                            field = new LabelField(view, fieldNode);
                            break;
                        case MetaFieldType.TextUppercase:
                            field = new UpperCaseTextField(view, fieldNode);
                            break;
                        case MetaFieldType.Multiline:
                            field = new MultilineTextField(view, fieldNode);
                            break;
                        case MetaFieldType.Number:
                            field = new NumberField(view, fieldNode);
                            break;
                        case MetaFieldType.PhoneNumber:
                            field = new PhoneNumberField(view, fieldNode);
                            break;
                        case MetaFieldType.Date:
                            field = new DateField(view, fieldNode);
                            break;
                        case MetaFieldType.Time:
                            field = new TimeField(view, fieldNode);
                            break;
                        case MetaFieldType.DateTime:
                            field = new DateTimeField(view, fieldNode);
                            break;
                        case MetaFieldType.Checkbox:
                            field = new CheckBoxField(view, fieldNode);
                            break;
                        case MetaFieldType.YesNo:
                            field = new YesNoField(view, fieldNode);
                            break;
                        case MetaFieldType.Option:
                            field = new OptionField(view, fieldNode);
                            break;
                        case MetaFieldType.CommandButton:
                            field = new CommandButtonField(view, fieldNode);
                            break;
                        case MetaFieldType.Image:
                            field = new ImageField(view, fieldNode);
                            break;
                        case MetaFieldType.Mirror:
                            field = new MirrorField(view, fieldNode);
                            break;
                        case MetaFieldType.Grid:
                            field = new GridField(view, fieldNode);
                            break;
                        case MetaFieldType.LegalValues:
                            field = new DDLFieldOfLegalValues(view, fieldNode);
                            break;
                        case MetaFieldType.Codes:
                            field = new DDLFieldOfCodes(view, fieldNode);
                            break;
                        case MetaFieldType.List:
                            field = new DDListField(view, fieldNode);
                            break;
                        case MetaFieldType.CommentLegal:
                            field = new DDLFieldOfCommentLegal(view, fieldNode);
                            break;
                        case MetaFieldType.Relate:
                            field = new RelatedViewField(view, fieldNode);
                            break;
                        case MetaFieldType.RecStatus:
                            field = new RecStatusField(view);
                            break;
                        case MetaFieldType.UniqueKey:
                            field = new UniqueKeyField(view);
                            break;
                        case MetaFieldType.ForeignKey:
                            field = new ForeignKeyField(view);
                            break;
                        default:
                            throw new GeneralException("Invalid Field Type");
                    }
                    //field.LoadFromRow(row);
                    fields.Add(field);
                }
                return (fields);
            }
            finally
            {
            }
        }
コード例 #13
0
        /// <summary>
        /// Retrieves data for option field from xml metadata
        /// </summary>
        /// <param name="field">An option field</param>
        /// <param name="fieldNode">The field node in the Xml metadata file</param>
        public void GetFieldData(OptionField field, XmlNode fieldNode)
        {
            field.Id = Int32.Parse(fieldNode.Attributes["FieldId"].Value);
            field.Name = fieldNode.Attributes["Name"].Value;
            field.PromptText = fieldNode.Attributes["PromptText"].Value;
            //field.ControlFont = System.Drawing.Font(fieldNode.Attributes["ControlFontFamily"].Value);
            //field.ControlFont.Style = fieldNode.Attributes["ControlFontStyle"].Value;
            //field.ControlFont.Size = float.Parse(fieldNode.Attributes["ControlFontSize"].Value);
            field.ControlTopPositionPercentage = Double.Parse(fieldNode.Attributes["ControlTopPositionPercentage"].Value);
            field.ControlLeftPositionPercentage = Double.Parse(fieldNode.Attributes["ControlLeftPositionPercentage"].Value);
            field.ControlHeightPercentage = Double.Parse(fieldNode.Attributes["ControlHeightPercentage"].Value);
            field.ControlWidthPercentage = Double.Parse(fieldNode.Attributes["ControlWidthPercentage"].Value);
            field.TabIndex = Int32.Parse(fieldNode.Attributes["TabIndex"].Value);
            field.HasTabStop = bool.Parse(fieldNode.Attributes["HasTabStop"].Value);
            //field.PromptFont.FontFamily.Name = fieldNode.Attributes["PromptFontFamily"].Value;
            //field.PromptFont.Style = fieldNode.Attributes["PromptFontStyle"].Value;
            //field.PromptFont.Size = fieldNode.Attributes["PromptFontSize"].Value;
            //field.PromptFont.Name = fieldNode.Attributes["PromptScriptName"].Value;
            //field.ControlFont.Name = fieldNode.Attributes["ControlScriptName"].Value;
            field.ShouldRepeatLast = bool.Parse(fieldNode.Attributes["ShouldRepeatLast"].Value);
            field.IsRequired = bool.Parse(fieldNode.Attributes["IsRequired"].Value);
            field.IsReadOnly = bool.Parse(fieldNode.Attributes["IsReadOnly"].Value);
            field.ShowTextOnRight = bool.Parse(fieldNode.Attributes["ShowTextOnRight"].Value);
            //field.IsControlResizable = bool.Parse(fieldNode.Attributes["ShouldRetainImageSize"].Value);
            field.TableName = fieldNode.Attributes["DataTableName"].Value;

            //field. = fieldNode.Attributes["FieldTypeId"].Value;

            field.Page = new Page(field.GetView());
            //field.Page.Name =
            field.Page.Id = int.Parse(fieldNode.Attributes["PageId"].Value);

            //field.CheckCodeAfter = fieldNode.Attributes["CheckCodeAfter"].Value.ToString();
        }
コード例 #14
0
        /// <summary>
        /// Create Option field.
        /// </summary>
        /// <param name="field">Option field to create.</param>
        /// <returns>Id of the newly created field.</returns>
        public int CreateField(OptionField field)
        {
            try
            {
                #region InputValidation
                if (field == null)
                {
                    throw new ArgumentNullException("OptionField");
                }
                #endregion

                XmlDocument xmlDoc = GetXmlDocument();
                XmlNode fieldsNode = GetFieldsNode(field.ViewElement);
                View view = field.GetView();
                XmlElement fieldElement = xmlDoc.CreateElement("Field");

                XmlAttribute fieldIdAttribute = xmlDoc.CreateAttribute("FieldId");
                fieldIdAttribute.Value = view.GetFieldId(field.ViewElement).ToString();
                fieldElement.Attributes.Append(fieldIdAttribute);
                field.Id = Int32.Parse(fieldIdAttribute.Value);

                XmlAttribute fieldNameAttribute = xmlDoc.CreateAttribute("Name");
                fieldNameAttribute.Value = field.Name;
                fieldElement.Attributes.Append(fieldNameAttribute);

                XmlAttribute fieldPromptText = xmlDoc.CreateAttribute("PromptText");
                fieldPromptText.Value = field.PromptText;
                fieldElement.Attributes.Append(fieldPromptText);

                XmlAttribute fieldControlFontFamily = xmlDoc.CreateAttribute("ControlFontFamily");
                fieldControlFontFamily.Value = field.ControlFont.FontFamily.Name;
                fieldElement.Attributes.Append(fieldControlFontFamily);

                XmlAttribute controlFontStyle = xmlDoc.CreateAttribute("ControlFontStyle");
                controlFontStyle.Value = field.ControlFont.Style.ToString();
                fieldElement.Attributes.Append(controlFontStyle);

                XmlAttribute controlFontSize = xmlDoc.CreateAttribute("ControlFontSize");
                controlFontSize.Value = field.ControlFont.Size.ToString();
                fieldElement.Attributes.Append(controlFontSize);

                XmlAttribute controlTopPositionPercentage = xmlDoc.CreateAttribute("ControlTopPositionPercentage");
                controlTopPositionPercentage.Value = field.ControlTopPositionPercentage.ToString();
                fieldElement.Attributes.Append(controlTopPositionPercentage);

                XmlAttribute controlLeftPositionPercentage = xmlDoc.CreateAttribute("ControlLeftPositionPercentage");
                controlLeftPositionPercentage.Value = field.ControlLeftPositionPercentage.ToString();
                fieldElement.Attributes.Append(controlLeftPositionPercentage);

                XmlAttribute controlHeightPercentage = xmlDoc.CreateAttribute("ControlHeightPercentage");
                controlHeightPercentage.Value = field.ControlHeightPercentage.ToString();
                fieldElement.Attributes.Append(controlHeightPercentage);

                XmlAttribute controlWidthPercentage = xmlDoc.CreateAttribute("ControlWidthPercentage");
                controlWidthPercentage.Value = field.ControlWidthPercentage.ToString();
                fieldElement.Attributes.Append(controlWidthPercentage);

                XmlAttribute tabIndex = xmlDoc.CreateAttribute("TabIndex");
                tabIndex.Value = field.TabIndex.ToString();
                fieldElement.Attributes.Append(tabIndex);

                XmlAttribute hasTabStop = xmlDoc.CreateAttribute("HasTabStop");
                hasTabStop.Value = (bool.Parse(field.HasTabStop.ToString())).ToString();
                fieldElement.Attributes.Append(hasTabStop);

                XmlAttribute promptFontFamily = xmlDoc.CreateAttribute("PromptFontFamily");
                promptFontFamily.Value = field.PromptFont.FontFamily.Name;
                fieldElement.Attributes.Append(promptFontFamily);

                XmlAttribute promptFontStyle = xmlDoc.CreateAttribute("PromptFontStyle");
                promptFontStyle.Value = field.PromptFont.Style.ToString();
                fieldElement.Attributes.Append(promptFontStyle);

                XmlAttribute promptFontSize = xmlDoc.CreateAttribute("PromptFontSize");
                promptFontSize.Value = field.PromptFont.Size.ToString();
                fieldElement.Attributes.Append(promptFontSize);

                XmlAttribute promptScriptName = xmlDoc.CreateAttribute("PromptScriptName");
                promptScriptName.Value = field.PromptFont.Name;
                fieldElement.Attributes.Append(promptScriptName);

                XmlAttribute controlScriptName = xmlDoc.CreateAttribute("ControlScriptName");
                controlScriptName.Value = field.ControlFont.Name;
                fieldElement.Attributes.Append(controlScriptName);

                XmlAttribute shouldRepeatLast = xmlDoc.CreateAttribute("ShouldRepeatLast");
                shouldRepeatLast.Value = bool.Parse(field.ShouldRepeatLast.ToString()).ToString();
                fieldElement.Attributes.Append(shouldRepeatLast);

                XmlAttribute isRequired = xmlDoc.CreateAttribute("IsRequired");
                isRequired.Value = (bool.Parse(field.IsRequired.ToString()).ToString());
                fieldElement.Attributes.Append(isRequired);

                XmlAttribute isReadOnly = xmlDoc.CreateAttribute("IsReadOnly");
                isReadOnly.Value = (bool.Parse(field.IsReadOnly.ToString())).ToString();
                fieldElement.Attributes.Append(isReadOnly);

                XmlAttribute shouldRetainImageSize = xmlDoc.CreateAttribute("ShouldRetainImageSize");
                //shouldRetainImageSize.Value = (bool.Parse(field.IsControlResizable.ToString())).ToString();
                fieldElement.Attributes.Append(shouldRetainImageSize);

                XmlAttribute showTextOnRight = xmlDoc.CreateAttribute("ShowTextOnRight");
                showTextOnRight.Value = (bool.Parse(field.ShowTextOnRight.ToString())).ToString();
                fieldElement.Attributes.Append(showTextOnRight);

                XmlAttribute dataTableName = xmlDoc.CreateAttribute("DataTableName");
                dataTableName.Value = field.TableName;
                fieldElement.Attributes.Append(dataTableName);

                XmlAttribute fieldTypeId = xmlDoc.CreateAttribute("FieldTypeId");
                fieldTypeId.Value = field.FieldType.ToString();
                fieldElement.Attributes.Append(fieldTypeId);

                XmlAttribute pageId = xmlDoc.CreateAttribute("PageId");
                pageId.Value = field.Page.Id.ToString();
                fieldElement.Attributes.Append(pageId);

                XmlElement checkCodeAfterElement = xmlDoc.CreateElement("CheckCodeAfter");
                XmlAttribute checkCodeAfter = xmlDoc.CreateAttribute("CheckCodeAfter");
                checkCodeAfter.Value = field.CheckCodeAfter.ToString();
                checkCodeAfterElement.Attributes.Append(checkCodeAfter);
                fieldElement.AppendChild(checkCodeAfterElement);

                fieldsNode.AppendChild(fieldElement);
                view.Project.Save();
                return field.Id;

                //TODO:  Save option items in xml project file - EJ
            }
            finally
            {
            }
        }
コード例 #15
0
        /// <summary>
        /// Update Option field.
        /// </summary>
        /// <param name="field">Option field to update.</param>
        /// <returns>Id of the updated field.</returns>
        public void UpdateField(OptionField field)
        {
            try
            {
                #region InputValidation
                if (field == null)
                {
                    throw new ArgumentNullException("OptionField");
                }
                #endregion

                XmlDocument xmlDoc = GetXmlDocument();
                XmlNode fieldsNode = GetFieldsNode(GetFieldViewElement(field));
                View view = field.GetView();
                string fieldId = field.Id.ToString();
                XmlNode fieldNode = fieldsNode.SelectSingleNode("//Field[@FieldId= '" + fieldId + "']");

                fieldNode.Attributes["Name"].Value = field.Name;
                fieldNode.Attributes["PromptText"].Value = field.PromptText;
                fieldNode.Attributes["ControlFontFamily"].Value = field.ControlFont.FontFamily.Name;
                fieldNode.Attributes["ControlFontStyle"].Value = field.ControlFont.Style.ToString();
                fieldNode.Attributes["ControlFontSize"].Value = field.ControlFont.Size.ToString();
                fieldNode.Attributes["ControlTopPositionPercentage"].Value = field.ControlTopPositionPercentage.ToString();
                fieldNode.Attributes["ControlLeftPositionPercentage"].Value = field.ControlLeftPositionPercentage.ToString();
                fieldNode.Attributes["ControlHeightPercentage"].Value = field.ControlHeightPercentage.ToString();
                fieldNode.Attributes["ControlWidthPercentage"].Value = field.ControlWidthPercentage.ToString();
                fieldNode.Attributes["TabIndex"].Value = field.TabIndex.ToString();
                fieldNode.Attributes["HasTabStop"].Value = (bool.Parse(field.HasTabStop.ToString())).ToString();
                fieldNode.Attributes["PromptFontFamily"].Value = field.PromptFont.FontFamily.Name;
                fieldNode.Attributes["PromptFontStyle"].Value = field.PromptFont.Style.ToString();
                fieldNode.Attributes["PromptFontSize"].Value = field.PromptFont.Size.ToString();
                fieldNode.Attributes["PromptScriptName"].Value = field.PromptFont.Name;
                fieldNode.Attributes["ControlScriptName"].Value = field.ControlFont.Name;
                fieldNode.Attributes["ShouldRepeatLast"].Value = bool.Parse(field.ShouldRepeatLast.ToString()).ToString();
                fieldNode.Attributes["IsRequired"].Value = (bool.Parse(field.IsRequired.ToString()).ToString());
                fieldNode.Attributes["IsReadOnly"].Value = (bool.Parse(field.IsReadOnly.ToString())).ToString();
                fieldNode.Attributes["ShowTextOnRight"].Value = (bool.Parse(field.ShowTextOnRight.ToString())).ToString();
                //field.IsControlResizable = bool.Parse(fieldNode.Attributes["ShouldRetainImageSize"].Value);
                fieldNode.Attributes["DataTableName"].Value = field.TableName;
                fieldNode.LastChild.Attributes["CheckCodeAfter"].Value = field.CheckCodeAfter;

                view.Project.Save();
            }
            catch (Exception ex)
            {
                throw new GeneralException("Could not update OptionField in the database", ex);
            }
            finally
            {

            }
        }
コード例 #16
0
 /// <summary>
 /// Constructor for the class
 /// </summary>
 public OptionFieldItem(OptionField parent)
 {
     this.parent = parent;
 }