Пример #1
0
        public int InsertTouzhuSpf(TouzhuSpf spf)
        {
            try
            {
                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())
                    {
                        
                        string sqlStr = @"
insert into touzhu_spf
(
batchid,riqi,zhudui,kedui,result,peilv,beishu,rangqiu,lucky,jiangjin,operator,operatetime

)
values
(
?batchid,?riqi,?zhudui,?kedui,?result,?peilv,?beishu,?rangqiu,?lucky,?jiangjin,?operator,?operatetime
)
";
                        mySqlCom.CommandText = sqlStr;
                        mySqlCom.Parameters.AddWithValue("?batchid", spf.BatchID);
                        mySqlCom.Parameters.AddWithValue("?riqi", spf.Riqi);
                        mySqlCom.Parameters.AddWithValue("?zhudui", spf.Zhudui);
                        mySqlCom.Parameters.AddWithValue("?kedui", spf.Kedui);
                        mySqlCom.Parameters.AddWithValue("?result", spf.Result);
                        mySqlCom.Parameters.AddWithValue("?peilv", spf.Peilv);
                        mySqlCom.Parameters.AddWithValue("?beishu", spf.Beishu);
                        mySqlCom.Parameters.AddWithValue("?rangqiu", spf.Rangqiu);
                        mySqlCom.Parameters.AddWithValue("?lucky", spf.Lucky);
                        mySqlCom.Parameters.AddWithValue("?jiangjin", spf.Jiangjin);
                        mySqlCom.Parameters.AddWithValue("?operator", spf.Operator);
                        mySqlCom.Parameters.AddWithValue("?operatetime", spf.OperateTime);
                        mySqlCom.ExecuteScalar();
                        return 0;

                    }
                }
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
                return -1;
            }
            
        }
Пример #2
0
        private void btnXiazhu_Click(object sender, EventArgs e)
        {
            long batchid = Convert.ToInt64(DateTime.Now.ToString("MMddhhmmss") + DateTime.Now.Millisecond);
            //二串一
            string zhudui = "";
            string kedui = "";
            string riqi = "";
            string rangqiu = "";
            string peilv = "";
            string result = "";
            string rangqiu1 = "";
            string rangqiu2 = "";
            string bianhao1 = "";
            string bianhao2 = "";
            DataGridViewRow touzhurow = null;
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if(row.Cells["beishu"].Value.ToString() == "0")
                {
                    touzhurow = row;
                    zhudui = row.Cells["zhudui1"].Value.ToString() + "," + row.Cells["zhudui2"].Value.ToString();
                    kedui = row.Cells["kedui1"].Value.ToString() + "," + row.Cells["kedui2"].Value.ToString();
                    riqi = row.Cells["riqi"].Value.ToString() + "," + row.Cells["riqi"].Value.ToString();
                    rangqiu = row.Cells["rangqiushu1"].Value.ToString() +"," +row.Cells["rangqiushu2"].Value.ToString();
                    //peilv = row.Cells["touzhusp1"].Value.ToString() + "," + row.Cells["touzhusp2"].Value.ToString();
                    rangqiu1 = row.Cells["rangqiushu1"].Value.ToString();
                    rangqiu2 = row.Cells["rangqiushu2"].Value.ToString();

                    string result1= row.Cells["result1"].Value.ToString();
                    string result2 = row.Cells["result2"].Value.ToString();
                    foreach (char ch1 in result1.ToCharArray())
                    {
                        foreach (char ch2 in result2.ToCharArray())
                        {
                            double peilv1 = GetPeilv(bianhao1, riqi, rangqiu1, ch1.ToString());
                            double peilv2 = GetPeilv(bianhao2, riqi, rangqiu2, ch2.ToString());
                            peilv = peilv1 + "," + peilv2;
                            result = GetZhongwenResult(ch1.ToString()) + "," + GetZhongwenResult(ch2.ToString());

                            TouzhuSpf touspf = new TouzhuSpf();
                            touspf.Beishu = Convert.ToInt32(lblBeishu.Text);
                            touspf.Lucky = -1; //-1表示未验证是否中奖
                            touspf.Operator = "吴林";
                            touspf.OperateTime = DateTime.Now;
                            touspf.Jiangjin = "0";
                            touspf.Zhudui = zhudui;
                            touspf.Kedui = kedui;
                            touspf.Result = result;
                            touspf.Peilv = peilv;
                            touspf.Rangqiu = rangqiu;
                            touspf.Riqi = riqi;

                            touspf.BatchID = batchid;
                            new TouzhuSpfDAL().InsertTouzhuSpf(touspf);
                        }
                    }
                    
                    break;
                }
            }
            if (touzhurow != null)
            {
                //TouzhuSpf touspf = new TouzhuSpf();
                //touspf.Beishu = Convert.ToInt32(lblBeishu.Text);
                //touspf.Lucky = -1; //-1表示未验证是否中奖
                //touspf.Operator = "吴林";
                //touspf.OperateTime = DateTime.Now;
                //touspf.Jiangjin = "0";
                //touspf.Zhudui = zhudui;
                //touspf.Kedui = kedui;
                //touspf.Result = result;
                //touspf.Peilv = peilv;
                //touspf.Rangqiu = rangqiu;
                //touspf.Riqi = riqi;

                //touspf.BatchID = batchid;
                //new TouzhuSpfDAL().InsertTouzhuSpf(touspf);

                //这里插入income数据
                Income income = new Income();
                income.Amount = Convert.ToDouble(lblBeishu.Text) * touzhurow.Cells["result1"].Value.ToString().Length *touzhurow.Cells["result2"].Value.ToString().Length * 2;
                income.IncomeType = "购奖";
                income.OperateTime = DateTime.Now;
                income.Operator = "吴林";
                income.TouzhuType = "竞彩足球";
                income.TouzhuID = batchid;
                new IncomeDAL().InsertIncome(income);
                MessageBox.Show("投注成功!");
            }
            else
            {
                MessageBox.Show("没有需要投注的比赛!");
            }
            
        }
