ASP.net+sqlserver企业网站设计+流程图+用例ER图(16)
时间:2016-11-25 22:04 来源:毕业论文 作者:毕业论文 点击:次
(3) 输入正确,系统将通过访问数据库,直接进入到网站个人首页。 功能实现代码: // 登录 public partial class login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { }//加载页面 protected void btLogin_Click(object sender, ImageClickEventArgs e) { }//点击登录按钮 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { if (TextBox2.Text.ToString().Trim() == "" || TextBox1.Text.ToString().Trim() == "") { Response.Write("<script>javascript:alert('请输入完整 ');history.back();</script>"); Response.End(); } string sql; sql = "select * from allusers where username='" + TextBox2.Text.ToString().Trim() + "' and pwd='" + TextBox1.Text.ToString().Trim() + "'"; DataSet result = new DataSet(); result = new Class1().hsggetdata(sql); // result = new TestOnline.Class1().hsggetdata(sql); if (result != null) { if (result.Tables[0].Rows.Count > 0) { Session["username"] = TextBox2.Text.ToString().Trim(); Session["role"] = result.Tables[0].Rows[0]["cx"].ToString().Trim(); Response.Redirect("default.htm"); } else { Response.Write("<script>javascript:alert('对不起,用户名或密码不 正确!');</script>"); } } else (责任编辑:qin) |