protected void btn_Login_Click(object sender, EventArgs e) { string strUserName = this.txt_username.Value.Trim(); string strPassword = this.txt_password.Value.Trim(); if (string.IsNullOrEmpty(strUserName) || string.IsNullOrEmpty(strPassword)) { Response.Write("<script>alert('Please Input Username or Password !');location.href='Login.aspx'</script>"); } else { BLL.UserInfo bll = new BLL.UserInfo(); DataSet ds = bll.Login(strUserName, strPassword); if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; Session["User_ID"] = dr["U_ID"]; Session["User_UserName"] = dr["U_nickname"]; Session["User_Power"] = dr["U_power"]; Response.Redirect("DashBoard.aspx"); } else { Response.Write("<script>alert('Username or Password Incorrect !');location.href='Login.aspx'</script>"); } } }
private void button1_Click(object sender, EventArgs e) { string userName = textBox1.Text.Trim(); string password = textBox2.Text.Trim(); if (userName == "" || password == "") { MessageBox.Show("用户名或密码不能为空!"); textBox1.Focus(); return; } else { BLL.UserInfo user = new BLL.UserInfo(); if (user.Login(userName, password)) { UserHelper.userName = textBox1.Text.Trim(); UserHelper.password = textBox2.Text.Trim(); this.Hide(); scheduleUI f; f = new scheduleUI(); f.Show(); } else { MessageBox.Show("用户名或密码错误,请重新输入!", "错误"); textBox1.Text = ""; textBox2.Text = ""; textBox1.Focus(); } } }