-
Notifications
You must be signed in to change notification settings - Fork 2
/
login.aspx.cs
executable file
·71 lines (67 loc) · 2.3 KB
/
login.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
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SuperMarket.Model;
using SuperMarket.Logic;
namespace SuperMarket
{
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.Button1.Attributes["onclick"] = "return check();";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
/*取得帐号密码信息*/
string userName = this.txtName.Text;
string password = this.txtPwd.Text;
string identify = this.Identify.SelectedValue;
if ("管理员" == identify)
{
AdminModel adminModel = new AdminModel();
adminModel.AdminUsername = userName;
adminModel.AdminPassword = password;
AdminLogic adminLogic = new AdminLogic();
/*如果管理员帐号信息正确*/
if (adminLogic.IsExistAdminInfo(adminModel))
{
Session["adminFlag"] = true;
Session["adminUsername"] = userName;
Response.Redirect("Admin/index.aspx");
}
/*如果管理员帐号信息不正确*/
else
{
Response.Write("<script>alert('" + adminLogic.ErrMessage + "');</script>");
}
}
else
{
/*如果员工帐号信息正确*/
EmployeeLogic employeeLogic = new EmployeeLogic();
if(employeeLogic.CheckLogin(userName,password))
{
Session["employeeFlag"] = true;
Session["employeeNo"] = userName;
Response.Redirect("Employee/index.aspx");
}
/*如果员工帐号信息不正确*/
else
{
Response.Write("<script>alert('" + employeeLogic.ErrMessage + "');</script>");
}
}
}
}
}