-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProfStatistic.aspx.cs
99 lines (84 loc) · 3.32 KB
/
ProfStatistic.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
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class ProfStatistic : System.Web.UI.Page
{
string conString = ConfigurationManager.ConnectionStrings["DatabaseConnecting"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Name"] != null && Session.Timeout != 0)
{
if (Session["UserType"].ToString() == "professor" && Session["Status"].ToString() == "1")
{
Master.lblusername.Text = "Hi " + Session["Name"].ToString();
Master.logout.Visible = true;
Master.login.Visible = false;
Master.signup.Visible = false;
Master.imgprofile.Visible = true;
Master.home.PostBackUrl = "ProfessorHome.aspx";
LoadGridView();
GetCountofQuestions();
}
else
{
Response.Redirect("StudentHome.aspx");
}
}
else
{
Response.Redirect("Login.aspx");
Master.home.Enabled = true;
}
}
private void LoadGridView()
{
SqlConnection con = new SqlConnection(conString);
con.Open();
string q = "select * from Tbl_User where Username='" + Session["Name"] + "'";
SqlCommand cmd = new SqlCommand(q, con);
SqlDataReader read = cmd.ExecuteReader();
while (read.Read())
{
Session["EducationLevel"] = read["EduLevel"].ToString();
}
con.Close();
BoundField NewColumn = new BoundField();
NewColumn.DataField ="UserName";
NewColumn.HeaderText = "Students who took my exam";
GridView1.Columns.Add(NewColumn);
}
private void GetCountofQuestions()
{
SqlConnection con = new SqlConnection(conString);
con.Open();
string Query = "SELECT COUNT(*) AS 'Count' FROM Tbl_Ques_Ans where Username='" + Session["Name"].ToString() + "'";
string q1 = "select UserName from Tbl_Certification where SubjectID = (select SubjectID from Tbl_Subject where SubjectName = (select Subject from Tbl_User where Username = '" + Session["Name"] + "'))";
SqlCommand cmd1 = new SqlCommand(Query, con);
SqlDataReader read = cmd1.ExecuteReader();
read.Read();
LabelNoQuestions.Text = read["Count"].ToString();
con.Close();
//
con.Open();
string QueryTF = "SELECT COUNT(*) AS 'Count' FROM Tbl_Ques_Ans where Username='" + Session["Name"].ToString() + "' and QuestionType='True OR False'";
SqlCommand cmd2 = new SqlCommand(QueryTF, con);
SqlDataReader read2 = cmd2.ExecuteReader();
read2.Read();
LabelNoQuestionsTf.Text = read2["Count"].ToString();
con.Close();
//
con.Open();
string QueryMCQ = " SELECT COUNT(*)AS 'Count' FROM Tbl_Ques_Ans where Username = '" + Session["Name"].ToString() + "' and QuestionType = 'MCQ'";
SqlCommand cmd3 = new SqlCommand(QueryMCQ, con);
SqlDataReader read3 = cmd3.ExecuteReader();
read3.Read();
LabelNoQuestionsMcq.Text = read3["Count"].ToString();
con.Close();
}
}