Advertisement
Guest User

Untitled

a guest
May 8th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 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 = "server=162.253.224.12;user id=meisterc;persistsecurityinfo=True;database=meisterc_mybb598";
  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. /* If chkRemember is checked, save the users's credentials, otherwise reset them to an empty string */
  46. if (chkRemember.Checked)
  47. {
  48. Properties.Settings.Default.username = txtUsername.Text.Trim();
  49. Properties.Settings.Default.password = txtPassword.Text;
  50. }
  51. else
  52. {
  53. Properties.Settings.Default.username = String.Empty;
  54. Properties.Settings.Default.password = String.Empty;
  55. }
  56.  
  57. /* Set the remember state */
  58. Properties.Settings.Default.remember = chkRemember.Checked;
  59.  
  60. /* Save the settings */
  61. Properties.Settings.Default.Save();
  62.  
  63. /* Hide Login, show Loader and close Login */
  64. this.Hide();
  65. AuthLoad loader = new AuthLoad(txtUsername.Text.Trim());
  66. loader.ShowDialog();
  67. this.Close();
  68. }
  69. con.Close();
  70. }
  71. private void btnCancel_Click(object sender, EventArgs e)
  72. {
  73. /* Exit the loader */
  74. Application.Exit();
  75. }
  76.  
  77. private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
  78. {
  79.  
  80. }
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement