-
Notifications
You must be signed in to change notification settings - Fork 1
/
UPelanggan.pas
230 lines (209 loc) · 6.39 KB
/
UPelanggan.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
unit UPelanggan;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls, ExtCtrls;
type
TForm3 = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Shape1: TShape;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Edit1: TEdit;
DBGrid1: TDBGrid;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Panel5: TPanel;
Label6: TLabel;
Edit5: TEdit;
ComboBox1: TComboBox;
Label7: TLabel;
Panel6: TPanel;
Panel7: TPanel;
procedure Panel7Click(Sender: TObject);
procedure Panel2Click(Sender: TObject);
procedure Panel5Click(Sender: TObject);
procedure Panel4Click(Sender: TObject);
procedure Panel3Click(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
procedure Panel6Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure Edit3KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses
UDataModule, UMekanik;
{$R *.dfm}
procedure TForm3.Panel7Click(Sender: TObject);
var
id : string;
begin
// coding untuk memilih kode dengan nomor yg paling terbesar :
DM.ADOQIdPelanggan.Close;
DM.ADOQIdPelanggan.SQL.Clear;
DM.ADOQIdPelanggan.SQL.Add('SELECT TOP 1 DataPelanggan.idPelanggan FROM DataPelanggan');
DM.ADOQIdPelanggan.SQL.Add('ORDER BY DataPelanggan.idPelanggan DESC');
DM.ADOQIdPelanggan.Open;
// coding untuk mengcopy nilai yang di seleksi :
id := Copy(DM.ADOQIdPelanggan.Fields[0].AsString, 4, 6);
// coding jika seleksi = 0 maka id = 00001 jika tdk maka tambah 1 :
if id <> '' then id := FormatFLoat('000000', StrtoInt(id) + 1)
else id := '000001';
// coding melakukan pengabungan kode string dan integer :
Form3.Edit1.Text := 'ID-' + id;
Panel5.Enabled := True;
Panel4.Enabled := False;
Panel3.Enabled := False;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
Edit5.Clear;
ComboBox1.Text := '';
DM.ADOQDataPelanggan.Filtered := False;
end;
procedure TForm3.Panel2Click(Sender: TObject);
begin
Panel5.Enabled := False;
Panel4.Enabled := False;
Panel3.Enabled := False;
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
Edit5.Clear;
ComboBox1.Text := '';
DM.ADOQDataPelanggan.Filtered := False;
end;
procedure TForm3.Panel5Click(Sender: TObject);
begin
if Edit1.Text = '' then MessageDlg('ID Pelanggan Kosong',mtinformation,[mbok],0) else
if Edit2.Text = '' then MessageDlg('Nama Pelanggan Kosong',mtinformation,[mbok],0) else
if Edit3.Text = '' then MessageDlg('No Telpon Kosong',mtinformation,[mbok],0) else
if Edit4.Text = '' then MessageDlg('Alamat Kosong',mtinformation,[mbok],0) else
begin
DM.ADOQDataPelanggan.Append;
DM.ADOQDataPelanggan['idPelanggan'] := Edit1.Text;
DM.ADOQDataPelanggan['namaPelanggan'] := Edit2.Text;
DM.ADOQDataPelanggan['noTelpon'] := Edit3.Text;
DM.ADOQDataPelanggan['ALamat'] := Edit4.Text;
DM.ADOQDataPelanggan.Post;
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
Panel5.Enabled := False;
end;
end;
procedure TForm3.Panel4Click(Sender: TObject);
begin
if Edit1.Text = '' then MessageDlg('ID Pelanggan Kosong',mtinformation,[mbok],0) else
if Edit2.Text = '' then MessageDlg('Nama Pelanggan Kosong',mtinformation,[mbok],0) else
if Edit3.Text = '' then MessageDlg('No Telpon Kosong',mtinformation,[mbok],0) else
if Edit4.Text = '' then MessageDlg('Alamat Kosong',mtinformation,[mbok],0) else
begin
DM.ADOQDataPelanggan.Edit;
DM.ADOQDataPelanggan['idPelanggan'] := Edit1.Text;
DM.ADOQDataPelanggan['namaPelanggan'] := Edit2.Text;
DM.ADOQDataPelanggan['noTelpon'] := Edit3.Text;
DM.ADOQDataPelanggan['ALamat'] := Edit4.Text;
DM.ADOQDataPelanggan.Post;
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
Panel4.Enabled := False;
Panel3.Enabled := False;
end;
end;
procedure TForm3.Panel3Click(Sender: TObject);
begin
if Dm.ADOQDataPelanggan.IsEmpty then MessageDlg('Data Kosong',mtInformation,[mbok],0) else
if Application.MessageBox('Yakin Hapus Data ??','Pesan',Mb_YesNo or Mb_IconQuestion)=MrYes then
Begin
Dm.ADOQDataPelanggan.Delete;
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
Panel4.Enabled := False;
Panel3.Enabled := False;
End;
end;
procedure TForm3.DBGrid1CellClick(Column: TColumn);
begin
if Dm.ADOQDataPelanggan.IsEmpty then MessageDlg('Data Pelanggan Kosong',mtInformation,[mbok],0) else
begin
Edit1.Text := DM.ADOQDataPelanggan['idPelanggan'] ;
Edit2.Text := DM.ADOQDataPelanggan['namaPelanggan'] ;
Edit3.Text := DM.ADOQDataPelanggan['noTelpon'] ;
Edit4.Text := DM.ADOQDataPelanggan['Alamat'] ;
Panel5.Enabled := False;
Panel4.Enabled := True;
Panel3.Enabled := True;
end;
end;
procedure TForm3.Panel6Click(Sender: TObject);
begin
if (ComboBox1.Text = '') and (Edit5.Text = '') then
begin
DM.ADOQDataPelanggan.Filtered := False;
end
else
if (ComboBox1.Text = 'ID PELANGGAN') and (Edit5.Text <> '') then
begin
Dm.ADOQDataPelanggan.Close;
Dm.ADOQDataPelanggan.Open;
Dm.ADOQDataPelanggan.Filtered := False;
DM.ADOQDataPelanggan.Filter :='idPelanggan LIKE '+Quotedstr('%'+Edit5.Text+'%');
Dm.ADOQDataPelanggan.Filtered := True;
end
else
if (ComboBox1.Text = 'NAMA PELANGGAN') and (Edit5.Text <> '') then
begin
Dm.ADOQDataPelanggan.Close;
Dm.ADOQDataPelanggan.Open;
Dm.ADOQDataPelanggan.Filtered := False;
DM.ADOQDataPelanggan.Filter :='namaPelanggan LIKE '+Quotedstr('%'+Edit5.Text+'%');
Dm.ADOQDataPelanggan.Filtered := True;
end
else
if (ComboBox1.Text <> '') and (Edit5.Text = '') then
begin
DM.ADOQDataPelanggan.Filtered := False;
end;
end;
procedure TForm3.FormActivate(Sender: TObject);
begin
Panel5.Enabled := False;
Panel4.Enabled := False;
Panel3.Enabled := False;
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
Edit5.Clear;
ComboBox1.Text := '';
DM.ADOQDataPelanggan.Filtered := False;
end;
procedure TForm3.Edit3KeyPress(Sender: TObject; var Key: Char);
begin
if not(key in['0'..'9', #8, #13, #32]) then
begin
key :=#0;
MessageDlg('Nilai yang diinput harus angka !!!',mtError,[mbOK],0);
end
end;
end.