//This method checks to see if password and username input from each textbox matches password and username data stored in the USER table in the application database. public void LoginUser() { ModelRegisterLogin user = new ModelRegisterLogin(); List <ModelRegisterLogin> list = cl.GetAllFromUser(connectionString); try { user = list.Find((ModelRegisterLogin x) => x.USER_LIBRARY_CARD_ID == Int32.Parse(tbUsernameLog.Text)); if (user == null) { MessageBox.Show("Incorrect username or password\nPlease recheck your credentials and try again", "Error"); tbUsernameLog.Text = ""; tbPasswordLog.Password = ""; } else if (user.USER_LIBRARY_CARD_ID.ToString().Equals(tbUsernameLog.Text) && user.USER_PASSWORD.ToString().Equals(tbPasswordLog.Password)) { MessageBox.Show("Login Successful !\nWelcome " + user.USER_FNAME.ToString()); MainMenu mm = new MainMenu(Int32.Parse(tbUsernameLog.Text)); mm.Show(); this.Close(); } else { MessageBox.Show("Incorrect username or password\nPlease recheck your credentials and try again", "Error"); tbUsernameLog.Text = ""; tbPasswordLog.Password = ""; } } catch (System.Exception) { MessageBox.Show("Incorrect username or password\nPlease recheck your credentials and try again", "Error"); tbUsernameLog.Text = ""; tbPasswordLog.Password = ""; } }