Пример #1
0
        private void btnPaijiang_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dgTouzhuSpf.Rows)
            {
                long batchid = Convert.ToInt64(row.Cells["id"].Value);
                string type = "竞彩足球";
                double jiangjin = Convert.ToDouble(row.Cells["jiangjin"].Value);
                if(jiangjin != 0)
                {
                    Income income = new Income();
                    income.Amount = jiangjin;
                    income.IncomeType = "中奖";
                    income.TouzhuID = batchid;
                    income.TouzhuType = type;
                    income.Operator = "吴林";
                    income.OperateTime = DateTime.Now;
                    income.id = batchid;
                    IncomeDAL dal = new IncomeDAL();

                    //如果没有排过奖
                    if(dal.HasPaijiang(income)==0)
                    {
                        dal.InsertIncome(income);
                    }

                }
                
            }
            MessageBox.Show("派奖成功!");
        }
Пример #2
0
        public bool InsertIncome(Income income)
        {
            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 mySqlCom = mySqlCon.CreateCommand())
                {
                    //这里需要注意的是在 Sql 语句中有一个参数是 ?BlogsName 
                    //很明显,这个参数有点古怪,和我们一直使用的 @ 不一样, 
                    //这是因为在 MySql 以前的提供的 .NET Connector 中 
                    //都是采用 ? 来标志一个参数的,而现在的 .NET Connector 呢, 
                    //您既可以采用 ? 来标志一个参数,您也可以使用一个 @ 符号来标志一个参数 
                    //新版的 .NET Connector 对此都是支持的 
                    string sqlStr = @"insert into income(amount,incometype,operator,operatetime,touzhuid,touzhutype)
value(?amount,?incometype,?operator,?operatetime,?touzhuid,?touzhutype)
";

                    mySqlCom.CommandText = sqlStr;
                    mySqlCom.Parameters.AddWithValue("?amount", income.Amount);
                    mySqlCom.Parameters.AddWithValue("?incometype", income.IncomeType);
                    mySqlCom.Parameters.AddWithValue("?operator", income.Operator);
                    mySqlCom.Parameters.AddWithValue("?operatetime", income.OperateTime);
                    mySqlCom.Parameters.AddWithValue("?touzhuid", income.id);
                    mySqlCom.Parameters.AddWithValue("?touzhutype", income.TouzhuType);

                    total = Convert.ToInt32(mySqlCom.ExecuteScalar());
                }
            }

            return total == 0 ? true : false;

        }
Пример #3
0
        private void btnChongzhi_Click(object sender, EventArgs e)
        {
            Income income = new Income();
            income.IncomeType = "充值";
            income.Amount = Convert.ToDouble(txtChongzhijine.Text);
            income.OperateTime = DateTime.Now;
            income.Operator = "吴林";
            new IncomeDAL().InsertIncome(income);

            //刷新下页面UI控件
            GetAllAmount();
            BindGrid("全部");
            MessageBox.Show("充值"+ txtChongzhijine.Text +"成功!");
        }
Пример #4
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("没有需要投注的比赛!");
            }
            
        }
Пример #5
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);


        }
Пример #6
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


        }
Пример #7
0
        /// <summary>
        /// 1表示已派奖,0表示未派奖
        /// </summary>
        /// <param name="income"></param>
        /// <returns></returns>
        public int HasPaijiang(Income income)
        {

            DataSet ds = new DataSet();
            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())
                {
                    //这里需要注意的是在 Sql 语句中有一个参数是 ?BlogsName 
                    //很明显,这个参数有点古怪,和我们一直使用的 @ 不一样, 
                    //这是因为在 MySql 以前的提供的 .NET Connector 中 
                    //都是采用 ? 来标志一个参数的,而现在的 .NET Connector 呢, 
                    //您既可以采用 ? 来标志一个参数,您也可以使用一个 @ 符号来标志一个参数 
                    //新版的 .NET Connector 对此都是支持的 
//                    string sqlStr = @"select * from income where TouzhuID = ?touzhuid
//and TouzhuType = ?touzhutype";
                    string sqlStr = @"select * from income where touzhuid = ?touzhuid and incometype = ?incometype";
                    MySqlDataAdapter da = new MySqlDataAdapter();
                    mySqlCom.CommandText = sqlStr;
                    da.SelectCommand = mySqlCom;
                    mySqlCom.Parameters.AddWithValue("?touzhuid", income.id);
                    mySqlCom.Parameters.AddWithValue("?incometype", income.IncomeType);
                    da.Fill(ds);
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        return 0;
                    }
                }
            }

            return 1;
        }