예제 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     userSession = (Utility.UserSession)Session["user"];
     if (!IsPostBack)
     {
         this.Label1.Text  = userSession.USERNAME;
         this.LabTime.Text = DateTime.Now.ToString();
     }
 }
예제 #2
0
        //提交
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //校验输入
            if (CheckFormSubmit())
            {
                string username = txtUserName.Text.Trim();
                string password = txtPassword.Text.Trim();

                password = Smart.Security.Encrypter.Encrypt(password, ConfigurationManager.AppSettings["EncryptKey"]);

                Entity.BASE_USER entity = bll.GetUser(username, password);
                if (entity != null)
                {
                    //登录成功
                    //加入Session
                    Utility.UserSession session = new Utility.UserSession(Convert.ToInt32(entity.USERID));

                    Session["user"] = session;

                    //放入cookie
                    Response.Cookies.Add(new HttpCookie("uid", session.USERID.ToString()));
                    Response.Cookies.Add(new HttpCookie("dpt", session.DEPTID.ToString()));

                    //301页面跳转
                    //Response.Redirect("~/AdminDefault.aspx", true);
                    Response.Redirect("~/index.aspx", true);
                }
                else
                {
                    //登录失败
                    ResetForm();

                    litMessage.Text = "用户名或密码错误!";
                }
            }
        }