Advertisement
Guest User

Untitled

a guest
May 8th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 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.Text;
  7. using System.Windows.Forms;
  8. using System.Data.Sql;
  9. using System.Data.OleDb;
  10. using System.Data.SqlClient;
  11.  
  12. namespace v1go
  13. {
  14. public partial class Login : Form
  15. {
  16. public Login()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21. private void Login_Load(object sender, EventArgs e)
  22. {
  23. /* Center Form on screen */
  24. this.CenterToScreen();
  25.  
  26. /* Load the user's credentials and remember state from Settings */
  27. txtUsername.Text = Properties.Settings.Default.username;
  28. txtPassword.Text = Properties.Settings.Default.password;
  29. chkRemember.Checked = Properties.Settings.Default.remember;
  30. }
  31.  
  32. private void btnLogin_Click(object sender, EventArgs e)
  33. {
  34. SqlConnection con = new SqlConnection();
  35. con.ConnectionString = "Data Source=162.253.224.12;Initial Catalog=mybbkj_users;Integrated Security=True";
  36. con.Open();
  37. string userid = txtUsername.Text;
  38. string password = txtPassword.Text;
  39. SqlCommand cmd = new SqlCommand("select userid,password from login where userid='" + txtUsername.Text + "'and password='" + txtPassword.Text + "'", con);
  40. SqlDataAdapter da = new SqlDataAdapter(cmd);
  41. DataTable dt = new DataTable();
  42. da.Fill(dt);
  43. if (dt.Rows.Count > 0)
  44. {
  45. MessageBox.Show("Invalid Login please check username and password");
  46. }
  47. /* If chkRemember is checked, save the users's credentials, otherwise reset them to an empty string */
  48. if (chkRemember.Checked)
  49. {
  50. Properties.Settings.Default.username = txtUsername.Text.Trim();
  51. Properties.Settings.Default.password = txtPassword.Text;
  52. }
  53. else
  54. {
  55. Properties.Settings.Default.username = String.Empty;
  56. Properties.Settings.Default.password = String.Empty;
  57. }
  58.  
  59. /* Set the remember state */
  60. Properties.Settings.Default.remember = chkRemember.Checked;
  61.  
  62. /* Save the settings */
  63. Properties.Settings.Default.Save();
  64.  
  65. /**
  66. * Because I'm not using AIMWARE myself, I don't know the messages for invalid credentials or HWID failures.
  67. * We'll accept any combination of credentials here.
  68. */
  69.  
  70. /* Hide Login, show Loader and close Login */
  71. this.Hide();
  72. AuthLoad loader = new AuthLoad(txtUsername.Text.Trim());
  73. loader.ShowDialog();
  74. this.Close();
  75. }
  76.  
  77. private void btnCancel_Click(object sender, EventArgs e)
  78. {
  79. /* Exit the loader */
  80. Application.Exit();
  81. }
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement