Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using MySql.Data.Entity;
  11. using MySql.Data.MySqlClient;
  12.  
  13. namespace chatt_client
  14. {
  15. public partial class loginWindow : Form
  16. {
  17. //SQL stuff
  18. string sqlConnString;
  19. string commandString;
  20. MySqlConnection sqlConnection;
  21. MySqlCommand cmd;
  22. MySqlDataReader sqlReader;
  23.  
  24.  
  25. //Login-related variables
  26. string username;
  27. string password;
  28. string id;
  29.  
  30. public loginWindow()
  31. {
  32. sqlConnString = "server=localhost; database=chitchat; user=root; password=onRLlT2Z7X54eOeO;";
  33.  
  34. InitializeComponent();
  35. }
  36.  
  37. private void textBox1_TextChanged(object sender, EventArgs e)
  38. {
  39. username = usernameText.Text;
  40. }
  41.  
  42. private void textBox2_TextChanged(object sender, EventArgs e)
  43. {
  44. password = passwordText.Text;
  45. }
  46.  
  47. private void loginButton_Click(object sender, EventArgs e)
  48. {
  49. sqlConnection = new MySqlConnection(sqlConnString);
  50. sqlConnection.Open();
  51.  
  52. commandString = "SELECT member_id from users where username = '" + username + "' and password = '" + password + "'";
  53. cmd = new MySqlCommand(commandString, sqlConnection);
  54.  
  55. sqlReader = cmd.ExecuteReader();
  56.  
  57. while (sqlReader.Read())
  58. {
  59. if (sqlReader["member_id"] != "0" && sqlReader["member_id"] != null)
  60. {
  61. this.Hide();
  62. id = Convert.ToString(sqlReader["member_id"]);
  63. var newChatWindow = new chatWindow(id);
  64. newChatWindow.Closed += (s, args) => this.Close();
  65. newChatWindow.Show();
  66. }
  67. }
  68. }
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement