public void ValidLogin() { clsOrder AWidget = new clsOrder(); string Error = ""; string username = "******"; string password = "******"; Error = AWidget.LoginValid(username, password); Assert.AreEqual(Error, ""); }
protected void Button1_Click(object sender, EventArgs e) { var username = TextBox1.Text; var password = TextBox2.Text; usernameError.Text = ""; passwordError.Text = ""; loginError.Text = ""; clsOrder order = new clsOrder(); var error = order.LoginValid(username, password); if (error == "") { string constring = ConfigurationManager.ConnectionStrings["studentconn"].ToString(); con = new SqlConnection(constring); //if (username == "Admin" && password == "Admin") //{ // Response.Write("<script>alert('Login Done!')</script>"); // Response.Redirect("Dashboard.aspx"); // //ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('hello')", true); //} var listCustomer = GetStudent(username); if (listCustomer.Count > 0) { if (listCustomer[0].Email == username && listCustomer[0].Password == password) { Session["UserName"] = username; Session["Name"] = listCustomer[0].Name.ToString(); Response.Redirect("OrdersCreate.aspx"); } else { loginError.Text = "Please Check your Credentials"; } } else { loginError.Text = "User Not Found! Please Check your Credentials or try new Account"; } } else { if (error == "Please Enter you Password") { passwordError.Text = error; } if (error == "Please Enter you Email") { usernameError.Text = error; } if (error == "Please Enter Your Credentials") { loginError.Text = "Please Enter your Credentials"; } } }