62,254
社区成员
发帖
与我相关
我的任务
分享
namespace Logistics.Web
{
/// <summary>
/// Logon 的摘要说明。
/// </summary>
public partial class Logon : System.Web.UI.Page
{
private ILog log = LogManager.GetLogger(typeof(Logon));
protected void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
GlobalSetMgr globalSetMgr = new GlobalSetMgr();
GlobalSetEntity entity=globalSetMgr.GetEntity();
this.chkSupportAgent.Visible = false;// entity.SupportAgent == YesNoType.YesInt;
}
}
protected void btnSubmit_Click1(object sender, ImageClickEventArgs e)
{
UserMgr userMgr = new UserMgr();
CityMgr cityMgr=new CityMgr();
UserEntity userData = new UserEntity();
if (userMgr.Logon(txtUserID.Text, txtPassword.Text, ref userData,Request))
{
//如果已经在线的用户大于等于4.那么不能登陆
List<UserEntity> onlineUsers = userMgr.GetOnlineUser();
if (onlineUsers.Count >= 5)
{
divTip.InnerText = "不能登陆,当前在线用户数为:" + onlineUsers.Count + ".已经超过了最大的在线用户数量.";
return;
}
SessionUser sessionUser = new SessionUser();
sessionUser.Password = txtPassword.Text.Trim();
sessionUser.UserName = txtUserID.Text.Trim();
sessionUser.PKID = userData.PKID;
//查询职员的信息
long employeeID = userData.EmployeeID;
EmployeeMgr employee = new EmployeeMgr();
EmployeeEntity employeeData = employee.GetEmployeeByID(employeeID);
if (employeeData != null)
{
sessionUser.Birthday = employeeData.BirthDay;
sessionUser.DepartmentID = employeeData.DepartmentID;
sessionUser.EmployeePKID = employeeID;
sessionUser.EmployeeCode = employeeData.PersonCode;
sessionUser.EmployeeName = employeeData.Name;
sessionUser.JobID = employeeData.PostID;
sessionUser.Sex = employeeData.Sex;
sessionUser.CityID = employeeData.CityID;
//查询部门名称,职位名称
DepartmentMgr deptMgr = new DepartmentMgr();
DepartmentEntity deptEntity = deptMgr.GetByPKID(employeeData.DepartmentID);
if (deptEntity != null)
{
sessionUser.DepartmentName = deptEntity.Name;
}
//查询城市名称
CityEntity cityEntity = cityMgr.GetByPKID(employeeData.CityID);
sessionUser.CityName = cityEntity != null ? cityEntity.Name : "";
}
else
{
sessionUser.EmployeeName = sessionUser.UserName;
sessionUser.EmployeeCode = sessionUser.UserName;
sessionUser.DepartmentID = -1;
sessionUser.JobID = -1;
}
if (!this.chkSupportAgent.Checked)//没有开启代理功能
{
sessionUser.WeiTuoUserName = sessionUser.UserName;
Session[Constants.SessionUser] = sessionUser;
Session["nihao"] = "nihaoSesson";
Session.Add("111","111");
FormsAuthentication.SetAuthCookie(txtUserID.Text.Trim(), false);
FormsAuthentication.SetAuthCookie(Constants.SessionUser, false);
log.Debug(Session[Constants.SessionUser]+"+++++++++++++++");
);//把这个修改成Response.Redirect("Index3.aspx");
//Server.Transfer("Index3.aspx")也不行。
Response.Redirect("Index3.aspx",false
}
else
{
Session[Constants.SessionUser] = sessionUser;
FormsAuthentication.SetAuthCookie(txtUserID.Text.Trim(), false);
Response.Redirect("LogonTwo.aspx", false);
}
}
else {
this.divTip.InnerText = "用户名或者密码错误!";
}
}
}
}
灵异事件