/// <summary>
        /// 更新一条数据
        /// </summary>
        public void AddUpdate(QH_HoldAccountTableInfo_Delta model, ReckoningTransaction tm)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update QH_HoldAccountTable set ");
            strSql.Append("HistoryHoldAmount=HistoryHoldAmount+@HistoryHoldAmount,");
            strSql.Append("HistoryFreezeAmount=HistoryFreezeAmount+@HistoryFreezeAmount,");
            strSql.Append("TodayHoldAmount=TodayHoldAmount+@TodayHoldAmount,");
            strSql.Append("TodayFreezeAmount=TodayFreezeAmount+@TodayFreezeAmount,");
            strSql.Append("Margin=Margin+@Margin");
            strSql.Append(" where AccountHoldLogoId=@AccountHoldLogoId ");
            Database  db        = tm.Database;
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "AccountHoldLogoId", DbType.Int32, model.AccountHoldLogoId);
            db.AddInParameter(dbCommand, "HistoryHoldAmount", DbType.Decimal, model.HistoryHoldAmountDelta);
            db.AddInParameter(dbCommand, "HistoryFreezeAmount", DbType.Decimal, model.HistoryFreezeAmountDelta);
            db.AddInParameter(dbCommand, "TodayHoldAmount", DbType.Decimal, model.TodayHoldAmountDelta);
            db.AddInParameter(dbCommand, "TodayFreezeAmount", DbType.Decimal, model.TodayFreezeAmountDelta);
            db.AddInParameter(dbCommand, "Margin", DbType.Decimal, model.MarginDelta);
            db.ExecuteNonQuery(dbCommand, tm.Transaction);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 一个资金id多次插入
        /// </summary>
        private static void Test2T()
        {
            MemoryDataManager.Start();

            var table  = MemoryDataManager.QHCapitalMemoryList.GetByCapitalAccountLogo(1);
            var table1 = MemoryDataManager.QHHoldMemoryList.GetByAccountHoldLogoId(1);

            Console.WriteLine("开始Test1T");
            QH_CapitalAccountTable_DeltaInfo delta = new QH_CapitalAccountTable_DeltaInfo();

            delta.AvailableCapitalDelta = 1;

            QH_HoldAccountTableInfo_Delta holdDelta = new QH_HoldAccountTableInfo_Delta();
            var data = table1.Data;

            holdDelta.Data = data;
            holdDelta.AccountHoldLogoId     = data.AccountHoldLogoId;
            holdDelta.TodayHoldAmountDelta += 1;

            Database database = DatabaseFactory.CreateDatabase();

            using (DbConnection connection = database.CreateConnection())
            {
                connection.Open();
                DbTransaction transaction = connection.BeginTransaction();

                bool isSuccess = false;
                try
                {
                    //table.AddDeltaToDB(delta, database, transaction);

                    //MakeException();

                    //table.AddDeltaToDB(delta, database, transaction);
                    //table.AddDeltaToDB(delta, database, transaction);

                    //table1.AddDeltaToDB(holdDelta, database, transaction);
                    transaction.Commit();
                    isSuccess = true;
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    isSuccess = false;
                    Console.WriteLine("Exception:" + ex.Message);
                }

                if (isSuccess)
                {
                    //table.AddDeltaToMemory(delta);
                    //table.AddDeltaToMemory(delta);
                    //table.AddDeltaToMemory(delta);

                    //table1.AddDeltaToMemory(holdDelta);
                }
            }
            Console.WriteLine(table.Data.AvailableCapital);
            Console.WriteLine(table1.Data.TodayHoldAmount);


            ExitConsole();
            MemoryDataManager.End();
        }