彩票走势图源码

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Common;
using DevExpress.LookAndFeel;
using System.Threading;
using Entity;
using DevExpress.XtraEditors;

namespace CaiPiao
{
    /// <summary>
    /// 罗旭成
    /// 2014年11月26日
    /// http://www.cnblogs.com/jara/
    /// </summary>
    public partial class CaiPiaoForm : BaseForm
    {
        public CaiPiaoForm()
            : base()
        {
            DevExpress.UserSkins.BonusSkins.Register();
            UserLookAndFeel.Default.SetSkinStyle("Office 2007 Blue");
            InitializeComponent();
        }

        #region * 查询
        protected override void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                base.ShowWaitDialog("正在查询,请稍候...");
                //--
                base.btnSearch_Click(sender, e);
                //基本走势图
                ThreadPool.QueueUserWorkItem(new WaitCallback(GetData1));
                //红球三分区走势图
                ThreadPool.QueueUserWorkItem(new WaitCallback(GetData2));
                //红球四分区走势图
                ThreadPool.QueueUserWorkItem(new WaitCallback(GetData3));
                //红球七分区走势图
                ThreadPool.QueueUserWorkItem(new WaitCallback(GetData4));
                //篮球综合走势图
                ThreadPool.QueueUserWorkItem(new WaitCallback(GetData5));
                //红球连号走势图
                ThreadPool.QueueUserWorkItem(new WaitCallback(GetData6));
                //红球和值走势图
                ThreadPool.QueueUserWorkItem(new WaitCallback(GetData7));
                //历史数据
                ThreadPool.QueueUserWorkItem(new WaitCallback(GetData8));
            }
            catch (Exception exMsg)
            {
                XtraMessageBox.Show("查询出错:" + exMsg.ToString());
            }
            finally
            {
                base.CloseWaitDialog();
            }
        }
        #endregion

        #region * 基本走势图
        /// <summary>
        /// 基本走势图
        /// </summary>
        /// <param name="obj"></param>
        private void GetData1(object obj)
        {
            table.Clear();
            cleantable.Clear();
            if (listWinNo != null && listWinNo.Count > 0)
            {
                foreach (WinNo item in listWinNo)
                {
                    DataRow dr = table.NewRow();
                    dr["QiHao"] = item.QiHao;
                    dr["R" + item.R1] = "R" + GetStr(item.R1.ToString());//红1
                    dr["R" + item.R2] = "R" + GetStr(item.R2.ToString());//红2
                    dr["R" + item.R3] = "R" + GetStr(item.R3.ToString());//红3
                    dr["R" + item.R4] = "R" + GetStr(item.R4.ToString());//红4
                    dr["R" + item.R5] = "R" + GetStr(item.R5.ToString());//红5
                    dr["R" + item.R6] = "R" + GetStr(item.R6.ToString());//红6
                    dr["B" + item.B] = "B" + GetStr(item.B.ToString());//篮球
                    table.Rows.Add(dr);

                    DataRow cleandr = cleantable.NewRow();
                    cleandr["QiHao"] = item.QiHao;
                    cleandr["R" + item.R1] = GetStr(item.R1.ToString());//红1
                    cleandr["R" + item.R2] = GetStr(item.R2.ToString());//红2
                    cleandr["R" + item.R3] = GetStr(item.R3.ToString());//红3
                    cleandr["R" + item.R4] = GetStr(item.R4.ToString());//红4
                    cleandr["R" + item.R5] = GetStr(item.R5.ToString());//红5
                    cleandr["R" + item.R6] = GetStr(item.R6.ToString());//红6
                    cleandr["B" + item.B] = GetStr(item.B.ToString());//篮球
                    cleantable.Rows.Add(cleandr);
                }

                for (int j = 1; j < 34; j++)
                {
                    int xint = 0;
                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        if (string.IsNullOrEmpty(table.Rows[i]["R" + j].ToString()))
                        {
                            xint++;
                            table.Rows[i]["R" + j] = xint;
                        }
                        else
                        {
                            xint = 0;
                        }
                    }
                }

                for (int j = 1; j < 17; j++)
                {
                    int xint = 0;
                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        if (string.IsNullOrEmpty(table.Rows[i]["B" + j].ToString()))
                        {
                            xint++;
                            table.Rows[i]["B" + j] = xint;
                        }
                        else
                        {
                            xint = 0;
                        }
                    }
                }

                if (this.IsHandleCreated)
                {
                    this.Invoke((MethodInvoker)delegate
                    {
                        if (flag)
                        {
                            cleantable.DefaultView.Sort = "QiHao DESC";
                            this.gridControl1.DataSource = cleantable.DefaultView.ToTable();
                        }
                        else
                        {
                            table.DefaultView.Sort = "QiHao DESC";
                            this.gridControl1.DataSource = table.DefaultView.ToTable();
                        }
                    });
                }
            }
        }
        #endregion

        #region * 红球三分区走势图
        /// <summary>
        /// 红球三分区走势图
        /// </summary>
        /// <param name="obj"></param>
        private void GetData2(object obj)
        {
            sedredtable.Clear();
            sedcleanredtable.Clear();
            if (listWinNo != null && listWinNo.Count > 0)
            {
                foreach (WinNo item in listWinNo)
                {
                    List<int> redList = new List<int>();
                    redList.Add(item.R1);
                    redList.Add(item.R2);
                    redList.Add(item.R3);
                    redList.Add(item.R4);
                    redList.Add(item.R5);
                    redList.Add(item.R6);
                    //--
                    DataRow reddr = sedredtable.NewRow();
                    reddr["QiHao"] = item.QiHao;
                    reddr["R" + item.R1] = "R" + GetStr(item.R1.ToString());//红1
                    reddr["R" + item.R2] = "R" + GetStr(item.R2.ToString());//红2
                    reddr["R" + item.R3] = "R" + GetStr(item.R3.ToString());//红3
                    reddr["R" + item.R4] = "R" + GetStr(item.R4.ToString());//红4
                    reddr["R" + item.R5] = "R" + GetStr(item.R5.ToString());//红5
                    reddr["R" + item.R6] = "R" + GetStr(item.R6.ToString());//红6
                    reddr["A1"] = item.R1 + item.R2 + item.R3 + item.R4 + item.R5 + item.R6;//和值
                    reddr["A2"] = item.R6 - item.R1;//跨度
                    reddr["A3"] = GetQujian(redList);//区间比
                    reddr["A4"] = GetJio(redList);//奇偶比
                    sedredtable.Rows.Add(reddr);

                    DataRow cleanreddr = sedcleanredtable.NewRow();
                    cleanreddr["QiHao"] = item.QiHao;
                    cleanreddr["R" + item.R1] = GetStr(item.R1.ToString());//红1
                    cleanreddr["R" + item.R2] = GetStr(item.R2.ToString());//红2
                    cleanreddr["R" + item.R3] = GetStr(item.R3.ToString());//红3
                    cleanreddr["R" + item.R4] = GetStr(item.R4.ToString());//红4
                    cleanreddr["R" + item.R5] = GetStr(item.R5.ToString());//红5
                    cleanreddr["R" + item.R6] = GetStr(item.R6.ToString());//红6
                    cleanreddr["A1"] = item.R1 + item.R2 + item.R3 + item.R4 + item.R5 + item.R6;//和值
                    cleanreddr["A2"] = item.R6 - item.R1;//跨度
                    cleanreddr["A3"] = GetQujian(redList);//区间比
                    cleanreddr["A4"] = GetJio(redList);//奇偶比
                    sedcleanredtable.Rows.Add(cleanreddr);
                }

                for (int j = 1; j < 34; j++)
                {
                    int xint = 0;
                    for (int i = 0; i < sedredtable.Rows.Count; i++)
                    {
                        if (string.IsNullOrEmpty(sedredtable.Rows[i]["R" + j].ToString()))
                        {
                            xint++;
                            sedredtable.Rows[i]["R" + j] = xint;
                        }
                        else
                        {
                            xint = 0;
                        }
                    }
                }

                if (this.IsHandleCreated)
                {
                    this.Invoke((MethodInvoker)delegate
                    {
                        if (flag)
                        {
                            sedcleanredtable.DefaultView.Sort = "QiHao DESC";
                            this.gridControl2.DataSource = sedcleanredtable.DefaultView.ToTable();
                        }
                        else
                        {
                            sedredtable.DefaultView.Sort = "QiHao DESC";
                            this.gridControl2.DataSource = sedredtable.DefaultView.ToTable();
                        }
                    });
                }
            }
        }

        /// <summary>
        /// 区间比
        /// </summary>
        /// <param name="redList"></param>
        /// <returns></returns>
        private string GetQujian(List<int> redList)
        {
            int xint1 = 0;
            int xint2 = 0;
            int xint3 = 0;
            foreach (int item in redList)
            {
                if (item < 12)
                {
                    xint1++;
                }
                else if (item > 11 && item < 23)
                {
                    xint2++;
                }
                else if (item > 22)
                {
                    xint3++;
                }
            }
            return xint1.ToString() + ":" + xint2.ToString() + ":" + xint3.ToString();
        }

        /// <summary>
        /// 奇偶比
        /// </summary>
        /// <param name="redList"></param>
        /// <returns></returns>
        private string GetJio(List<int> redList)
        {
            int xint1 = 0;//奇数
            int xint2 = 0;//偶数
            foreach (int item in redList)
            {
                if (item % 2 == 0)
                {
                    xint2++;//偶数
                }
                else
                {
                    xint1++;//奇数
                }
            }
            return xint1.ToString() + ":" + xint2.ToString();
        }
        #endregion

        #region * 红球四分区走势图
        /// <summary>
        /// 红球四分区走势图
        /// </summary>
        /// <param name="obj"></param>
        private void GetData3(object obj)
        {
            fourredtable.Clear();
            fourcleanredtable.Clear();
            if (listWinNo != null && listWinNo.Count > 0)
            {
                foreach (WinNo item in listWinNo)
                {
                    List<int> redList = new List<int>();
                    redList.Add(item.R1);
                    redList.Add(item.R2);
                    redList.Add(item.R3);
                    redList.Add(item.R4);
                    redList.Add(item.R5);
                    redList.Add(item.R6);
                    //--
                    DataRow reddr = fourredtable.NewRow();
                    reddr["QiHao"] = item.QiHao;
                    reddr["R" + item.R1] = "R" + GetStr(item.R1.ToString());//红1
                    reddr["R" + item.R2] = "R" + GetStr(item.R2.ToString());//红2
                    reddr["R" + item.R3] = "R" + GetStr(item.R3.ToString());//红3
                    reddr["R" + item.R4] = "R" + GetStr(item.R4.ToString());//红4
                    reddr["R" + item.R5] = "R" + GetStr(item.R5.ToString());//红5
                    reddr["R" + item.R6] = "R" + GetStr(item.R6.ToString());//红6
                    reddr["C1"] = GetFourFenQu(redList)[0];
                    reddr["C2"] = GetFourFenQu(redList)[1];
                    reddr["C3"] = GetFourFenQu(redList)[2];
                    reddr["C4"] = GetFourFenQu(redList)[3];
                    fourredtable.Rows.Add(reddr);

                    DataRow cleanreddr = fourcleanredtable.NewRow();
                    cleanreddr["QiHao"] = item.QiHao;
                    cleanreddr["R" + item.R1] = GetStr(item.R1.ToString());//红1
                    cleanreddr["R" + item.R2] = GetStr(item.R2.ToString());//红2
                    cleanreddr["R" + item.R3] = GetStr(item.R3.ToString());//红3
                    cleanreddr["R" + item.R4] = GetStr(item.R4.ToString());//红4
                    cleanreddr["R" + item.R5] = GetStr(item.R5.ToString());//红5
                    cleanreddr["R" + item.R6] = GetStr(item.R6.ToString());//红6
                    cleanreddr["C1"] = GetFourFenQu(redList)[0];
                    cleanreddr["C2"] = GetFourFenQu(redList)[1];
                    cleanreddr["C3"] = GetFourFenQu(redList)[2];
                    cleanreddr["C4"] = GetFourFenQu(redList)[3];
                    fourcleanredtable.Rows.Add(cleanreddr);
                }

                for (int j = 1; j < 34; j++)
                {
                    int xint = 0;
                    for (int i = 0; i < fourredtable.Rows.Count; i++)
                    {
                        if (string.IsNullOrEmpty(fourredtable.Rows[i]["R" + j].ToString()))
                        {
                            xint++;
                            fourredtable.Rows[i]["R" + j] = xint;
                        }
                        else
                        {
                            xint = 0;
                        }
                    }
                }

                if (this.IsHandleCreated)
                {
                    this.Invoke((MethodInvoker)delegate
                    {
                        if (flag)
                        {
                            fourcleanredtable.DefaultView.Sort = "QiHao DESC";
                            this.gridControl3.DataSource = fourcleanredtable.DefaultView.ToTable();
                        }
                        else
                        {
                            fourredtable.DefaultView.Sort = "QiHao DESC";
                            this.gridControl3.DataSource = fourredtable.DefaultView.ToTable();
                        }
                    });
                }
            }
        }

        /// <summary>
        /// 四分区个数
        /// </summary>
        /// <param name="redList"></param>
        /// <returns></returns>
        private List<string> GetFourFenQu(List<int> redList)
        {
            List<string> retlist = new List<string>();
            int xint1 = 0;
            int xint2 = 0;
            int xint3 = 0;
            int xint4 = 0;
            foreach (int item in redList)
            {
                if (item < 9)
                {
                    xint1++;
                }
                else if (item > 8 && item <= 17)
                {
                    xint2++;
                }
                else if (item > 17 && item < 26)
                {
                    xint3++;
                }
                else if (item > 25)
                {
                    xint4++;
                }
            }
            retlist.Add(xint1.ToString());
            retlist.Add(xint2.ToString());
            retlist.Add(xint3.ToString());
            retlist.Add(xint4.ToString());
            return retlist;
        }
        #endregion

        #region * 红球七分区走势图
        /// <summary>
        /// 红球七分区走势图
        /// </summary>
        /// <param name="obj"></param>
        private void GetData4(object obj)
        {
            sevenredtable.Clear();
            sevencleanredtable.Clear();
            if (listWinNo != null && listWinNo.Count > 0)
            {
                foreach (WinNo item in listWinNo)
                {
                    List<int> redList = new List<int>();
                    redList.Add(item.R1);
                    redList.Add(item.R2);
                    redList.Add(item.R3);
                    redList.Add(item.R4);
                    redList.Add(item.R5);
                    redList.Add(item.R6);
                    //--
                    DataRow reddr = sevenredtable.NewRow();
                    reddr["QiHao"] = item.QiHao;
                    reddr["R" + item.R1] = "R" + GetStr(item.R1.ToString());//红1
                    reddr["R" + item.R2] = "R" + GetStr(item.R2.ToString());//红2
                    reddr["R" + item.R3] = "R" + GetStr(item.R3.ToString());//红3
                    reddr["R" + item.R4] = "R" + GetStr(item.R4.ToString());//红4
                    reddr["R" + item.R5] = "R" + GetStr(item.R5.ToString());//红5
                    reddr["R" + item.R6] = "R" + GetStr(item.R6.ToString());//红6
                    reddr["D1"] = GetSevenFenQu(redList)[0];
                    reddr["D2"] = GetSevenFenQu(redList)[1];
                    reddr["D3"] = GetSevenFenQu(redList)[2];
                    reddr["D4"] = GetSevenFenQu(redList)[3];
                    reddr["D5"] = GetSevenFenQu(redList)[4];
                    reddr["D6"] = GetSevenFenQu(redList)[5];
                    reddr["D7"] = GetSevenFenQu(redList)[6];
                    sevenredtable.Rows.Add(reddr);

                    DataRow cleanreddr = sevencleanredtable.NewRow();
                    cleanreddr["QiHao"] = item.QiHao;
                    cleanreddr["R" + item.R1] = GetStr(item.R1.ToString());//红1
                    cleanreddr["R" + item.R2] = GetStr(item.R2.ToString());//红2
                    cleanreddr["R" + item.R3] = GetStr(item.R3.ToString());//红3
                    cleanreddr["R" + item.R4] = GetStr(item.R4.ToString());//红4
                    cleanreddr["R" + item.R5] = GetStr(item.R5.ToString());//红5
                    cleanreddr["R" + item.R6] = GetStr(item.R6.ToString());//红6
                    cleanreddr["D1"] = GetSevenFenQu(redList)[0];
                    cleanreddr["D2"] = GetSevenFenQu(redList)[1];
                    cleanreddr["D3"] = GetSevenFenQu(redList)[2];
                    cleanreddr["D4"] = GetSevenFenQu(redList)[3];
                    cleanreddr["D5"] = GetSevenFenQu(redList)[4];
                    cleanreddr["D6"] = GetSevenFenQu(redList)[5];
                    cleanreddr["D7"] = GetSevenFenQu(redList)[6];
                    sevencleanredtable.Rows.Add(cleanreddr);
                }

                for (int j = 1; j < 34; j++)
                {
                    int xint = 0;
                    for (int i = 0; i < sevenredtable.Rows.Count; i++)
                    {
                        if (string.IsNullOrEmpty(sevenredtable.Rows[i]["R" + j].ToString()))
                        {
                            xint++;
                            sevenredtable.Rows[i]["R" + j] = xint;
                        }
                        else
                        {
                            xint = 0;
                        }
                    }
                }

                if (this.IsHandleCreated)
                {
                    this.Invoke((MethodInvoker)delegate
                    {
                        if (flag)
                        {
                            sevencleanredtable.DefaultView.Sort = "QiHao DESC";
                            this.gridControl4.DataSource = sevencleanredtable.DefaultView.ToTable();
                        }
                        else
                        {
                            sevenredtable.DefaultView.Sort = "QiHao DESC";
                            this.gridControl4.DataSource = sevenredtable.DefaultView.ToTable();
                        }
                    });
                }
            }
        }

        private List<string> GetSevenFenQu(List<int> redList)
        {
            List<string> retlist = new List<string>();
            int xint1 = 0;
            int xint2 = 0;
            int xint3 = 0;
            int xint4 = 0;
            int xint5 = 0;
            int xint6 = 0;
            int xint7 = 0;
            foreach (int item in redList)
            {
                if (item < 6)
                {
                    xint1++;
                }
                else if (item > 5 && item < 11)
                {
                    xint2++;
                }
                else if (item > 10 && item < 16)
                {
                    xint3++;
                }
                else if (item > 15 && item < 21)
                {
                    xint4++;
                }
                else if (item > 20 && item < 26)
                {
                    xint5++;
                }
                else if (item > 25 && item < 31)
                {
                    xint6++;
                }
                else if (item > 30 && item < 34)
                {
                    xint7++;
                }
            }
            retlist.Add(xint1.ToString());
            retlist.Add(xint2.ToString());
            retlist.Add(xint3.ToString());
            retlist.Add(xint4.ToString());
            retlist.Add(xint5.ToString());
            retlist.Add(xint6.ToString());
            retlist.Add(xint7.ToString());
            return retlist;
        }
        #endregion

        #region * 篮球综合走势图
        /// <summary>
        /// 篮球综合走势图
        /// </summary>
        /// <param name="obj"></param>
        private void GetData5(object obj)
        {
            buletable.Clear();
            bulecleantable.Clear();
            if (listWinNo != null && listWinNo.Count > 0)
            {
                foreach (WinNo item in listWinNo)
                {
                    DataRow buledr = buletable.NewRow();
                    buledr["QiHao"] = item.QiHao;
                    buledr["R"] = GetStr(item.R1.ToString()) + " " + GetStr(item.R2.ToString()) + " " + GetStr(item.R3.ToString()) + " " + GetStr(item.R4.ToString()) + " " + GetStr(item.R5.ToString()) + " " + GetStr(item.R6.ToString());
                    buledr["B"] = GetStr(item.B.ToString());
                    buledr["B" + item.B] = "B" + GetStr(item.B.ToString());//篮球
                    buledr["X1"] = GetDa(item.B);//
                    buledr["X2"] = GetXiao(item.B);//
                    buledr["X3"] = GetJiShu(item.B);//
                    buledr["X4"] = GetOShu(item.B);//
                    buledr["X5"] = GetZhiShu(item.B);//
                    buledr["X6"] = GetHeShu(item.B);//
                    buledr["X7"] = GetFenQu1(item.B);//一区
                    buledr["X8"] = GetFenQu2(item.B);//二区
                    buledr["X9"] = GetFenQu3(item.B);//三区
                    buledr["X10"] = GetFenQu4(item.B);//四区
                    buledr["X11"] = GetWeiShu(item.B);//尾数
                    buledr["X12"] = GetWeiShuQuJian(item.B, 0);//0-1
                    buledr["X13"] = GetWeiShuQuJian(item.B, 2);//2-3
                    buledr["X14"] = GetWeiShuQuJian(item.B, 4);//4-5
                    buledr["X15"] = GetWeiShuQuJian(item.B, 6);//6-7
                    buledr["X16"] = GetWeiShuQuJian(item.B, 8);//8-9
                    buletable.Rows.Add(buledr);
                    //--
                    DataRow bulecleandr = bulecleantable.NewRow();
                    bulecleandr["QiHao"] = item.QiHao;
                    bulecleandr["R"] = GetStr(item.R1.ToString()) + " " + GetStr(item.R2.ToString()) + " " + GetStr(item.R3.ToString()) + " " + GetStr(item.R4.ToString()) + " " + GetStr(item.R5.ToString()) + " " + GetStr(item.R6.ToString());
                    bulecleandr["B"] = GetStr(item.B.ToString());
                    bulecleandr["B" + item.B] = GetStr(item.B.ToString());//篮球
                    bulecleandr["X1"] = GetDa(item.B);//
                    bulecleandr["X2"] = GetXiao(item.B);//
                    bulecleandr["X3"] = GetJiShu(item.B);//
                    bulecleandr["X4"] = GetOShu(item.B);//
                    bulecleandr["X5"] = GetZhiShu(item.B);//
                    bulecleandr["X6"] = GetHeShu(item.B);//
                    bulecleandr["X7"] = GetFenQu1(item.B);//一区
                    bulecleandr["X8"] = GetFenQu2(item.B);//二区
                    bulecleandr["X9"] = GetFenQu3(item.B);//三区
                    bulecleandr["X10"] = GetFenQu4(item.B);//四区
                    bulecleandr["X11"] = GetWeiShu(item.B);//尾数
                    bulecleandr["X12"] = GetWeiShuQuJian(item.B, 0);//0-1
                    bulecleandr["X13"] = GetWeiShuQuJian(item.B, 2);//2-3
                    bulecleandr["X14"] = GetWeiShuQuJian(item.B, 4);//4-5
                    bulecleandr["X15"] = GetWeiShuQuJian(item.B, 6);//6-7
                    bulecleandr["X16"] = GetWeiShuQuJian(item.B, 8);//8-9
                    bulecleantable.Rows.Add(bulecleandr);
                }

                for (int j = 1; j < 17; j++)
                {
                    int xint = 0;
                    for (int i = 0; i < buletable.Rows.Count; i++)
                    {
                        if (string.IsNullOrEmpty(buletable.Rows[i]["B" + j].ToString()))
                        {
                            xint++;
                            buletable.Rows[i]["B" + j] = xint;
                        }
                        else
                        {
                            xint = 0;
                        }
                    }
                }

                for (int j = 1; j < 17; j++)
                {
                    int xint = 0;
                    for (int i = 0; i < buletable.Rows.Count; i++)
                    {
                        if (string.IsNullOrEmpty(buletable.Rows[i]["X" + j].ToString()))
                        {
                            xint++;
                            buletable.Rows[i]["X" + j] = xint;
                        }
                        else
                        {
                            xint = 0;
                        }
                    }
                }

                if (this.IsHandleCreated)
                {
                    this.Invoke((MethodInvoker)delegate
                    {
                        if (flag)
                        {
                            bulecleantable.DefaultView.Sort = "QiHao DESC";
                            this.gridControl5.DataSource = bulecleantable.DefaultView.ToTable();
                        }
                        else
                        {
                            buletable.DefaultView.Sort = "QiHao DESC";
                            this.gridControl5.DataSource = buletable.DefaultView.ToTable();
                        }
                    });
                }
            }
        }

        /// <summary>
        /// 大数
        /// </summary>
        /// <param name="BuleCode"></param>
        /// <returns></returns>
        private string GetDa(int BuleCode)
        {
            if (BuleCode > 8)
            {
                return "";
            }
            else
            {
                return "";
            }
        }

        /// <summary>
        /// 小数
        /// </summary>
        /// <param name="BuleCode"></param>
        /// <returns></returns>
        private string GetXiao(int BuleCode)
        {
            if (BuleCode < 9)
            {
                return "";
            }
            else
            {
                return "";
            }
        }

        /// <summary>
        /// 奇数
        /// </summary>
        /// <param name="BuleCode"></param>
        /// <returns></returns>
        private string GetJiShu(int BuleCode)
        {
            if (BuleCode % 2 != 0)
            {
                return "";
            }
            else
            {
                return "";
            }
        }

        /// <summary>
        /// 偶数
        /// </summary>
        /// <param name="BuleCode"></param>
        /// <returns></returns>
        private string GetOShu(int BuleCode)
        {
            if (BuleCode % 2 == 0)
            {
                return "";
            }
            else
            {
                return "";
            }
        }

        /// <summary>
        /// 质数
        /// </summary>
        /// <param name="BuleCode"></param>
        /// <returns></returns>
        private string GetZhiShu(int BuleCode)
        {
            if (BuleCode == 1 || BuleCode == 2 || BuleCode == 3 || BuleCode == 5 || BuleCode == 7 || BuleCode == 11 || BuleCode == 13)
            {
                return "";
            }
            else
            {
                return "";
            }
        }

        /// <summary>
        /// 合数
        /// </summary>
        /// <param name="BuleCode"></param>
        /// <returns></returns>
        private string GetHeShu(int BuleCode)
        {
            if (BuleCode == 4 || BuleCode == 6 || BuleCode == 8 || BuleCode == 9 || BuleCode == 10 || BuleCode == 12 || BuleCode == 14 || BuleCode == 15 || BuleCode == 16)
            {
                return "";
            }
            else
            {
                return "";
            }
        }

        /// <summary>
        /// 分区1
        /// </summary>
        /// <param name="BuleCode"></param>
        /// <returns></returns>
        private string GetFenQu1(int BuleCode)
        {
            if (BuleCode < 5)
            {
                return "X" + BuleCode.ToString();
            }
            else
            {
                return "";
            }
        }

        /// <summary>
        /// 分区2
        /// </summary>
        /// <param name="BuleCode"></param>
        /// <returns></returns>
        private string GetFenQu2(int BuleCode)
        {
            if (BuleCode > 4 && BuleCode < 9)
            {
                return "X" + BuleCode.ToString();
            }
            else
            {
                return "";
            }
        }

        /// <summary>
        /// 分区3
        /// </summary>
        /// <param name="BuleCode"></param>
        /// <returns></returns>
        private string GetFenQu3(int BuleCode)
        {
            if (BuleCode > 8 && BuleCode < 13)
            {
                return "X" + BuleCode.ToString();
            }
            else
            {
                return "";
            }
        }

        /// <summary>
        /// 分区4
        /// </summary>
        /// <param name="BuleCode"></param>
        /// <returns></returns>
        private string GetFenQu4(int BuleCode)
        {
            if (BuleCode > 12)
            {
                return "X" + BuleCode.ToString();
            }
            else
            {
                return "";
            }
        }

        /// <summary>
        /// 尾数
        /// </summary>
        /// <param name="BuleCode"></param>
        /// <returns></returns>
        private string GetWeiShu(int BuleCode)
        {
            if (BuleCode < 10)
            {
                return BuleCode.ToString();
            }
            else
            {
                return BuleCode.ToString().Substring(1, 1);
            }
        }

        private string GetWeiShuQuJian(int BuleCode, int xint)
        {
            string weishu = GetWeiShu(BuleCode);
            if (int.Parse(weishu) >= 0 + xint && int.Parse(weishu) <= 1 + xint)
            {
                return "Y" + weishu;
            }
            else
            {
                return "";
            }
        }
        #endregion

        #region * 红球连号走势图
        /// <summary>
        /// 红球连号走势图
        /// </summary>
        /// <param name="obj"></param>
        private void GetData6(object obj)
        {
            lianhaotable.Clear();
            lianhaocleantable.Clear();
            if (listWinNo != null && listWinNo.Count > 0)
            {
                foreach (WinNo item in listWinNo)
                {
                    List<int> redList = new List<int>();
                    redList.Add(item.R1);
                    redList.Add(item.R2);
                    redList.Add(item.R3);
                    redList.Add(item.R4);
                    redList.Add(item.R5);
                    redList.Add(item.R6);
                    //--
                    DataRow reddr = lianhaotable.NewRow();
                    DataRow cleanreddr = lianhaocleantable.NewRow();
                    reddr["QiHao"] = item.QiHao;
                    cleanreddr["QiHao"] = item.QiHao;
                    reddr["R"] = GetStr(item.R1.ToString()) + " " + GetStr(item.R2.ToString()) + " " + GetStr(item.R3.ToString()) + " " + GetStr(item.R4.ToString()) + " " + GetStr(item.R5.ToString()) + " " + GetStr(item.R6.ToString());
                    cleanreddr["R"] = GetStr(item.R1.ToString()) + " " + GetStr(item.R2.ToString()) + " " + GetStr(item.R3.ToString()) + " " + GetStr(item.R4.ToString()) + " " + GetStr(item.R5.ToString()) + " " + GetStr(item.R6.ToString());
                    //--
                    List<string> list = new List<string>();
                    list = GetList(redList);
                    int group = 0;
                    if (list != null && list.Count > 0)
                    {
                        foreach (string strlist in list)
                        {
                            string[] arr = strlist.Split(",".ToCharArray());
                            group += arr.Count() - 1;
                            foreach (string code in arr)
                            {
                                reddr["R" + code] = "R" + GetStr(code);
                                cleanreddr["R" + code] = GetStr(code);
                            }
                        }
                    }
                    reddr["A"] = list.Count();
                    cleanreddr["A"] = list.Count();
                    reddr["B"] = group.ToString();
                    cleanreddr["B"] = group.ToString();
                    //--
                    lianhaotable.Rows.Add(reddr);
                    lianhaocleantable.Rows.Add(cleanreddr);
                }

                for (int j = 1; j < 34; j++)
                {
                    int xint = 0;
                    for (int i = 0; i < lianhaotable.Rows.Count; i++)
                    {
                        if (string.IsNullOrEmpty(lianhaotable.Rows[i]["R" + j].ToString()))
                        {
                            xint++;
                            lianhaotable.Rows[i]["R" + j] = xint;
                        }
                        else
                        {
                            xint = 0;
                        }
                    }
                }

                if (this.IsHandleCreated)
                {
                    this.Invoke((MethodInvoker)delegate
                    {
                        if (flag)
                        {
                            lianhaocleantable.DefaultView.Sort = "QiHao DESC";
                            this.gridControl6.DataSource = lianhaocleantable.DefaultView.ToTable();
                        }
                        else
                        {
                            lianhaotable.DefaultView.Sort = "QiHao DESC";
                            this.gridControl6.DataSource = lianhaotable.DefaultView.ToTable();
                        }
                    });
                }
            }
        }

        /// <summary>
        /// 计算连号
        /// </summary>
        /// <param name="RedCode"></param>
        /// <returns></returns>
        private List<string> GetList(List<int> RedCode)
        {
            List<string> retlist = new List<string>();
            for (int i = 0; i < RedCode.Count; i++)
            {
                string retstr = string.Empty;
                if (i < 5)
                {
                    if (RedCode[i + 1] - RedCode[i] == 1)//两连号
                    {
                        retstr = RedCode[i] + "," + RedCode[i + 1];
                    }
                }
                if (i < 4)
                {
                    if (RedCode[i + 2] - RedCode[i + 1] == 1 && RedCode[i + 1] - RedCode[i] == 1)//三连号
                    {
                        retstr = RedCode[i] + "," + RedCode[i + 1] + "," + RedCode[i + 2];
                    }
                }
                if (i < 3)
                {
                    if (RedCode[i + 3] - RedCode[i + 2] == 1 && RedCode[i + 2] - RedCode[i + 1] == 1 && RedCode[i + 1] - RedCode[i] == 1)//四连号
                    {
                        retstr = RedCode[i] + "," + RedCode[i + 1] + "," + RedCode[i + 2] + "," + RedCode[i + 3];
                    }
                }
                if (i < 2)
                {
                    if (RedCode[i + 4] - RedCode[i + 3] == 1 && RedCode[i + 3] - RedCode[i + 2] == 1 && RedCode[i + 2] - RedCode[i + 1] == 1 && RedCode[i + 1] - RedCode[i] == 1)//五连号
                    {
                        retstr = RedCode[i] + "," + RedCode[i + 1] + "," + RedCode[i + 2] + "," + RedCode[i + 3] + "," + RedCode[i + 4];
                    }
                }
                if (!string.IsNullOrEmpty(retstr))
                {
                    if (retlist != null && retlist.Count > 0)
                    {
                        var tmp = from c in retlist
                                  where ("," + c + ",").Contains("," + retstr + ",")
                                  select c;
                        if (tmp.Count() == 0)
                        {
                            retlist.Add(retstr);
                        }
                    }
                    else
                    {
                        retlist.Add(retstr);
                    }
                }
            }
            return retlist;
        }
        #endregion

        #region * 红球和值走势图
        /// <summary>
        /// 红球和值走势图
        /// </summary>
        /// <param name="obj"></param>
        private void GetData7(object obj)
        {
            hezhitable.Clear();
            hezhicleantable.Clear();
            if (listWinNo != null && listWinNo.Count > 0)
            {
                foreach (WinNo item in listWinNo)
                {
                    DataRow reddr = hezhitable.NewRow();
                    DataRow cleanreddr = hezhicleantable.NewRow();
                    reddr["QiHao"] = item.QiHao;
                    cleanreddr["QiHao"] = item.QiHao;
                    reddr["R"] = GetStr(item.R1.ToString()) + " " + GetStr(item.R2.ToString()) + " " + GetStr(item.R3.ToString()) + " " + GetStr(item.R4.ToString()) + " " + GetStr(item.R5.ToString()) + " " + GetStr(item.R6.ToString());
                    cleanreddr["R"] = GetStr(item.R1.ToString()) + " " + GetStr(item.R2.ToString()) + " " + GetStr(item.R3.ToString()) + " " + GetStr(item.R4.ToString()) + " " + GetStr(item.R5.ToString()) + " " + GetStr(item.R6.ToString());
                    decimal total = item.R1 + item.R2 + item.R3 + item.R4 + item.R5 + item.R6;
                    reddr["TOTAL"] = total;
                    cleanreddr["TOTAL"] = total;
                    //--
                    string r1 = total > 20 && total < 61 ? total.ToString() : "";
                    string r2 = total > 60 && total < 71 ? total.ToString() : "";
                    string r3 = total > 70 && total < 81 ? total.ToString() : "";
                    string r4 = total > 80 && total < 91 ? total.ToString() : "";
                    string r5 = total > 90 && total < 101 ? total.ToString() : "";
                    string r6 = total > 100 && total < 111 ? total.ToString() : "";
                    string r7 = total > 110 && total < 121 ? total.ToString() : "";
                    string r8 = total > 120 && total < 131 ? total.ToString() : "";
                    string r9 = total > 130 && total < 141 ? total.ToString() : "";
                    string r10 = total > 140 && total < 151 ? total.ToString() : "";
                    string r11 = total > 150 && total < 161 ? total.ToString() : "";
                    string r12 = total > 160 && total < 184 ? total.ToString() : "";
                    string w = total.ToString().Substring(total.ToString().Length - 1, 1);
                    //--
                    reddr["R1"] = !string.IsNullOrEmpty(r1) ? "R" + r1 : "";
                    reddr["R2"] = !string.IsNullOrEmpty(r2) ? "R" + r2 : "";
                    reddr["R3"] = !string.IsNullOrEmpty(r3) ? "R" + r3 : "";
                    reddr["R4"] = !string.IsNullOrEmpty(r4) ? "R" + r4 : "";
                    reddr["R5"] = !string.IsNullOrEmpty(r5) ? "R" + r5 : "";
                    reddr["R6"] = !string.IsNullOrEmpty(r6) ? "R" + r6 : "";
                    reddr["R7"] = !string.IsNullOrEmpty(r7) ? "R" + r7 : "";
                    reddr["R8"] = !string.IsNullOrEmpty(r8) ? "R" + r8 : "";
                    reddr["R9"] = !string.IsNullOrEmpty(r9) ? "R" + r9 : "";
                    reddr["R10"] = !string.IsNullOrEmpty(r10) ? "R" + r10 : "";
                    reddr["R11"] = !string.IsNullOrEmpty(r11) ? "R" + r11 : "";
                    reddr["R12"] = !string.IsNullOrEmpty(r12) ? "R" + r12 : "";
                    reddr["W"] = w;
                    reddr["W" + w] = "W" + w;
                    //--
                    cleanreddr["R1"] = r1;
                    cleanreddr["R2"] = r2;
                    cleanreddr["R3"] = r3;
                    cleanreddr["R4"] = r4;
                    cleanreddr["R5"] = r5;
                    cleanreddr["R6"] = r6;
                    cleanreddr["R7"] = r7;
                    cleanreddr["R8"] = r8;
                    cleanreddr["R9"] = r9;
                    cleanreddr["R10"] = r10;
                    cleanreddr["R11"] = r11;
                    cleanreddr["R12"] = r12;
                    cleanreddr["W"] = w;
                    cleanreddr["W" + w] = w;
                    //--
                    hezhitable.Rows.Add(reddr);
                    hezhicleantable.Rows.Add(cleanreddr);
                }

                for (int j = 1; j < 13; j++)
                {
                    int xint = 0;
                    for (int i = 0; i < hezhitable.Rows.Count; i++)
                    {
                        if (string.IsNullOrEmpty(hezhitable.Rows[i]["R" + j].ToString()))
                        {
                            xint++;
                            hezhitable.Rows[i]["R" + j] = xint;
                        }
                        else
                        {
                            xint = 0;
                        }
                    }
                }

                for (int j = 0; j < 10; j++)
                {
                    int xint = 0;
                    for (int i = 0; i < hezhitable.Rows.Count; i++)
                    {
                        if (string.IsNullOrEmpty(hezhitable.Rows[i]["W" + j].ToString()))
                        {
                            xint++;
                            hezhitable.Rows[i]["W" + j] = xint;
                        }
                        else
                        {
                            xint = 0;
                        }
                    }
                }

                if (this.IsHandleCreated)
                {
                    this.Invoke((MethodInvoker)delegate
                    {
                        if (flag)
                        {
                            hezhicleantable.DefaultView.Sort = "QiHao DESC";
                            this.gridControl7.DataSource = hezhicleantable.DefaultView.ToTable();
                        }
                        else
                        {
                            hezhitable.DefaultView.Sort = "QiHao DESC";
                            this.gridControl7.DataSource = hezhitable.DefaultView.ToTable();
                        }
                    });
                }
            }
        }
        #endregion

        #region * 历史数据
        /// <summary>
        /// 历史数据
        /// </summary>
        /// <param name="obj"></param>
        private void GetData8(object obj)
        {
            historytable.Clear();
            if (historyWinNo != null && historyWinNo.Count > 0)
            {
                foreach (WinNo item in historyWinNo)
                {
                    DataRow reddr = historytable.NewRow();
                    reddr["QiHao"] = item.QiHao;
                    reddr["R"] = GetStr(item.R1.ToString()) + " " + GetStr(item.R2.ToString()) + " " + GetStr(item.R3.ToString()) + " " + GetStr(item.R4.ToString()) + " " + GetStr(item.R5.ToString()) + " " + GetStr(item.R6.ToString());
                    reddr["B"] = GetStr(item.B.ToString());
                    for (int i = 0; i < item.Data.Count; i++)
                    {
                        reddr["A" + (i + 1)] = item.Data[i];
                    }
                    //--
                    historytable.Rows.Add(reddr);
                }

                if (this.IsHandleCreated)
                {
                    this.Invoke((MethodInvoker)delegate
                    {
                        historytable.DefaultView.Sort = "QiHao DESC";
                        this.gridControl8.DataSource = historytable.DefaultView.ToTable();
                    });
                }
            }
        }
        #endregion

        #region * 保证两位数
        /// <summary>
        /// 保证两位数
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        private string GetStr(string str)
        {
            string retstr = string.Empty;
            if (!string.IsNullOrEmpty(str) && str.Length > 0)
            {
                if (str.Length == 1)
                {
                    retstr = "0" + str;
                }
                else
                    retstr = str;
            }
            return retstr;
        }
        #endregion

    }
}

 

posted @ 2018-07-16 14:52  landv  阅读(2516)  评论(0编辑  收藏  举报