示例#1
0
 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");
     }
 }
示例#2
0
 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);
 }
示例#3
0
 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");
 }
示例#4
0
        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("设置新密码失败!"));
     }
 }
示例#6
0
        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);
                    }
                }
            }
        }