Guest User

Untitled

a guest
Nov 3rd, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. private void btnLogin_Click(object sender, EventArgs e)
  2. {
  3. progressPanel1.Visible = true;
  4. Thread thread = new Thread(new ThreadStart(logadmin));
  5. thread.Start();
  6. }
  7.  
  8. public void logadmin()
  9. {
  10. if (string.IsNullOrWhiteSpace(tbUsername.Text))
  11. { MessageBox.Show("Enter username"); tbUsername.Focus(); }
  12. else if (string.IsNullOrWhiteSpace(tbPassword.Text))
  13. { MessageBox.Show("Enter password"); tbPassword.Focus(); }
  14. else
  15. {
  16. connection.Close();
  17. try
  18. {
  19. MySqlCommand cmd = new MySqlCommand("select * from usertbl where Username = '" + tbUsername.Text + "' and Password = '" + tbPassword.Text + "'", connection);
  20. connection.Open();
  21. reader = cmd.ExecuteReader();
  22.  
  23. while (reader.Read())
  24. {
  25. count = count + 1;
  26. }
  27.  
  28. if (count == 1)
  29. {
  30. Form1 ma = new Form1();
  31. ma.Show();
  32. connection.Close();
  33. this.Hide();
  34. }
  35. else
  36. {
  37. MessageBox.Show("Log-in Failed!");
  38. }
  39. }
  40.  
  41. catch (Exception ex)
  42. {
  43. MessageBox.Show(ex.Message);
  44. }
  45. }
  46. }
Add Comment
Please, Sign In to add comment