Advertisement
Guest User

Untitled

a guest
Mar 27th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 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 System.Data.SqlClient;
  11.  
  12. namespace WindowsFormsApp2
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21. private void label1_Click(object sender, EventArgs e)
  22. {
  23.  
  24. }
  25.  
  26. private void label2_Click(object sender, EventArgs e)
  27. {
  28.  
  29. }
  30.  
  31. private void Form1_Load(object sender, EventArgs e)
  32. {
  33.  
  34. }
  35.  
  36. private void btn_login_Click(object sender, EventArgs e)
  37. {
  38. SqlConnection con = new SqlConnection(@"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\Users\serge\source\repos\WindowsFormsApp2\Database.mdf; Integrated Security = True; Connect Timeout = 30;");
  39. SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) From Login where Username = '" + textBox1.Text + " ' and Password = ' " + textBox2.Text + " ' ", con);
  40. DataTable dt = new DataTable();
  41. sda.Fill(dt);
  42. if (dt.Rows[0][0].ToString() == "1")
  43. {
  44. this.Hide();
  45. Main ss = new Main();
  46. ss.Show();
  47. }
  48. else
  49. {
  50. MessageBox.Show("Please Check your Username and Password");
  51. }
  52. }
  53.  
  54. private void btn_exit_Click(object sender, EventArgs e)
  55. {
  56. this.Close();
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement