//This method inputs new user data into the database. public void RegisterNewLecturer() { //a try catch is used to determine if database username data matches the users input. If the pk constraint throws an error it signals that a username with the same name already exists and reflects this to the user in a message. try { var login = Int32.Parse(tbUsername.Text); var password = tbPassword.Password; var fName = tbFName.Text; var lName = tbLName.Text; var c = new ModelRegisterLogin { LECT_USERNAME = login, LECT_PASSWORD = password, LECT_FNAME = fName, LECT_LNAME = lName }; //The InsertLecturerRegData method from thr data access layer ddl performs a sql query that inserts the user input into the LecturerLogin table within the application database. cl.InsertLecturerRegData(c, connectionString); MessageBox.Show($"Registration Successful!" + "\nYou may now Login LECTURER " + tbUsername.Text + " !"); tabLoginRegister.SelectedIndex = 1; } catch (System.Exception) { MessageBox.Show("User already exists or the input for LECTURER NUMBER is not a number\nPlease try again", "Error"); tbUsername.Text = ""; tbPassword.Password = ""; } }
public void RegisterNewLecturer() { try { var login = tbUsername.Text; var password = tbPassword.Password; var c = new ModelRegisterLogin { LECT_USERNAME = login, LECT_PASSWORD = password }; cl.InsertLecturerRegData(c, connectionString); MessageBox.Show($"Registration Successful!" + "\nYou may now Login, LECTURER " + tbUsername.Text + " !"); tabLoginRegister.SelectedIndex = 1; } catch (System.Exception) { MessageBox.Show("User already exists\nPlease try again", "Error"); tbUsername.Text = ""; tbPassword.Password = ""; } }