-
Notifications
You must be signed in to change notification settings - Fork 1
/
pcek.pas
400 lines (364 loc) · 8.67 KB
/
pcek.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
{
p01y - Cek takip modulu...
}
{$I PDEFS}
unit PCek;
interface
uses
PTypes,PKey,
GView,XOld,XInput,XSys,Dos,Drivers,XTypes,XGfx,XStr,Debris,Tools,XDev,
XPrn,Objects;
type
PCekRec = ^TCekRec;
TCekRec = record
Bank : string[39];
Name : string[39];
CekNo : string[39];
Date : longint;
Amount : comp;
end;
PCekColl = ^TCekColl;
TCekColl = object(TSortedCollection)
function Compare(k1,k2:pointer):integer;virtual;
procedure FreeItem(item:pointer);virtual;
end;
PCekLister = ^TCekLister;
TCekLister = object(TFormattedLister)
function GetText(item:longint):string;virtual;
end;
PCekDialog = ^TCekDialog;
TCekDialog = object(TDialog)
constructor Init(ahdr:string);
end;
PCekWindow = ^TCekWindow;
TCekWindow = object(TDialog)
vLister,aLister : PCekLister;
constructor Init;
procedure HandleEvent(var Event:TEvent);virtual;
end;
procedure CektakipEt;
implementation
procedure TCekColl.FreeItem;
begin
Dispose(PCekRec(item));
end;
function TCekColl.Compare;
var
p1,p2:PCekRec;
begin
p1 := k1;
p2 := k2;
if CompareMoment(p1^.Date,p2^.Date) >=0 then Compare := 1 else Compare := -1;
end;
const
vCekList : PCekColl = NIL;
aCekList : PCekColl = NIL;
procedure ReadCek(fn:String; Pc:PCekColl);
var
T:TDosStream;
P:PCekRec;
begin
Pc^.FreeAll;
T.Init(fn,stOpenRead);
if T.Status = stOK then begin
while T.GetPos < T.GetSize do begin
New(P);
T.Read(P^,SizeOf(TCekRec));
Pc^.Insert(P);
end;
end;
T.Done;
end;
procedure LoadCek;
begin
EventWait;
if vCekList = NIL then New(vCekList,Init(10,10));
if aCekList = NIL then New(aCekList,Init(10,10));
ReadCek(wkdir+vcekFile,vCekList);
ReadCek(wkdir+acekFile,aCekList);
end;
procedure WriteCek(fn:string; Pc:PCekCOll);
var
T:TDosStream;
P:PCekRec;
n:integer;
begin
{$IFNDEF DEMO}
T.Init(fn,stCreate);
if Pc <> NIL then for n := 0 to Pc^.Count-1 do begin
P := Pc^.At(n);
T.Write(P^,SizeOf(TCekRec));
end;
T.Done;
{$ENDIF}
end;
procedure SaveCek;
begin
EventWait;
WriteCek(wkdir+vCekFile,vCekList);
WriteCek(wkdir+aCekFile,aCekList);
end;
function TCekLister.GetText;
var
P:PCekRec;
begin
P := itemList^.At(item);
GetText := Date2Str(P^.Date,true)+'|'+P^.Name+'|'+P^.CekNo+'|'+P^.Bank+'|'+cn2b(c2s(P^.Amount));
end;
constructor TCekWindow.Init;
var
R:TRect;
s:string;
procedure putlabel(s:string);
var
P:PLabel;
begin
New(P,Init(r.a.x,r.a.y,s,ViewFont));
P^.GetBounds(R);
Insert(P);
end;
function putlister(x,y:integer; alist:PCekColl):PCekLister;
var
P:PCekLister;
begin
New(P,Init(x,y,ViewFont,15,
NewColumn('Tarih',90,cofNormal,
NewColumn('˜sim',150,cofNormal,
NewColumn('€ek no',120,cofNormal,
NewColumn('Banka',120,cofNormal,
NewColumn('Tutar',120,cofRJust,
NIL)))))));
P^.SetConfig(Lvc_KeepList,True);
P^.NewList(vCekList);
PutListerScroller(P,@Self);
P^.GetBounds(R);
Insert(P);
putlister := P;
end;
begin
R.Assign(0,0,0,0);
inherited Init(R,'Cek takibi');
Options := Options or OCf_Centered;
r.a.x := 5;
r.a.y := 5;
putlabel('Verilen cekler');
vLister := putlister(5,r.b.y+5,vCekList);
s := GetBlock(5,r.b.y+5,mnfHorizontal+mnfNoSelect,
NewButton('Ek~le',cmVAdd,
NewButton('S~il',cmVDel,
NewButton('Y~azdr',cmVPrint,
NIL))));
GetBlockBounds(s,R);
InsertBlock(s);
r.a.x := 5;
r.a.y := r.b.y+5;
putlabel('Alinan cekler');
aLister := putlister(5,r.b.y+5,aCekList);
InsertBlock(GetBlock(5,r.b.y+5,mnfHorizontal+mnfNoSelect,
NewButton('~Ekle',cmAAdd,
NewButton('~Sil',cmADel,
NewButton('~Yazdr',cmPrint,
NewButton('~Kapat',cmClose,
NIL))))));
Insert(New(Paccelerator,Init(
NewAcc(kbIns,cmAdd,
NewAcc(kbDel,cmDel,
NIL)))));
FitBounds;
end;
procedure TCekWindow.HandleEvent;
type
TCekScr = record
Cekno : string[39];
Bank : string[39];
Name : string[39];
day : string[2];
month : string[2];
year : string[4];
Amount : comp;
end;
procedure VAdddddddd;
var
rec:TCekScr;
T:DateTime;
Pd:PCekDialog;
P:PCekRec;
l:longint;
code:word;
begin
New(Pd,Init('Yeni "verilmi$ cek" kaydi'));
code := GSystem^.ExecView(Pd);
if code = cMOK then begin
EventWait;
Pd^.GetData(rec);
New(P);
P^.Name := rec.Name;
P^.Amount := rec.Amount;
P^.Bank := rec.Bank;
P^.Cekno := rec.Cekno;
T.Year := s2l(rec.year);
T.Month := s2l(rec.month);
T.Day := s2l(rec.Day);
T.Hour := 2;
T.Min := 33;
T.Sec := 40;
PackTime(T,l);
P^.Date := l;
vCekList^.Insert(P);
vLister^.Update(vCekList);
end;
Dispose(Pd,Done);
end;
procedure VDelllllll;
begin
if vCekList = NIL then Error('Delllll','Bu ne curet? Ceklist nIL???');
if vCekList^.Count = 0 then exit;
if MessageBox('Se‡ili kayd silmek istedi§inizden emin misiniz?',0,mfYesNo+mfConfirm) = cmYes then begin
EventWait;
vLister^.DeleteItem(vLister^.FocusedItem);
end;
end;
procedure AAdddddddd;
var
rec:TCekScr;
T:DateTime;
Pd:PCekDialog;
P:PCekRec;
l:longint;
code:word;
begin
New(Pd,Init('Yeni "alinmi$ cek" kaydi'));
code := GSystem^.ExecView(Pd);
if code = cMOK then begin
EventWait;
Pd^.GetData(rec);
New(P);
P^.Name := rec.Name;
P^.Amount := rec.Amount;
P^.Bank := rec.Bank;
P^.Cekno := rec.Cekno;
T.Year := s2l(rec.year);
T.Month := s2l(rec.month);
T.Day := s2l(rec.Day);
T.Hour := 2;
T.Min := 33;
T.Sec := 40;
PackTime(T,l);
P^.Date := l;
aCekList^.Insert(P);
aLister^.Update(aCekList);
end;
Dispose(Pd,Done);
end;
procedure ADelllllll;
begin
if aCekList = NIL then Error('Delllll','Bu ne curet? Ceklist nIL???');
if aCekList^.Count = 0 then exit;
if MessageBox('Se‡ili kayd silmek istedi§inizden emin misiniz?',0,mfYesNo+mfConfirm) = cmYes then begin
EventWait;
aLister^.DeleteItem(aLister^.FocusedItem);
end;
end;
procedure VPrint;
var
n:integer;
P:PCekRec;
begin
if vCekList^.Count = 0 then exit;
BeginPrint;
WritePrn(keycode+' VER˜LEN €EK L˜STES˜');
WritePrn('');
for n:=0 to vCekList^.Count-1 do begin
P := vCekList^.At(n);
WritePrn(Date2Str(P^.Date,true)+' '+Fix(p^.CekNo,30)+' '+Fix(P^.Name,20)+' '+RFix(cn2b(c2s(P^.Amount)),15));
end;
EndPrint;
end;
procedure Print;
var
n:integer;
P:PCekRec;
begin
EventWait;
if aCekList^.Count = 0 then exit;
BeginPrint;
WritePrn(keycode+' ALINAN €EK L˜STES˜');
WritePrn('');
for n:=0 to aCekList^.Count-1 do begin
P := aCekList^.At(n);
WritePrn(Date2Str(P^.Date,true)+' '+Fix(p^.CekNo,30)+' '+Fix(P^.Name,20)+' '+RFix(cn2b(c2s(P^.Amount)),15));
end;
EndPrint;
end;
begin
inherited HandleEvent(Event);
if Event.What = evCommand then case Event.Command of
cmVAdd : VAdddddddd;
cmVPrint : VPrint;
cmPrint : Print;
cmVDel : VDelllllll;
cmAAdd : AAdddddddd;
cmADel : ADelllllll;
end; {case}
end;
constructor TCekDialog.Init;
var
R:TRect;
blackPearlJam:integer;
procedure putinput(x,y:integer; prompt:string; len:byte; config:word);
var
Pi:PInputStr;
begin
New(Pi,Init(x,y,len,prompt,len,config));
Pi^.GetBounds(R);
Insert(Pi);
end;
procedure putninput(x,y:integer; prompt:string; numtype,len:byte; config:word);
var
Pi:PInputNum;
begin
New(Pi,Init(x,y,len,prompt,numtype,len,0,config));
Pi^.GetBounds(R);
Insert(Pi);
end;
begin
R.Assign(0,0,0,0);
inherited Init(R,ahdr);
Options := Options or Ocf_Centered;
putinput(5,5, '€ek no ',39,Idc_StrDefault);
putinput(5,r.b.y+5, 'Banka ad ',39,Idc_StrDefault);
putinput(5,r.b.y+5, '˜sim ',39,Idc_StrDefault+Idc_FirstUpper);
blackPearlJam := r.b.y+5;
putinput(5,blackPearlJam,
'€ek tarihi ',2,Idc_StrDefault);
putinput(r.b.x+1,blackPearlJam,'/',2,Idc_StrDefault);
putinput(r.b.x+1,blackPearlJam,'/',4,Idc_StrDefault);
putninput(5,r.b.y+5,'Tutar ',Stf_Comp,15,Idc_NumDefault);
InsertBlock(getBlock(5,r.b.y+5,mnfHorizontal,
NewButton('~Kaydet',cmOK,
NewButton('~Vazge‡',cmCancel,
NIL))));
SelectNext(True);
FitBounds;
end;
procedure CekTakipEt;
var
P:PCekWindow;
begin
New(P,Init);
LoadCek;
P^.vLister^.NewList(vCekList);
P^.aLister^.NEwLIst(aCekList);
GSystem^.ExecView(P);
SaveCek;
Dispose(P,Done);
if vCekList <> NIL then begin
Dispose(vCekList,Done);
vCekList := NIL;
end;
if aCekList <> NIL then begin
Dispose(aCekList,Done);
aCekList := NIL;
end;
end;
end.