Exemplo n.º 1
0
 protected void nextLeagueRadGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
 {
     if (!StoredData.User.TempDivision.Value && !StoredData.User.AccessExpired.Value && StoredData.User.NextDivision.HasValue)
     {
         using (FlexibleTennisLeagueDataContext dataContext = new FlexibleTennisLeagueDataContext())
         {
             List <LeaguePerformance> leaguePerformance = dataContext.SelectLeaguePerformanceByDivision(StoredData.User.NextDivision.Value).ToList();
             nextLeagueRadGrid.DataSource = leaguePerformance;
         }
     }
 }
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;
                        }
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Request.IsAuthenticated)
            {
                Response.Redirect(WebConfigurationManager.AppSettings["LoginPageURL"].ToString());
            }

            RadAjaxManager.GetCurrent(Page).AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(Schedule_AjaxRequest);
            RadScheduler1.CustomAttributeNames           = new string[] { "UserId" };

            if (!StoredData.User.TempDivision.Value && !StoredData.User.AccessExpired.Value)
            {
                using (FlexibleTennisLeagueDataContext dataContext = new FlexibleTennisLeagueDataContext())
                {
                    if (!Page.IsPostBack)
                    {
                        List <SelectDivisionResult> selectDivisionResult = dataContext.SelectDivision(StoredData.User.Division.Value).ToList();
                        foreach (SelectDivisionResult result in selectDivisionResult)
                        {
                            if (result.StartDate > DateTime.Now)
                            {
                                warningImage.Visible      = true;
                                warningLinkButton.Visible = true;
                                warningLinkButton.Text    = "Although you may play practice matches with members in your league. You will not be able to record scores until the league start date of " + result.StartDate.ToShortDateString();
                            }
                            else
                            {
                                List <LeaguePerformance> leaguePerformance = dataContext.SelectLeaguePerformanceByDivision(StoredData.User.Division).ToList();
                                leaguePerformance.Remove(leaguePerformance.Find(p => p.UserId == StoredData.User.UserId));
                                playersRadGrid.DataSource = leaguePerformance;
                            }
                        }
                    }
                    //If a player has been selected from the players grid - get appointments fro both players
                    //else just get appointment for current user.
                    List <DLL.Appointment> appointments = new List <DLL.Appointment>();
                    bool opponentAvailabilitySet        = false;
                    if (playersRadGrid.SelectedItems.Count > 0)
                    {
                        int opponentId = Convert.ToInt32(playersRadGrid.SelectedItems[0].OwnerTableView.DataKeyValues[playersRadGrid.SelectedItems[0].ItemIndex]["UserId"]);
                        appointments = GetAppointments(StoredData.User.UserId, opponentId, out opponentAvailabilitySet);
                    }
                    else
                    {
                        appointments = GetAppointments(StoredData.User.UserId, -1, out opponentAvailabilitySet);
                    }
                    RadScheduler1.DataSource = appointments;
                }
            }
            else
            {
                RadScheduler1.Enabled     = false;
                playersRadGrid.Enabled    = false;
                warningImage.Visible      = true;
                warningLinkButton.Visible = true;

                if (StoredData.User.TempDivision.Value)
                {
                    warningLinkButton.Text = "Your account is still being created. You will not be able to schedule matches or report scores. Please wait for the email confirming your account activation.";
                }
                else if (StoredData.User.AccessExpired.Value)
                {
                    warningLinkButton.Text        = "Your access has expired. Please click here to subscribe to the current season and regain access.";
                    warningLinkButton.PostBackUrl = WebConfigurationManager.AppSettings["NewLeagueRegisterURL"].ToString();
                }
            }
        }