Example #1
0
    protected void imgbtnLanding_Click(object sender, ImageClickEventArgs e)
    {
        string name = txtName.Text;
        string pass = Operate.Encrypting(txtPass.Text);
        string yzm  = txtYzm.Text;

        if (Session["CheckCode"].ToString().Equals(yzm))
        {
            try
            {
                string sql = "select count(*) from tb_login where Name='" + name + "' and Pass ='******'";
                int    i   = mydo.isData(sql);
                if (i > 0)
                {
                    sql = "select * from tb_login where Name='" + name + "'";
                    OleDbDataReader odr = mydo.row(sql);
                    odr.Read();

                    if (odr["lock"].ToString() == "0")
                    {
                        Session["UserName"] = name;
                        Response.Redirect("index.aspx");
                    }
                    else
                    {
                        Page.RegisterStartupScript("false", "<script>alert('此用户已被锁定!')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('密码或用户名错误!')</script>");
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message.ToString());
            }
        }
        else
        {
            Page.RegisterStartupScript("false", "<script>alert('验证码错误!')</script>");
        }
    }
Example #2
0
    //添加用户

    //自定义方法
    protected bool  add()
    {
        string name = txtName.Text;
        string pass = Operate.Encrypting(txtPass.Text);
        string sex;

        //获取性别
        if (RadioButtonMan.Checked)
        {
            sex = "男";
        }
        else
        {
            sex = "女";
        }
        string trueName     = txtTrueName.Text;       //获取真实姓名
        string idCard       = this.txtIDCard.Text;    //获取电话
        string passQuestion = this.txtPassQuestion.Text;
        string passSolution = FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtPassSolution.Text, "MD5");
        string email        = txtEmail.Text;   //获取电子邮件
        string sql          = "insert into tb_login(Name,Pass,ZName,Sex,Email,IDCard,PassQuestion,PassSolution) values('" + name + "','" + pass + "','" + trueName + "','" + sex + "','" + email + "','" + idCard + "','" + passQuestion + "','" + passSolution + "')";

        return(mydo.adlData(sql));
    }