Guest User

Untitled

a guest
Nov 18th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. using System.Configuration;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4.  
  5. namespace test.DataAccess
  6. {
  7. public class MemberDA
  8. {
  9. private static string connectionString = ConfigurationManager.ConnectionStrings["DataSource.Connection"].ConnectionString;
  10. public static string GetLoggedinID()
  11. {
  12. string _id = "";
  13. try
  14. {
  15. if (AppPrincipal.CurrentIdentity.IsAuthenticated && AppPrincipal.CurrentIdentity.LoginIdentity != "")
  16. {
  17. _id = AppPrincipal.CurrentIdentity.LoginIdentity;
  18. }
  19. }
  20. catch { }
  21. return _id;
  22. }
  23. public static bool CheckRegistered(string ID)
  24. {
  25. bool isRegistered = true;
  26. string queryString = "SELECT * FROM TEST_APP_INIT WHERE OUTCOME = 'NEW' AND ID = @ID";
  27.  
  28. using (SqlConnection connection = new SqlConnection(connectionString))
  29. {
  30. SqlCommand cmd = new SqlCommand(queryString, connection);
  31. cmd.Parameters.Add("@ID", SqlDbType.VarChar, 10).Value = ID;
  32. connection.Open();
  33. SqlDataReader reader = cmd.ExecuteReader();
  34.  
  35. try
  36. {
  37. while (reader.Read())
  38. {
  39. isRegistered = false;
  40. }
  41. }
  42. finally
  43. {
  44. reader.Close();
  45. }
  46.  
  47. connection.Close();
  48. }
  49.  
  50. return isRegistered;
  51. }
  52. }
  53. }
Add Comment
Please, Sign In to add comment