/// <summary>
 /// Constructor for the class
 /// </summary>
 /// <param name="frm">The parent form</param>
 /// <param name="field">The fied to be edited</param>
 public UpperCaseTextFieldDefinition(MainForm frm, UpperCaseTextField field)
     : base(frm)
 {
     InitializeComponent();
     this.mode = FormMode.Edit;
     this.field = field;
     this.page = field.Page;
     LoadFormData();
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Update Uppercase text field.
        /// </summary>
        /// <param name="field">Uppercase text field to update.</param>
        public void UpdateField(UpperCaseTextField field)
        {
            try
            {
                #region InputValidation
                if (field == null)
                {
                    throw new ArgumentNullException("UpperCaseTextField");
                }
                #endregion

                Query updateQuery = db.CreateQuery("update metaFields set [CheckCodeAfter] = @CheckCodeAfter, [CheckCodeBefore] = @CheckCodeBefore, " +
                    "[ControlFontFamily] = @ControlFontFamily, [ControlFontStyle] = @ControlFontStyle, [ControlFontSize] = @ControlFontSize, " +
                    "[ControlHeightPercentage] = @ControlHeightPercentage, [ControlLeftPositionPercentage] = @ControlLeftPositionPercentage, [ControlTopPositionPercentage] = @ControlTopPositionPercentage, " +
                    "[ControlWidthPercentage] = @ControlWidthPercentage, [HasTabStop] = @HasTabStop, [IsReadOnly] = @IsReadOnly, [IsRequired] = @IsRequired, " +
                    "[MaxLength] = @MaxLength, [Name] = @Name, [PageId] = @PageId, [PromptFontFamily] = @PromptFontFamily, [PromptFontStyle] = @PromptFontStyle, " +
                    "[PromptFontSize] = @PromptFontSize, [PromptLeftPositionPercentage] = @PromptLeftPositionPercentage, [PromptText] = @PromptText, " +
                    "[PromptTopPositionPercentage] = @PromptTopPositionPercentage, [ShouldRepeatLast] = @ShouldRepeatLast, [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));

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

                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("@MaxLength", DbType.Int16, field.MaxLength));
                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("@PromptLeftPositionPercentage", DbType.Double, field.PromptLeftPositionPercentage));
                updateQuery.Parameters.Add(new QueryParameter("@PromptText", DbType.String, field.PromptText));
                updateQuery.Parameters.Add(new QueryParameter("@PromptTopPositionPercentage", DbType.Double, field.PromptTopPositionPercentage));
                updateQuery.Parameters.Add(new QueryParameter("@ShouldRepeatLast", DbType.Boolean, field.ShouldRepeatLast));
                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 UpperCaseTextField in the database", ex);
            }
            finally
            {

            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Retrieves data for upper case text field from xml metadata.
 /// </summary>
 /// <param name="field">An upper case text field.</param>
 /// <param name="fieldNode">XML node for upper case text field.</param>
 public void GetFieldData(UpperCaseTextField field, XmlNode fieldNode)
 {
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Insert a UpperCaseTextField record into the metaFields table.
        /// </summary>
        /// <param name="field">Upper-case text field.</param>
        /// <returns>Returns the Id of the last UpperCaseTextField added.</returns>
        public int CreateField(UpperCaseTextField field)
        {
            try
            {
                #region InputValidation
                if (field == null)
                {
                    throw new ArgumentNullException("UpperCaseTextField");
                }
                #endregion

                Query insertQuery = db.CreateQuery("insert into metaFields([DataTableName], [ViewId], [UniqueId], [CheckCodeAfter], [CheckCodeBefore], [ControlFontFamily], [ControlFontStyle], [ControlFontSize], [ControlHeightPercentage], [ControlLeftPositionPercentage], [ControlTopPositionPercentage], [ControlWidthPercentage], [HasTabStop], [IsReadOnly], [IsRequired], [MaxLength], [Name], [PageId], [PromptFontFamily], [PromptFontStyle], [PromptFontSize], [PromptLeftPositionPercentage], [PromptText], [PromptTopPositionPercentage], [ShouldRepeatLast], [TabIndex]) " +
                    "values (@DataTableName, @ViewId, @UniqueId, @CheckCodeAfter, @CheckCodeBefore, @ControlFontFamily, @ControlFontStyle, @ControlFontSize, @ControlHeightPercentage, @ControlLeftPositionPercentage, @ControlTopPositionPercentage, @ControlWidthPercentage, @HasTabStop, @IsReadOnly, @IsRequired, @MaxLength, @Name, @PageId, @PromptFontFamily, @PromptFontStyle, @PromptFontSize, @PromptLeftPositionPercentage, @PromptText, @PromptTopPositionPercentage, @ShouldRepeatLast, @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));

                if (field.CheckCodeBefore == null)
                    insertQuery.Parameters.Add(new QueryParameter(ColumnNames.CHECK_CODE_BEFORE, DbType.String, DBNull.Value));
                else
                    insertQuery.Parameters.Add(new QueryParameter("@CheckCodeBefore", DbType.String, field.CheckCodeBefore));

                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("@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("@MaxLength", DbType.Int16, field.MaxLength));
                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("@PromptLeftPositionPercentage", DbType.Double, field.PromptLeftPositionPercentage));
                insertQuery.Parameters.Add(new QueryParameter("@PromptText", DbType.String, field.PromptText));
                insertQuery.Parameters.Add(new QueryParameter("@PromptTopPositionPercentage", DbType.Double, field.PromptTopPositionPercentage));
                insertQuery.Parameters.Add(new QueryParameter("@ShouldRepeatLast", DbType.Boolean, field.ShouldRepeatLast));
                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);
            }
            finally
            {

            }
        }
Ejemplo n.º 6
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
            {
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Create Uppercase text field.
        /// </summary>
        /// <param name="field">Uppercase text field to create.</param>
        /// <returns>Id of the newly created field.</returns>
        public int CreateField(UpperCaseTextField field)
        {
            try
            {
                #region InputValidation
                if (field == null)
                {
                    throw new ArgumentNullException("UpperCaseTextField");
                }
                #endregion

                return field.Id;
            }
            finally
            {

            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Update Uppercase text field.
 /// </summary>
 /// <param name="field">Uppercase text field to update.</param>
 /// <returns>Id of the updated field.</returns>
 public void UpdateField(UpperCaseTextField field)
 {
     try
     {
         #region InputValidation
         if (field == null)
         {
             throw new ArgumentNullException("UpperCaseTextField");
         }
         #endregion
     }
     catch (Exception ex)
     {
         throw new GeneralException("Could not update UpperCaseTextField in the database", ex);
     }
 }