Example #1
0
        private void btnTianjian_Click(object sender, EventArgs e)
        {
            Xinshui xinshui = new Xinshui();
            xinshui.Riqi = dateTimePicker1.Value.Date.ToString("yyyy-MM-dd");
            xinshui.Bianhao1 = textBox1.Text;
            xinshui.Liansai1 = textBox2.Text;
            xinshui.Zhudui1 = textBox3.Text;
            xinshui.Rangqiushu1 = textBox4.Text;
            xinshui.Kedui1 = textBox5.Text;            
            xinshui.Result1 = textBox6.Text;

            
            xinshui.Bianhao2 = textBox7.Text;
            xinshui.Liansai2 = textBox8.Text;
            xinshui.Zhudui2 = textBox9.Text;
            xinshui.Rangqiushu2 = textBox10.Text;
            xinshui.Kedui2 = textBox11.Text;
            xinshui.Result2 = textBox12.Text;

            xinshui.OperateTime = DateTime.Now;
            xinshui.Operator = "吴林";
            xinshui.Lucky = -1;
            xinshui.Exclude = 0;
            

            new XinshuiDAL().InsertXinshui(xinshui);
            BindGrid();
            MessageBox.Show("添加成功!");
        }
        private Xinshui ConvertToXinshui(DataRow row)
        {

            Xinshui xinshui = new Xinshui();
            xinshui.Riqi  = row["riqi"].ToString();
            //xinshui.Beishu =  Convert.ToInt32(row["beishu"].ToString());
            xinshui.Bianhao1 = row["bianhao1"].ToString();
            xinshui.Liansai1 = row["liansai1"].ToString();
            xinshui.Zhudui1 = row["zhuidui1"].ToString();
            xinshui.Kedui1 = row["kedui1"].ToString();
            xinshui.Rangqiushu1 = row["rangqiushu1"].ToString();
            xinshui.Result1 = row["result1"].ToString();
            xinshui.Bianhao2 = row["bianhao2"].ToString();
            xinshui.Liansai2 = row["liansai2"].ToString();
            xinshui.Zhudui2 = row["zhudui2"].ToString();
            xinshui.Kedui2 = row["kedui2"].ToString();
            xinshui.Rangqiushu2 = row["rangqiushu2"].ToString();
            xinshui.Result2 = row["result2"].ToString();
            //xinshui.RealResult1 = row["realresult1"].ToString();
            //xinshui.RealResult2 = row["realresult2"].ToString();
            //xinshui.RealResultSp1 = row["realresultsp1"].ToString();
            //xinshui.RealResultSp2 = row["realresultsp2"].ToString();
            //xinshui.Lucky = Convert.ToInt32(row["lucky"].ToString());
            //xinshui.Jiangjin = Convert.ToDouble(row["jiangjin"].ToString());
            //xinshui.Exclude = Convert.ToInt32(row["exclude"].ToString());
            xinshui.Operator = "自动导入";
            xinshui.OperateTime = DateTime.Now;
            return xinshui;
        }
Example #3
0
        private void btnTouzhu_Click(object sender, EventArgs e)
        {
            XinshuiDAL dal = new XinshuiDAL();
            double shouyi = Convert.ToDouble(textBox13.Text);
            double needtowin = shouyi;
            //从头开始算
            DataSet dsXinshui = new XinshuiDAL().GetValidXinshui();
            foreach(DataRow row in dsXinshui.Tables[0].Rows){
                int beishu = Convert.ToInt32(row["beishu"]);
                //如果倍数为0,说明该条记录未开奖过
                if (beishu == 0)
                {
                    //如果为空,说明当前行没有进行过投注,需要投注,投注需要获取赔率,获取以前行的投注记录
                    string bianhao1 = row["bianhao1"].ToString();
                    string bianhao2 = row["bianhao2"].ToString();
                    string rangqiushu1 = row["rangqiushu1"].ToString();
                    string rangqiushu2 = row["rangqiushu2"].ToString();
                    string result1 = row["result1"].ToString();
                    string result2 = row["result2"].ToString();
                    string riqi = row["riqi"].ToString();
                    int id = Convert.ToInt32(row["id"].ToString());
                    string realresult1 = "";
                    string realresult2 = "";
                    string realresultsp1 = "";
                    string realresultsp2 = "";
                    string touzhusp1 = "";
                    string touzhusp2 = "";
                    //获取赔率
                    DataSet ds = dal.GetPeilv(riqi, bianhao1);
                    DataSet ds2 = dal.GetPeilv(riqi, bianhao2);
                    List<double> peilv1 = new List<double>();
                    List<double> peilv2 = new List<double>();
                    foreach (DataRow peilvrow in ds.Tables[0].Rows)
                    {

                        string rangqiushu = peilvrow["rangqiu"].ToString();
                        if (rangqiushu == "0" && rangqiushu1 == "0")
                        {
                           
                            foreach (char ch in result1.ToCharArray())
                            {
                                string  spString = "0";
                                switch(ch)
                                {
                                    case '3': spString = peilvrow["shengsp"].ToString(); break;
                                    case '1': spString = peilvrow["pingsp"].ToString(); break;
                                    case '0': spString = peilvrow["fusp"].ToString(); break;
                                }
                                peilv1.Add(Convert.ToDouble(spString));
                            }
                           
                        }
                        else if (rangqiushu != "0" && rangqiushu1 != "0")
                        {
                            
                            foreach (char ch in result1.ToCharArray())
                            {
                                string spString = "0";
                                switch (ch)
                                {
                                    case '3': spString = peilvrow["shengsp"].ToString(); break;
                                    case '1': spString = peilvrow["pingsp"].ToString(); break;
                                    case '0': spString = peilvrow["fusp"].ToString(); break;
                                }
                                peilv1.Add(Convert.ToDouble(spString));
                            }
                           
                        }

                    }
                    foreach (DataRow peilvrow in ds2.Tables[0].Rows)
                    {
                        string rangqiushu = peilvrow["rangqiu"].ToString();
                        if (rangqiushu == "0" && rangqiushu2 == "0")
                        {
                            
                            foreach (char ch in result2.ToCharArray())
                            {
                                string spString = "0";
                                switch (ch)
                                {
                                    case '3': spString = peilvrow["shengsp"].ToString(); break;
                                    case '1': spString = peilvrow["pingsp"].ToString(); break;
                                    case '0': spString = peilvrow["fusp"].ToString(); break;
                                }
                                peilv2.Add(Convert.ToDouble(spString));
                            }
                        }
                        else if (rangqiushu != "0" && rangqiushu2 != "0")
                        {                          
                            
                            foreach (char ch in result2.ToCharArray())
                            {
                                string spString = "0";
                                switch (ch)
                                {
                                    case '3': spString = peilvrow["shengsp"].ToString(); break;
                                    case '1': spString = peilvrow["pingsp"].ToString(); break;
                                    case '0': spString = peilvrow["fusp"].ToString(); break;
                                }
                                peilv2.Add(Convert.ToDouble(spString));
                            }
                        }
                    }

                    double sp1 = peilv1.Min();
                    double sp2 = peilv2.Min();
                    touzhusp1 = sp1.ToString();
                    touzhusp2 = sp2.ToString();
                    //这里得修改为result的长度的乘积
                    //int needBeishu = (int)(shouyi /2/ (sp1 * sp2 - 1));
                    int needBeishu = (int)(shouyi / 2 / (sp1 * sp2 - peilv1.Count * peilv2.Count));
                    int touru = needBeishu * peilv1.Count * peilv2.Count * 2;
                    double jiangjin = 0;
                    
                    //获取开奖信息
                    DataSet kaijiang1 = dal.GetKaijiang(riqi, bianhao1);
                    DataSet kaijiang2 = dal.GetKaijiang(riqi, bianhao2);

                    //如果没有开奖信息则报异常,且退出程序
                    //这里需要修改一下,不是退出,而是算出一个倍数,然后提示
                    if (kaijiang1.Tables[0].Rows.Count == 0 || kaijiang2.Tables[0].Rows.Count == 0)
                    {
                        lblRiqi.Text = riqi;
                        lblBeishu.Text = needBeishu.ToString();
                        lblShouyi.Text = shouyi.ToString();
                        MessageBox.Show("日期为"+ riqi + "应该投注" + needBeishu + "倍,预期收益为" + shouyi);
                        //riqi
                        //MessageBox.Show("缺少" + riqi + "的开奖信息,请检查数据再操作!");
                        return;
                    }
                    //获取开奖信息
                    DataRow kaijiangrow1 = kaijiang1.Tables[0].Rows[0];
                    DataRow kaijiangrow2 = kaijiang2.Tables[0].Rows[0];
                    

                    bool zhongjiang1 = false;
                    bool zhongjiang2 = false;

                    if (rangqiushu1 != "0")
                    {
                        string rqspfresult1 = kaijiangrow1["rqspfresult"].ToString();
                        if(result1.IndexOf(rqspfresult1) != -1){
                            zhongjiang1 = true;
                        }
                        realresult1 = rqspfresult1;
                        realresultsp1 = kaijiangrow1["rqspfsp"].ToString();
                    }
                    else
                    {
                        string spfresult1 = kaijiangrow1["spfresult"].ToString();
                        if(result1.IndexOf(spfresult1) != -1){
                            zhongjiang1 = true;
                        }
                        realresult1 = spfresult1;
                        realresultsp1 = kaijiangrow1["spfsp"].ToString();
                    }

                    if (rangqiushu2 != "0")
                    {
                        string rqspfresult2 = kaijiangrow2["rqspfresult"].ToString();
                        if (result2.IndexOf(rqspfresult2) != -1)
                        {
                            zhongjiang2 = true;
                        }
                        realresult2 = rqspfresult2;
                        realresultsp2 = kaijiangrow2["rqspfsp"].ToString();
                    }
                    else
                    {
                        string spfresult2 = kaijiangrow2["spfresult"].ToString();
                        if (result2.IndexOf(spfresult2) != -1)
                        {
                            zhongjiang2 = true;
                        }
                        realresult2 = spfresult2;
                        realresultsp2 = kaijiangrow2["spfsp"].ToString();
                    }
                    //判断是否中奖,如果没有中奖则要加入收益,作为下一行的收益
                    int reallucky = 0;
                    if(zhongjiang1 && zhongjiang2)
                    {
                        reallucky = 1;
                    }
                    if (reallucky != 1)
                    {
                        shouyi = shouyi + touru;
                    }
                    else
                    {
                        //如果中奖,则收益reset为原始收益
                        shouyi = Convert.ToDouble(textBox13.Text);
                        jiangjin = touru * Convert.ToDouble(touzhusp1) * Convert.ToDouble(touzhusp2) /peilv1.Count /peilv2.Count;
                    }
                    
                    //更新当前行数据
                    Xinshui xinshui = new Xinshui();
                    xinshui.ID = id;
                    xinshui.Beishu = needBeishu;
                    xinshui.Touru = touru;
                    xinshui.Lucky = reallucky;

                    xinshui.Jiangjin = jiangjin;
                    xinshui.RealResult1 = realresult1;
                    xinshui.RealResult2 = realresult2;
                    xinshui.RealResultSp1 = realresultsp1;
                    xinshui.RealResultSp2 = realresultsp2;
                    xinshui.TouzhuSp1 = touzhusp1;
                    xinshui.TouzhuSp2 = touzhusp2;
                    dal.UpdateXinshui(xinshui);

                }
                else
                {
                    //如果倍数不为空,则说明已经处理过,只需要判断该条记录是否中奖,判断lucky标志,如果lucky为2,则终止,说明有异常数据
                    int lucky = Convert.ToInt32(row["lucky"].ToString());
                    if(lucky == 2 || lucky == -1){
                        MessageBox.Show("有异常数据,请检查数据再执行。");
                        return;
                    }
                    else if(lucky == 1)
                    {
                        shouyi = Convert.ToDouble(textBox13.Text);

                    }
                    else if(lucky == 0)
                    {
                        int realbeishu = Convert.ToInt32(row["beishu"].ToString());
                        string result1 = row["result1"].ToString();
                        string result2 = row["result2"].ToString();
                        int touru = realbeishu * result1.Length * result2.Length;
                        shouyi = shouyi + touru;
                    }
                }
                
                
            }
            MessageBox.Show("自动投注成功!");
        }
