protected void btnRegister_Click(object sender, EventArgs e) { if (txtUsername.Text != "" && txtPassword.Text != "" && txtPassword.Text == txtPassword2.Text) { MyOwnSiteDataContext db = new MyOwnSiteDataContext(); UserInfo userInfo = new UserInfo(); userInfo.UserName = txtUsername.Text; userInfo.Password = txtPassword.Text; userInfo.MailAddr = txtEmailaddrs.Text; userInfo.Tel = txtPhonenumber.Text; db.UserInfo.InsertOnSubmit(userInfo); db.SubmitChanges(); Response.Redirect("RegSuccess.aspx"); } }
protected void btnLogin_Click(object sender, EventArgs e) { MyOwnSiteDataContext db = new MyOwnSiteDataContext(); if (ddlCh.Text == "用户") { if (txtUsername.Text != "" && txtPassword.Text != "") { var usertemp = from r in db.UserInfo where r.UserName == txtUsername.Text select new { r.UserName }; var pwtemp = from r in db.UserInfo where r.UserName == txtUsername.Text && r.Password == txtPassword.Text select new { r.Password }; if (usertemp.Count() == 1 && pwtemp.Count() == 1) { Response.Redirect("mainpage2.aspx"); } else if (usertemp.Count() == 1) { Response.Redirect("LoginFalse.aspx"); } else { Response.Redirect("LoginFalse0.aspx"); } } } else if (ddlCh.Text == "管理员") { if (txtUsername.Text != "" && txtPassword.Text != "") { var admintemp = from r in db.AdminInfo where r.AdminName == txtUsername.Text select new { r.AdminName }; var pwtemp = from r in db.AdminInfo where r.AdminName == txtUsername.Text && r.password == txtPassword.Text select new { r.password }; if (admintemp.Count() == 1 && pwtemp.Count() == 1) { Response.Redirect("mainpage0.aspx"); } else if (admintemp.Count() == 1) { Response.Redirect("LoginFalse.aspx"); } else { Response.Redirect("LoginFalse0.aspx"); } } } else { if (txtUsername.Text != "" && txtPassword.Text != "") { Response.Redirect("login.aspx"); } } }