protected void Fetch_Click(object sender, EventArgs e)
        {
            if (List01.SelectedIndex == 0)
            {
                MessageLabel.Text = "Select a team to view its players";
            }
            else
            {
                try
                {
                    TeamController sysmgr01 = new TeamController();
                    Team           info01   = null;
                    info01                  = sysmgr01.FindByPKID(int.Parse(List01.SelectedValue));
                    IDLabel01.Text          = "Coach:";
                    IDLabel02.Text          = info01.Coach.ToString();
                    NameLabel01.Text        = "Assistant Coach:";
                    NameLabel02.Text        = info01.AssistantCoach.ToString();
                    Label2.Text             = "Wins:";
                    Label3.Text             = info01.Wins.ToString();
                    DescriptionLabel01.Text = "Losses";
                    DescriptionLabel02.Text = info01.Losses.ToString();

                    PlayerController sysmgr02 = new PlayerController();
                    List <Player>    info02   = null;
                    info02 = sysmgr02.FindByID(int.Parse(List01.SelectedValue));
                    info02.Sort((x, y) => x.Name.CompareTo(y.Name));
                    List02.DataSource = info02;
                    List02.DataBind();
                }
                catch (Exception ex)
                {
                    MessageLabel.Text = ex.Message;
                }
            }
        }
Пример #2
0
 protected void Fetch_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(IDArg.Text))
     {
         MessageLabel.Text = "Enter a Team ID .";
         TeamID.Text       = "";
         TeamName.Text     = "";
     }
     else
     {
         int id = 0;
         if (int.TryParse(IDArg.Text, out id))
         {
             if (id > 0)
             {
                 TeamController sysmgr = new TeamController();
                 Team           info   = null;
                 info = sysmgr.FindByPKID(id);
                 if (info == null)
                 {
                     MessageLabel.Text = "ID not found.";
                     TeamID.Text       = "";
                     TeamName.Text     = "";
                 }
                 else
                 {
                     TeamID.Text   = info.TeamID.ToString();
                     TeamName.Text = info.TeamName;
                 }
             }
             else
             {
                 MessageLabel.Text = "ID must be greater than 0";
                 TeamID.Text       = "";
                 TeamName.Text     = "";
             }
         }
         else
         {
             MessageLabel.Text = "ID must be a number.";
             TeamID.Text       = "";
             TeamName.Text     = "";
         }
     }
 }
Пример #3
0
        protected void Fetch_Click(object sender, EventArgs e)
        {
            if (List01.SelectedIndex == 0)
            {
                MessageLabel.Text = "Select a Team to view its products";
            }
            else
            {
                try
                {
                    TeamController sysmgr01 = new TeamController();
                    Team           info01   = null;
                    info01                = sysmgr01.FindByPKID(int.Parse(List01.SelectedValue));
                    IDLabel01.Text        = "Team ID:";
                    IDLabel02.Text        = info01.TeamID.ToString();
                    NameLabel01.Text      = "Team Name:";
                    NameLabel02.Text      = info01.TeamName;
                    Coach01.Text          = "Coach:";
                    Coach02.Text          = info01.Coach;
                    AssistantCoach01.Text = "Assistant Coach:";
                    AssistantCoach02.Text = info01.AssistantCoach;
                    Wins01.Text           = "Wins:";
                    Wins02.Text           = nameof(info01.Wins);
                    Losses01.Text         = "Losses:";
                    Losses02.Text         = nameof(info01.Losses);


                    PlayerController sysmgr02 = new PlayerController();
                    List <Player>    info02   = null;
                    info02 = sysmgr02.FindByID(int.Parse(List01.SelectedValue));
                    info02.Sort((x, y) => x.NameLastandFirst.CompareTo(y.NameLastandFirst));
                    List02.DataSource = info02;
                    List02.DataBind();
                }
                catch (Exception ex)
                {
                    MessageLabel.Text = ex.Message;
                }
            }
        }