Esempio n. 1
0
        /// <summary>
        /// Updates Single Field step.
        /// </summary>
        /// <param name="dto">The DTO object.</param>
        /// <exception cref="System.ArgumentException"></exception>
        /// <exception cref="System.Data.DBConcurrencyException"></exception>
        public void UpdateSingleFieldProcessViewSectionStep(SingleFieldProcessViewSectionStepDto dto)
        {
            if (dto == null) throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

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

                const string CommandText =
                    @"
DECLARE @ProcessViewSectionStepId int

SELECT @ProcessViewSectionStepId= ProcessViewSectionStepId FROM SingleFieldProcessViewSectionStep WHERE Id=@p_Id

UPDATE [dbo].[ProcessViewSectionSteps]
SET [Order]=@p_Order
WHERE Id=@ProcessViewSectionStepId


UPDATE [dbo].[SingleFieldProcessViewSectionStep]
SET [FieldSystemName]=@p_FieldSystemName
WHERE Id=@p_Id
";
                using (var command = new SqlCommand(CommandText, connection))
                {
                    command.Parameters.AddWithValue("@p_Id", dto.Id);
                    command.Parameters.AddWithValue("@p_FieldSystemName", dto.FieldSystemName);
                    command.Parameters.AddWithValue("@p_Order", dto.Order);

                    if (command.ExecuteNonQuery() == 0)
                    {
                        throw new DBConcurrencyException(Resources.StaleDataException);
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Inserts Single Field step.
        /// </summary>
        /// <param name="dto">The DTO object.</param>
        /// <exception cref="System.ArgumentException"></exception>
        public void InsertSingleFieldProcessViewSectionStep(SingleFieldProcessViewSectionStepDto dto)
        {
            if (dto == null) throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

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

                const string CommandText =
                    @"
INSERT INTO [dbo].[ProcessViewSectionSteps]
    ([SectionId]
    ,[StepName]
    ,[Order]
)
VALUES
    (@p_SectionId
    ,@p_StepName
    ,@p_Order)

INSERT INTO [dbo].[SingleFieldProcessViewSectionStep]
    ([SectionId]
    ,[FieldSystemName]
    ,ProcessViewSectionStepId
)
VALUES
    (@p_SectionId
    ,@p_FieldSystemName
    ,CAST(SCOPE_IDENTITY() AS INT))


SELECT CAST(SCOPE_IDENTITY() AS INT)
";
                using (var command = new SqlCommand(CommandText, connection))
                {
                    command.Parameters.AddWithValue("@p_SectionId", dto.SectionId);
                    command.Parameters.AddWithValue("@p_FieldSystemName", dto.FieldSystemName);
                    command.Parameters.AddWithValue("@p_StepName", "SingleFieldStepEdit");
                    command.Parameters.AddWithValue("@p_Order", dto.Order);

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