Example #1
0
        /// <summary>
        /// Updates Document List step.
        /// </summary>
        /// <param name="dto">The DTO object.</param>
        /// <exception cref="System.ArgumentException"></exception>
        /// <exception cref="System.Data.DBConcurrencyException"></exception>
        public void UpdateDocumentListProcessViewSectionStep(DocumentListProcessViewSectionStepDto 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;

                var CommandText =
                    @"
DECLARE @ProcessViewSectionStepId int

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

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

--DELETE FROM [dbo].[APQPProcessViewDocument] WHERE DocumentListProcessViewSectionStepId=@p_Id
";
                using (var command = new SqlCommand(CommandText, connection))
                {
                    command.Parameters.AddWithValue("@p_Id", dto.Id);
                    command.Parameters.AddWithValue("@p_Order", dto.Order);

                    if (command.ExecuteNonQuery() == 0)
                    {
                        throw new DBConcurrencyException(Resources.StaleDataException);
                    }

                }
            }
        }
Example #2
0
        /// <summary>
        /// Inserts Document List step.
        /// </summary>
        /// <param name="dto">The DTO object.</param>
        /// <exception cref="System.ArgumentException"></exception>
        public void InsertDocumentListProcessViewSectionStep(DocumentListProcessViewSectionStepDto 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;

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

INSERT INTO [dbo].[DocumentListProcessViewSectionStep]
    ([SectionId]
    ,ProcessViewSectionStepId
)
VALUES
    (@p_SectionId
    ,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_StepName", "DocumentListStepEdit");
                    command.Parameters.AddWithValue("@p_Order", dto.Order);

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