Example #4
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            string url = @"http://zx.aicai.com/zx/zc";
            string htmlData = GetHtmlFromUrl(url);

            htmlData = htmlData.Replace("</option>;","</option>");
            HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
            document.LoadHtml(htmlData);
            HtmlNode rootNode = document.DocumentNode;
            HtmlNode zjBackSelect = rootNode.SelectSingleNode(@"//div[@class='zjbackSelect']");
            //这里不知道为什么取不到innertext,只能换策略
            string selectText = zjBackSelect.InnerText;
            selectText = selectText.Substring(selectText.IndexOf("战绩回查") + 5).Trim();
            string[] options = selectText.Replace("2014"," 2014").Trim().Split(' ');
            //HtmlNodeCollection options = zjBackSelect.SelectNodes(@"./select/option[@selected='selected']");
            HtmlNode tjList = rootNode.SelectSingleNode(@"//div[@class='tjLis']");
            HtmlNodeCollection tables = tjList.SelectNodes(@"./table[@class='ke-zeroborder']");

            for (int i = 0; i < options.Length; i++)
            {
                String option = options[i];
                HtmlNode table = tables[i];

                //获取相关的记录插入心水推荐
                string riqi = DateTime.ParseExact(option, "yyyyMMdd", CultureInfo.CurrentCulture).ToString("yyyy-MM-dd");
                HtmlNodeCollection trs = table.SelectNodes(@"./tbody/tr");
                HtmlNode tr1 = trs[0];
                HtmlNode tr2 = trs[1];

                HtmlNodeCollection tds1 = tr1.SelectNodes(@"./td");
                HtmlNodeCollection tds2 = tr2.SelectNodes(@"./td");

                Xinshui xinshui = new Xinshui();
                xinshui.Riqi = riqi;
                string preBianhao1 = tds1[0].InnerText;

                xinshui.Bianhao1 = preBianhao1.Substring(preBianhao1.Length - 3);
                xinshui.Liansai1 = tds1[1].InnerText;
                xinshui.Zhudui1 = tds1[2].InnerText;
                xinshui.Rangqiushu1 = tds1[3].InnerText;
                xinshui.Kedui1 = tds1[4].InnerText;
                string preResult1 = tds1[5].InnerText;
                xinshui.Result1 = preResult1.Substring(preResult1.IndexOf(":") + 1);

                string preBianhao2 = tds2[0].InnerText;
                xinshui.Bianhao2 = preBianhao2.Substring(preBianhao2.Length - 3);
                xinshui.Liansai2 = tds2[1].InnerText;
                xinshui.Zhudui2 = tds2[2].InnerText;
                xinshui.Rangqiushu2 = tds2[3].InnerText;
                xinshui.Kedui2 = tds2[4].InnerText;
                string preResult2 = tds2[5].InnerText;
                xinshui.Result2 = preResult2.Substring(preResult2.IndexOf(":") + 1);

                xinshui.Exclude = 0;
                xinshui.Operator = "自动导入";
                xinshui.OperateTime = DateTime.Now;
               
                XinshuiDAL dal = new XinshuiDAL();

                //增加投注sp1和投注sp2的逻辑
                DataSet ds = dal.GetPeilv(riqi, xinshui.Bianhao1);
                DataSet ds2 = dal.GetPeilv(riqi, xinshui.Bianhao2);


                dal.InsertXinshuiWhenNotExist(xinshui);

            }
            MessageBox.Show("导入成功!");

        }
