Exemple #1
0
        protected void OnSaveGolfer(object sender, EventArgs e)
        {
            GolferService.Save(firstname_textbox.Text, lastname_textbox.Text, tour_list.SelectedValue);

            firstname_textbox.Text = "";
            lastname_textbox.Text  = "";

            message_label_panel.Visible = true;
            message_label.Text          = "Golfer was saved";

            BindData();
        }
Exemple #2
0
        protected void OnSelectTournament(object sender, EventArgs e)
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["default"].ConnectionString);

            connection.Open();

            if (!String.IsNullOrEmpty(tournament_list.SelectedValue))
            {
                var golfers = GolferService.ListActive(Convert.ToInt32(tournament_list.SelectedValue));
                golfer_list.DataSource = golfers;
                golfer_list.DataBind();
                golfer_list.Items.Insert(0, "");
                golfer_list.SelectedIndex = 0;
            }

            connection.Close();

            BindGrids();
        }
Exemple #3
0
        protected void BindData()
        {
            var golfers = GolferService.ListActive();

            golfer_grid.DataSource = golfers;
            golfer_grid.DataBind();

            using (var db = new FantasyGolfContext())
            {
                var tours = from x in db.Tour
                            where x.IsActive == true
                            orderby x.Name
                            select x;

                tour_list.DataSource = tours.ToList();
                tour_list.DataBind();
                tour_list.Items.Insert(0, "");
                tour_list.SelectedIndex = 0;
            }
        }
Exemple #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (base.IsLeagueSelected)
                {
                    //load up values
                    //SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["default"].ConnectionString);
                    //connection.Open();

                    //var tournaments = connection.Query<Tournament>("Tournament_List", new { LeagueId = base.CurrentLeague }, commandType: CommandType.StoredProcedure);
                    using (var db = new FantasyGolfContext())
                    {
                        var tournaments = TournamentService.List(this.CurrentLeagueId);
                        tournament_list.DataSource = tournaments;
                        tournament_list.DataBind();
                        tournament_list.Items.Insert(0, "");
                        tournament_list.SelectedIndex = 0;

                        //var users = connection.Query<RonsHouse.FantasyGolf.Model.User>("LeagueUser_List", new { LeagueId = base.CurrentLeague }, commandType: CommandType.StoredProcedure);
                        var users = UserService.List(this.CurrentLeagueId);
                        user_list.DataSource = users;
                        user_list.DataBind();
                        user_list.Items.Insert(0, "");
                        user_list.SelectedIndex = 0;

                        //var golfers = connection.Query<Golfer>("select *, LastName + ', ' + FirstName as Name from Golfer order by LastName");
                        var golfers = GolferService.ListActive();
                        golfer_list.DataSource = golfers;
                        golfer_list.DataBind();
                        golfer_list.Items.Insert(0, "");
                        golfer_list.SelectedIndex = 0;
                    }
                }
                message_label_panel.Visible = false;
            }
        }
Exemple #5
0
        protected void OnDataBoundUserPicks(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DropDownList golfer_list = (DropDownList)e.Row.FindControl("golfer_list");
                golfer_list.DataSource = GolferService.ListActive();                    //hopefully the caching works
                golfer_list.DataBind();
                golfer_list.Items.Insert(0, "-- Choose a Golfer --");

                //get current pick (if any)
                int tournamentId = Convert.ToInt32(((HiddenField)e.Row.FindControl("userpick_hidden")).Value);
                int userId       = Convert.ToInt32(user_list.SelectedValue);

                var pick = UserPickService.Get(userId, tournamentId);                   //should get all on page load and search through collection (too many db calls)
                try
                {
                    if (pick != null)
                    {
                        golfer_list.SelectedValue = pick.GolferId.ToString();
                    }
                }
                catch { }
            }
        }