Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. <authentication mode="Forms">
  2. <forms loginUrl="~/Login.aspx" timeout="2880" defaultUrl="~/" />
  3. </authentication>
  4. <authorization>
  5. <deny users="?"/>
  6. </authorization>
  7.  
  8. protected void btnSubmit_Click(object sender, EventArgs e)
  9. {
  10. String LoginID = txtUsername.Text.Trim().ToLower();
  11. String LoginPassword = txtPassword.Text.Trim();
  12.  
  13. SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString);
  14. conn.Open();
  15. SqlCommand cmd = new SqlCommand("select username,password,usertype from tbl_User where username =@username and password=@password and Active= 1 ", conn);
  16. cmd.Parameters.AddWithValue("@username", txtUsername.Text);
  17. cmd.Parameters.AddWithValue("@password", txtPassword.Text);
  18. SqlDataAdapter da = new SqlDataAdapter(cmd);
  19. DataTable dt = new DataTable();
  20. da.Fill(dt);
  21. if (dt != null && dt.Rows.Count > 0)
  22. {
  23. if (dt.Rows[0]["usertype"].ToString() == "0") //SuperAdmin
  24. {
  25. Session["User"] = "0";
  26. Response.Redirect("csrpage.aspx");
  27. }
  28. else if (dt.Rows[0]["usertype"].ToString() == "1") // Admin
  29. {
  30. Session["User"] = "1";
  31. Response.Redirect("Admin.aspx");
  32. }
  33. else if (dt.Rows[0]["usertype"].ToString() == "2") // User
  34. {
  35. Session["User"] = "2";
  36. Response.Redirect("User.aspx");
  37. }
  38. }
  39. else
  40. {
  41. ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Invalid Username and Password')</script>");
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement