private void Button_Start_Click(object sender, EventArgs e)
        {
            switch (button_Start.Text)
            {
            case "开始检测":
                if (!YH_Client.AutoLogin(dataGridView_warehouse, username, password))
                {
                    return;
                }
                if ("".Equals(dzhPath))
                {
                    MessageBox.Show("请先选择大智慧安装目录!");
                    return;
                }
                CheckBuyTimer.Start();
                button_Start.Text = "停止检测";
                break;

            case "停止检测":
                CheckBuyTimer.Stop();
                button_Start.Text = "开始检测";
                break;
            }
        }
 private void button_getBalance_Click(object sender, EventArgs e)
 {
     YH_Client.GetBalance(dataGridView_warehouse);
 }
        private void CheckBuy()
        {
            try
            {
                StreamReader  sr = new StreamReader(dzhPath + @"\WarningTxt\" + DateTime.Now.Year + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00") + ".txt", Encoding.Default);
                string        line;
                StringBuilder allLine   = new StringBuilder();
                int           lineCount = 0;
                while ((line = sr.ReadLine()) != null)
                {
                    string[] lineArray = line.Split('\t');
                    bool     isBuy     = true;
                    if (lineArray.Length > 0)
                    {
                        //300782	股票名称	2019-12-24 13:57	421.22	0.52%	6345	BUY
                        foreach (DataGridViewRow row in dataGridView_warehouse.Rows)
                        {
                            //预警时间在10分钟之前的股票不再买入
                            if (DateTime.Parse(lineArray[2]).AddMinutes(10) < DateTime.Now)
                            {
                                isBuy = false;
                                break;
                            }
                            //当天不能重复买入同一个股票
                            if (lineArray[0].Equals(row.Cells[0].Value) && Convert.ToInt32(row.Cells[2].Value) > Convert.ToInt32(row.Cells[3].Value))
                            {
                                isBuy = false;
                                break;
                            }
                        }
                        if (isBuy)
                        {
                            YH_Client.Buy(lineArray[0], Convert.ToDouble(lineArray[3]), 100);
                        }
                    }
                    else
                    {
                        return;
                    }

                    lineCount++;
                    allLine.Append(line + "\n");
                    //todo 买入,写dat文件保存已买入的股票600519	股票名称	2019-12-24 13:56	1148.03	-0.11%	8283	BUY
                }
                sr.Close();
                if (lineCount > SendCount)//有新数据时
                {
                    SendCount = lineCount;
                    allLine.Replace(DateTime.Now.ToString("yyyy-MM-dd"), "").Replace("\t", " ").Replace("  ", " ");
                    allLine.ToString();
                }
                else
                {
                    return;
                }
            }
            catch (FileNotFoundException)
            {
                return;
            }
        }
 private void CheckClient()
 {
     YH_Client.AutoLogin(dataGridView_warehouse, username, password);
 }