-
Notifications
You must be signed in to change notification settings - Fork 0
/
adminlogin.aspx.cs
101 lines (76 loc) · 3 KB
/
adminlogin.aspx.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
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace DB_Prpject
{
public partial class adminlogin : System.Web.UI.Page
{
//protected void Page_Load(object sender, EventArgs e)
//{
//}
protected void Button1_Click(object sender, EventArgs e)
{
// Response.Write("<script>alert('Good');</script>");
//string strconnect = "Data Source=DESKTOP-BTS0DDI\\HAFIZHAMZASHAHID;Initial Catalog=dbproject;Integrated Security=True";
try
{
string strconnect = "Data Source=AKKHAN;Initial Catalog=dbproject;Integrated Security=True";
SqlConnection con = new SqlConnection(strconnect);
con.Open();
SqlCommand cmd = new SqlCommand("select * from admin_ where login_id='" + TextBox1.Text.Trim() + "' AND _password='" + TextBox2.Text.Trim() + "'", con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
//Response.Write("<script>alert('" + dr.GetValue(8).ToString() + "');</script>");
Response.Write("<script>alert('User Login Succesfful');</script>");
Session["login_id"] = dr.GetValue(0).ToString();
//Session["fullname"] = dr.GetValue(2).ToString();
Session["role"] = "seller";
//Session["status"] = dr.GetValue(10).ToString();
}
Response.Redirect("adminMainPage.aspx");
}
else
{
Response.Write("<script>alert('Invalid credentials');</script>");
}
}
catch (Exception ex)
{
}
}
//catch (Exception ex)
//{
//}
// try
// {
//string strconnect = "Data Source=DESKTOP-BTS0DDI\\HAFIZHAMZASHAHID;Initial Catalog=dbproject;Integrated Security=True";
//SqlConnection con = new SqlConnection(strconnect);
//con.Open();
//SqlCommand cmd = new SqlCommand("select * from where login_id='" + TextBox1.Text.Trim() + "' AND _password='" + TextBox2.Text.Trim() + "'", con);
//SqlDataReader dr = cmd.ExecuteReader();
//if (dr.HasRows)
//{
// Response.Write("<script>alert('LoginSuccesfful');</script>");
// while (dr.Read())
// {
// //Response.Write("<script>alert('" + dr.GetValue(8).ToString() + "');</script>");
// Response.Redirect("adminmaster.Master");
// }
//}
//else
//{
// Response.Write("<script>alert('Invalid credentials');</script>");
//}
// }
// catch (Exception ex)
// {
// }
}
}