Example #1
0
        public void SetScore(int customerSysNo, int pointDelt, int pointLogType, string poingLogMemo)
        {
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                int rowsAffected = new PointDac().SetScore(customerSysNo, pointDelt);
                if (rowsAffected != 1)
                {
                    throw new BizException("客户积分更新失败,可能因为积分不足。");
                }

                if (pointDelt != 0)
                {
                    CustomerPointLogInfo oPointLog = new CustomerPointLogInfo(customerSysNo, pointLogType, pointDelt, poingLogMemo);
                    oPointLog.LogCheck = oPointLog.CalcLogCheck();

                    if (1 != new PointDac().InsertLog(oPointLog))
                    {
                        throw new BizException("增加积分流水失败");
                    }
                }

                scope.Complete();
            }
        }
Example #2
0
        //2006-08-11
        public void AddScore(int CustomerSysNo, int increment)
        {
            if (HasAddScoreForHF(CustomerSysNo, 17))
            {
                return;
            }
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                int rowsAffected = new PointDac().SetScore(CustomerSysNo, increment);
                if (rowsAffected != 1)
                {
                    throw new BizException("客户积分更新失败,可能因为积分不足。");
                }

                if (increment != 0)
                {
                    int    pointLogType            = 17;
                    string poingLogMemo            = "浩号送积分";
                    CustomerPointLogInfo oPointLog = new CustomerPointLogInfo(CustomerSysNo, pointLogType, increment, poingLogMemo);
                    oPointLog.LogCheck = oPointLog.CalcLogCheck();

                    if (1 != new PointDac().InsertLog(oPointLog))
                    {
                        throw new BizException("增加积分流水失败");
                    }
                }

                scope.Complete();
            }
        }
Example #3
0
 private void map(CustomerPointLogInfo oParam, DataRow tempdr)
 {
     oParam.SysNo         = Util.TrimIntNull(tempdr["SysNo"]);
     oParam.CustomerSysNo = Util.TrimIntNull(tempdr["CustomerSysNo"]);
     oParam.PointLogType  = Util.TrimIntNull(tempdr["PointLogType"]);
     oParam.PointAmount   = Util.TrimIntNull(tempdr["PointAmount"]);
     oParam.CreateTime    = Util.TrimDateNull(tempdr["CreateTime"]);
     oParam.Memo          = Util.TrimNull(tempdr["Memo"]);
     oParam.LogCheck      = Util.TrimNull(tempdr["LogCheck"]);
 }
Example #4
0
        public void ImportPointLog()
        {
            if (!AppConfig.IsImportable)
            {
                throw new BizException("Is Importable is false");
            }

            /*  do not  use the following code after Data Pour in */
            string  sql = " select top 1 * from Customer_PointLog ";
            DataSet ds  = SqlHelper.ExecuteDataSet(sql);

            if (Util.HasMoreRow(ds))
            {
                throw new BizException("the table Point log is not empty");
            }

            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                //先清理ipp2003里面积分log amt为零的记录
                new PointDac().DeleteLog();

                string  sql1 = @"select pkid as sysno, customersysno, logtype as pointlogtype,amount as pointamount, logtime as createtime, memo, '' as LogCheck
								from ipp2003..pointlog order by sysno"                                ;
                DataSet ds1  = SqlHelper.ExecuteDataSet(sql1);
                foreach (DataRow dr1 in ds1.Tables[0].Rows)
                {
                    CustomerPointLogInfo oPoint = new CustomerPointLogInfo();
                    map(oPoint, dr1);
                    oPoint.LogCheck = oPoint.CalcLogCheck();
                    new PointDac().InsertLog(oPoint);
                }
                scope.Complete();
            }
        }
Example #5
0
        public int InsertLog(CustomerPointLogInfo oParam)
        {
            string sql = @"INSERT INTO Customer_PointLog
                            (
                            CustomerSysNo, PointLogType, PointAmount, 
                            CreateTime, Memo, LogCheck
                            )
                            VALUES (
                            @CustomerSysNo, @PointLogType, @PointAmount, 
                            @CreateTime, @Memo, @LogCheck
                            );set @SysNo = SCOPE_IDENTITY();";

            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo         = new SqlParameter("@SysNo", SqlDbType.Int, 4);
            SqlParameter paramCustomerSysNo = new SqlParameter("@CustomerSysNo", SqlDbType.Int, 4);
            SqlParameter paramPointLogType  = new SqlParameter("@PointLogType", SqlDbType.Int, 4);
            SqlParameter paramPointAmount   = new SqlParameter("@PointAmount", SqlDbType.Int, 4);
            SqlParameter paramCreateTime    = new SqlParameter("@CreateTime", SqlDbType.DateTime);
            SqlParameter paramMemo          = new SqlParameter("@Memo", SqlDbType.NVarChar, 200);
            SqlParameter paramLogCheck      = new SqlParameter("@LogCheck", SqlDbType.NVarChar, 200);

            paramSysNo.Direction = ParameterDirection.Output;

            if (oParam.CustomerSysNo != AppConst.IntNull)
            {
                paramCustomerSysNo.Value = oParam.CustomerSysNo;
            }
            else
            {
                paramCustomerSysNo.Value = System.DBNull.Value;
            }
            if (oParam.PointLogType != AppConst.IntNull)
            {
                paramPointLogType.Value = oParam.PointLogType;
            }
            else
            {
                paramPointLogType.Value = System.DBNull.Value;
            }
            if (oParam.PointAmount != AppConst.IntNull)
            {
                paramPointAmount.Value = oParam.PointAmount;
            }
            else
            {
                paramPointAmount.Value = System.DBNull.Value;
            }
            if (oParam.CreateTime != AppConst.DateTimeNull)
            {
                paramCreateTime.Value = oParam.CreateTime;
            }
            else
            {
                paramCreateTime.Value = System.DBNull.Value;
            }
            if (oParam.Memo != AppConst.StringNull)
            {
                paramMemo.Value = oParam.Memo;
            }
            else
            {
                paramMemo.Value = System.DBNull.Value;
            }
            if (oParam.LogCheck != AppConst.StringNull)
            {
                paramLogCheck.Value = oParam.LogCheck;
            }
            else
            {
                paramLogCheck.Value = System.DBNull.Value;
            }

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramCustomerSysNo);
            cmd.Parameters.Add(paramPointLogType);
            cmd.Parameters.Add(paramPointAmount);
            cmd.Parameters.Add(paramCreateTime);
            cmd.Parameters.Add(paramMemo);
            cmd.Parameters.Add(paramLogCheck);

            return(SqlHelper.ExecuteNonQuery(cmd, out oParam.SysNo));
        }