示例#1
0
        private async void ResolveBets()
        {
            // get unresolved bets
            DataTable bets;

            int homeScore, awayScore;

            bets = tblBetsTableAdapter.GetDataByUnresolved();

            foreach (DataRow r in bets.Rows)
            {
                p = await hapi.GetGameResult(r["gameID"].ToString());

                homeScore = p.teams.home.teamStats.teamSkaterStats.goals;
                awayScore = p.teams.away.teamStats.teamSkaterStats.goals;

                // first check if there is any score, if not, the game has not been played yet
                if (homeScore == 0 && awayScore == 0)
                {
                    continue;
                }


                DBUtilities.ResolveBet((int)r["ID"], homeScore, awayScore);
            }


            this.tblUsersTableAdapter.Fill(this.hockeyPoolDataSet.tblUsers);
        }
示例#2
0
        /// <summary>
        /// Enter a bet by assigning a random score to the current user.
        /// </summary>
        /// <param name="amount"></param>
        /// <returns></returns>
        private int EnterBet(int amount)
        {
            if (dataGridSchedule.CurrentRow == null)
            {
                return(1);
            }

            HockeyPoolGame g = (HockeyPoolGame)dataGridSchedule.CurrentRow.DataBoundItem;
            BettingSquares squares;

            squares = DBUtilities.GetGameBets(g.GameID);

            if (squares.SquaresFull())
            {
                MessageBox.Show("No more bets available for this game.");
                return(1);
            }


            int home, away;

            do
            {
                RandomScore(out home, out away);
            } while (!squares.IsSquareAvailable(home, away));

            // we have a score and a bet, now record the bet
            int betResult = DBUtilities.EnterBet(currentUser.ID, 1, g.GameID, home, away);

            return(betResult);
        }
示例#3
0
        public HockeyPoolMenu(string user)
        {
            InitializeComponent();
            ResolveBets();

            todayGames = new List <HockeyPoolGame>();

            currentUser = DBUtilities.GetUser(user);

            dataGridBets.ColumnCount = 10;

            for (int r = 0; r < 10; r++)
            {
                DataGridViewRow row = new DataGridViewRow();

                for (int c = 0; c < 10; c++)
                {
                    row.Cells.Add(new DataGridViewTextBoxCell()
                    {
                        Value = ""
                    });

                    dataGridBets.Columns[c].HeaderText = c.ToString();
                }
                dataGridBets.Rows.Add(row);
                dataGridBets.Rows[r].HeaderCell.Value = r.ToString();
            }

            dataGridBets.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
        }
示例#4
0
        private void LoadBets()
        {
            List <BettingSquares> squares = new List <BettingSquares>();

            foreach (HockeyPoolGame g in todayGames)
            {
                BettingSquares bs = DBUtilities.GetGameBets(g.GameID);

                squares.Add(bs);
            }
            BindingSource binder = new BindingSource(squares, "");

            navBets.BindingSource = binder;
            navBets.BindingSource.PositionChanged += navBetsBindingSource_PositionChanged;
        }