Esempio n. 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");
            }
        }
Esempio n. 2
0
 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);
 }
Esempio n. 3
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);
        }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
 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);
 }
Esempio n. 6
0
 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);
 }
Esempio n. 7
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");
 }
Esempio n. 8
0
 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;
 }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
 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;
     }
 }
Esempio n. 12
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();
        }
Esempio n. 13
0
        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("设置新密码失败!"));
            }
        }
Esempio n. 14
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);
                    }
                }
            }
        }
Esempio n. 15
0
 public void UpdateSysUserSignStateByUserName(MSysUser objSysUser)
 {
     user.UpdateSysUserSignStateByUserName(objSysUser);
 }
Esempio n. 16
0
 public DataTable SelectSysUserByUserName(MSysUser objSysUser)
 {
     return(user.SelectSysUserByUserName(objSysUser));
 }
Esempio n. 17
0
 public void InsertIntoSysUser(MSysUser objSysUser)
 {
     user.InsertIntoSysUser(objSysUser);
 }
Esempio n. 18
0
 public void DeleteSysUser(MSysUser objSysUser)
 {
     user.DeleteSysUser(objSysUser);
 }
Esempio n. 19
0
 public bool UpdateSysUserPwdByUserName(MSysUser objSysUser)
 {
     return(user.UpdateSysUserPwdByUserName(objSysUser));
 }
Esempio n. 20
0
 public void UpdateSysUserLoginTimeAndSignState(MSysUser objSysUser)
 {
     user.UpdateSysUserLoginTimeAndSignState(objSysUser);
 }