-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddWindowController.m
69 lines (60 loc) · 1.69 KB
/
AddWindowController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// AddWindowController.m
// PasswordSaver
//
// Created by GuoJing on 12-11-28.
//
//
#import "AddWindowController.h"
@implementation AddWindowController
@synthesize key_textfield;
@synthesize pwd_textfield;
@synthesize decs_textfield;
@synthesize done_button;
@synthesize error_textfield;
@synthesize loading_resc;
@synthesize add_panel;
-(id)init{
[super init];
helper = [[SqliteHelper alloc] init];
return self;
}
-(IBAction)onAddButtonClicked:(id)sender{
BOOL is_key_not_entered=[key_textfield.title isEqual:@""];
BOOL is_pwd_not_entered=[pwd_textfield.title isEqual:@""];
if(is_key_not_entered||is_pwd_not_entered)
{
error_textfield.title=@"Please input all the text field.";
}
else
{
[loading_resc setHidden:FALSE];
[loading_resc setDisplayedWhenStopped:NO];
[loading_resc startAnimation:sender];
//insert into db
[helper connect];
if(![helper checkKey:key_textfield.title])
{
[helper insertKey:key_textfield.title insertPwd:pwd_textfield.title insertDesc:decs_textfield.title];
[loading_resc stopAnimation:sender];
[loading_resc setHidden:TRUE];
[add_panel orderOut:sender];
[self emptyTextField:sender];
}
else
{
[loading_resc stopAnimation:sender];
[loading_resc setHidden:TRUE];
error_textfield.title=@"Already the same key.";
}
[helper disconnect];
}
}
-(IBAction)emptyTextField:(id)sender{
key_textfield.title=@"";
pwd_textfield.title=@"";
decs_textfield.title=@"";
error_textfield.title=@"";
NSLog(@"open window");
}
@end