/// <summary>
 /// 显示开奖相关信息
 /// </summary>
 void showOpenInfo()
 {
     lastOpen = LotteryOpenDAL.LastOpenNo(Lottery.Id);
     if (lastOpen != null)
     {
         gbLotteryInfo.Text = string.Format("{0} 第{1}期 开奖号码", this.Text.Substring(0, this.Text.IndexOf("开奖器")), lastOpen.Expect);
         var nList = (lastOpen.OpenCode == null?lastOpen.ScheduleOpenCode:lastOpen.OpenCode).Split(',');
         lblLNo1.Text = MyTool.AddZeroStr(nList[0], 2);
         lblLNo2.Text = MyTool.AddZeroStr(nList[1], 2);
         lblLNo3.Text = MyTool.AddZeroStr(nList[2], 2);
         lblLNo4.Text = MyTool.AddZeroStr(nList[3], 2);
         lblLNo5.Text = MyTool.AddZeroStr(nList[4], 2);
         var pm = LotteryOpenDAL.GetPrizePoolMoney(Lottery.Id);
         if (pm != null)
         {
             lblPool.Text = pm.PoolMoney + "元";
         }
     }
     nextOpen = LotteryOpenDAL.NextOpenNo(Lottery.Id);
     if (nextOpen != null)
     {
         var dtNow = EntitiesTool.GetDateTimeNow();
         while (dtNow > nextOpen.OpenTime)
         {
             nextOpen = LotteryOpenDAL.NextOpenNo(Lottery.Id);
         }
         gbLotteryTime.Text = string.Format("距离{0}期开奖:", nextOpen.Expect);
         dtOne = new TimeSpan(TimeSpan.TicksPerSecond * Convert.ToInt32((nextOpen.ScheduleOpenTime - dtNow).TotalSeconds));
         dgvInfo.Rows.Insert(0, new DataGridViewRow());
         var row = dgvInfo.Rows[0];
         row.Cells[0].Value = nextOpen.Id;
         row.Cells[1].Value = nextOpen.Expect;
         row.Cells[2].Value = nextOpen.ScheduleOpenTime;
         row.Cells[3].Value = nextOpen.ScheduleOpenCode;
     }
 }
 private void timer1_Tick(object sender, EventArgs e)
 {
     dtOne         = dtOne.Add(-_1s);
     lblHours.Text = MyTool.AddZeroStr(dtOne.Hours, 2);
     lblMin.Text   = MyTool.AddZeroStr(dtOne.Minutes, 2);
     lblSec.Text   = MyTool.AddZeroStr(dtOne.Seconds, 2);
     if (flag && dtOne.TotalSeconds % 3 == 0)
     {
         lastOpen = LotteryOpenDAL.LastOpenNo(Lottery.Id);
         if (lastOpen != null && lastOpen.OpenCode != null)
         {
             gbLotteryInfo.Text = string.Format("{0} 第{1}期 开奖号码", this.Text.Substring(0, this.Text.IndexOf("开奖器")), lastOpen.Expect);
             var nList = lastOpen.OpenCode.Split(',');
             lblLNo1.Text = MyTool.AddZeroStr(nList[0], 2);
             lblLNo2.Text = MyTool.AddZeroStr(nList[1], 2);
             lblLNo3.Text = MyTool.AddZeroStr(nList[2], 2);
             lblLNo4.Text = MyTool.AddZeroStr(nList[3], 2);
             lblLNo5.Text = MyTool.AddZeroStr(nList[4], 2);
             var pm = LotteryOpenDAL.GetPrizePoolMoney(Lottery.Id);
             var pi = LotteryOpenDAL.GetPrizePoolInfo(lastOpen.Id);
             for (int i = 0; i < dgvInfo.RowCount; i++)
             {
                 if ((long)dgvInfo.Rows[i].Cells[0].Value == lastOpen.Id)
                 {
                     dgvInfo.Rows[i].Cells[4].Value = lastOpen.OpenTime;
                     dgvInfo.Rows[i].Cells[5].Value = lastOpen.OpenCode;
                     if (pi != null)
                     {
                         dgvInfo.Rows[i].Cells[6].Value = pi.TotalBet;
                         dgvInfo.Rows[i].Cells[7].Value = pi.TotalAgenBack;
                         dgvInfo.Rows[i].Cells[8].Value = pi.TotalBack;
                         dgvInfo.Rows[i].Cells[9].Value = pi.TotalBet - pi.TotalAgenBack - pi.TotalBack;
                         if (pi.TotalBet > 0)
                         {
                             dgvInfo.Rows[i].Cells[10].Value = Math.Round((pi.TotalAgenBack + pi.TotalBack) * 100 / pi.TotalBet, 2) + "%";
                         }
                     }
                 }
             }
             if (pm != null)
             {
                 lblPool.Text = pm.PoolMoney + "元";
             }
             flag = false;
         }
     }
     if (dtOne.TotalSeconds == 1)
     {
         //LotteryOpenDAL.SetNextOpenNo(Lottery.Id);
         //开奖
         try
         {
             Thread t = new Thread(new ThreadStart(open));
             t.Start();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
             return;
         }
     }
     if (dtOne.TotalSeconds == 0)
     {
         nextOpen = LotteryOpenDAL.NextOpenNo(Lottery.Id);
         if (nextOpen != null)
         {
             var dtNow = EntitiesTool.GetDateTimeNow();
             while (dtNow > nextOpen.OpenTime)
             {
                 nextOpen = LotteryOpenDAL.NextOpenNo(Lottery.Id);
             }
             gbLotteryTime.Text = string.Format("距离{0}期开奖:", nextOpen.Expect);
             dtOne = new TimeSpan(TimeSpan.TicksPerSecond * Convert.ToInt32((nextOpen.ScheduleOpenTime - dtNow).TotalSeconds));
             dgvInfo.Rows.Insert(0, new DataGridViewRow());
             var row = dgvInfo.Rows[0];
             row.Cells[0].Value = nextOpen.Id;
             row.Cells[1].Value = nextOpen.Expect;
             row.Cells[2].Value = nextOpen.ScheduleOpenTime;
             row.Cells[3].Value = nextOpen.ScheduleOpenCode;
         }
         flag = true;
     }
     if (DateTime.Now.Hour == 6 && DateTime.Now.Minute == 0 && DateTime.Now.Second == 0)
     {
         var dt = EntitiesTool.GetDateTimeNow();
         LotteryOpenPrivateInfoDAL.InitialTodayInfo(Lottery, dt.AddDays(1));
     }
     if (dtOne.TotalSeconds < 0)
     {
         btnStop_Click(null, null);
     }
 }