//自定义方法用来判断用户名是否存在 public int isName() { int i; string sql = "select count(*) from tb_login where Name='" + this.txtName.Text.Trim() + "'"; return(i = mydo.isData(sql)); }
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>"); } }