示例#1
0
        /// <summary>
        /// Creates a RecStatus column in the database.
        /// </summary>
        /// <param name="column">A RecStatusColumn object</param>
        /// <returns>Id of the newly created column.</returns>
        public int CreateGridColumn(RecStatusColumn column)
        {
            try
            {
                #region InputValidation
                if (column == null)
                {
                    throw new ArgumentNullException("RecStatusColumn");
                }
                #endregion

                Query insertQuery = db.CreateQuery("insert into metaGridColumns([Name], [FieldTypeId], [Width], [Size], [Position], [Text], [ShouldRepeatLast], [IsRequired], [IsReadOnly], [FieldId]) " +
                    "values (@Name, @FieldTypeId, @Width, @Size, @Position, @Text, @ShouldRepeatLast, @IsRequired, @IsReadOnly, @FieldId)");

                insertQuery.Parameters.Add(new QueryParameter("@Name", DbType.String, column.Name));
                insertQuery.Parameters.Add(new QueryParameter("@FieldTypeId", DbType.Int32, (int)column.GridColumnType));
                insertQuery.Parameters.Add(new QueryParameter("@Width", DbType.Int32, 0));
                insertQuery.Parameters.Add(new QueryParameter("@Size", DbType.Int32, 0));
                insertQuery.Parameters.Add(new QueryParameter("@Position", DbType.Int32, 1));
                insertQuery.Parameters.Add(new QueryParameter("@Text", DbType.String, string.Empty));
                insertQuery.Parameters.Add(new QueryParameter("@ShouldRepeatLast", DbType.Boolean, false));
                insertQuery.Parameters.Add(new QueryParameter("@IsRequired", DbType.Boolean, false));
                insertQuery.Parameters.Add(new QueryParameter("@IsReadOnly", DbType.Boolean, true));
                insertQuery.Parameters.Add(new QueryParameter("@FieldId", DbType.Int32, column.Grid.Id));

                db.ExecuteNonQuery(insertQuery);
                return GetMaxGridColumnId(column.Grid.Id);
            }
            catch (Exception ex)
            {
                throw new GeneralException("Could not create grid RecStatus column in the database", ex);
            }
            finally
            {

            }
        }
        /// <summary>
        /// Sets the field's properties based on GUI values
        /// </summary>
        protected override void SetFieldProperties()
        {
            field.PromptText = txtPrompt.Text;
            field.Name = txtFieldName.Text;
            if (field.Columns == null)
            {
                field.Columns = new List<GridColumnBase>();
                //UniqueKeyColumn uniqueKeyColumn = new UniqueKeyColumn(field);
                UniqueRowIdColumn uniqueRowIdColumn = new UniqueRowIdColumn(field);
                RecStatusColumn recStatusColumn = new RecStatusColumn(field);
                ForeignKeyColumn foreignKeyColumn = new ForeignKeyColumn(field);
                GlobalRecordIdColumn globalRecordIdColumn = new GlobalRecordIdColumn(field);

                field.Columns.AddRange (new List<GridColumnBase> {
                    //uniqueKeyColumn,
                    uniqueRowIdColumn,
                    recStatusColumn,
                    foreignKeyColumn,
                    globalRecordIdColumn
                });
            }
        }
        /// <summary>
        /// Creates a new <see cref="Epi.Fields.RecStatusColumn"/> in <see cref="Epi.Fields.GridField"/>.
        /// </summary>
        /// <param name="column"><see cref="Epi.Fields.RecStatusColumn"/> to create.</param>
        /// <returns>Id of the newly created column.</returns>
        public int CreateGridColumn(RecStatusColumn column)
        {
            try
            {
                #region InputValidation
                if (column == null)
                {
                    throw new ArgumentNullException("RecStatusColumn");
                }
                #endregion

                Query insertQuery = db.CreateQuery("insert into metaGridColumns([DataTableName], [ViewId], [FieldTypeId], [Name]) " +
                    "values (@Name, @FieldTypeId,)");

                insertQuery.Parameters.Add(new QueryParameter("@Name", DbType.String, column.Name));
                insertQuery.Parameters.Add(new QueryParameter("@FieldTypeId", DbType.Int32, (int)column.GridColumnType));

                db.ExecuteNonQuery(insertQuery);
                return GetMaxGridColumnId(column.Grid.Id);
            }
            catch (Exception ex)
            {
                throw new GeneralException("Could not create RecStatus grid column in the database.", ex);
            }
            finally
            {

            }
        }