protected void Page_Load(object sender, EventArgs e) { //为管理员和普通职员分配不同界面 sysUser user = new sysUser(); MSysUser objsysuser = new MSysUser(); objsysuser.UserName = Session["loginName"].ToString(); DataTable dt = user.SelectSysUserByUserName(objsysuser); if (dt.Rows.Count > 0) { if (Convert.ToBoolean(Session["IsSysManager"])) { AdminNav1.Visible = true; UserNav1.Visible = false; } else { AdminNav1.Visible = false; UserNav1.Visible = true; } } else { Response.Redirect("~/Default.aspx"); } }
public void DeleteSysUser(MSysUser objSysUser) { StringBuilder sb = new StringBuilder(); sb.Append("DELETE FROM tb_sysUser WHERE(userName=@UserName)"); OleDbParameter[] param ={ OleDbHelper.GetParameter("@UserName",OleDbType.VarWChar,20,"userName",objSysUser.UserName) }; OleDbHelper.ExecuteSql(sb.ToString(), param); }
protected void Application_End(object sender, EventArgs e) { // 在应用程序关闭时运行的代码 sysUser sysuser = new sysUser(); MSysUser objsysuser = new MSysUser(); objsysuser.UserName = Session["loginName"].ToString(); objsysuser.SignState = false; sysuser.UpdateSysUserSignStateByUserName(objsysuser); }
public DataTable SelectSysUserByUserName(MSysUser objSysUser) { StringBuilder sb = new StringBuilder(); sb.Append("select * from tb_sysUser where userName=@UserName"); OleDbParameter[] param = { OleDbHelper.GetParameter("@UserName",OleDbType.VarWChar,20,"userName",objSysUser.UserName) }; DataTable dt = OleDbHelper.ExecuteDt(sb.ToString(), param); return dt; }
public void UpdateSysUserSignStateByUserName(MSysUser objSysUser) { StringBuilder sb = new StringBuilder(); sb.Append("update tb_sysUser set signState=@SignState where userName=@UserName"); OleDbParameter[] param ={ OleDbHelper.GetParameter("@SignState",OleDbType.Boolean,"signState",objSysUser.SignState), OleDbHelper.GetParameter("@UserName",OleDbType.VarWChar,20,"userName",objSysUser.UserName) }; OleDbHelper.ExecuteSql(sb.ToString(), param); }
public void InsertIntoSysUser(MSysUser objSysUser) { StringBuilder sb = new StringBuilder(); sb.Append("INSERT INTO tb_sysUser (userName, userPwd, IsSystemManager) values(@UserName,@UserPwd,@IsSysManager)"); OleDbParameter[] param ={ OleDbHelper.GetParameter("@UserName",OleDbType.VarWChar,20,"userName",objSysUser.UserName), OleDbHelper.GetParameter("@UserPwd",OleDbType.VarWChar,50,"userPwd",objSysUser.UserPwd), OleDbHelper.GetParameter("@IsSysManager",OleDbType.Boolean,"IsSystemManager",objSysUser.IsSystemManager) }; OleDbHelper.ExecuteSql(sb.ToString(), param); }
protected void imgBtnLogonOut_Click(object sender, ImageClickEventArgs e) { if (Session["loginName"] != null) { sysUser user = new sysUser(); MSysUser objsysuser = new MSysUser(); objsysuser.UserName = Session["loginName"].ToString(); user.UpdateSysUserSignStateByUserName(objsysuser); } Session["loginName"] = null; Response.Redirect("~/Default.aspx"); }
public DataTable SelectSysUserByUserNameAndUserPwd(MSysUser objSysUser) { StringBuilder sb = new StringBuilder(); sb.Append("select top 1 * from tb_sysUser where userName=@UserName and userPwd=@UserPwd and IsSystemManager=@IsSysManager"); OleDbParameter[] param = { OleDbHelper.GetParameter("@UserName",OleDbType.VarWChar,20,"userName",objSysUser.UserName), OleDbHelper.GetParameter("@UserPwd",OleDbType.VarWChar,50,"userPwd",objSysUser.UserPwd), OleDbHelper.GetParameter("@IsSysManager",OleDbType.Boolean,"IsSystemManager",objSysUser.IsSystemManager) }; DataTable dt = OleDbHelper.ExecuteDt(sb.ToString(), param); return dt; }
public void InsertIntoSysUser(MSysUser objSysUser) { StringBuilder sb = new StringBuilder(); sb.Append("INSERT INTO tb_sysUser (userName, userPwd, loginTime, IsSystemManager) values(@UserName,@UserPwd,'',@IsSysManager)"); SqlParameter[] param = { SQLDbHelper.GetParameter("@UserName", SqlDbType.VarChar, 20, "userName", objSysUser.UserName), SQLDbHelper.GetParameter("@UserPwd", SqlDbType.VarChar, 50, "userPwd", objSysUser.UserPwd), SQLDbHelper.GetParameter("@IsSysManager", SqlDbType.Bit, "IsSystemManager", objSysUser.IsSystemManager) }; SQLDbHelper.ExecuteSql(sb.ToString(), param); }
public void UpdateSysUserLoginTimeAndSignState(MSysUser objSysUser) { StringBuilder sb = new StringBuilder(); sb.Append("update tb_sysUser set loginTime=@LoginTime,signState=@SignState where userName=@UserName"); SqlParameter[] param = { SQLDbHelper.GetParameter("@LoginTime", SqlDbType.DateTime, "loginTime", objSysUser.LoginTime), SQLDbHelper.GetParameter("@SignState", SqlDbType.Bit, "signState", objSysUser.SignState), SQLDbHelper.GetParameter("@UserName", SqlDbType.VarChar, 20, "userName", objSysUser.UserName) }; SQLDbHelper.ExecuteSql(sb.ToString(), param); }
public bool UpdateSysUserPwdByUserName(MSysUser objSysUser) { StringBuilder sb = new StringBuilder(); sb.Append("update tb_sysUser set userPwd=@UserPwd where userName=@UserName"); OleDbParameter[] param = { OleDbHelper.GetParameter("@UserName",OleDbType.VarWChar,20,"userName",objSysUser.UserName), OleDbHelper.GetParameter("@UserPwd",OleDbType.VarWChar,50,"userPwd",objSysUser.UserPwd) }; bool is_succeed = OleDbHelper.ExecuteSql(sb.ToString(), param); if (is_succeed) { return true; } else { return false; } }
protected void Session_End(object sender, EventArgs e) { // 在会话结束时运行的代码。 // 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为 // InProc 时,才会引发 Session_End 事件。如果会话模式设置为 StateServer // 或 SQLServer,则不会引发该事件。 sysUser sysuser = new sysUser(); MSysUser objsysuser = new MSysUser(); objsysuser.UserName = Session["loginName"].ToString(); objsysuser.SignState = false; sysuser.UpdateSysUserSignStateByUserName(objsysuser); Application.Lock(); int iNum = Int32.Parse(Application["online"].ToString()) - 1; Application.Set("online", iNum); Application.UnLock(); }
protected void Button1_Click(object sender, EventArgs e) { sysUser user = new sysUser(); MSysUser objsysuser = new MSysUser(); objsysuser.UserName = Session["loginName"].ToString(); objsysuser.UserPwd = TextBox1.Text.Trim().ToString(); bool bl = user.UpdateSysUserPwdByUserName(objsysuser); if (bl) { this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('设置新密码成功!');</script>"); //Response.Write(bc.MessageBox("设置新密码成功!")); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('设置新密码失败!');</script>"); //Response.Write(bc.MessageBox("设置新密码失败!")); } }
protected void btnLogin_Click(object sender, EventArgs e) { if (Page.IsValid == true) { HttpCookie cookie = Request.Cookies["CheckCode"]; if (string.Compare(cookie.Value, Validator.Text.Trim().ToString(), true) != 0) { string myscript = @"alert('验证码输入错误,请重新输入验证码!!!');window.location.href='Default.aspx';"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true); return; } if (txtPwd.Text == "" && txtName.Text == "") { string myscript = @"alert('用户名称和密码不能为空!');window.location.href='Default.aspx';"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true); return; } sysUser user = new sysUser(); MSysUser objsysuser = new MSysUser(); objsysuser.UserName = txtName.Text.Trim(); objsysuser.UserPwd = txtPwd.Text.Trim(); if (rdoBtnAdmin.Checked) //系统管理员登录 { objsysuser.IsSystemManager = true; DataTable dt = user.SelectSysUserByUserNameAndUserPwd(objsysuser); if (dt.Rows.Count > 0) { //登录成功后,设置登录时间和标识 objsysuser.SignState = true; objsysuser.LoginTime = DateTime.Now; user.UpdateSysUserLoginTimeAndSignState(objsysuser); //存储登录用户名称 Session["loginName"] = objsysuser.UserName; //存储登录用户身份 Session["IsSysManager"] = true; //登录成功后,进入系统主页 Response.Redirect("~/SystemDefault.aspx"); } else { string myscript = @"alert('用户名或密码错误!');window.location.href='Default.aspx';"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true); } } else //普通操作职员 { objsysuser.IsSystemManager = false; DataTable dt = user.SelectSysUserByUserNameAndUserPwd(objsysuser); if (dt.Rows.Count > 0) { //登录成功后,设置登录时间和标识 objsysuser.SignState = true; objsysuser.LoginTime = DateTime.Now; user.UpdateSysUserLoginTimeAndSignState(objsysuser); //存储登录用户名称 Session["loginName"] = objsysuser.UserName; //存储登录用户身份 Session["IsSysManager"] = false; //登录成功后,进入系统主页 Response.Redirect("~/SystemDefault.aspx"); } else { string myscript = @"alert('用户名或密码错误!');window.location.href='Default.aspx';"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true); } } } }
public void UpdateSysUserSignStateByUserName(MSysUser objSysUser) { user.UpdateSysUserSignStateByUserName(objSysUser); }
public DataTable SelectSysUserByUserName(MSysUser objSysUser) { return(user.SelectSysUserByUserName(objSysUser)); }
public void InsertIntoSysUser(MSysUser objSysUser) { user.InsertIntoSysUser(objSysUser); }
public void DeleteSysUser(MSysUser objSysUser) { user.DeleteSysUser(objSysUser); }
public bool UpdateSysUserPwdByUserName(MSysUser objSysUser) { return(user.UpdateSysUserPwdByUserName(objSysUser)); }
public void UpdateSysUserLoginTimeAndSignState(MSysUser objSysUser) { user.UpdateSysUserLoginTimeAndSignState(objSysUser); }