-
Notifications
You must be signed in to change notification settings - Fork 0
/
unitaddcontact.pas
109 lines (88 loc) · 2.16 KB
/
unitaddcontact.pas
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
unit unitAddContact;
{$mode ObjFPC}{$H+}
interface
uses
UnitData, Utils,
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
LazLogger,
SQLDB;
type
{ TFrmAddContact }
TFrmAddContact = class(TForm)
ButtonSave: TButton;
ButtonCancel: TButton;
EditID: TEdit;
EditFirst: TEdit;
EditLast: TEdit;
LabelUserPrompt: TLabel;
Label_ID: TLabel;
LabelFirst: TLabel;
LabelLast: TLabel;
Panel1: TPanel;
Panel2: TPanel;
procedure ButtonCancelClick(Sender: TObject);
procedure ButtonSaveClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
mEditMode : Boolean;
public
function GetEditMode(): Boolean;
procedure SetEditMode(Value : Boolean);
end;
var
FrmAddContact: TFrmAddContact;
implementation
{$R *.lfm}
{ TFrmAddContact }
procedure TFrmAddContact.ButtonSaveClick(Sender: TObject);
var
InsertId : Integer;
begin
if (editFirst.Text = '') and (editLast.Text = '') then
begin
MessageDlg('Must have at least one non blank name to save!', mtInformation, mbOkCancel, 0);
end
else
begin
if (mEditMode) then
begin
InsertId := StrToInt(EditId.Text);
Utils.EditUser(DataModule1.QueryInsert, InsertId, EditFirst.Text, EditLast.Text);
end
else
begin
InsertId := Utils.AddUser(DataModule1.QueryInsert, EditFirst.Text, EditLast.Text);
EditID.Text := IntToStr(InsertId);
end;
Self.Close();
end;
end;
procedure TFrmAddContact.FormShow(Sender: TObject);
begin
if (mEditMode = true) then
begin
LabelUserPrompt.Caption := 'Editing Existing User:';
FrmAddContact.Caption := 'Edit Contact';
end
else
begin
LabelUserPrompt.Caption := 'Create New Contact?';
FrmAddContact.Caption := 'Add Contact';
end;
end;
procedure TFrmAddContact.ButtonCancelClick(Sender: TObject);
begin
Self.Close();
end;
function TFrmAddContact.GetEditMode(): Boolean;
begin
GetEditMode := mEditMode;
end;
procedure TFrmAddContact.SetEditMode(Value : Boolean);
begin
if (mEditMode <> Value) then
begin
mEditMode := value;
end;
end;
end.