-
Notifications
You must be signed in to change notification settings - Fork 0
/
LOGIN.cs
114 lines (100 loc) · 3.4 KB
/
LOGIN.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
112
113
114
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Configuration;
using System.Data.SqlClient;
namespace Calender
{
public partial class LOGIN : Form
{
string cs = ConfigurationManager.ConnectionStrings["dbcs"].ConnectionString;
public LOGIN()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
bool check = checkBox1.Checked;
switch(check)
{
case true:
textBox2.UseSystemPasswordChar = false;
break;
default:
textBox2.UseSystemPasswordChar = true;
break;
}
}
private void button1_Click(object sender, EventArgs e)
{
if(textBox1.Text!="" && textBox2.Text!="")
{
SqlConnection con = new SqlConnection(cs);
string query = "select * from login_table where username=@user and pass=@pass";
SqlCommand cmd = new SqlCommand(query, con);
cmd.Parameters.AddWithValue("@user", textBox1.Text);
cmd.Parameters.AddWithValue("@pass", textBox2.Text);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows == true)
{
MessageBox.Show("Login Successfull !!", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information);
Booking bk = new Booking();
bk.Show();
this.Hide();
}
else
{
Error err = new Error();
err.Show();
this.Hide();
MessageBox.Show("Invalid Username or Password !!", "FALIURE", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
con.Close();
}
else
{
MessageBox.Show("Fill Both Fields !!!", "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
private void textBox1_Leave(object sender, EventArgs e)
{
if(string.IsNullOrEmpty(textBox1.Text)==true)
{
textBox1.Focus();
errorProvider1.SetError(this.textBox1, "Please fill this field");
}
else
{
errorProvider1.Clear();
}
}
private void textBox2_Leave(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox2.Text) == true)
{
textBox2.Focus();
errorProvider2.SetError(this.textBox2, "Please enter password");
}
else
{
errorProvider2.Clear();
}
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
SIGNUP li = new SIGNUP();
li.Show();
this.Hide();
}
}
}