示例#1
0
        private void TouzhuByNatureForMingren()
        {
            //按自然顺序二串一
            Dictionary<String, List<SelectedTouzhu>> dic = new Dictionary<string, List<SelectedTouzhu>>();
            SelectedTouzhu touzhu = null;
            foreach (DataGridViewRow row in dgvTuijian.Rows)
            {
                if (dic.Keys.Count == 2)
                {
                    SaveTouzhu(dic, 2, "竞彩足球-自动投注5");
                    dic = new Dictionary<string, List<SelectedTouzhu>>();
                }
                bool flag = false;
                if (row.Cells[5].Style.BackColor == Color.Red || row.Cells[5].Style.BackColor == Color.Blue)
                {
                    touzhu = new SelectedTouzhu();
                    touzhu.Zhudui = row.Cells[2].Value.ToString();
                    touzhu.Kedui = row.Cells[3].Value.ToString();
                    touzhu.Rangqiu = row.Cells[4].Value.ToString();
                    touzhu.Result = "胜";
                    touzhu.Peilv = Convert.ToDouble(row.Cells[5].Value);
                    touzhu.Riqi = row.Cells[8].Value.ToString();
                    flag = true;
                    if (flag)
                    {
                        String key = row.Cells[2].Value.ToString() + row.Cells[3].Value.ToString() + row.Cells[8].Value.ToString();
                        List<SelectedTouzhu> sel = null;
                        if (dic.TryGetValue(key, out sel))
                        {
                            sel.Add(touzhu);

                        }
                        else
                        {
                            sel = new List<SelectedTouzhu>();
                            sel.Add(touzhu);
                            dic[key] = sel;
                        }
                    }
                }
                if (row.Cells[6].Style.BackColor == Color.Red || row.Cells[6].Style.BackColor == Color.Blue)
                {
                    touzhu = new SelectedTouzhu();
                    touzhu.Zhudui = row.Cells[2].Value.ToString();
                    touzhu.Kedui = row.Cells[3].Value.ToString();
                    touzhu.Rangqiu = row.Cells[4].Value.ToString();
                    touzhu.Result = "平";
                    touzhu.Peilv = Convert.ToDouble(row.Cells[6].Value);
                    touzhu.Riqi = row.Cells[8].Value.ToString();
                    flag = true;
                    if (flag)
                    {
                        String key = row.Cells[2].Value.ToString() + row.Cells[3].Value.ToString() + row.Cells[8].Value.ToString();
                        List<SelectedTouzhu> sel = null;
                        if (dic.TryGetValue(key, out sel))
                        {
                            sel.Add(touzhu);

                        }
                        else
                        {
                            sel = new List<SelectedTouzhu>();
                            sel.Add(touzhu);
                            dic[key] = sel;
                        }
                    }
                }
                if (row.Cells[7].Style.BackColor == Color.Red || row.Cells[7].Style.BackColor == Color.Blue)
                {
                    touzhu = new SelectedTouzhu();
                    touzhu.Zhudui = row.Cells[2].Value.ToString();
                    touzhu.Kedui = row.Cells[3].Value.ToString();
                    touzhu.Rangqiu = row.Cells[4].Value.ToString();
                    touzhu.Result = "负";
                    touzhu.Peilv = Convert.ToDouble(row.Cells[7].Value);
                    touzhu.Riqi = row.Cells[8].Value.ToString();
                    flag = true;
                    if (flag)
                    {
                        String key = row.Cells[2].Value.ToString() + row.Cells[3].Value.ToString() + row.Cells[8].Value.ToString();
                        List<SelectedTouzhu> sel = null;
                        if (dic.TryGetValue(key, out sel))
                        {
                            sel.Add(touzhu);

                        }
                        else
                        {
                            sel = new List<SelectedTouzhu>();
                            sel.Add(touzhu);
                            dic[key] = sel;
                        }
                    }
                }
            }
        }
示例#2
0
        private void clbChuanJiang_ItemCheck(object sender, ItemCheckEventArgs e)
        {
          
            
            //获取选中的比赛
            Dictionary<String, List<SelectedTouzhu>> dic = new Dictionary<string, List<SelectedTouzhu>>();
            SelectedTouzhu touzhu = null;
            foreach (DataGridViewRow row in dgPeilv.Rows)
            {
                bool flag = false;
                if (row.Cells[5].Selected == true)
                {
                    touzhu = new SelectedTouzhu();
                    touzhu.Zhudui = row.Cells[2].Value.ToString();
                    touzhu.Kedui = row.Cells[3].Value.ToString();
                    touzhu.Rangqiu = row.Cells[4].Value.ToString();
                    touzhu.Result = "胜";
                    touzhu.Peilv = Convert.ToDouble(row.Cells[5].Value);
                    touzhu.Riqi = row.Cells[8].Value.ToString();
                    flag = true;
                    if (flag)
                    {
                        String key = row.Cells[2].Value.ToString() + row.Cells[3].Value.ToString() + row.Cells[8].Value.ToString();
                        List<SelectedTouzhu> sel = null;
                        if (dic.TryGetValue(key, out sel))
                        {
                            sel.Add(touzhu);

                        }
                        else
                        {
                            sel = new List<SelectedTouzhu>();
                            sel.Add(touzhu);
                            dic[key] = sel;
                        }
                    }
                }
                if (row.Cells[6].Selected == true)
                {
                    touzhu = new SelectedTouzhu();
                    touzhu.Zhudui = row.Cells[2].Value.ToString();
                    touzhu.Kedui = row.Cells[3].Value.ToString();
                    touzhu.Rangqiu = row.Cells[4].Value.ToString();
                    touzhu.Result = "平";
                    touzhu.Peilv = Convert.ToDouble(row.Cells[6].Value);
                    touzhu.Riqi = row.Cells[8].Value.ToString();
                    flag = true;
                    if (flag)
                    {
                        String key = row.Cells[2].Value.ToString() + row.Cells[3].Value.ToString() + row.Cells[8].Value.ToString();
                        List<SelectedTouzhu> sel = null;
                        if (dic.TryGetValue(key, out sel))
                        {
                            sel.Add(touzhu);

                        }
                        else
                        {
                            sel = new List<SelectedTouzhu>();
                            sel.Add(touzhu);
                            dic[key] = sel;
                        }
                    }
                }
                if (row.Cells[7].Selected == true)
                {
                    touzhu = new SelectedTouzhu();
                    touzhu.Zhudui = row.Cells[2].Value.ToString();
                    touzhu.Kedui = row.Cells[3].Value.ToString();
                    touzhu.Rangqiu = row.Cells[4].Value.ToString();
                    touzhu.Result = "负";
                    touzhu.Peilv = Convert.ToDouble(row.Cells[7].Value);
                    touzhu.Riqi = row.Cells[8].Value.ToString();
                    flag = true;
                    if (flag)
                    {
                        String key = row.Cells[2].Value.ToString() + row.Cells[3].Value.ToString() + row.Cells[8].Value.ToString();
                        List<SelectedTouzhu> sel = null;
                        if (dic.TryGetValue(key, out sel))
                        {
                            sel.Add(touzhu);

                        }
                        else
                        {
                            sel = new List<SelectedTouzhu>();
                            sel.Add(touzhu);
                            dic[key] = sel;
                        }
                    }
                }
               
            }
            //计算总数和奖金界限
            #region 只计算总数
            int total = 0;
            double maxJiangjin = double.MinValue;
            double minJiangjin = double.MaxValue;

            for (int i = 0; i < clbChuanJiang.Items.Count; i++)
            {
                if (i != clbChuanJiang.SelectedIndex)
                {
                    if (clbChuanJiang.GetItemChecked(i))
                    {
                        double max = 0;
                        double min = 0;
                        int zhushu = 0;
                        string chuanjiang = clbChuanJiang.GetItemText(clbChuanJiang.Items[i]);
                        int chuan = Convert.ToInt32(chuanjiang.Substring(0, 1));
                        //total += GetZhushu(dic, chuan);

                        SaveTouzhu(dic, chuan, out min, out max, out zhushu);
                        total += zhushu;
                        if (min < minJiangjin)
                        {
                            minJiangjin = min;
                        }
                        if (max > maxJiangjin)
                        {
                            maxJiangjin = max;
                        }
                    }
                }
                else
                {
                    if (!clbChuanJiang.GetItemChecked(i))
                    {
                        double max = 0;
                        double min = 0;
                        int zhushu = 0;
                      
                        string chuanjiang = clbChuanJiang.GetItemText(clbChuanJiang.Items[i]);
                        int chuan = Convert.ToInt32(chuanjiang.Substring(0, 1));
                        //total += GetZhushu(dic, chuan);

                        SaveTouzhu(dic, chuan, out min, out max, out zhushu);
                        total += zhushu;
                        if (min < minJiangjin)
                        {
                            minJiangjin = min;
                        }
                        if (max > maxJiangjin)
                        {
                            maxJiangjin = max;
                        }
                    }
                }
            }

            lblMinJiangjin.Text = minJiangjin.ToString();
            lblMaxJiangjin.Text = maxJiangjin.ToString();
            txtTouru.Text = (total * Convert.ToDouble(txtBeishu.Text) * 2).ToString();

            //int total = 0;
            ////计算所有的可能
            //for (int i = 0; i < clbChuanJiang.Items.Count; i++)
            //{
            //    if (i != clbChuanJiang.SelectedIndex)
            //    {
            //        if (clbChuanJiang.GetItemChecked(i))
            //        {
            //            string chuanjiang = clbChuanJiang.GetItemText(clbChuanJiang.Items[i]);
            //            int chuan = Convert.ToInt32(chuanjiang.Substring(0, 1));
            //            total += GetZhushu(dic, chuan);
            //        }
            //    }
            //    else
            //    {
            //        if (!clbChuanJiang.GetItemChecked(i))
            //        {
            //            string chuanjiang = clbChuanJiang.GetItemText(clbChuanJiang.Items[i]);
            //            int chuan = Convert.ToInt32(chuanjiang.Substring(0, 1));
            //            total += GetZhushu(dic, chuan);
            //        }
            //    }
            //}
            
            ////更新投入的金额
            //txtTouru.Text = (total * Convert.ToInt32(txtBeishu.Text) * 2).ToString();
            #endregion
        }
示例#3
0
        private void TouzhuBySp()
        {
            //按sp顺序二串一

            SortedList<string, SelectedTouzhu> touzhuList = new SortedList<string, SelectedTouzhu>();
            SelectedTouzhu touzhu = null;
            foreach (DataGridViewRow row in dgvTuijian.Rows)
            {

                if (row.Cells[5].Style.BackColor == Color.Red || row.Cells[5].Style.BackColor == Color.Blue)
                {
                    touzhu = new SelectedTouzhu();
                    touzhu.Zhudui = row.Cells[2].Value.ToString();
                    touzhu.Kedui = row.Cells[3].Value.ToString();
                    touzhu.Rangqiu = row.Cells[4].Value.ToString();
                    touzhu.Result = "胜";
                    touzhu.Peilv = Convert.ToDouble(row.Cells[5].Value);
                    touzhu.Riqi = row.Cells[8].Value.ToString();
                    touzhuList.Add(touzhu.Peilv + touzhu.Zhudui, touzhu);
                }
                if (row.Cells[6].Style.BackColor == Color.Red || row.Cells[6].Style.BackColor == Color.Blue)
                {
                    touzhu = new SelectedTouzhu();
                    touzhu.Zhudui = row.Cells[2].Value.ToString();
                    touzhu.Kedui = row.Cells[3].Value.ToString();
                    touzhu.Rangqiu = row.Cells[4].Value.ToString();
                    touzhu.Result = "平";
                    touzhu.Peilv = Convert.ToDouble(row.Cells[6].Value);
                    touzhu.Riqi = row.Cells[8].Value.ToString();

                    touzhuList.Add(touzhu.Peilv + touzhu.Zhudui, touzhu);
                }
                if (row.Cells[7].Style.BackColor == Color.Red || row.Cells[7].Style.BackColor == Color.Blue)
                {
                    touzhu = new SelectedTouzhu();
                    touzhu.Zhudui = row.Cells[2].Value.ToString();
                    touzhu.Kedui = row.Cells[3].Value.ToString();
                    touzhu.Rangqiu = row.Cells[4].Value.ToString();
                    touzhu.Result = "负";
                    touzhu.Peilv = Convert.ToDouble(row.Cells[7].Value);
                    touzhu.Riqi = row.Cells[8].Value.ToString();

                    touzhuList.Add(touzhu.Peilv + touzhu.Zhudui, touzhu);
                }

            }

            SelectedTouzhu p1, p2;
            p1 = null;
            p2 = null;
            foreach (SelectedTouzhu tou in touzhuList.Values)
            {
                p1 = p2;
                p2 = tou;
                if (p1 != null && p2 != null && p1.Zhudui != p2.Zhudui)
                {
                    Dictionary<String, List<SelectedTouzhu>> dic = new Dictionary<string, List<SelectedTouzhu>>();
                    String key1 = p1.Zhudui + p1.Kedui + p1.Riqi;
                    List<SelectedTouzhu> sel1 = null;
                    sel1 = new List<SelectedTouzhu>();
                    sel1.Add(p1);
                    dic[key1] = sel1;
                    String key2 = p2.Zhudui + p2.Kedui + p2.Riqi;
                    List<SelectedTouzhu> sel2 = null;
                    sel2 = new List<SelectedTouzhu>();
                    sel2.Add(p2);
                    dic[key2] = sel2;
                    SaveTouzhu(dic, 2, "竞彩足球-自动投注2");
                    p1 = null;
                    p2 = null;
                }
            }


        }
