Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. public void startClient()
  2. {
  3. Login = Fname.getText().toString().trim();
  4. Password = Lpass.getText().toString().trim();
  5. //clients = dbh.getAllClients();
  6.  
  7. if (Login.length() == 0) {
  8. Toast.makeText(getApplicationContext(), "Enter Username", Toast.LENGTH_LONG).show();
  9. } else if (Password.length() == 0) {
  10. Toast.makeText(getApplicationContext(), "Enter password", Toast.LENGTH_LONG).show();
  11. } else {
  12. DBHelper db = new DBHelper(getApplicationContext());
  13. //get data from database
  14. final List<Client> user = db.getAllClients();
  15. String username = Login;
  16. String password = Password;
  17. if (username.equals(user.get(0).getFirst()) && password.equals(user.get(0).getPassword())) {
  18. Intent i = new Intent(getApplicationContext(), Client.class);
  19. startActivity(i);
  20. } else if (username.equals(user.get(0).getFirst()) && !password.equals(user.get(0).getPassword())) {
  21. Password.equals("");
  22. Toast.makeText(MainActivity.this, "Wrong Password", Toast.LENGTH_SHORT).show();
  23. } else if (!username.equals(user.get(0).getFirst())) {
  24. Toast.makeText(MainActivity.this, "Wrong Username", Toast.LENGTH_SHORT).show();
  25.  
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement