Advertisement
RockField64

Log-In Page

Apr 19th, 2022
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.25 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 Gwenchaners_Voting_System_Project
  13. {
  14.     public partial class LogInPage : Form
  15.     {
  16.         SqlConnection con = new SqlConnection();
  17.         SqlCommand com = new SqlCommand();
  18.  
  19.  
  20.         public LogInPage()
  21.         {
  22.  
  23.             InitializeComponent();
  24.             con.ConnectionString = @"Data Source=DESKTOP-NDPHD3N;Initial Catalog=UserVoters;Integrated Security=True";
  25.         }
  26.  
  27.         private void btnLogin_Click(object sender, EventArgs e)
  28.         {
  29.             con.Open();
  30.             com.Connection = con;
  31.             com.CommandText = "select * from UserInfo";
  32.  
  33.  
  34.             if (dr.Read())
  35.             {
  36.                 if (txtboxIDNo.Text.Equals(dr["ID Number"].ToString()) && txtboxPassword.Text.Equals(dr["Password"].ToString()))
  37.                 {
  38.                     this.Hide();
  39.                     Homepage homepage = new Homepage();
  40.                     homepage.Show();
  41.                 }
  42.  
  43.                 else
  44.                 {
  45.                     MessageBox.Show("Either your ID Number or your Password is Incorrect. Please Try Again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  46.                 }
  47.  
  48.  
  49.             }
  50.             con.Close();
  51.         }
  52.  
  53.         private void txtboxIDNo_TextChanged(object sender, EventArgs e)
  54.         {
  55.             if (txtboxIDNo.Text.Equals("IDNo"))
  56.             {
  57.                 txtboxIDNo.Text = "";
  58.             }
  59.         }
  60.  
  61.         private void txtboxPassword_TextChanged(object sender, EventArgs e)
  62.         {
  63.             if (txtboxPassword.Text.Equals("Password"))
  64.             {
  65.                 txtboxPassword.Text = "";
  66.             }
  67.         }
  68.  
  69.         private void checkBoxShowPassword_CheckedChanged(object sender, EventArgs e)
  70.         {
  71.             if (checkBoxShowPassword.Checked == true)
  72.             {
  73.                 txtboxPassword.UseSystemPasswordChar = false;
  74.             }
  75.             else
  76.             {
  77.                 txtboxPassword.UseSystemPasswordChar = true;
  78.             }
  79.         }
  80.     }
  81. }
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement