Exemplo n.º 1
0
        /// <summary>
        /// 添加会员促销活动.
        /// </summary>
        /// <param name="promoteVip">
        /// Promote_Vip的对象实例.
        /// </param>
        /// <returns>
        /// 会员促销活动的编号.
        /// </returns>
        public int Add(Promote_Vip promoteVip)
        {
            SqlTransaction transaction = null;
            try
            {
                var promoteVipID = this.promoteVipDA.Insert(promoteVip, out transaction);
                if (promoteVip.Scopes != null && promoteVip.Scopes.Count > 0)
                {
                    foreach (var scope in promoteVip.Scopes)
                    {
                        scope.PromoteVipID = promoteVipID;
                        this.promoteVipScopeDA.Insert(scope, transaction);
                    }
                }

                transaction.Commit();
                return promoteVipID;
            }
            catch (Exception exception)
            {
                if (transaction != null)
                {
                    transaction.Rollback();
                }

                throw new Exception(exception.Message, exception);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加会员促销活动.
        /// </summary>
        /// <param name="promoteVip">
        /// Promote_Vip的对象实例.
        /// </param>
        public void Modify(Promote_Vip promoteVip)
        {
            SqlTransaction transaction = null;
            try
            {
                this.promoteVipDA.Update(promoteVip, out transaction);
                if (promoteVip.Scopes != null && promoteVip.Scopes.Count > 0)
                {
                    this.promoteVipScopeDA.Delete(promoteVip.ID, transaction);
                    foreach (var scope in promoteVip.Scopes)
                    {
                        scope.PromoteVipID = promoteVip.ID;
                        this.promoteVipScopeDA.Insert(scope, transaction);
                    }
                }

                transaction.Commit();
            }
            catch (Exception exception)
            {
                if (transaction != null)
                {
                    transaction.Rollback();
                }

                throw new Exception(exception.Message, exception);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 添加会员促销活动.
        /// </summary>
        /// <param name="promoteVip">
        /// Promote_Vip的对象实例.
        /// </param>
        /// <param name="transaction">
        /// 数据库事务.
        /// </param>
        /// <returns>
        /// 会员促销活动的编号.
        /// </returns>
        public int Insert(Promote_Vip promoteVip, out SqlTransaction transaction)
        {
            if (promoteVip == null)
            {
                throw new ArgumentNullException("promoteVip");
            }

            this.SqlServer.BeginTransaction();
            transaction = this.SqlServer.Transaction;

            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "EmployeeID",
                                         SqlDbType.Int,
                                         promoteVip.EmployeeID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Name",
                                         SqlDbType.NVarChar,
                                         promoteVip.Name,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "StartTime",
                                         SqlDbType.DateTime,
                                         promoteVip.StartTime,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "EndTime",
                                         SqlDbType.DateTime,
                                         promoteVip.EndTime,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "IsNewUser",
                                         SqlDbType.Bit,
                                         promoteVip.IsNewUser,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "IsMobileValidate",
                                         SqlDbType.Bit,
                                         promoteVip.IsMobileValidate,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "IsUseCoupon",
                                         SqlDbType.Bit,
                                         promoteVip.IsUseCoupon,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Status",
                                         SqlDbType.Int,
                                         promoteVip.Status,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Description",
                                         SqlDbType.NVarChar,
                                         promoteVip.Description,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "ReferenceID",
                                         SqlDbType.Int,
                                         promoteVip.ID,
                                         ParameterDirection.Output)
                                 };

            this.SqlServer.ExecuteNonQuery(
                CommandType.StoredProcedure,
                "sp_Promote_Vip_Insert",
                parameters,
                transaction);
            return (int)parameters.Find(parameter => parameter.ParameterName == "ReferenceID").Value;
        }
Exemplo n.º 4
0
        /// <summary>
        /// 修改会员促销活动.
        /// </summary>
        /// <param name="promoteVip">
        /// Promote_Vip的对象实例.
        /// </param>
        /// <param name="transaction">
        /// 数据库事务.
        /// </param>
        public void Update(Promote_Vip promoteVip, out SqlTransaction transaction)
        {
            if (promoteVip == null)
            {
                throw new ArgumentNullException("promoteVip");
            }

            this.SqlServer.BeginTransaction(IsolationLevel.ReadCommitted);
            transaction = this.SqlServer.Transaction;
            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "ID",
                                         SqlDbType.Int,
                                         promoteVip.ID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "EmployeeID",
                                         SqlDbType.Int,
                                         promoteVip.EmployeeID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Name",
                                         SqlDbType.NVarChar,
                                         promoteVip.Name,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "IsNewUser",
                                         SqlDbType.Bit,
                                         promoteVip.IsNewUser,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "IsMobileValidate",
                                         SqlDbType.Bit,
                                         promoteVip.IsMobileValidate,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "IsUseCoupon",
                                         SqlDbType.Bit,
                                         promoteVip.IsUseCoupon,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "StartTime",
                                         SqlDbType.DateTime,
                                         promoteVip.StartTime,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "EndTime",
                                         SqlDbType.DateTime,
                                         promoteVip.EndTime,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Description",
                                         SqlDbType.NVarChar,
                                         promoteVip.Description,
                                         ParameterDirection.Input)
                                 };

            this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_Promote_Vip_Update", parameters, transaction);
        }