Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.IsAuthenticated)
            {
                int opponentId = Convert.ToInt32(Request.QueryString["opponentId"]);
                int matchId    = Convert.ToInt32(Request.QueryString["matchId"]);
                matchIdHiddenField.Value    = matchId.ToString();
                opponentIdHiddenField.Value = opponentId.ToString();

                if (!Page.IsPostBack)
                {
                    using (FlexibleTennisLeagueDataContext dataContext = new FlexibleTennisLeagueDataContext())
                    {
                        ISingleResult <SelectUserPublicProfileResult> users = dataContext.SelectUserPublicProfile(opponentId);
                        SelectUserPublicProfileResult user = users.First();

                        ISingleResult <SelectMatchResult> matches = dataContext.SelectMatch(matchId);
                        SelectMatchResult match = matches.First();

                        ISingleResult <SelectMatchPointLogsByMatchIdResult> matchResults = dataContext.SelectMatchPointLogsByMatchId(matchId);
                        SelectMatchPointLogsByMatchIdResult matchResult = matchResults.First();

                        string winner = string.Empty;
                        if (matchResult.UserId == StoredData.User.UserId)
                        {
                            if (matchResult.Win)
                            {
                                winner = StoredData.User.FirstName + " " + StoredData.User.LastName;
                            }
                            else
                            {
                                winner = user.FirstName + " " + user.LastName;
                            }
                        }
                        else
                        {
                            if (matchResult.Win)
                            {
                                winner = user.FirstName + " " + user.LastName;
                            }
                            else
                            {
                                winner = StoredData.User.FirstName + " " + StoredData.User.LastName;
                            }
                        }

                        matchLabel.Text = string.Format("{0} vs {1} on {2} {3}. Winner: {4} ({5})", StoredData.User.FirstName + " " + StoredData.User.LastName, user.FirstName + " " + user.LastName, match.MatchDate.ToShortDateString(), match.MatchDate.ToShortTimeString(), winner, match.Score);

                        ISingleResult <SelectMatchPointLogsByMatchIdUserIdResult> ratings = dataContext.SelectMatchPointLogsByMatchIdUserId(matchId, StoredData.User.UserId);
                        SelectMatchPointLogsByMatchIdUserIdResult rating = ratings.First();

                        ownBackhandRadSlider.Value           = rating.OwnBackhand.Value;
                        ownCourtCoverageRadSlider.Value      = rating.OwnCourtCoverage.Value;
                        ownDropRadSlider.Value               = rating.OwnDrop.Value;
                        ownForehandRadSlider.Value           = rating.OwnForehand.Value;
                        ownOverheadRadSlider.Value           = rating.OwnOverhead.Value;
                        ownServeRadSlider.Value              = rating.OwnServe.Value;
                        ownVolleyRadSlider.Value             = rating.OwnVolley.Value;
                        opponentBackhandRadSlider.Value      = rating.OpponentBackhand.Value;
                        opponentCourtCoverageRadSlider.Value = rating.OpponentCourtCoverage.Value;
                        opponentDropRadSlider.Value          = rating.OpponentDrop.Value;
                        opponentForehandRadSlider.Value      = rating.OpponentForehand.Value;
                        opponentOverheadRadSlider.Value      = rating.OpponentOverhead.Value;
                        opponentServeRadSlider.Value         = rating.OpponentServe.Value;
                        opponentVolleyRadSlider.Value        = rating.OpponentVolley.Value;
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.IsAuthenticated)
            {
                int?   opponentId = null;
                int?   matchId    = null;
                string mode       = string.Empty;
                if (Request.QueryString["opponentId"] != null)
                {
                    opponentId = Convert.ToInt32(Request.QueryString["opponentId"]);
                    opponentIdHiddenField.Value = opponentId.ToString();
                }
                //RadDatePicker1.MinDate = DateTime.Now;
                if (Request.QueryString["matchId"] != null)
                {
                    matchId = Convert.ToInt32(Request.QueryString["matchId"]);
                    matchIdHiddenField.Value = matchId.ToString();
                }
                if (Request.QueryString["mode"] != null)
                {
                    mode = Request.QueryString["mode"].ToString();
                }
                ViewState["Submitted"] = false;

                Page.Title = "Report Score";
                if (!Page.IsPostBack)
                {
                    using (FlexibleTennisLeagueDataContext dataContext = new FlexibleTennisLeagueDataContext())
                    {
                        opponentDropDownList.Items.Clear();
                        List <LeaguePerformance> leaguePerformances = dataContext.SelectLeaguePerformanceByDivision(StoredData.User.Division).ToList();
                        opponentDropDownList.Items.Add(new ListItem(string.Empty, string.Empty));
                        foreach (LeaguePerformance leaguePerformance in leaguePerformances)
                        {
                            if (leaguePerformance.UserId != StoredData.User.UserId)
                            {
                                opponentDropDownList.Items.Add(new ListItem(leaguePerformance.FirstName + " " + leaguePerformance.LastName, leaguePerformance.UserId.ToString()));
                            }
                        }
                        opponentDropDownList.SelectedValue = opponentId.ToString();


                        List <TennisCourt> tennisCourts = dataContext.SelectTennisCourtsByLeague(leaguePerformances[0].LeagueId).ToList();
                        locationDropDownList.DataSource     = tennisCourts;
                        locationDropDownList.DataTextField  = "CourtName";
                        locationDropDownList.DataValueField = "CourtId";
                        locationDropDownList.DataBind();

                        //RadDatePicker1.MinDate = Convert.ToDateTime("1/1/2009");
                        if (!string.IsNullOrEmpty(mode))
                        {
                            RadDatePicker1.MinDate = DateTime.Now.AddDays(-14);
                        }

                        if (matchId.HasValue)
                        {
                            ISingleResult <SelectMatchResult> matches = dataContext.SelectMatch(matchId);
                            SelectMatchResult match = matches.First();
                            RadDatePicker1.SelectedDate        = match.MatchDate;
                            RadTimePicker1.SelectedDate        = match.MatchDate;
                            locationDropDownList.SelectedValue = match.TennisCourt.ToString();
                            RadDatePicker1.MaxDate             = match.MatchDate;
                        }
                        else
                        {
                            locationDropDownList.SelectedValue = StoredData.User.HomeCourt.ToString();
                            RadDatePicker1.MaxDate             = DateTime.Now;
                        }

                        winnerDropDownList.Items.Clear();
                        winnerDropDownList.Items.Add(new ListItem());
                        winnerDropDownList.Items.Add(new ListItem(StoredData.User.FirstName + " " + StoredData.User.LastName, StoredData.User.UserId.ToString()));
                        if (opponentId.HasValue)
                        {
                            winnerDropDownList.Items.Add(new ListItem(opponentDropDownList.SelectedItem.Text, opponentDropDownList.SelectedItem.Value));
                            opponentDropDownList.Enabled = false;
                        }
                    }
                }
            }
        }