コード例 #1
0
        protected void Search_Click(object sender, EventArgs e)
        {
            if (TeamList.SelectedIndex == 0)
            {
                MessageLabel.Text = "Select a team to view its details";
            }
            else
            {
                int teamID = 0;
                if (int.TryParse(TeamList.Text, out teamID))
                {
                    try
                    {
                        TeamController sysmgr = new TeamController();
                        Team           info   = sysmgr.Team_Find(teamID);

                        CoachName.Text   = info.Coach.ToString();
                        AssistCoach.Text = info.AssistantCoach.ToString();
                        WinLabel.Text    = info.Wins.ToString();
                        if (info.Wins == null)
                        {
                            WinLabel.Text = "0";
                        }
                        LossLabel.Text = info.Losses.ToString();
                        if (info.Losses == null)
                        {
                            LossLabel.Text = "0";
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageLabel.Text = ex.Message;
                    }

                    try
                    {
                        PlayerController sysmgr = new PlayerController();
                        List <Player>    info   = null;
                        info = sysmgr.Player_GetByTeam(int.Parse(TeamList.Text));
                        info.Sort((x, y) => x.LastName.CompareTo(y.LastName));

                        TeamRoster.DataSource = info;
                        TeamRoster.DataBind();
                    }
                    catch (Exception ex)
                    {
                        MessageLabel.Text = ex.Message;
                    }
                }
                else
                {
                    MessageLabel.Text = "Team id must be a number.";
                }
            }
        }
コード例 #2
0
        protected void Search_Click(object sender, EventArgs e)
        {
            if (TeamList.SelectedIndex == 0)
            {
                MessageLabel.Text = "Select a team to view its roster.";
            }
            else
            {
                int teamid = int.Parse(TeamList.SelectedValue);

                try
                {
                    TeamController teamMgr  = new TeamController();
                    Team           teamInfo = null;
                    teamInfo = teamMgr.Team_Find(teamid);

                    if (teamInfo == null)
                    {
                        MessageLabel.Text   = "Team not found.";
                        Coach.Text          = "";
                        AssistantCoach.Text = "";
                        Wins.Text           = "";
                        Losses.Text         = "";
                    }
                    else
                    {
                        Coach.Text          = teamInfo.Coach;
                        AssistantCoach.Text = teamInfo.AssistantCoach;
                        Wins.Text           = teamInfo.Wins.ToString() == "" ? "0" : teamInfo.Wins.ToString();
                        Losses.Text         = teamInfo.Losses.ToString() == "" ? "0" : teamInfo.Losses.ToString();
                    }

                    PlayerController playerMgr = new PlayerController();
                    List <Player>    info      = null;

                    info = playerMgr.Player_GetByTeam(teamid);
                    info.Sort((x, y) => x.LastName.CompareTo(y.LastName));
                    TeamRoster.DataSource = info;

                    TeamRoster.DataBind();
                }
                catch (Exception ex)
                {
                    MessageLabel.Text = ex.Message;
                }
            }
        }