Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. protected void button_Click(object sender, EventArgs e)
  2. {
  3.  
  4. DBKariyerBL.User user = new DBKariyerBL.User();
  5. user.UserName = txtKlnAd.Text;
  6. user.Password = txtParola.Text;
  7. if (user.Login(user))
  8. {
  9. Session["LogIn"] = "1";
  10. Response.Redirect("Default.aspx");
  11. }
  12. }
  13.  
  14. public class User
  15. {
  16. public string UserName { get; set; }
  17. public string Password { get; set; }
  18.  
  19. SqlConnection conn = new SqlConnection(Util.ConnectionString);
  20.  
  21. public bool Login(User user)
  22. {
  23. return Convert.ToInt32(SqlHelper.ExecuteScalar(conn, CommandType.Text, "SELECT COUNT(*) FROM Users WHERE UserName=@UserName AND Password=@Password", new SqlParameter[] { new SqlParameter("@UserName", user.UserName), new SqlParameter("@Password", user.Password) })) > 0;
  24. }
  25.  
  26.  
  27. }
  28.  
  29. public class User : System.Web.Services.WebService
  30. {
  31.  
  32. [WebMethod]
  33. public bool Login(DBKariyerBL.User user)
  34. {
  35. DBKariyerBL.User kull = new DBKariyerBL.User();
  36. return kull.Login(user);
  37. }
  38. }
  39.  
  40. public class Util
  41. {
  42.  
  43. public static string ConnectionString
  44. {
  45. get { return ConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString; }
  46. }
  47. }
  48.  
  49. public class Util
  50. {
  51.  
  52. public static string ConnectionString
  53. {
  54. get { return "Data Source=ServerName;" +
  55. "Initial Catalog=DataBaseName;" +
  56. "User id=UserName;" +
  57. "Password=pwd;"; }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement