Advertisement
Guest User

Untitled

a guest
Jul 9th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. private void Loginbtn_Click(object sender, EventArgs e)
  2. {
  3. SqlConnection con = new SqlConnection(@"Data Source=.SQLEXPRESS;Initial Catalog=MySupportHub;Integrated Security=True");
  4. SqlDataAdapter sda = new SqlDataAdapter(@"SELECT * FROM [dbo].[Login] Where Username='" + usernameTextBox.Text + "' and Password='" + passwordTextBox.Text + "'", con);
  5. DataTable dt = new DataTable();
  6. sda.Fill(dt);
  7. if (dt.Rows.Count == 1)
  8. {
  9. Settings.Default["CurrentUserName"] = usernameTextBox.Text;
  10. Settings.Default.Save();
  11.  
  12. this.Hide();
  13. Home home = new Home();
  14. home.Show();
  15. }
  16. else
  17. {
  18. MessageBox.Show("Invalid Username and/or Password..!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  19. Clearbtn_Click(sender, e);
  20. }
  21. }
  22.  
  23. //Identify and display current logged in user
  24.  
  25. CurrentUser.Caption = Settings.Default["CurrentUserName"].ToString();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement