Ejemplo n.º 1
0
        /// <summary>
        /// Updates process view field.
        /// </summary>
        /// <param name="dto">The DTO object.</param>
        /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception>
        /// <exception cref="System.Data.DBConcurrencyException">Indicates stale data.</exception>
        public void UpdateProcessViewField(ProcessViewFieldEditDto dto)
        {
            if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            const string CommandText =
    @"
UPDATE [dbo].[ProcessViewFields]
SET
    [Guid]                     = @p_Guid
    ,[TemplateFieldGuid]        = @p_TemplateFieldGuid
    ,[FieldSystemName]          = @p_FieldSystemName
    ,[DisplayOrder]             = @p_DisplayOrder
    ,[DisplayType]              = @p_DisplayType
    ,[IconId]                   = @p_IconId
    ,[CustomConfig]             = @p_CustomConfig
WHERE [Id] = @p_Id;
";
            using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false))
            {
                var connection = ctx.Connection;

                using (var command = new SqlCommand(CommandText, connection))
                {
                    command.Parameters.AddWithValue("@p_Id", dto.Id);
                    command.Parameters.AddWithValue("@p_Guid", dto.Guid);
                    command.Parameters.AddWithValue("@p_TemplateFieldGuid", dto.TemplateFieldGuid);
                    command.Parameters.AddWithValue("@p_FieldSystemName", dto.FieldSystemName);
                    command.Parameters.AddWithValue("@p_DisplayOrder", dto.DisplayOrder);
                    command.Parameters.AddWithValue("@p_DisplayType", dto.DisplayType);
                    command.Parameters.AddWithValue("@p_IconId", AdoHelper.NullCheck(dto.IconId));
                    command.Parameters.AddWithValue("@p_CustomConfig", dto.CustomConfig);

                    if (command.ExecuteNonQuery() == 0)
                    {
                        throw new DBConcurrencyException(Resources.StaleDataException);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Inserts process view field.
        /// </summary>
        /// <param name="dto">The DTO object.</param>
        /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception>
        public void InsertProcessViewField(ProcessViewFieldEditDto dto)
        {
            if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            const string CommandText =
    @"
INSERT INTO [dbo].[ProcessViewFields]
(
     [SectionId]
    ,[Guid]
    ,[TemplateFieldGuid]
    ,[FieldSystemName]
    ,[DisplayOrder]
    ,[DisplayType]
    ,[IconId]
    ,[CustomConfig]
)
VALUES
(
     @p_SectionId
    ,@p_Guid
    ,@p_TemplateFieldGuid
    ,@p_FieldSystemName
    ,@p_DisplayOrder
    ,@p_DisplayType
    ,@p_IconId
    ,@p_CustomConfig
);
SELECT [Id]
FROM [dbo].[ProcessViewFields]
WHERE [Id] = SCOPE_IDENTITY()";

            using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false))
            {
                var connection = ctx.Connection;

                using (var command = new SqlCommand(CommandText, connection))
                {
                    command.Parameters.AddWithValue("@p_SectionId", dto.SectionId);
                    command.Parameters.AddWithValue("@p_Guid", dto.Guid);
                    command.Parameters.AddWithValue("@p_TemplateFieldGuid", dto.TemplateFieldGuid);
                    command.Parameters.AddWithValue("@p_FieldSystemName", dto.FieldSystemName);
                    command.Parameters.AddWithValue("@p_DisplayOrder", dto.DisplayOrder);
                    command.Parameters.AddWithValue("@p_DisplayType", dto.DisplayType);
                    command.Parameters.AddWithValue("@p_IconId", AdoHelper.NullCheck(dto.IconId));
                    command.Parameters.AddWithValue("@p_CustomConfig", dto.CustomConfig);

                    dto.Id = (int)command.ExecuteScalar();
                }
            }
        }