This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student.cs
176 lines (134 loc) · 3.8 KB
/
Student.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.ServiceModel.Configuration;
using System.Web;
using System.Web.UI;
/// <summary>
/// Summary description for Student
/// </summary>
public class Student
{
private DegForm form_obj;
private CompForm form_comp;
private Feedback feedback_form;
private Deg_Token degree_token;
private string user_id ;
private string password;
private string name;
public Student()
{
form_obj = null;
form_comp = null;
degree_token = null;
}
public void create_form_degree() // creates a degree issuance form
{
if (form_obj == null)
{
form_obj = new DegForm();
form_obj.SetUserId(this.user_id);
}
}
public void create_form_complaint() // creates a complaint issuance form
{
if (form_comp == null)
{
form_comp = new CompForm();
form_comp.SetUserId(this.user_id);
}
form_comp.assign_ID();
}
public void create_form_feedback() // creates a feedback form
{
if (feedback_form == null)
{
feedback_form = new Feedback();
feedback_form.set_userid(this.user_id);
}
feedback_form.assign_ID();
}
public bool SubmitForm()
{
string form_id = form_obj.check_already_inserted();
bool already_inserted = false;
if (form_id == "")
already_inserted = false;
else
already_inserted = true;
if (already_inserted)
{
return false; // the user has already inserted in the table
}
else
{
form_obj.insert_form_db();
return true;
}
}
public DegForm getdegform()
{
return form_obj;
}
public CompForm getcompform()
{
return form_comp;
}
public Feedback getfeedbackform()
{
return feedback_form;
}
public void fetch_info(string u)
{
string connectionString = "Data Source=DESKTOP-DH5VMPH\\SQLEXPRESS;Initial Catalog=final_se;Integrated Security=True;";
string query = "SELECT * FROM users WHERE user_id = @userId";
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand(query, connection);
command.Parameters.AddWithValue("@userId", u);
try
{
connection.Open();
SqlDataReader reader = command.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
this.user_id = reader["user_id"].ToString();
this.name= reader["name"].ToString();
this.password = reader["password"].ToString();
}
}
else
{
// Console.WriteLine("No data found.");
}
reader.Close();
}
catch (Exception ex)
{
//Console.WriteLine("An error occurred: " + ex.Message);
}
}
}
public string getuserid()
{
return user_id;
}
public string getname()
{
return name;
}
public void create_tokdeg()
{
if (degree_token == null)
{
degree_token = new Deg_Token();
}
}
public Deg_Token get_tokdeg()
{
return degree_token ;
}
}