Example #1
0
        private void SaveData()
        {
            string     qh   = this.t_qh.Text;
            SsqNumbers item = SsqNumbersManager.GetInstance().GetByQh(qh);

            if (item != null && string.IsNullOrEmpty(this.qh))
            {
                MessageBox.Show("该期号已经存在");
                return;
            }
            else
            {
                if (item == null)
                {
                    item = new SsqNumbers();
                }
                item.Qh       = qh;
                item.SsqDate  = Common.ToDateTime(this.t_rq.Text);
                item.NumBlue7 = this.t_blue.Text;
                item.NumRed1  = this.t_red1.Text;
                item.NumRed2  = this.t_red2.Text;
                item.NumRed3  = this.t_red3.Text;
                item.NumRed4  = this.t_red4.Text;
                item.NumRed5  = this.t_red5.Text;
                item.NumRed6  = this.t_red6.Text;
                List <SsqNumbers> aa = new List <SsqNumbers>();
                aa.Add(item);
                SsqNumbersManager.GetInstance().Save(aa);
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Example #2
0
 public SSQ_Add(string qh)
 {
     InitializeComponent();
     this.qh = qh;
     if (!string.IsNullOrEmpty(qh))
     {
         SsqNumbers item = SsqNumbersManager.GetInstance().GetByQh(qh);
         this.t_qh.Text   = item.Qh;
         this.t_rq.Text   = item.SsqDate.ToString("yyyy-MM-dd");
         this.t_blue.Text = item.NumBlue7;
         this.t_red1.Text = item.NumRed1;
         this.t_red2.Text = item.NumRed2;
         this.t_red3.Text = item.NumRed3;
         this.t_red4.Text = item.NumRed4;
         this.t_red5.Text = item.NumRed5;
         this.t_red6.Text = item.NumRed6;
     }
 }
Example #3
0
        private void btn_dr_Click(object sender, EventArgs e)
        {
            int pos = 0;

            try
            {
                List <SsqNumbers> sList = new List <SsqNumbers>();
                if (this.openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    string fileName = this.openFileDialog.FileName;


                    string          connStr = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=Excel 12.0;", @fileName);
                    OleDbConnection conn    = new OleDbConnection(connStr);
                    conn.Open();

                    DataTable       dt        = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new Object[] { null, null, null, "TABLE" });
                    string          tableName = dt.Rows[0]["TABLE_NAME"].ToString();
                    string          sql       = String.Format("SELECT * FROM [{0}]", tableName);
                    OleDbCommand    cmd       = new OleDbCommand(sql, conn);
                    OleDbDataReader reader    = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        string xh = ReadExcelCell(reader, 0).Trim();
                        System.Text.RegularExpressions.Regex rex = new System.Text.RegularExpressions.Regex(@"^\d+$");

                        if (!rex.IsMatch(xh))
                        {
                            continue;
                        }

                        string   ssqDate  = ReadExcelCell(reader, 1).Trim();
                        string   qh       = ReadExcelCell(reader, 2).Trim();
                        string   numbers  = ReadExcelCell(reader, 3).Trim();
                        string[] numberss = numbers.Split(' ');
                        if (numberss.Length != 7)
                        {
                            continue;
                        }

                        SsqNumbers s = new SsqNumbers();
                        s.SsqDate = Common.ToDateTime(ssqDate);
                        s.Qh      = qh;
                        List <int> temp = new List <int>();
                        temp.Add(Common.ToInt32(numberss[0]));
                        temp.Add(Common.ToInt32(numberss[1]));
                        temp.Add(Common.ToInt32(numberss[2]));
                        temp.Add(Common.ToInt32(numberss[3]));
                        temp.Add(Common.ToInt32(numberss[4]));
                        temp.Add(Common.ToInt32(numberss[5]));
                        temp.Sort();

                        s.NumBlue7 = Common.ToInt32(numberss[6]).ToString();
                        s.NumRed1  = temp[0].ToString();
                        s.NumRed2  = temp[1].ToString();
                        s.NumRed3  = temp[2].ToString();
                        s.NumRed4  = temp[3].ToString();
                        s.NumRed5  = temp[4].ToString();
                        s.NumRed6  = temp[5].ToString();

                        sList.Add(s);
                        ++pos;
                    }
                    SsqNumbersManager.GetInstance().Save(sList);
                    MessageBox.Show(string.Format("导入成功{0}条数据", pos));
                    InitList();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Log.GetInstance().WriteLog(ex.Message + ex.StackTrace, Log.Level.Error);
            }
        }
Example #4
0
        public void InitList()
        {
            try
            {
                this.listView.Clear();
                this.listView.View = View.Details;

                this.listView.Columns.Add("0", "序号", 50, HorizontalAlignment.Center, 0);
                this.listView.Columns.Add("1", "时间", 90, HorizontalAlignment.Center, 0);
                this.listView.Columns.Add("2", "期号", 90, HorizontalAlignment.Center, 0);
                this.listView.Columns.Add("3", "红1", 70, HorizontalAlignment.Center, 0);
                this.listView.Columns.Add("4", "红2", 70, HorizontalAlignment.Center, 0);
                this.listView.Columns.Add("5", "红3", 70, HorizontalAlignment.Center, 0);
                this.listView.Columns.Add("6", "红4", 70, HorizontalAlignment.Center, 0);
                this.listView.Columns.Add("7", "红5", 70, HorizontalAlignment.Center, 0);
                this.listView.Columns.Add("8", "红6", 70, HorizontalAlignment.Center, 0);
                this.listView.Columns.Add("9", "蓝1", 70, HorizontalAlignment.Center, 0);
                this.listView.Columns.Add("10", "中奖", 200, HorizontalAlignment.Center, 0);

                list = SsqNumbersManager.GetInstance().GetList(this.t_xsrq_s.Text, this.t_xsrq_e.Text);
                //分析数据
                FxSSQ(list);
                //中奖号码
                this.l_winning.Text = string.Format("中奖号码({7}):{0} {1} {2} {3} {4} {5}     {6}", winningRed[0], winningRed[1], winningRed[2], winningRed[3], winningRed[4], winningRed[5], winningBlue, winningTypeName);

                if (list.Count > 0)
                {
                    int pos = 0;
                    foreach (SsqNumbers item in list)
                    {
                        ++pos;
                        ListViewItem listItem = new ListViewItem();
                        listItem.SubItems.Clear();

                        listItem.Text = pos.ToString();
                        listItem.Tag  = item;
                        listItem.SubItems.Add(item.SsqDate.ToString("yyyy-MM-dd"));
                        listItem.SubItems.Add(item.Qh);
                        listItem.SubItems.Add(item.NumRed1);
                        listItem.SubItems.Add(item.NumRed2);
                        listItem.SubItems.Add(item.NumRed3);
                        listItem.SubItems.Add(item.NumRed4);
                        listItem.SubItems.Add(item.NumRed5);
                        listItem.SubItems.Add(item.NumRed6);
                        listItem.SubItems.Add(item.NumBlue7);

                        bool isBlue = false;
                        //蓝色球相同
                        if (winningBlue.Equals(Common.ToInt32(item.NumBlue7).ToString()))
                        {
                            isBlue = true;
                        }
                        //红球几个
                        int winCount = 0;
                        if (winningRed.Contains(item.NumRed1))
                        {
                            ++winCount;
                        }
                        if (winningRed.Contains(item.NumRed2))
                        {
                            ++winCount;
                        }
                        if (winningRed.Contains(item.NumRed3))
                        {
                            ++winCount;
                        }
                        if (winningRed.Contains(item.NumRed4))
                        {
                            ++winCount;
                        }
                        if (winningRed.Contains(item.NumRed5))
                        {
                            ++winCount;
                        }
                        if (winningRed.Contains(item.NumRed6))
                        {
                            ++winCount;
                        }
                        if (isBlue && winCount == 0)
                        {
                            listItem.SubItems.Add(string.Format("0+1,六等奖(5.88/100),5元"));
                            listItem.SubItems[10].BackColor = Color.Yellow;
                        }
                        if (isBlue && winCount == 1)
                        {
                            listItem.SubItems.Add(string.Format("1+1,六等奖(5.88/100),5元"));
                            listItem.SubItems[10].BackColor = Color.Yellow;
                        }
                        if (isBlue && winCount == 2)
                        {
                            listItem.SubItems.Add(string.Format("2+1,六等奖(5.88/100),5元"));
                            listItem.SubItems[10].BackColor = Color.Yellow;
                        }
                        if (!isBlue && winCount == 4)
                        {
                            listItem.SubItems.Add(string.Format("4+0,五等奖(1/2728),10元"));
                            listItem.SubItems[10].BackColor = Color.Yellow;
                        }
                        if (isBlue && winCount == 3)
                        {
                            listItem.SubItems.Add(string.Format("3+1,五等奖(1/2728),10元"));
                            listItem.SubItems[10].BackColor = Color.Yellow;
                        }
                        if (!isBlue && winCount == 5)
                        {
                            listItem.SubItems.Add(string.Format("5+0,四等奖(1/2万),200元"));
                            listItem.SubItems[10].BackColor = Color.Red;
                        }
                        if (isBlue && winCount == 4)
                        {
                            listItem.SubItems.Add(string.Format("4+1,四等奖(1/2万),200元"));
                            listItem.SubItems[10].BackColor = Color.Red;
                        }
                        if (isBlue && winCount == 5)
                        {
                            listItem.SubItems.Add(string.Format("5+1,三等奖(162/1770万),3000元"));
                            listItem.SubItems[10].BackColor = Color.Red;
                        }
                        if (!isBlue && winCount == 6)
                        {
                            listItem.SubItems.Add(string.Format("6+0,二等奖(15/1770万),25%"));
                            listItem.SubItems[10].BackColor = Color.Red;
                        }
                        if (isBlue && winCount == 6)
                        {
                            listItem.SubItems.Add(string.Format("6+0,一等奖(1/1770万),100%"));
                            listItem.SubItems[10].BackColor = Color.Red;
                        }
                        if (!isBlue && winCount == 0)
                        {
                            listItem.SubItems.Add(string.Format("0+0,一个未中"));
                            listItem.SubItems[10].BackColor = Color.Green;
                        }

                        listItem.SubItems[3].ForeColor = Color.Red;
                        listItem.SubItems[4].ForeColor = Color.Red;
                        listItem.SubItems[5].ForeColor = Color.Red;
                        listItem.SubItems[6].ForeColor = Color.Red;
                        listItem.SubItems[7].ForeColor = Color.Red;
                        listItem.SubItems[8].ForeColor = Color.Red;

                        listItem.SubItems[9].ForeColor = Color.Blue;

                        this.listView.Items.Add(listItem);
                        this.listView.Items[pos - 1].UseItemStyleForSubItems = false; //可以单独设置listview的颜色
                    }
                    this.l_count.Text = string.Format("共{0}条数据", pos);
                }
            }
            catch (Exception e)
            {
                Log.GetInstance().WriteLog(e.Message, Log.Level.Error);
                Log.GetInstance().WriteLog(e.StackTrace, Log.Level.Error);
            }
        }