Example #5
0
        public void InsertXinshuiWhenNotExist(Xinshui xinshui)
        {
            try
            {
                int total = 0;
                string conStr = "server=localhost;User Id=root;database=aicai;" +
                               "Password=root;Character Set=utf8;";
                using (MySqlConnection mySqlCon = new MySqlConnection(conStr))
                {
                    mySqlCon.Open();
                    using (MySqlCommand existCom = mySqlCon.CreateCommand())
                    {
                        string existSql = @"select count(*) from xinshuituijian where riqi = ?riqi and bianhao1 = ?bianhao1 and bianhao2=?bianhao2";
                        existCom.CommandText = existSql;
                        existCom.Parameters.AddWithValue("?riqi", xinshui.Riqi);
                        existCom.Parameters.AddWithValue("?bianhao1", xinshui.Bianhao1);
                        existCom.Parameters.AddWithValue("?bianhao2", xinshui.Bianhao2);
                        object obj = existCom.ExecuteScalar();
                        int resultCount = Convert.ToInt32(obj);
                        if (resultCount != 0)
                        {
                            return;
                        }

                    }
                    using (MySqlCommand mySqlCom = mySqlCon.CreateCommand())
                    {
                        //这里需要注意的是在 Sql 语句中有一个参数是 ?BlogsName 
                        //很明显,这个参数有点古怪,和我们一直使用的 @ 不一样, 
                        //这是因为在 MySql 以前的提供的 .NET Connector 中 
                        //都是采用 ? 来标志一个参数的,而现在的 .NET Connector 呢, 
                        //您既可以采用 ? 来标志一个参数,您也可以使用一个 @ 符号来标志一个参数 
                        //新版的 .NET Connector 对此都是支持的 
                        string sqlStr = @"
insert into xinshuituijian(
riqi,beishu,bianhao1,liansai1,zhudui1,kedui1,rangqiushu1,result1,bianhao2,liansai2,zhudui2,kedui2,rangqiushu2,result2,realresult1,realresult2,realresultsp1,realresultsp2,
lucky,jiangjin,exclude,operator,operatetime
)
values(
?riqi,?beishu,?bianhao1,?liansai1,?zhudui1,?kedui1,?rangqiushu1,?result1,?bianhao2,?liansai2,?zhudui2,
?kedui2,?rangqiushu2,?result2,?realresult1,?realresult2,?realresultsp1,?realresultsp2,?lucky,?jiangjin,?exclude,?operator,?operatetime
)
";
                        //"SELECT COUNT(*) FROM BlogsUsers WHERE BlogsName=?BlogsName";
                        mySqlCom.CommandText = sqlStr;
                        mySqlCom.Parameters.AddWithValue("?riqi", xinshui.Riqi);
                        mySqlCom.Parameters.AddWithValue("?beishu", xinshui.Beishu);
                        mySqlCom.Parameters.AddWithValue("?bianhao1", xinshui.Bianhao1);
                        mySqlCom.Parameters.AddWithValue("?liansai1", xinshui.Liansai1);
                        mySqlCom.Parameters.AddWithValue("?zhudui1", xinshui.Zhudui1);
                        mySqlCom.Parameters.AddWithValue("?kedui1", xinshui.Kedui1);
                        mySqlCom.Parameters.AddWithValue("?rangqiushu1", xinshui.Rangqiushu1);
                        mySqlCom.Parameters.AddWithValue("?result1", xinshui.Result1);
                        mySqlCom.Parameters.AddWithValue("?bianhao2", xinshui.Bianhao2);
                        mySqlCom.Parameters.AddWithValue("?liansai2", xinshui.Liansai2);
                        mySqlCom.Parameters.AddWithValue("?zhudui2", xinshui.Zhudui2);
                        mySqlCom.Parameters.AddWithValue("?kedui2", xinshui.Kedui2);
                        mySqlCom.Parameters.AddWithValue("?rangqiushu2", xinshui.Rangqiushu2);
                        mySqlCom.Parameters.AddWithValue("?result2", xinshui.Result2);
                        mySqlCom.Parameters.AddWithValue("?realresult1", xinshui.RealResult1);
                        mySqlCom.Parameters.AddWithValue("?realresult2", xinshui.RealResult2);
                        mySqlCom.Parameters.AddWithValue("?realresultsp1", xinshui.RealResultSp1);
                        mySqlCom.Parameters.AddWithValue("?realresultsp2", xinshui.RealResultSp2);
                        mySqlCom.Parameters.AddWithValue("?lucky", xinshui.Lucky);
                        mySqlCom.Parameters.AddWithValue("?jiangjin", xinshui.Jiangjin);
                        mySqlCom.Parameters.AddWithValue("?exclude", xinshui.Exclude);
                        mySqlCom.Parameters.AddWithValue("?operator", xinshui.Operator);
                        mySqlCom.Parameters.AddWithValue("?operatetime", xinshui.OperateTime);
                        mySqlCom.ExecuteScalar();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
           
        }
Example #6
0
        public void UpdateXinshui(Xinshui xinshui)
        {
            string conStr = "server=localhost;User Id=root;database=aicai;" +
                         "Password=root;Character Set=utf8;";
            using (MySqlConnection mySqlCon = new MySqlConnection(conStr))
            {
                mySqlCon.Open();
                using (MySqlCommand mySqlCom = mySqlCon.CreateCommand())
                {
                    MySqlDataAdapter da = new MySqlDataAdapter();
                    //string sqlStr = @"Select bianhao,liansai,zhudui,kedui,rangqiu,shengsp,pingsp,fusp,riqi from peilv order by bianhao";
                    string sqlStr = @"
update xinshuituijian
set beishu = ?beishu,
Touru = ?Touru,
RealResult1 = ?RealResult1,
RealResult2 = ?RealResult2,
RealResultSp1 = ?RealResultSp1,
RealResultSp2 = ?RealResultSp2,
TouzhuSp1 = ?TouzhuSp1,
TouzhuSp2 = ?TouzhuSp2,
Lucky = ?Lucky,
Jiangjin = ?Jiangjin
where id = ?id";

                    mySqlCom.CommandText = sqlStr;
                    mySqlCom.Parameters.AddWithValue("?beishu", xinshui.Beishu);
                    mySqlCom.Parameters.AddWithValue("?Touru", xinshui.Touru);
                    mySqlCom.Parameters.AddWithValue("?RealResult1", xinshui.RealResult1);
                    mySqlCom.Parameters.AddWithValue("?RealResult2", xinshui.RealResult2);
                    mySqlCom.Parameters.AddWithValue("?RealResultSp1", xinshui.RealResultSp1);
                    mySqlCom.Parameters.AddWithValue("?RealResultSp2", xinshui.RealResultSp2);
                    mySqlCom.Parameters.AddWithValue("?TouzhuSp1", xinshui.TouzhuSp1);
                    mySqlCom.Parameters.AddWithValue("?TouzhuSp2", xinshui.TouzhuSp2);
                    mySqlCom.Parameters.AddWithValue("?Lucky", xinshui.Lucky);
                    mySqlCom.Parameters.AddWithValue("?Jiangjin", xinshui.Jiangjin);
                    mySqlCom.Parameters.AddWithValue("?id", xinshui.ID);
                    mySqlCom.ExecuteScalar();

                }
            }
           
        }