Exemplo n.º 1
0
        public bool SaveStoneStackDailyRecordInfo(StoneStackDailyRecordInfo dailyInfo)
        {
            MySqlConnection myconn = MyDBHelper.Instance.CreateConnection();
            MySqlCommand    mycmd  = null;

            try
            {
                mycmd = myconn.CreateCommand();

                string cmdTextSelect = "select * from stonestackdailyrecordinfo where `Day` = @Day;";
                mycmd.CommandText = cmdTextSelect;
                mycmd.Parameters.AddWithValue("@Day", dailyInfo.Day);

                MySqlDataAdapter adapter = new MySqlDataAdapter(mycmd);
                DataTable        table   = new DataTable();
                adapter.Fill(table);
                adapter.Dispose();
                mycmd.Dispose();

                mycmd = myconn.CreateCommand();
                string cmdTextA = "";
                if (table.Rows.Count > 0)
                {
                    int id = Convert.ToInt32(table.Rows[0]["id"]);

                    cmdTextA = "update stonestackdailyrecordinfo set `OpenPrice` = @OpenPrice, `ClosePrice` = @ClosePrice, `MinTradeSucceedPrice` = @MinTradeSucceedPrice, " +
                               " `MaxTradeSucceedPrice` = @MaxTradeSucceedPrice, `TradeSucceedStoneHandSum` = @TradeSucceedStoneHandSum, `TradeSucceedRMBSum` = @TradeSucceedRMBSum, " +
                               " `DelegateSellStoneSum` = @DelegateSellStoneSum, `DelegateBuyStoneSum` = @DelegateBuyStoneSum " +
                               " where `id` = @id ";

                    mycmd.Parameters.AddWithValue("@id", id);
                }
                else
                {
                    cmdTextA = "insert into stonestackdailyrecordinfo " +
                               "(`Day`, `OpenPrice`, `ClosePrice`, `MinTradeSucceedPrice`, `MaxTradeSucceedPrice`, `TradeSucceedStoneHandSum`, `TradeSucceedRMBSum`, `DelegateSellStoneSum`, `DelegateBuyStoneSum` ) " +
                               " values " +
                               "(@Day, @OpenPrice, @ClosePrice, @MinTradeSucceedPrice, @MaxTradeSucceedPrice, @TradeSucceedStoneHandSum, @TradeSucceedRMBSum, @DelegateSellStoneSum, @DelegateBuyStoneSum ); ";

                    mycmd.Parameters.AddWithValue("@Day", dailyInfo.Day);
                }

                mycmd.CommandText = cmdTextA;
                mycmd.Parameters.AddWithValue("@OpenPrice", dailyInfo.OpenPrice);
                mycmd.Parameters.AddWithValue("@ClosePrice", dailyInfo.ClosePrice);
                mycmd.Parameters.AddWithValue("@MinTradeSucceedPrice", dailyInfo.MinTradeSucceedPrice);
                mycmd.Parameters.AddWithValue("@MaxTradeSucceedPrice", dailyInfo.MaxTradeSucceedPrice);
                mycmd.Parameters.AddWithValue("@TradeSucceedStoneHandSum", dailyInfo.TradeSucceedStoneHandSum);
                mycmd.Parameters.AddWithValue("@TradeSucceedRMBSum", dailyInfo.TradeSucceedRMBSum);
                mycmd.Parameters.AddWithValue("@DelegateSellStoneSum", dailyInfo.DelegateSellStoneSum);
                mycmd.Parameters.AddWithValue("@DelegateBuyStoneSum", dailyInfo.DelegateBuyStoneSum);

                myconn.Open();
                mycmd.ExecuteNonQuery();
                return(true);
            }
            finally
            {
                if (mycmd != null)
                {
                    mycmd.Dispose();
                }
                MyDBHelper.Instance.DisposeConnection(myconn);
            }
        }
Exemplo n.º 2
0
        void ListTodayRealTimeTradeRecords_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            StoneStackDailyRecordInfo newItem = null;

            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset)
            {
                _listTodayMinuteTradeRecords.Clear();
                _needRendAll = true;
            }
            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
            {
                if (e.NewItems == null || e.NewItems.Count == 0)
                {
                    return;
                }
                newItem = e.NewItems[0] as StoneStackDailyRecordInfo;
                if (newItem == null)
                {
                    return;
                }

                //_needRendAll = true;
                if (this._listTodayMinuteTradeRecords.Count == 0)
                {
                    this._listTodayMinuteTradeRecords.Add(newItem);
                }
                else
                {
                    var lastRecord = this._listTodayMinuteTradeRecords[this._listTodayMinuteTradeRecords.Count - 1];

                    if (lastRecord.Day.Hour == newItem.Day.Hour && lastRecord.Day.Minute == newItem.Day.Minute)
                    {
                        this._listTodayMinuteTradeRecords[this._listTodayMinuteTradeRecords.Count - 1] = newItem;
                        this._addItem = false;
                    }
                    else
                    {
                        this._listTodayMinuteTradeRecords.Add(newItem);
                        this._addItem = true;
                    }
                }

                if (this.OpenPrice != newItem.OpenPrice)
                {
                    this._needRendAll = true;
                }
                this.OpenPrice = newItem.OpenPrice;
                double newRangeValue = Math.Abs(Math.Round((double)(newItem.ClosePrice - newItem.OpenPrice), 2));
                if (newRangeValue > this._maxRangeValue)
                {
                    _needRendAll        = true;
                    this._maxRangeValue = newRangeValue;
                }
            }

            _syn.Post(o =>
            {
                if (_needRendAll)
                {
                    Draw();
                }
                else
                {
                    if (newItem != null && newItem.Day != null)
                    {
                        Point newPoint = ConvertStoneStackDailyRecordInfoToPoint(newItem);
                        if (this._addItem)
                        {
                            this.polyLine.Points.Add(newPoint);
                        }
                        else
                        {
                            if (this.polyLine.Points.Count == 0)
                            {
                                this.polyLine.Points.Add(newPoint);
                            }
                            else
                            {
                                this.polyLine.Points[this.polyLine.Points.Count - 1] = newPoint;
                            }
                        }
                    }
                }
            }, null);
        }
Exemplo n.º 3
0
 public DailyRecordUIElement(StoneStackDailyRecordInfo data)
 {
     this.Data = data;
 }