Exemplo n.º 1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        /* if (this.txttest.Text.Trim().ToString() == null || this.txttest.Text.Trim().ToString() != ViewState["test"].ToString())
         * {
         *   Page.ClientScript.RegisterStartupScript(typeof(string), "s", "<script>alert('验证码错误')</script>");
         *   Random random = new Random();
         *   ViewState["test"] = random.Next(1000, 9999);
         *   this.lbltest.Text = ViewState["test"].ToString();
         * }
         * else8*/
        {
            UserRegistration user = new UserRegistration();
            user.UserName = this.txtusername.Text.Trim();
            user.PassWord = this.txtpwd.Text.Trim();
            user.Name     = this.txtname.Text.Trim();
            if (this.sex.Text.Trim() == "男")
            {
                user.sex = 1;
            }
            else
            {
                user.sex = 0;
            }

            /* if (this.Rbtnmen.Checked == true)
             * {
             *   user.sex = 1;
             * }
             * else { user.sex = 0; }*/
            user.tel     = this.txttel.Text.Trim();
            user.Email   = this.txtemil.Text.Trim();
            user.address = this.txtaddress.Text.Trim();
            int ef = new BLL_BolgLogin().BLL_select_username(this.txtusername.Text.Trim());
            int d  = new BLL_BolgLogin().BLL_insert_UserRegistration(user);
            if (ef != 0)
            {
                Page.ClientScript.RegisterStartupScript(typeof(string), "s", "<script>alert('用户已存在')</script>");
            }
            else
            {
                if (d == 0)
                {
                    Page.ClientScript.RegisterStartupScript(typeof(string), "p", "<script>alert('注册失败')</script>");
                }
                else
                {
                    Session["username"] = this.txtusername.Text.Trim();
                    Response.Redirect(@"~/bogleaspx/JournalList.aspx");
                }
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 登陆按钮
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button1_Click(object sender, EventArgs e)
    {
        UserRegistration usertion = new UserRegistration();

        usertion.UserName = this.txtname.Text;
        usertion.PassWord = this.txtpassword.Text;
        int a = new BLL_BolgLogin().BLL_select_UserRegistration(usertion);

        if (a != 0)
        {
            Session["username"] = this.txtname.Text;
            Page.ClientScript.RegisterStartupScript(typeof(string), "j", "<script>alert('登陆成功')</script>");
            this.txtname.Text = this.txtpassword.Text = "";
            List <UserRegistration> liste = new BLL_BolgLogin().BLL__select_userID_UserRegistration(usertion);
            Session["userID"]     = liste[0].userID;
            Session["usermaster"] = liste[0].usermaster;
            Response.Redirect(@"~/bogleaspx/JournalList.aspx");
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(typeof(string), "s", "<script>alert('用户名或密码错误')</script>");
        }
    }