Пример #1
0
 /// <summary>
 /// Returns the user to the previous window
 /// </summary>
 private void btnGoBack_Click(object sender, EventArgs e)
 {
     if (CurrentUser.teamId == 1)
     {
         this.Hide();
         var window = new NoTeamForm();
         window.ShowDialog();
         this.Close();
     }
     else
     {
         this.Hide();
         var window = new TeamInfoForm();
         window.ShowDialog();
         this.Close();
     }
 }
Пример #2
0
 /// <summary>
 /// The method changes the current user's team
 /// </summary>
 private void btnJoin_Click(object sender, EventArgs e)
 {
     if (dgTeamsShow.SelectedRows.Count != 1)
     {
         string            message = "Please select ONE team";
         string            caption = "Error!";
         MessageBoxButtons buttons = MessageBoxButtons.OK;
         MessageBox.Show(message, caption, buttons);
     }
     else
     {
         try
         {
             string teamName  = GetSelecttedTeamName();
             int    newTeamId = GetSelectedTeamId(teamName);
             TeamBusiness.CheckIfTeamDifferent(newTeamId);
             CurrentUser.ChangeTeam(newTeamId);
             string            message2 = "Joined" + teamName + "!";
             string            caption2 = "Success!";
             MessageBoxButtons buttons2 = MessageBoxButtons.OK;
             MessageBox.Show(message2, caption2, buttons2);
             this.Hide();
             var window = new TeamInfoForm();
             window.ShowDialog();
             this.Close();
         }
         catch (IndexOutOfRangeException)
         {
             string            message = "Please select ONE team";
             string            caption = "Error!";
             MessageBoxButtons buttons = MessageBoxButtons.OK;
             MessageBox.Show(message, caption, buttons);
         }
         catch (AlreadyInTeamExeption)
         {
             string            message = "You are already in team";
             string            caption = "Error!";
             MessageBoxButtons buttons = MessageBoxButtons.OK;
             MessageBox.Show(message, caption, buttons);
         }
     }
 }
Пример #3
0
 /// <summary>
 /// Creates a team and joins the current user
 /// </summary>
 private void btnCreate_Click(object sender, EventArgs e)
 {
     try
     {
         TeamBusiness.CreateTeam(teamName);
         string            message2 = "Team Created!";
         string            caption2 = "Success!";
         MessageBoxButtons buttons2 = MessageBoxButtons.OK;
         MessageBox.Show(message2, caption2, buttons2);
         this.Hide();
         var window = new TeamInfoForm();
         window.ShowDialog();
         this.Close();
     }
     catch (TeamNameNullExeption)
     {
         string            message = "Team name cannot be null!";
         string            caption = "Error!";
         MessageBoxButtons buttons = MessageBoxButtons.OK;
         MessageBox.Show(message, caption, buttons);
     }
     catch (TeamAlreadyExistsExeption)
     {
         teamName = "";
         lblTeamNameShown.Text = "";
         string            message = "Team already exists!";
         string            caption = "Error!";
         MessageBoxButtons buttons = MessageBoxButtons.OK;
         MessageBox.Show(message, caption, buttons);
     }
     catch (InvalidOperationException)
     {
         string            message = "Team name cannot be over 10 characters!";
         string            caption = "Error!";
         MessageBoxButtons buttons = MessageBoxButtons.OK;
         MessageBox.Show(message, caption, buttons);
     }
 }