-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
111 lines (83 loc) · 2.26 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using System.Data.SqlClient;
namespace JAT_AIR_Airline_Form
{
public partial class Login : Form
{
//Place Connect string some where here
SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=""C:\Users\tnt52\source\repos\JAT-AIR Airline Form\CredentialsDatabase1.mdf"";Integrated Security=True");
SqlCommand cmd;
public Login()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void UsernameTextBox_TextChanged(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
//Login Button
private void LoginButton_Click(object sender, EventArgs e)
{
try
{
string SQLSelect = "Select count(*) From login_Table Where uname = @username and password = @pass"; SqlCommand cmd = new SqlCommand(SQLSelect, conn);
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@username", UsernameTextBox.Text);
cmd.Parameters.AddWithValue("@pass", PasswordTextBox.Text);
conn.Open();
if (cmd.ExecuteScalar().ToString() == "1")
{
MessageBox.Show("Welcome back, " + UsernameTextBox.Text + " you are logged in.");
this.Hide();
Form2 f2 = new Form2();
f2.Show();
}
else
{
MessageBox.Show("Incorrect Username or Password, Try again!");
UsernameTextBox.Clear();
PasswordTextBox.Clear();
}
conn.Close();
}
catch (Exception err)
{
MessageBox.Show(err.Message, "Error Message");
}
}
//The Exit Button
private void ExitButton_Click(object sender, EventArgs e)
{
DialogResult confirm = MessageBox.Show("Are you sure you want to exit?", "Exit Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (confirm == DialogResult.Yes)
{
Application.Exit();
}
}
private void label3_Click(object sender, EventArgs e)
{
}
private void label3_Click_1(object sender, EventArgs e)
{
}
private void label3_Click_2(object sender, EventArgs e)
{
}
private void label4_Click(object sender, EventArgs e)
{
}
}
}