Guest User

Untitled

a guest
Dec 28th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. using MySql.Data.MySqlClient;
  2. ...
  3. private void buttonOk_Click(object sender, EventArgs e)
  4. {
  5. timer2.Start();
  6. }
  7.  
  8. public static string Datasource = "localhost";
  9. public static string Port = "3306";
  10. public static string InitialCatalog = "user";
  11. public static string Username = "user";
  12. public static string Password = "pass";
  13.  
  14. //MySql
  15. MySqlConnection connection = new MySqlConnection("datasource=" + Datasource + ";port=" + Port + ";Initial Catalog='" + InitialCatalog + "';username=" + Username + ";password=" + Password);
  16. MySqlDataAdapter adapter;
  17. DataTable table = new DataTable();
  18.  
  19. public void MySqlConnect()
  20. {
  21. adapter = new MySqlDataAdapter("SELECT `username`, `password` FROM `users` WHERE `username` = '" + textBoxUsername.Text + "' AND `password` = '" + textBoxPassword.Text + "'", connection);
  22. adapter.Fill(table); //PROBLEM
  23.  
  24. if (table.Rows.Count <= 0)
  25. {
  26. panel1.Height = 0;
  27. labelMessage.ForeColor = Color.Red;
  28. labelMessage.Text = "Username Or Password Are Invalid";
  29. timer1.Start();
  30. }
  31. else
  32. {
  33. panel1.Height = 0;
  34. labelMessage.ForeColor = Color.Green;
  35. labelMessage.Text = "Login Successfully";
  36. timer1.Start();
  37. }
  38.  
  39. table.Clear();
  40. }
  41.  
  42. private void timer1_Tick(object sender, EventArgs e)
  43. {
  44. if (panel1.Height != 100)
  45. {
  46. panel1.Height = panel1.Height + 5;
  47. if (panel1.Height == 100)
  48. {
  49. timer1.Stop();
  50. }
  51. }
  52. }
  53.  
  54. private void timer2_Tick(object sender, EventArgs e)
  55. {
  56. if (panel1.Height != 0)
  57. {
  58. panel1.Height = panel1.Height - 5;
  59. if (panel1.Height == 0)
  60. {
  61. timer2.Stop();
  62. }
  63. }
  64. }
  65.  
  66. private void checkBoxShowPass_CheckedChanged(object sender, EventArgs e)
  67. {
  68. if (checkBoxShowPass.Checked)
  69. {
  70. textBoxPassword.UseSystemPasswordChar = true;
  71. }
  72. else
  73. {
  74. textBoxPassword.UseSystemPasswordChar = false;
  75. }
  76. }
  77. ...
Add Comment
Please, Sign In to add comment