Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. private void button1_Click(object sender, EventArgs e)
  2. {
  3. try
  4. {
  5. string myConnection = "datasource=sql7.freemysqlhosting.net;port=3306;username=sql7148389;password=MisLVjvDUG";
  6. MySqlConnection myConn = new MySqlConnection(myConnection);
  7.  
  8. MySqlCommand SelectCommand = new MySqlCommand("select dzial,admin from sql7148389.user where username='" + this.username_txt.Text + " ' and password='" + this.password_txt.Text + "';", myConn);
  9.  
  10. MySqlDataReader myReader;
  11. myConn.Open();
  12. myReader = SelectCommand.ExecuteReader();
  13. int count = 0;
  14.  
  15. while(myReader.Read())
  16. {
  17. count = count + 1;
  18. }
  19. if (count == 1 && (myReader.GetValue(0).ToString()=="Biuro"))
  20. {
  21.  
  22.  
  23.  
  24. MessageBox.Show("Login i hasło są poprawne");
  25. username = username_txt.Text;
  26. this.Hide();
  27. Form8 f3 = new Form8(username);
  28. f3.ShowDialog();
  29.  
  30. }
  31. else if (count == 1 && (myReader.GetValue(1).ToString() == "1"))
  32. {
  33. // MessageBox.Show(myReader.GetValue(0).ToString());
  34. MessageBox.Show("Login i hasło są poprawne");
  35.  
  36. this.Hide();
  37. Form3 f3 = new Form3();
  38. f3.ShowDialog();
  39. }
  40. else if (count == 1 && (myReader.GetValue(0).ToString() == "Warsztat"))
  41. {
  42. MessageBox.Show("Login i hasło są poprawne");
  43. username = username_txt.Text;
  44. this.Hide();
  45. Form1 f3 = new Form1(username);
  46. f3.ShowDialog();
  47. }
  48. else if (count > 1)
  49. {
  50. MessageBox.Show("Zduplikowany login i hasło. Brak dostępu");
  51. }
  52. else
  53. MessageBox.Show("Login i hasło są niepoprawne");
  54. myConn.Close();
  55. }
  56.  
  57. catch (Exception ex)
  58. {
  59. MessageBox.Show(ex.Message);
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement