/// <summary>
        /// 置顶操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItemToTop_Click(object sender, EventArgs e)
        {
            int           id    = Convert.ToInt32(commonDataGridView1.dgv_HoldStock.CurrentRow.Cells["ID"].Value.ToString());
            M_ExpectStock model = ExpectStock.GetModel(id);

            model.OrderIndex = 1;
            DataTable dt = ExpectStock.GetList("1=1 order by OrderIndex").Tables[0];
            int       i  = 1;

            foreach (DataRow dr in dt.Rows)
            {
                i++;
                M_ExpectStock modelUpdate = ExpectStock.DataRowToModel(dr);
                if (!modelUpdate.StockName.Equals(model.StockName, StringComparison.CurrentCultureIgnoreCase))
                {
                    modelUpdate.OrderIndex = i;
                    ExpectStock.Update(modelUpdate);
                }
            }
            ExpectStock.Update(model);
            dt_expectStock = GetStockHold();
            commonDataGridView1.dgv_HoldStock.DataSource = dt_expectStock;
            //ExpectStock.Delete(id);
            //dt_expectStock = GetStockHold();
        }
        private void MenuItemDelete_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(commonDataGridView1.dgv_HoldStock.CurrentRow.Cells["ID"].Value.ToString());

            ExpectStock.Delete(id);
            dt_expectStock = GetStockHold();
        }
 private void btnSaveExpectPrice_Click(object sender, EventArgs e)
 {
     foreach (KeyValuePair <int, double> keyvalue in dicExpectPrice)
     {
         M_ExpectStock saveExpect = ExpectStock.GetModel(keyvalue.Key);
         saveExpect.ExpectPrice = keyvalue.Value;
         ExpectStock.Update(saveExpect);
     }
     //MessageBox.Show("保存成功");
     dicExpectPrice.Clear();
 }
 private void FrmStockExpect_Load(object sender, EventArgs e)
 {
     commonDataGridView1.dgv_HoldStock.DataSource = ExpectStock.GetList(" 1=1 order by OrderIndex").Tables[0];
     myDgv.ReadOnly = false;
     for (int i = 0; i < myDgv.ColumnCount; i++)
     {
         if (myDgv.Columns[i].Name != "ExpectPrice")
         {
             myDgv.Columns[i].ReadOnly = true;
         }
     }
     myDgv.CellValueChanged        += ChangeExpectPrice;
     BwExpectStock.SetHoldStockInfo = UpdateHoldStockInfo;
     BwExpectStock.OnStart();
 }
 /// <summary>
 /// 把从网络上获取的股票价格信息更新到后台数据库
 /// </summary>
 /// <param name="listUrlStock"></param>
 private void RefreshExpectData(List <M_UrlStock> listUrlStock)
 {
     foreach (M_UrlStock stock in listUrlStock)
     {
         M_ExpectStock mExpectStock = null;
         string        stockNo      = stock.StockNo;
         string        strWhere     = string.Format("{0}='{1}'", "StockNo", stockNo);
         DataTable     dt           = ExpectStock.GetList(1, strWhere, "StockNo").Tables[0];
         if (dt.Rows.Count != 0)
         {
             int id = Convert.ToInt32(dt.Rows[0]["ID"].ToString());
             mExpectStock            = ExpectStock.GetModel(id);
             mExpectStock.Price      = stock.Price;
             mExpectStock.UpdateTime = stock.UpdateTime;
             ExpectStock.Update(mExpectStock);
         }
     }
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string     stockNo  = txtStockNo.Text.Trim();
            M_UrlStock urlStock = CommonFunction.GetNowStockInfo(stockNo);

            if (ExpectStock.Exists(stockNo))
            {
                MessageBox.Show("此股票已存在!");
                return;
            }
            if (urlStock == null || string.IsNullOrEmpty(urlStock.StockNo))
            {
                return;
            }
            M_ExpectStock expectStock = new M_ExpectStock();

            expectStock.StockNo     = urlStock.StockNo;
            expectStock.StockName   = urlStock.StockName;
            expectStock.Price       = urlStock.Price;
            expectStock.ExpectPrice = double.Parse(numExpectPrice.Value.ToString());
            expectStock.UpdateTime  = urlStock.UpdateTime;
            ExpectStock.Add(expectStock);
        }
 /// <summary>
 /// 获取持仓信息
 /// </summary>
 private DataTable GetStockHold()
 {
     return(ExpectStock.GetList(" 1=1 order by OrderIndex").Tables[0]);
 }