private void btnSignUp_Click(object sender, EventArgs e) { if ((txtRegID.Text == "" || txtUserName.Text == "" || txtPassword.Text == "" || txtConfirmPass.Text == "")) { MessageBox.Show("One or more filed(s) empty!"); return; } if (txtPassword.Text != txtConfirmPass.Text) { MessageBox.Show("Password fields did'nt match!"); return; } try { if (accountLevel == "student") { var found = studentCRUD.FindStudent(int.Parse(txtRegID.Text)); if (!found) { MessageBox.Show("Registration ID does not find in our records!"); return; } } else if (accountLevel == "teacher") { var found = teacherCRUD.FindTeacher(int.Parse(txtRegID.Text)); if (!found) { MessageBox.Show("Registration ID does not find in our records!"); return; } } var user = new RegisterUser { RegistrationID = int.Parse(txtRegID.Text), UserName = txtUserName.Text, Password = txtPassword.Text, AccountLevel = accountLevel }; var added = userRegistrationCRUD.AddUser(user); if (added) { MessageBox.Show("Added successfully, please SignIn with your UserName and Password."); ClearTextBoxes(); } else { MessageBox.Show("Error while adding record."); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }