-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.aspx.cs
102 lines (88 loc) · 3.18 KB
/
default.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
102
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
namespace Internship
{
public partial class _default : System.Web.UI.Page
{
SqlConnection cn;
SqlCommand cm;
SqlDataReader dr;
protected void Page_Load(object sender, EventArgs e)
{
if(! IsPostBack)
{
}
}
protected void Button2_Click(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
String k = ConfigurationManager.AppSettings["mydb"];
cn = new SqlConnection(k);
cn.Open();
string b = "select *from logintb where uerid = @user1 and Password = @password1";
cm = new SqlCommand(b, cn);
cm.Parameters.AddWithValue("@user1", txtid.Text);
cm.Parameters.AddWithValue("@password1", txtpassword.Text);
dr = cm.ExecuteReader();
if (dr.Read())
{
Session["user"] = dr["uerid"].ToString();
string role = dr["role"].ToString();
if (role == "admin")
{
Response.Redirect("dashboardadmin.aspx");
}
else if (role == "hod" || role == "HOD")
{
dr.Close();
string a = "select department from hodtb where uerid = @uerid1";
cm = new SqlCommand(a, cn);
cm.Parameters.AddWithValue("uerid1", txtid.Text);
dr = cm.ExecuteReader();
if (dr.Read())
{
Session["branch"] = dr["department"].ToString();
}
Response.Redirect("student.aspx");
}
else if (role == "student")
{
dr.Close();
string a = "select *from studenttb where studentid = @uerid1";
cm = new SqlCommand(a, cn);
cm.Parameters.AddWithValue("uerid1", txtid.Text);
dr = cm.ExecuteReader();
if (dr.Read())
{
Session["studentid1"] = dr["studentid"].ToString();
Session["name1"] = dr["name"].ToString();
Session["branch1"] = dr["branch"].ToString();
Session["section1"] = dr["section"].ToString();
}
Response.Redirect("internshipstudent.aspx");
}
else
{
Response.Write("Incorect ");
}
dr.Close();
}
else
{
Response.Write("Record Unmatch");
dr.Close();
}
}
protected void Button2_Click1(object sender, EventArgs e)
{
}
}
}