Пример #3
0
        private void SaveTouzhu(Dictionary<string, List<SelectedTouzhu>> dic, int chuanShu, string type)
        {
            int arrayCount = dic.Keys.Count;
            int[] peilvCount = new int[arrayCount];
            List<SelectedTouzhu>[] selectedTouzhus = new List<SelectedTouzhu>[arrayCount];
            int counter = 0;
            int touru = 1;
            foreach (String key in dic.Keys)
            {
                peilvCount[counter] = dic[key].Count;
                selectedTouzhus[counter] = dic[key];
                counter++;
                touru = touru * dic[key].Count;
            }

            double maxNumber = Math.Pow(10, arrayCount);
            int chuan = chuanShu;

            long batchid = Convert.ToInt64(DateTime.Now.ToString("MMddhhmmss") + DateTime.Now.Millisecond);

            for (int i = 0; i < maxNumber; i++)
            {
                int[] digits = new int[arrayCount];
                if (GetNoZeroCount(i, ref digits) == chuan)
                {
                    //所在位置不大于对应数组的值
                    if (NotLargeThanArray(i, peilvCount))
                    {
                        List<SelectedTouzhu> composite = new List<SelectedTouzhu>();
                        for (int j = 0; j < digits.Length; j++)
                        {
                            int digit = digits[j];
                            if (digit != 0)
                            {
                                composite.Add(selectedTouzhus[j][digit - 1]);
                            }
                        }
                        //将组合数据保存在数据库中
                        string riqi = "";
                        string zhudui = "";
                        string kedui = "";
                        string result = "";
                        string peilv = "";
                        string beishu = "";
                        string rangqiu = "";
                        string jiangjin = "";
                        string Operator = "";
                        string operatetime = "";

                        foreach (SelectedTouzhu tou in composite)
                        {
                            riqi += tou.Riqi + ",";
                            zhudui += tou.Zhudui + ",";
                            kedui += tou.Kedui + ",";
                            result += tou.Result + ",";
                            peilv += tou.Peilv + ",";
                            rangqiu += tou.Rangqiu + ",";

                        }
                        zhudui = zhudui.Trim(',');
                        kedui = kedui.Trim(',');
                        result = result.Trim(',');
                        peilv = peilv.Trim(',');
                        rangqiu = rangqiu.Trim(',');
                        riqi = riqi.Trim(',');
                        TouzhuSpf touspf = new TouzhuSpf();
                        touspf.Beishu = 1000;
                        touspf.Lucky = -1; //-1表示未验证是否中奖
                        touspf.Operator = "吴林";
                        touspf.OperateTime = DateTime.Now;
                        touspf.Jiangjin = "0";
                        touspf.Zhudui = zhudui;
                        touspf.Kedui = kedui;
                        touspf.Result = result;
                        touspf.Peilv = peilv;
                        touspf.Rangqiu = rangqiu;
                        touspf.Riqi = riqi;

                        touspf.BatchID = batchid;
                        new TouzhuSpfDAL().InsertTouzhuSpf(touspf);
                    }
                }
            }

            //这里插入income数据
            Income income = new Income();
            //income.Amount = Convert.ToDouble(txtTouru.Text);
            income.Amount = touru * 1000.0 * 2;
            income.IncomeType = "购奖";
            income.OperateTime = DateTime.Now;
            income.Operator = "吴林";

            income.TouzhuType = type;
            income.TouzhuID = batchid;
            new IncomeDAL().InsertIncome(income);


        }
Пример #4
0
        private void btnTouzhu_Click(object sender, EventArgs e)
        {
            //先获取选中的两行
            List<DataGridViewRow> rows = new List<DataGridViewRow>();
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (row.DefaultCellStyle.BackColor == Color.Green)
                {
                    rows.Add(row);
                }
            }
            TouzhuSpfDAL dal = new TouzhuSpfDAL();
            TouzhuSpf spf = new TouzhuSpf();

            long batchid = Convert.ToInt64(DateTime.Now.ToString("MMddhhmmss") + DateTime.Now.Millisecond);
            spf.BatchID = batchid;
            spf.Beishu = 1000;
            spf.Riqi = rows[0].Cells["时间"].Value.ToString() + "," + rows[1].Cells["时间"].Value.ToString();
            spf.Zhudui = rows[0].Cells["主队"].Value.ToString() + "," + rows[1].Cells["主队"].Value.ToString();
            spf.Kedui = rows[0].Cells["客队"].Value.ToString() + "," + rows[1].Cells["客队"].Value.ToString();
            spf.Result = rows[0].Cells["预测结果"].Value.ToString() + "," + rows[1].Cells["预测结果"].Value.ToString();
            spf.Rangqiu = rows[0].Cells["让球数"].Value.ToString() + "," + rows[1].Cells["让球数"].Value.ToString();
            spf.Peilv = rows[0].Cells["赔率"].Value.ToString() + "," + rows[1].Cells["赔率"].Value.ToString();

            spf.Lucky = -1;
            spf.OperateTime = DateTime.Now;
            spf.Operator = "系统随机推荐";
            dal.InsertTouzhuSpf(spf);

            MessageBox.Show("投注成功!");
        }