示例#1
0
        private void CurrLogin()
        {
            if (!this.Page.IsValid)
            {
                return;
            }
            string pattern = "[\\u4e00-\\u9fa5a-zA-Z0-9]+[\\u4e00-\\u9fa5_a-zA-Z0-9]*";

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(pattern);
            if (!regex.IsMatch(this.txtUserName.Text.Trim()) || this.txtUserName.Text.Trim().Length < 2 || this.txtUserName.Text.Trim().Length > 20)
            {
                this.ShowMessage("用户名不能为空,必须以汉字或是字母开头,且在2-20个字符之间", false);
                return;
            }
            if (this.txtUserName.Text.Contains(","))
            {
                this.ShowMessage("用户名不能包含逗号", false);
                return;
            }
            string text = this.UserLogin(this.txtUserName.Text.Trim(), this.txtPassword.Text);

            if (!string.IsNullOrEmpty(text))
            {
                // 登入失败插入日志
                logdetail.Type       = 0;
                logdetail.MemberName = txtUserName.Text.Trim();
                logdetail.LogType    = 3;
                logdetail.LoginIP    = Globals.IPAddress;
                EventLogs.UpdateLoginLog(logdetail);
                this.ShowMessage(text, false);
                return;
            }
            string text2 = this.Page.Request.QueryString["ReturnUrl"];

            if (string.IsNullOrEmpty(text2))
            {
                text2 = Globals.ApplicationPath + "/User/UserDefault.aspx";
            }
            else
            {
                if (string.IsNullOrEmpty(Login.ReturnURL))
                {
                    text2 = Login.ReturnURL;
                }
            }
            // 登入成功插入日志
            logdetail.Type       = 1;
            logdetail.MemberName = txtUserName.Text.Trim();
            logdetail.LogType    = 3;
            logdetail.LoginIP    = Globals.IPAddress;
            EventLogs.UpdateLoginLog(logdetail);
            this.Page.Response.Redirect(text2);
        }