Exemplo n.º 1
0
        private void navBetsBindingSource_PositionChanged(object sender, EventArgs e)
        {
            BindingSource  bs      = (BindingSource)sender;
            BettingSquares squares = (BettingSquares)bs.Current;

            updateBetGrid(squares);
        }
Exemplo n.º 2
0
        private void updateBetGrid(BettingSquares squares)
        {
            for (int home = 0; home < 10; home++)
            {
                for (int away = 0; away < 10; away++)
                {
                    //dataGridBets.Rows[home].Cells[away].Value = DBUtilities.GetUserName(squares.GetSquareUser(home, away));
                    dataGridBets.Rows[home].Cells[away].Value = squares.GetSquareUser(home, away);
                }
            }

            dataGridBets.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
0
        public static BettingSquares GetGameBets(int gameID)
        {
            BettingSquares squares = new BettingSquares();

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["HockeyPoolConnectionString"].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("SELECT * FROM FN_GetGameBets(@gameID)", conn))
                {
                    conn.Open();
                    cmd.Parameters.AddWithValue("@gameID", gameID);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            int     user = (int)reader["UserID"];
                            decimal amt  = (decimal)reader["BetAmount"];
                            UserBet bet  = new UserBet(user, amt);
                            squares.BuySquare(bet, (int)reader["HomeScore"], (int)reader["AwayScore"]);
                        }
                    }
                }
            }
            return(squares);
        }