Exemple #1
0
    private static string registerError()
    {
        string output = "registerError\n";

        for (int i = 0; i < count; i++)
        {
            User u = new User(names[i], names[i], names[i]);
            if (AccountAssist.register(u) > 0)
            {
                output += "Error! 重复用户\"" + names[i] + "\"注册居然成功?!\n";
                errorCount++;
            }
            else
            {
                output += "Ok! 重复用户\"" + names[i] + "\"注册失败!\n";
            }
        }
        return(output);
    }
Exemple #2
0
    private static string loginOk()
    {
        string output = "loginOk\n";

        for (int i = 0; i < count; i++)
        {
            User u = new User(names[i], names[i], names[i]);
            if (AccountAssist.login(u) == null)
            {
                output += "Error! 已注册用户\"" + names[i] + "\"登陆失败!\n";
                errorCount++;
            }
            else
            {
                output += "Ok! 已注册用户\"" + names[i] + "\"登陆成功!\n";
            }
        }
        return(output);
    }
Exemple #3
0
    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        User trylog = new User();

        trylog.UserName = Login1.UserName;
        trylog.UserPass = Login1.Password;

        User user;

        if ((user = AccountAssist.login(trylog)) != null)
        {
            //ClientScript.RegisterStartupScript(GetType(), "message", @"<script>alert('登录成功!');</script>");
            Session["user"] = user;
            Response.Redirect("News.aspx");
        }
        else
        {
            //ClientScript.RegisterStartupScript(GetType(), "message", @"<script>alert('登录失败!');</script>");
        }
    }
Exemple #4
0
    private static string loginError()
    {
        string output = "loginError\n";

        Random r = new Random();

        for (int i = 0; i < count; i++)
        {
            int    no   = r.Next(1000, 9000);
            string temp = "样例" + no;
            User   u    = new User(temp, temp, temp);
            if (AccountAssist.login(u) != null)
            {
                output += "Error! 未注册用户\"" + temp + "\"登陆居然成功?!\n";
                errorCount++;
            }
            else
            {
                output += "Ok! 未注册用户\"" + temp + "\"登陆失败!\n";
            }
        }
        return(output);
    }
Exemple #5
0
    private static string registerOk()
    {
        string output = "registerOk\n";

        Random r = new Random();

        for (int i = 0; i < count; i++)
        {
            int no = r.Next(1000, 9000);
            names[i] = "测试样例" + no;
            User u = new User(names[i], names[i], names[i]);
            ids[i] = AccountAssist.register(u);
            if (ids[i] < 0)
            {
                output += "Error! 新用户\"" + names[i] + "\"注册失败!\n";
                errorCount++;
            }
            else
            {
                output += "Ok! 新用户\"" + names[i] + "\"注册成功!\n";
            }
        }
        return(output);
    }
Exemple #6
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        //这里前台js应该先进行一次合法性检测,这里省略
        if (TextBox1.Text == "")
        {
            clearContent();
            tip1.Text = "请输入用户名";
            return;
        }

        if (TextBox2.Text == "")
        {
            clearContent();
            tip2.Text = "请输入密码";
            return;
        }

        if (TextBox3.Text != TextBox2.Text)
        {
            clearContent();
            tip3.Text = "两次输入的密码不一致";
            return;
        }

        string mailRegex = @"^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$";

        if (!Regex.IsMatch(TextBox4.Text.Trim(), mailRegex))
        {
            clearContent();
            tip4.Text = "请输入有效的邮箱地址!";
            return;
        }


        User user = new User(TextBox1.Text.Trim(), TextBox2.Text, TextBox4.Text.Trim());
        int  signal;

        if ((signal = AccountAssist.register(user)) > 0)

        {
            ClientScript.RegisterStartupScript(GetType(), "message", @"<script>alert('注册成功!');</script>");
            clearContent();
            return;
        }
        else
        {
            switch (signal)
            {
            case -1:
                tip1.Text = "用户名重复";
                ClientScript.RegisterStartupScript(GetType(), "message", @"<script>alert('注册失败,请重试!');</script>");
                return;

            case -2:
                ClientScript.RegisterStartupScript(GetType(), "message", @"<script>alert('数据库操作失败,请重试!');</script>");
                return;

            case -3:
                tip4.Text = "邮箱地址重复";
                ClientScript.RegisterStartupScript(GetType(), "message", @"<script>alert('注册失败,请重试!');</script>");
                return;

            default:
                ClientScript.RegisterStartupScript(GetType(), "message", @"<script>alert('注册失败,原因不明,请重试!');</script>");
                return;
            }
        }
    }