コード例 #1
0
 /// <summary>
 /// 更新股票价格信息
 /// </summary>
 private void UpdateHoldStockInfo()
 {
     try
     {
         DataTable     dt          = HoldStock.GetList("").Tables[0];
         List <string> listStockNo = new List <string>();
         foreach (DataRow dr in dt.Rows)
         {
             listStockNo.Add(dr["StockNo"].ToString());
         }
         List <M_UrlStock> listUrlStock = CommonFunction.GetNowStockInfoList(listStockNo);
         RefreshHoldData(listUrlStock);
         Invoke(new MethodInvoker(delegate()
         {
             GetStockHold();
             AddRiseColumn();
             UpdatePrice(listUrlStock);
             UpdateDailyEarn();
         }));
     }
     catch
     {
         return;
     }
 }
コード例 #2
0
 /// <summary>
 /// 把从网络上获取的股票价格信息更新到后台数据库
 /// </summary>
 /// <param name="listUrlStock"></param>
 private void RefreshHoldData(List <M_UrlStock> listUrlStock)
 {
     foreach (M_UrlStock stock in listUrlStock)
     {
         M_HoldStock mHoldStock = null;
         string      stockNo    = stock.StockNo;
         string      strWhere   = string.Format("{0}='{1}'", "StockNo", stockNo);
         DataTable   dt         = HoldStock.GetList(1, strWhere, "StockNo").Tables[0];
         if (dt.Rows.Count != 0)
         {
             int id = Convert.ToInt32(dt.Rows[0]["ID"].ToString());
             mHoldStock            = HoldStock.GetModel(id);
             mHoldStock.Price      = stock.Price;
             mHoldStock.UpdateTime = stock.UpdateTime;
             HoldStock.Update(mHoldStock);
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// 获取持仓信息
        /// </summary>
        private void GetStockHold()
        {
            dt_holdstock = HoldStock.GetList("").Tables[0];
            double sumHoldAmount = 0;

            if (dt_holdstock != null && dt_holdstock.Rows.Count > 0)
            {
                for (int i = 0; i < dt_holdstock.Rows.Count; i++)
                {
                    double holdAmount = Convert.ToDouble(dt_holdstock.Rows[i]["HoldAmount"].ToString());
                    double price      = Convert.ToDouble(dt_holdstock.Rows[i]["Price"].ToString());
                    sumHoldAmount += holdAmount * price;
                }
            }
            txtHoldAsset.Text   = Math.Round(sumHoldAmount, 2).ToString();
            txtRemainAsset.Text = (Convert.ToDouble(txtAssetRef.Text) - Convert.ToDouble(txtHoldAsset.Text)).ToString();
            SetTip();
        }