Exemplo n.º 1
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
            {

            }
        }
Exemplo n.º 2
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);
            }
        }