Beispiel #1
0
        /// <summary>
        /// Creates a new <see cref="Epi.Fields.UniqueKeyColumn"/> in <see cref="Epi.Fields.GridField"/>.
        /// </summary>
        /// <param name="column"><see cref="Epi.Fields.UniqueKeyColumn"/></param>
        /// <returns>Id of the newly created column.</returns>
        public int CreateGridColumn(UniqueKeyColumn column)
        {
            try
            {
                #region InputValidation
                if (column == null)
                {
                    throw new ArgumentNullException("UniqueKeyColumn");
                }
                #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, 0));
                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, false));
                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 column in the database", ex);
            }
            finally
            {
            }
        }
        /// <summary>
        /// Creates a new <see cref="Epi.Fields.UniqueKeyColumn"/> in <see cref="Epi.Fields.GridField"/>.
        /// </summary>
        /// <param name="column"><see cref="Epi.Fields.UniqueKeyColumn"/> to create.</param>
        /// <returns>Id of the newly created column.</returns>
        public int CreateGridColumn(UniqueKeyColumn column)
        {
            try
            {
                #region InputValidation
                if (column == null)
                {
                    throw new ArgumentNullException("UniqueKeyColumn");
                }
                #endregion

                Query insertQuery = db.CreateQuery("insert into metaGridColumns([Name], [FieldTypeId]) " +
                    "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 UniqueKey grid column in the database.", ex);
            }
            finally
            {
            }
        }