Example #1
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            int index = students.searchList(usernameTextBox.Text);

            if (index > -1)
            {
                if (students.getStudents()[index].checkPassword(passwordTextBox.Text))
                {
                    //proceed
                    PlaylistEditorForm newForm = new PlaylistEditorForm(students, students.getStudents()[index], library);
                    this.Close();
                    newForm.Show();
                }
                else
                {
                    //wrong password
                    errorMessageLabel.Text = "Incorrect Password!";
                }
            }
            else
            {
                //wrong username
                errorMessageLabel.Text = "Incorrect Username!";
            }
        }
Example #2
0
        private void confirmButton_Click(object sender, EventArgs e)
        {
            bool ready = true;

            if (firstNameTextBox.Text.Length < 1 || lastNameTextBox.Text.Length < 1 || ageTextBox.Text.Length < 1 || passwordTextBox.Text.Length < 1 || reenterPasswordTextBox.Text.Length < 1)
            {
                errorMessageLabel.Text = "Make sure you fill in all the boxes!";
                ready = false;
            }

            if (!firstNameTextBox.Text.All(char.IsLetter))
            {
                errorMessageLabel.Text = "First name must only contain letters!";
                ready = false;
            }

            if (!lastNameTextBox.Text.All(char.IsLetter))
            {
                errorMessageLabel.Text = "Last name must only contain letters!";
                ready = false;
            }

            try
            {
                Convert.ToInt32(ageTextBox.Text);
            }
            catch
            {
                errorMessageLabel.Text = "Age must be an integer!";
                ready = false;
            }

            if (passwordTextBox.Text != reenterPasswordTextBox.Text)
            {
                errorMessageLabel.Text = "Passwords do not match!";
                ready = false;
            }

            if (ready)
            {
                students.addStudent(firstNameTextBox.Text, lastNameTextBox.Text, Convert.ToInt32(ageTextBox.Text), passwordTextBox.Text, library);
                //proceed
                PlaylistEditorForm newForm = new PlaylistEditorForm(students, students.getStudents()[students.getCount() - 1], library);
                this.Close();
                newForm.Show();
            }
        }