-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDefault.aspx.cs
66 lines (62 loc) · 2.03 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(((ELearn.User)Session["user"])!=null){
Response.Redirect("home.aspx");
}
List<ClassRoom> classes = ClassRoom.GetAllClassRooms();
foreach (ClassRoom cls in classes)
{
Level lvl=Level.GetLevelById(cls.levelID);
string lname="";
if (lvl != null) { lname = lvl.levelName; }
else { lname = cls.levelID.ToString(); }
ListBox1.Items.Add(new ListItem(lname + " - " + cls.classRoomID.ToString(), cls.classRoomID.ToString()));
}
LoginButton.Focus();
}
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
}
protected void LoginButton_Click(object sender, EventArgs e)
{
ELearn.User usr = ELearn.User.loginUser(userName_login.Text, passwordLogin.Text);
if (usr != null)
{
Session["user"] = usr;
if (usr is Student)
{
Session["userType"] = "student";
}
else if (usr is Staff)
{
Session["userType"] = "staff";
}
else if (usr is Teacher)
{
Session["userType"] = "teacher";
}
Response.Redirect("home.aspx");
}
else { ErrorLogin.Visible = true; }
}
protected void RegButton_Click(object sender, EventArgs e)
{
Student student = new Student(0, RegUser.Text, RegPass.Text, RegName.Text, RegMail.Text, DateTime.Now, Convert.ToInt32(ListBox1.SelectedValue));
student.Insert();
if (student.userID != -1)
{
Session["user"] = student;
Session["userType"] = "student";
Response.Redirect("home.aspx");
}
else { RegisError.Visible = true; }
}
}