Пример #1
0
        //A method to increase the level of a studdybuddy
        private void LevelUp(AStuddyBuddy StuddyBuddy)
        {
            int enumvalue = (int)StuddyBuddy.Status;

            StuddyBuddy.Status = enumvalue + 1;

            MessageBox.Show("Your new level: " + (Level)StuddyBuddy.Status);
        }
Пример #2
0
        private void Submit_Click(object sender, EventArgs e)
        {
            if (FacultyComboBox.SelectedIndex >= 0)
            {
                if (StudiesComboBox.SelectedIndex >= 0)
                {
                    AStuddyBuddy StuddyBuddy = new AStuddyBuddy(NicknameBox.Text.ToString(),
                                                                LinkBox.Text.ToString(),
                                                                FacultyComboBox.SelectedItem.ToString(),
                                                                StudiesComboBox.SelectedItem.ToString());

                    RegexChecker      regexObject = new RegexChecker();
                    DatabaseProcessor DBprocessor = new DatabaseProcessor();
                    bool nicknameValid            = regexObject.CheckNickname(StuddyBuddy.Nickname);
                    bool linkValid    = regexObject.CheckLink(StuddyBuddy.Link);
                    bool personExists = DBprocessor.FindExistingPerson(StuddyBuddy);

                    if (nicknameValid && linkValid && !personExists)
                    {
                        DBprocessor.AddEntryToDatabase(StuddyBuddy);

                        MessageBox.Show("Your nickname: " + StuddyBuddy.Nickname + Environment.NewLine +
                                        "Your Link: " + StuddyBuddy.Link + Environment.NewLine +
                                        "Chosen faculty: " + StuddyBuddy.Faculty + Environment.NewLine +
                                        "Chosen studies: " + StuddyBuddy.Studies + Environment.NewLine +
                                        "Your level: " + (Level)StuddyBuddy.Status);
                        //LevelUp(StuddyBuddy);
                        this.Close();
                    }
                    else if (!nicknameValid)
                    {
                        MessageBox.Show("Nickname is not valid");
                    }
                    else if (!linkValid)
                    {
                        MessageBox.Show("Link is not valid");
                    }
                    else if (personExists)
                    {
                        MessageBox.Show("This person already exists");
                    }
                }
            }
        }