📄 default.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Hr
{
public class _Default : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblInfo;
protected System.Web.UI.WebControls.Panel Panel1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.ImageButton ib_Login;
protected System.Web.UI.WebControls.CheckBox chkRemember;
protected System.Web.UI.WebControls.HyperLink HyperLink1;
protected System.Web.UI.WebControls.TextBox txtUserName;
protected System.Web.UI.WebControls.TextBox txtPassword;
protected System.Web.UI.WebControls.RadioButtonList RadioButtonList1;
private void Page_Load(object sender, System.EventArgs e)
{
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.ib_Login.Click += new System.Web.UI.ImageClickEventHandler(this.ib_Login_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void ib_Login_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
int id;
string UserName;
string password;
int UserType = Int32.Parse(RadioButtonList1.SelectedItem.Value);
UserName = this.txtUserName.Text.Trim();
password=this.txtPassword.Text.Trim();
if(UserType == 1)
{
Hr.component.Person person1 = new Hr.component.Person();
person1.Name = UserName;
person1.Password = password;
if(person1.Login())
{
person1.GetUserInfo();
id = person1.ID;
Session["UserName"] = UserName;
Session["UserID"] = id;
Session["UserType"] = UserType;
Response.Redirect("Home.aspx");
}
else
{
this.lblInfo.Text = "登录失败,请重试!";
}
}
else if(UserType ==2)
{
Hr.component.Company company1 = new Hr.component.Company();
company1.Name = UserName;
company1.Password = password;
if(company1.Login())
{
company1.GetUserInfo();
id = company1.ID;
Session["UserName"] = UserName;
Session["UserID"] = id;
Session["UserType"] = UserType;
Response.Redirect("Home.aspx");
}
else
{
this.lblInfo.Text = "登录失败,请重试!";
}
}
else
{
string managename,managepwd;
managename=System.Configuration.ConfigurationSettings.AppSettings["Manager"];
managepwd=System.Configuration.ConfigurationSettings.AppSettings["Password"];
if(managename==UserName && managepwd==password)
{
Session["UserName"] = UserName;
Session["UserID"] = "-1";
Session["UserType"] = UserType;
Response.Redirect("Home.aspx");
}
else
{
this.lblInfo.Text = "登录失败,请重试!";
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -