Guest User

Untitled

a guest
Dec 7th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.98 KB | None | 0 0
  1. @implementation OneView
  2. @synthesize addressInfo;
  3. @synthesize people;
  4. @synthesize appliances;
  5. @synthesize addressInfoKeys;
  6. @synthesize peopleKeys;
  7. @synthesize pid;
  8.  
  9. #pragma mark -
  10. #pragma mark View lifecycle
  11.  
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14.  
  15. self.title = @"Listing";
  16.  
  17. NSMutableDictionary *addressInfoTMP = [[NSMutableDictionary alloc]init];
  18. NSMutableArray *addressInfoKeysTMP = [[NSMutableArray alloc]init];
  19. NSMutableDictionary *peopleTMP = [[NSMutableDictionary alloc]init];
  20. NSMutableArray *peopleKeysTMP = [[NSMutableArray alloc]init];
  21.  
  22.  
  23.  
  24. PLSqliteDatabase *db = [[PLSqliteDatabase alloc] initWithPath: @"myDataBase.sqlite"];
  25. if (![db open]){ NSLog(@"Could not open database"); } else { NSLog(@"Connected to DB fine"); }
  26.  
  27. id<PLResultSet> results = [db executeQuery: @"SELECT username,password,viewingProperty FROM auth WHERE id=1"];
  28. while ([results next]) {
  29. NSString *sqlUsername = [results stringForColumn:@"username"];
  30. NSString *sqlPassword = [results stringForColumn:@"password"];
  31. pid = [results stringForColumn:@"viewingProperty"];
  32. NSLog(@"%@ %@ %@", sqlUsername, sqlPassword, pid);
  33. }
  34. [results close];
  35.  
  36. NSString *q = @"SELECT * FROM properties WHERE propertyId=";
  37. q = [q stringByAppendingString:pid];
  38. id<PLResultSet> results2 = [db executeQuery: q];
  39. while ([results2 next]) {
  40. // addressInfo
  41. //[addressInfo setValue:[results2 stringForColumn:@"firstName"] forKey:@"firstName"];
  42. //[addressInfo setValue:[results2 stringForColumn:@"lastName"] forKey:@"lastName"];
  43. NSString *fullName = [results2 stringForColumn:@"firstName"];
  44. fullName = [fullName stringByAppendingString:@" "];
  45. fullName = [fullName stringByAppendingString:[results2 stringForColumn:@"lastName"]];
  46. [addressInfoTMP setValue:fullName forKey:@"fullName"];
  47. [addressInfoKeysTMP addObject:@"fullName"];
  48. if(![results2 isNullForColumn:@"phoneNumber"]){
  49. [addressInfoTMP setValue:[results2 stringForColumn:@"phoneNumber"] forKey:@"phoneNumber"];
  50. [addressInfoKeysTMP addObject:@"phoneNumber"];
  51. }
  52. if(![results2 isNullForColumn:@"street"]){
  53. [addressInfoTMP setValue:[results2 stringForColumn:@"street"] forKey:@"street"];
  54. [addressInfoKeysTMP addObject:@"street"];
  55. }
  56. if(![results2 isNullForColumn:@"city"]){
  57. [addressInfoTMP setValue:[results2 stringForColumn:@"city"] forKey:@"city"];
  58. [addressInfoKeysTMP addObject:@"city"];
  59. }
  60. if(![results2 isNullForColumn:@"state"]){
  61. [addressInfoTMP setValue:[results2 stringForColumn:@"state"] forKey:@"state"];
  62. [addressInfoKeysTMP addObject:@"state"];
  63. }
  64. if(![results2 isNullForColumn:@"zipcode"]){
  65. [addressInfoTMP setValue:[results2 stringForColumn:@"zipcode"] forKey:@"zipcode"];
  66. [addressInfoKeysTMP addObject:@"zipcode"];
  67. }
  68. if(![results2 isNullForColumn:@"inspectionDate"]){
  69. [addressInfoTMP setValue:[results2 stringForColumn:@"inspectionDate"] forKey:@"inspectionDate"];
  70. [addressInfoKeysTMP addObject:@"inspectionDate"];
  71. }
  72. if(![results2 isNullForColumn:@"pending"]){
  73. [addressInfoTMP setValue:[results2 stringForColumn:@"pending"] forKey:@"pending"];
  74. [addressInfoKeysTMP addObject:@"pending"];
  75. }
  76. // people
  77. if(![results2 isNullForColumn:@"emailClient"]){
  78. [peopleTMP setValue:[results2 stringForColumn:@"emailClient"] forKey:@"emailClient"];
  79. [peopleKeysTMP addObject:@"emailClient"];
  80. }
  81. if(![results2 isNullForColumn:@"emailListingAgent"]){
  82. [peopleTMP setValue:[results2 stringForColumn:@"emailListingAgent"] forKey:@"emailListingAgent"];
  83. [peopleKeysTMP addObject:@"emailListingAgent"];
  84. }
  85. if(![results2 isNullForColumn:@"emailBuyersAgent"]){
  86. [peopleTMP setValue:[results2 stringForColumn:@"emailBuyersAgent"] forKey:@"emailBuyersAgent"];
  87. [peopleKeysTMP addObject:@"emailBuyersAgent"];
  88. }
  89. if(![results2 isNullForColumn:@"emailSellersAgent"]){
  90. [peopleTMP setValue:[results2 stringForColumn:@"emailSellersAgent"] forKey:@"emailSellersAgent"];
  91. [peopleKeysTMP addObject:@"emailSellersAgent"];
  92. }
  93. if(![results2 isNullForColumn:@"emailBuyersAttorney"]){
  94. [peopleTMP setValue:[results2 stringForColumn:@"emailBuyersAttorney"] forKey:@"emailBuyersAttorney"];
  95. [peopleKeysTMP addObject:@"emailBuyersAttorney"];
  96. }
  97. if(![results2 isNullForColumn:@"emailSellersAttorney"]){
  98. [peopleTMP setValue:[results2 stringForColumn:@"emailSellersAttorney"] forKey:@"emailSellersAttorney"];
  99. [peopleKeysTMP addObject:@"emailSellersAttorney"];
  100. }
  101. if(![results2 isNullForColumn:@"emailEscrowAgent"]){
  102. [peopleTMP setValue:[results2 stringForColumn:@"emailEscrowAgent"] forKey:@"emailEscrowAgent"];
  103. [peopleKeysTMP addObject:@"emailEscrowAgent"];
  104. }
  105. if(![results2 isNullForColumn:@"emailOther"]){
  106. [peopleTMP setValue:[results2 stringForColumn:@"emailOther"] forKey:@"emailOther"];
  107. [peopleKeysTMP addObject:@"emailOther"];
  108. }
  109.  
  110. }
  111. [results2 close];
  112. self.addressInfo = addressInfoTMP;
  113. self.addressInfoKeys = addressInfoKeysTMP;
  114. self.people = peopleTMP;
  115. self.peopleKeys = peopleKeysTMP;
  116.  
  117. NSLog(@"%@", peopleKeysTMP);
  118. }
Add Comment
Please, Sign In to add comment