protected void btnReg_Click(object sender, EventArgs e) { int selCntFirst = Convert.ToInt32(db.selDB("select count(*) ID from register where userName='******'")); if (fl == true) { Response.Write("<script>alert('*请选择性别');</script>"); } else { if (flag == true) { nan = "男"; fll = true; } if (flag == false) { nan = "女"; fll = true; } } if (fll == true && CompareValidator1.IsValid == true && rfvConPassWord.IsValid == true) { string psd = FormsAuthentication.HashPasswordForStoringInConfigFile(userPassWord.Text, "MD5"); db.updateQuery("insert into register(userName,userSex,userBorn,userPhone,userMail,userQQ,userPassWord,create_date) values('" + userName.Text + "','" + nan + "','" + tbBorn.Text.ToString() + "','" + tbPhone.Text + "','" + tbMail.Text + "','" + tbTencent.Text + "','" + psd + "','" + DateTime.Now.ToString() + "')"); Response.Write("<script>alert('用户注册成功!感谢您的加入!')</script>"); Response.Write("<script language=javascript>javascript:location.href='Default.aspx'</script>"); Response.Write("<script>alert('为了信息安全,请您手动输入信息登陆!')</script>"); return; } else { Response.Write("<script>alert('注册失败!')</script>"); } }
protected void btnLogin_Click(object sender, EventArgs e) { //if (userName.Text == "1" && userPassWord.Text == "1") //{ // //btnLogin.Attributes.Add("onclick", "yincang()"); // lbComeName.Text = HttpContext.Current.Session[Session.SessionID + "Name"].ToString(); // pOne.Visible = false; // pTwo.Visible = true; //} int selCnt = Convert.ToInt32(db.selDB("select count(*) ID from register where userName='******'")); if (userName.Text == null || selCnt == 0) { Response.Write("<script>alert('用户名输入错误或不存在');</script>"); return; } else { string psd = FormsAuthentication.HashPasswordForStoringInConfigFile(userPassWord.Text, "MD5"); string selCntFirst = db.selDB("select userPassWord from register where userName='******'").ToString(); if (!psd.Equals(selCntFirst) || userPassWord.Text == null) { Response.Write("<script>alert('密码输入错误');</script>"); return; } else { lbComeName.Text = HttpContext.Current.Session[Session.SessionID + "Name"].ToString(); pOne.Visible = false; pTwo.Visible = true; Response.Write("<script>alert('欢迎您回来');</script>"); return; } } }
protected void btnSel_Click(object sender, EventArgs e) { int selCntFirst = Convert.ToInt32(db.selDB("select count(*) ID from register where userName='******'")); if (tbSearch.Text.Trim() == null) { selResult.Text = "请输入用户名进行查询"; } else { if (selCntFirst != 0) { DataSet sda = db.sel_gv("select ID,userName,userSex,userBorn,userPhone,userMail,userQQ,create_date from register where userName='******'", "register"); gvSearch.DataKeyNames = new string[] { "ID" }; gvSearch.DataSource = sda; gvSearch.DataBind(); } else { selResult.Text = "未搜索到结果"; } } }