コード例 #1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        WebServices.UserInfo oEmployee = null;
        try
        {
            WebServices.Services services = new WebServices.Services();
            if (services.Login(txtUserCode.Text.Trim(), txtPwd.Text.Trim()))
            {
                oEmployee = services.GetUserInfo(txtUserCode.Text.Trim());
                string pwd = NetReusables.Encrypt.Encrypt(txtPwd.Text.Trim());
                if (oEmployee.Password == pwd || (oEmployee.Password == null && pwd == ""))
                {
                    if (oEmployee.Status)
                    {
                        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "js", "alert('该账号已被禁用,请联系管理员!');", true);
                    }
                    else if (oEmployee.ID.ToLower().Equals("admin"))//超级管理员
                    {
                        string url = "/cmsweb/SvcLogin.aspx?targetpage=" + Server.UrlEncode("/cmsweb/cmshost/CmsFrame.aspx?cmsbodypage=/cmsweb/adminres/ResourceFrameBody.aspx") + "&user="******"&ucode=" + oEmployee.Password;
                        Response.Redirect(url, false);
                    }
                    else
                    {
                        Session["Employee"] = oEmployee;

                        //HttpCookie myCookie = new HttpCookie("EmployeeCookies");
                        //myCookie.Values["EmployeeCode"] = oEmployee.ID.Trim();
                        //Response.Cookies.Add(myCookie);

                        //不同用户登录,进入不同界面
                        if (oEmployee.ID.Trim().ToLower() == "sysuser")
                        {
                            Response.Redirect("SystemIndex.aspx", false);
                        }
                        else
                        {
                            Response.Redirect("Index.aspx", false);
                        }
                    }
                }
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "js", "alert('用户名或密码不正确!');", true);
            }
        }
        catch (Exception)
        {
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "js", "alert('用户名或密码不正确!');", true);
            txtPwd.Text = "";
        }
    }
コード例 #2
0
ファイル: EidtPwd.aspx.cs プロジェクト: NingMoe/twsuirtmfput
    protected void Page_Load(object sender, EventArgs e)
    {
        UserID   = CurrentUser.ID;
        PassWord = CurrentUser.Password;
        string typeValue = Request.QueryString["typeValue"] == null ? "" : Request.QueryString["typeValue"];
        string json      = "";

        #region 修改密码
        if (typeValue.Equals("Updpass"))
        {
            string userId = Request.Form["userId"];
            string oldPwd = Request.Form["oldPwd"];
            string newPwd = Request.Form["newPwd"];

            WebServices.Services services = new WebServices.Services();
            if (services.Login(userId, oldPwd))
            {
                if (services.ChangePassword(userId, newPwd))
                {
                    json = "{\"success\": true}";
                }
                else
                {
                    json = "{\"success\": false}";
                }
            }
            else
            {
                json = "{\"success\": false}";
            }


            Response.Write(json);
            Response.End();
        }
        #endregion
    }