View difference between Paste ID: 4EnEWQWN and trSAtZ3X
SHOW: | | - or go back to the newest paste.
1
//class user.m
2
3
- (BOOL)isMatch:(NSString*)username andPassword:(NSString*)password
4
{
5
    BOOL value = NO;
6
    
7
    NSArray *results = [mainApp.db getData:[NSString stringWithFormat:@"SELECT COUNT(*)userLog FROM login WHERE username='%@' AND password='%@'", username, password]];
8
    NSLog(@"results %@", results);
9
    NSInteger count = [[results lastObject] objectForKey:@"userLog"];
10-
    if (results!=nil && [results count] > 0) 
10+
    if (results!=nil && count > 0) 
11
    {
12
        value = true;
13
    }
14
    
15
    NSLog(@"user %@, password %@, value : %i", username, password, value);
16
    return value;
17
}
18
19
20
//class LoginView.m
21
22
- (void)didLogin:(id)sender {
23
    
24
    user = [[User alloc] init];
25
    NSLog(@"user %@", [user description]);
26
    
27
    NSString *msg = @"";
28
    UIAlertView *alert = [[UIAlertView alloc] 
29
                          initWithTitle:@"Peringatan" 
30
                          message:msg 
31
                          delegate:self 
32
                          cancelButtonTitle:@"OK"
33
                          otherButtonTitles:nil];
34
    
35
    if([tfUserName.text length] == 0 & [tfPassword.text length] == 0  )
36
    { 
37
        
38
        msg = @"tolong isi username dan password anda";
39
        alert.message = msg;
40
        [alert show];
41
        
42
    } else if([tfUserName.text length] == 0){
43
        
44
        msg = @"tolong isi username anda";
45
        alert.message = msg;
46
        [alert show];
47
        
48
    }else if([tfPassword.text length] == 0){
49
        
50
        msg = @"tolong isi password";
51
        alert.message = msg;
52
        [alert show];
53
        
54
    } else if(![user isMatch:tfUserName.text andPassword:tfPassword.text]){  
55
        
56
        msg = @"cek kembali username dan password anda";
57
        alert.message = msg;
58
        [alert show];
59
        
60
    } else if ([user isMatch:tfUserName.text andPassword:tfPassword.text]){
61
        
62
        UIViewController *vc = [[UIViewController alloc] initWithNibName:@"Utama" bundle:nil];
63
        [self presentModalViewController:vc animated:YES];
64
65
    }
66
    
67
68
        
69
}