Пример #1
0
 public Trade(Trade t)
 {
     type = t.type;
     no = t.no;
     price = t.price;
     end = t.end;
     remain = t.remain;
     performance = t.performance;
     seq = t.seq;
 }
Пример #2
0
        public Performance AddBuy(int price, int seq)
        {
            Trade trade;
            String cmd;
            Performance per = new Performance();
            if (sellnum != 0)
            {
                do
                {
                    remain--;
                    trade = tqueue.Dequeue();
                    trade.type = Trade.TRADE_BUY;
                    trade.end = price;
                    trade.remain = remain;
                    trade.performance = trade.price - trade.end - 1;
                    per.perf += trade.performance;
                    performance += trade.performance;
                    trade.seq = seq;

                    cmd = String.Format("INSERT INTO Trade (type, no, price, end, remain, performance, seq) VALUES (");
                    cmd += System.Convert.ToString(trade.type) + ",";
                    cmd += System.Convert.ToString(trade.no) + ",";
                    cmd += System.Convert.ToString(trade.price) + ",";
                    cmd += System.Convert.ToString(trade.end) + ",";
                    cmd += System.Convert.ToString(trade.remain) + ",";
                    cmd += System.Convert.ToString(trade.performance) + ",";
                    cmd += System.Convert.ToString(trade.seq) + ");";
                    kit.CmdNonQuery(cmd);
                    sellnum--;
                } while (sellnum > 0);
            }



            trade = new Trade();
            buynum++;
            remain++;
            trade.type = Trade.TRADE_BUY;
            trade.no = buynum;
            trade.price = price;
            trade.end = 0;
            trade.remain = remain;
            trade.performance = 0;
            trade.seq = seq;
            tqueue.Enqueue(new Trade(trade));

            cmd = String.Format("INSERT INTO Trade (type, no, price, end, remain, performance, seq) VALUES (");
            cmd += System.Convert.ToString(trade.type) + ",";
            cmd += System.Convert.ToString(trade.no) + ",";
            cmd += System.Convert.ToString(trade.price) + ",";
            cmd += System.Convert.ToString(trade.end) + ",";
            cmd += System.Convert.ToString(trade.remain) + ",";
            cmd += System.Convert.ToString(trade.performance) + ",";
            cmd += System.Convert.ToString(trade.seq) + ");";
            kit.CmdNonQuery(cmd);

            per.total = performance;
            per.price = trade.price;
            per.num = buynum;
            return per;
        }