Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void Loginbtn_Click(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection(@"Data Source=.SQLEXPRESS;Initial Catalog=MySupportHub;Integrated Security=True");
- SqlDataAdapter sda = new SqlDataAdapter(@"SELECT * FROM [dbo].[Login] Where Username='" + usernameTextBox.Text + "' and Password='" + passwordTextBox.Text + "'", con);
- DataTable dt = new DataTable();
- sda.Fill(dt);
- if (dt.Rows.Count == 1)
- {
- Settings.Default["CurrentUserName"] = usernameTextBox.Text;
- Settings.Default.Save();
- this.Hide();
- Home home = new Home();
- home.Show();
- }
- else
- {
- MessageBox.Show("Invalid Username and/or Password..!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- Clearbtn_Click(sender, e);
- }
- }
- //Identify and display current logged in user
- CurrentUser.Caption = Settings.Default["CurrentUserName"].ToString();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement