-
Notifications
You must be signed in to change notification settings - Fork 0
/
Login.cs
76 lines (68 loc) · 2.33 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace cosmesticClinic
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
this.Text = string.Empty;
this.ControlBox = false;
}
private string conStr = connectionString.constr;
private void button1_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void btnSave_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection(conStr);
try
{
if (txtUser.Text.Equals(string.Empty) || txtPass.Text.Equals(string.Empty))
{
MessageBox.Show("Enter your login Details, USERNAME & PASSWORD", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
con.Open();
OleDbDataReader read;
string details = "SELECT * from tbl_User_login WHERE username='" + txtUser.Text + "' and password='" + txtPass.Text + "'";
OleDbCommand cmd = new OleDbCommand(details, con);
read = cmd.ExecuteReader();
if (read.Read() == true)
{
con.Close();
this.Hide();
Form1 form = new Form1();
form.ShowDialog();
}
else
{
con.Close();
MessageBox.Show("User not Found ", "invalid input", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
catch (Exception ex)
{
con.Close();
MessageBox.Show(ex.Message, "invalid input", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
private void Login_Load(object sender, EventArgs e)
{
txtPass.Text = "admin";
txtUser.Text = "admin";
}
}
}