Beispiel #1
0
        public static void RunAdmin(Admin admin)
        {
            var choice = AdminMenu();
            switch (choice)
            {
                case 1: //Create new competition
                    CreateCompetition();
                    AddReferees();
                    AddDiversToCompetition(TempCompetition.Rounds);
                    TempCompetition.SortDiveOrder();
                    admin.AddCompetition(TempCompetition);
                    break;

                case 2: // Add new diver to database
                    var diver = CreateDiver();
                    admin.AddDiver(diver);
                    break;

                case 3: // Add new referee to database
                    var referee = CreateReferee();
                    admin.AddReferee(referee);
                    break;

                case 4: // Show all competitions, choose one to start
                    DisplayCompetitions();
                    var id = ChooseCompetition();
                    if (id > 0)
                    {
                        admin.StartCompetition(id);
                        WriteLine($"Competition {id} has started!");
                    }
                    Thread.Sleep(1000);
                    Clear();
                    break;

                case 5:
                    WriteLine("Testsend");
                    ReadLine();
                    ClientNetworkHandler.SendToServer("SendJudge");
                    ReadLine();
                    break;

                case 0: // Logout user
                    ClientNetworkHandler.SendAndReceive("Logout");
                    LoginHandler.userState = LoginHandler.UserState.None;
                    // LoginHandler.LoginMenu();
                    break;

                default:
                    WriteLine("Try again!");
                    break;
            }
        }
Beispiel #2
0
        public void OnAddDiverToDatabase(object source, EventArgs args)
        {
            if (IsNullOrEmpty(AddDiver.nameBox.Text) ||
                IsNullOrEmpty(AddDiver.CountryBox.Text) ||
                IsNullOrEmpty(AddDiver.AgeBox.Text) ||
                IsNullOrEmpty(AddDiver.diverIDBox.Text))
            {
                ErrorMessageBox("Fyll i samtliga fält", "Vänligen fyll i alla fält");
                return;
            }
            var admin = new Admin();
            var genderChoice = "";
            if (AddDiver.radioMan.Checked)
                genderChoice = "M";
            else if (AddDiver.radioWoman.Checked)
                genderChoice = "F";

            var diver = new Diver(
                AddDiver.nameBox.Text, AddDiver.CountryBox.Text,
                int.Parse(AddDiver.AgeBox.Text), genderChoice,
                int.Parse(AddDiver.diverIDBox.Text));
            admin.AddDiver(diver);
            MessageBox.Show(
                "Hoppare tillagd till databasen!",
                "Hoppare tillagd", MessageBoxButtons.OK);
            AddDiver.Close();
        }