示例#4
0
        private void btnTouzhu_Click(object sender, EventArgs e)
        {
            Dictionary<String, List<SelectedTouzhu>> dic = new Dictionary<string, List<SelectedTouzhu>>();
            SelectedTouzhu touzhu = null;
            foreach (DataGridViewRow row in dgPeilv.Rows)
            {
                //为什么要设置这个标志位,看不懂了
                bool flag = false;
                if (row.Cells[5].Selected == true)
                {
                    touzhu = new SelectedTouzhu();
                    touzhu.Zhudui = row.Cells[2].Value.ToString();
                    touzhu.Kedui = row.Cells[3].Value.ToString();
                    touzhu.Rangqiu = row.Cells[4].Value.ToString();
                    touzhu.Result = "胜";
                    touzhu.Peilv = Convert.ToDouble(row.Cells[5].Value);
                    touzhu.Riqi = row.Cells[8].Value.ToString();
                    flag = true;
                    if (flag)
                    {
                        String key = row.Cells[2].Value.ToString() + row.Cells[3].Value.ToString() + row.Cells[8].Value.ToString();
                        List<SelectedTouzhu> sel = null;
                        if (dic.TryGetValue(key, out sel))
                        {
                            sel.Add(touzhu);

                        }
                        else
                        {
                            sel = new List<SelectedTouzhu>();
                            sel.Add(touzhu);
                            dic[key] = sel;
                        }
                    }
                }
                if (row.Cells[6].Selected == true)
                {
                    touzhu = new SelectedTouzhu();
                    touzhu.Zhudui = row.Cells[2].Value.ToString();
                    touzhu.Kedui = row.Cells[3].Value.ToString();
                    touzhu.Rangqiu = row.Cells[4].Value.ToString();
                    touzhu.Result = "平";
                    touzhu.Peilv = Convert.ToDouble(row.Cells[6].Value);
                    touzhu.Riqi = row.Cells[8].Value.ToString();
                    flag = true;
                    if (flag)
                    {
                        String key = row.Cells[2].Value.ToString() + row.Cells[3].Value.ToString() + row.Cells[8].Value.ToString();
                        List<SelectedTouzhu> sel = null;
                        if (dic.TryGetValue(key, out sel))
                        {
                            sel.Add(touzhu);

                        }
                        else
                        {
                            sel = new List<SelectedTouzhu>();
                            sel.Add(touzhu);
                            dic[key] = sel;
                        }
                    }
                }
                if (row.Cells[7].Selected == true)
                {
                    touzhu = new SelectedTouzhu();
                    touzhu.Zhudui = row.Cells[2].Value.ToString();
                    touzhu.Kedui = row.Cells[3].Value.ToString();
                    touzhu.Rangqiu = row.Cells[4].Value.ToString();
                    touzhu.Result = "负";
                    touzhu.Peilv = Convert.ToDouble(row.Cells[7].Value);
                    touzhu.Riqi = row.Cells[8].Value.ToString();
                    flag = true;
                    if (flag)
                    {
                        String key = row.Cells[2].Value.ToString() + row.Cells[3].Value.ToString() + row.Cells[8].Value.ToString();
                        List<SelectedTouzhu> sel = null;
                        if (dic.TryGetValue(key, out sel))
                        {
                            sel.Add(touzhu);

                        }
                        else
                        {
                            sel = new List<SelectedTouzhu>();
                            sel.Add(touzhu);
                            dic[key] = sel;
                        }
                    }
                }
                //if (flag)
                //{
                //    String key = row.Cells[2].Value.ToString() + row.Cells[3].Value.ToString()+row.Cells[8].Value.ToString();
                //    List<SelectedTouzhu> sel = null;
                //    if (dic.TryGetValue(key, out sel))
                //    {
                //        sel.Add(touzhu);

                //    }
                //    else
                //    {
                //        sel = new List<SelectedTouzhu>();
                //        sel.Add(touzhu);
                //        dic[key] = sel;
                //    }
                //}
            }

            long batchid = Convert.ToInt64(DateTime.Now.ToString("MMddhhmmss") + DateTime.Now.Millisecond);
            for (int i = 0; i < clbChuanJiang.Items.Count; i++)
            {
                if (clbChuanJiang.GetItemChecked(i))
                {
                    string chuanjiang =  clbChuanJiang.GetItemText(clbChuanJiang.Items[i]);
                    int chuan = Convert.ToInt32(chuanjiang.Substring(0, 1));
                    SaveTouzhu(dic, chuan, batchid);
                }
            }

            //这里插入income数据
            Income income = new Income();
            income.Amount = Convert.ToDouble(txtTouru.Text);
            income.IncomeType = "购奖";
            income.OperateTime = DateTime.Now;
            income.Operator = "吴林";
            income.TouzhuType = "竞彩足球";
            income.TouzhuID = batchid;
            new IncomeDAL().InsertIncome(income);

            MessageBox.Show("投注成功!");
            #region old code
            //int arrayCount = dic.Keys.Count;
            //int[] peilvCount = new int[arrayCount];
            //List<SelectedTouzhu>[] selectedTouzhus = new List<SelectedTouzhu>[arrayCount];
            //int counter = 0;
            //foreach (String key in dic.Keys)
            //{
            //    peilvCount[counter] = dic[key].Count;
            //    selectedTouzhus[counter] = dic[key];
            //    counter++;
            //}

            //double maxNumber = Math.Pow(10, arrayCount);
            //int chuan = 2;
            
            //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 = Convert.ToInt32(txtBeishu.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;
            //            new TouzhuSpfDAL().InsertTouzhuSpf(touspf);
            //        }
            //    }
            //}


            //int[] peilvCount = new int[8];
            //peilvCount[0] = 1;
            //peilvCount[1] = 1;
            //peilvCount[2] = 1;
            //peilvCount[3] = 1;
            //peilvCount[4] = 1;
            //peilvCount[5] = 1;
            //peilvCount[6] = 2;
            //peilvCount[7] = 1; ;
            //int peilvLenth = peilvCount.Length;
            //double maxNumber = Math.Pow(10, peilvLenth);
            //int chuan = 2;
            //for (int i = 0; i < maxNumber; i++)
            //{
            //    if (GetNoZeroCount(i) == chuan)
            //    {
            //        //所在位置不大于对应数组的值
            //        if (NotLargeThanArray(i, peilvCount))
            //        {
            //            Console.WriteLine(i);
            //        }
                    
            //    }
            //}
            #endregion


        }