-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMARCDisplayUnit.pas
executable file
·546 lines (457 loc) · 14.8 KB
/
MARCDisplayUnit.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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
unit MARCDisplayUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, TntButtons, TntStdCtrls, Grids, DBGrids,
TntDBGrids, Mask, DBCtrls, TntDBCtrls, dbcgrids, ExtCtrls, MyDump, TntForms,
TntDialogs, TntExtCtrls, ComCtrls, TntComCtrls, DADump;
type
TMARCDisplayForm = class(TTntForm)
TntComboBox1: TTntComboBox;
TntComboBox2: TTntComboBox;
TntLabel1: TTntLabel;
TntLabel2: TTntLabel;
TntBitBtn1: TTntBitBtn;
Button4: TTntBitBtn;
SaveDialog1: TTntSaveDialog;
MyDump1: TMyDump;
Panel14: TPanel;
DBCtrlGrid1: TDBCtrlGrid;
TntDBEdit1: TTntDBEdit;
TntDBEdit2: TTntDBEdit;
TntDBEdit3: TTntDBEdit;
TntDBEdit4: TTntDBEdit;
TntDBEdit5: TTntDBEdit;
TntDBEdit6: TTntDBEdit;
TntDBEdit7: TTntDBEdit;
TntDBEdit9: TTntDBEdit;
TntDBEdit10: TTntDBEdit;
Panel12: TPanel;
Panel11: TTntPanel;
Panel10: TTntPanel;
Panel9: TTntPanel;
Panel8: TTntPanel;
Panel7: TTntPanel;
Panel6: TTntPanel;
Panel5: TTntPanel;
Panel4: TTntPanel;
Panel3: TTntPanel;
Panel2: TTntPanel;
Panel1: TTntPanel;
Panel13: TTntPanel;
TntBitBtn2: TTntBitBtn;
TntBitBtn3: TTntBitBtn;
DBCheckBox2: TTntDBCheckBox;
TntBitBtn4: TTntBitBtn;
TntGroupBox1: TTntGroupBox;
TntLabel3: TTntLabel;
TntEdit1: TTntEdit;
TntBitBtn5: TTntBitBtn;
TntRichEdit1: TTntRichEdit;
TntGroupBox2: TTntGroupBox;
TntLabel4: TTntLabel;
TntLabel5: TTntLabel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
TntDBComboBox1: TTntDBComboBox;
TntDBComboBox2: TTntDBComboBox;
TntGroupBox3: TTntGroupBox;
TntLabel6: TTntLabel;
TntLabel7: TTntLabel;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
TntDBComboBox3: TTntDBComboBox;
TntDBComboBox4: TTntDBComboBox;
TntDBEdit8: TTntDBEdit;
TntDBEdit11: TTntDBEdit;
TntPanel1: TTntPanel;
TntDBEdit12: TTntDBEdit;
TntPanel2: TTntPanel;
TntDBCheckBox1: TTntDBCheckBox;
procedure Button4Click(Sender: TObject);
procedure TntBitBtn1Click(Sender: TObject);
procedure TntDBEdit1Change(Sender: TObject);
procedure TntDBEdit2Change(Sender: TObject);
procedure TntDBEdit3Change(Sender: TObject);
procedure TntComboBox1Change(Sender: TObject);
procedure TntDBEdit4Change(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure TntBitBtn2Click(Sender: TObject);
procedure TntBitBtn3Click(Sender: TObject);
procedure ck(Sender: TObject);
procedure TntBitBtn4Click(Sender: TObject);
procedure TntBitBtn5Click(Sender: TObject);
procedure TntEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure SpeedButton6Click(Sender: TObject);
private
{ Private declarations }
Procedure GetNameFromMarcdisplay;
public
{ Public declarations }
end;
var
MARCDisplayForm: TMARCDisplayForm;
implementation
uses DataUnit, MyAccess, DB, NewGroupUnit, DBAccess, common, utility,
GlobalProcedures;
{$R *.dfm}
Procedure TMARCDisplayForm.GetNameFromMarcdisplay;
begin
// Write in Combobox's dropdown list the distinct values from column Vocabulary.Name
TntComboBox1.Items.Clear;
with data.Query1 do
begin
Close;
SQL.Text :='SELECT DISTINCT Name FROM marcdisplay';
Open;
First;
while Not Eof do
begin
TntComboBox1.Items.Add(FieldByName('Name').AsString);
Next;
end;
Close;
end;
TntComboBox1.ItemIndex := 0;
TntComboBox2.ItemIndex := 0;
end;
procedure TMARCDisplayForm.Button4Click(Sender: TObject);
begin
PostTable(Data.marcdisplay);
close;
end;
procedure TMARCDisplayForm.TntBitBtn1Click(Sender: TObject);
begin
if SaveDialog1.Execute then
MyDump1.BackupToFile(SaveDialog1.FileName);
end;
procedure TMARCDisplayForm.TntDBEdit1Change(Sender: TObject);
var tfe, tfe1, tfe2 : string;
i : integer;
begin
tfe := TntDBEdit1.Text;
tfe1 :='';
for i := 1 to length(tfe) do
if tfe[i] in ['0','1','2','3','4','5','6','7','8','9','X','N','U','M'] then
tfe1 := tfe1 + tfe[i];
tfe2 := tfe1;
if Length(tfe2) > 3 then
Delete(tfe2,length(tfe2),1);
TntDBEdit1.Text := tfe2;
end;
procedure TMARCDisplayForm.TntDBEdit2Change(Sender: TObject);
var tfe, tfe1: string;
i : integer;
begin
tfe := TntDBEdit2.Text;
tfe1 :='';
for i := 1 to length(tfe) do
if tfe[i] in ['0','1','2','3','4','5','6','7','8','9',' ','?'] then
tfe1 := tfe1 + tfe[i];
TntDBEdit2.Text := tfe1;
end;
procedure TMARCDisplayForm.TntDBEdit3Change(Sender: TObject);
var tfe, tfe1: string;
i : integer;
begin
tfe := TntDBEdit3.Text;
tfe1 :='';
for i := 1 to length(tfe) do
if tfe[i] in ['0'..'9',' ','?'] then
tfe1 := tfe1 + tfe[i];
TntDBEdit3.Text := tfe1;
end;
procedure TMARCDisplayForm.TntComboBox1Change(Sender: TObject);
begin
with Data.marcdisplay do
begin
DBCheckBox2.Checked := true;
PostTable(Data.marcdisplay);
Close;
SQL.Clear;
SQL.Add('SELECT * FROM marcdisplay WHERE (Name=:Name) and (Lang=:Lang)');
ParamByName('Name').AsWideString := TntComboBox1.Text;
ParamByName('Lang').AsWideString := TntComboBox2.Text;
Execute;
end;
end;
procedure TMARCDisplayForm.TntDBEdit4Change(Sender: TObject);
var tfe, tfe1: string;
i : integer;
begin
tfe := TntDBEdit4.Text;
tfe1 :='';
for i := 1 to length(tfe) do
if tfe[i] in ['a'..'z','0'..'9','*','-'] then
tfe1 := tfe1 + tfe[i];
TntDBEdit4.Text := tfe1;
end;
procedure TMARCDisplayForm.FormActivate(Sender: TObject);
var
i : integer;
begin
GetNameFromMarcdisplay;
TntComboBox1Change(Sender);
Button4.SetFocus;
if data.basket.Active Then
TntEdit1.Text := data.basket.FieldByName('recno').AsString;
TntRichedit1.Lines.Clear;
//Populate font list
TntDBComboBox1.Items.Clear;
TntDBComboBox4.Items.Clear;
for i := 0 to Screen.Fonts.Count-1 do
begin
TntDBComboBox1.Items.Add(Screen.Fonts[i]);
TntDBComboBox4.Items.Add(Screen.Fonts[i]);
end;
end;
procedure TMARCDisplayForm.TntBitBtn2Click(Sender: TObject);
begin
with Data.marcdisplay do
begin
Append;
FieldByName('Name').AsString := TntComboBox1.Text;
FieldByName('Lang').AsString := TntComboBox2.Text;
FieldByName('print').AsBoolean := true;
FieldByName('linef').AsBoolean := true;
Post;
end;
end;
procedure TMARCDisplayForm.TntBitBtn3Click(Sender: TObject);
begin
NewGroupForm.showModal;
GetNameFromMarcdisplay;
TntComboBox1Change(Sender);
end;
procedure TMARCDisplayForm.ck(Sender: TObject);
begin
Data.marcdisplay.Delete;
end;
procedure TMARCDisplayForm.TntBitBtn4Click(Sender: TObject);
var
SWTex, SWT : WideString;
begin
SWTex := 'Are you sure you want to delete the selected tag with the fields:'+ #13+
' Name: '+Data.marcdisplay.FieldByName('Name').AsVariant + #13+
' Lang: '+ Data.marcdisplay.FieldByName('Lang').AsString + #13+
' Tag: '+ Data.marcdisplay.FieldByName('Tag').AsString;
SWT := 'MARC Display';
if MessageBoxW(0,PWideChar(SWTex),PWideChar(SWT), MB_YESNO + MB_ICONQUESTION + MB_TASKMODAL) = mrYes then
begin
Data.marcdisplay.Delete;
end;
end;
procedure TMARCDisplayForm.TntBitBtn5Click(Sender: TObject);
var
grouptext, book : WideString;
rec : UTF8String;
i, recno : integer;
begin
PostTable(Data.marcdisplay);
recno := StrToIntDef(TntEdit1.Text, -1);
grouptext:='';
if recno > 0 Then
begin
OpenSecureBasketTable(recno);
if data.SecureBasket.RecordCount > 0 Then
begin
SetLength(LabelPos, 0);
SetLength(ContentPos, 0);
rec := MakeMRCFromSecureBasket(recno);
book := ProcessRecnoForPrinting(rec, 1, -1, False, grouptext, TntComboBox1.Text, TntCombobox2.Text);
TntRichEdit1.Text := book;
//Apply Label font
for i := 0 to length(LabelPos)-1 do
with TntRichEdit1 do
begin
SelStart := LabelPos[i].Start;
SelLength := LabelPos[i].Len;
if LabelPos[i].Font.Name <> '' Then
SelAttributes.Name := LabelPos[i].Font.Name;
if length(LabelPos[i].Font.Style) = 3 Then
begin
if StrToIntDef(LabelPos[i].Font.Style[1], 0) = 1
Then SelAttributes.Style := SelAttributes.Style + [fsBold]
Else SelAttributes.Style := SelAttributes.Style - [fsBold];
if StrToIntDef(LabelPos[i].Font.Style[2], 0) = 1
Then SelAttributes.Style := SelAttributes.Style + [fsItalic]
Else SelAttributes.Style := SelAttributes.Style - [fsItalic];
if StrToIntDef(LabelPos[i].Font.Style[3], 0) = 1
Then SelAttributes.Style := SelAttributes.Style + [fsUnderline]
Else SelAttributes.Style := SelAttributes.Style - [fsUnderline];
end;
if LabelPos[i].Font.Size > 0 Then
SelAttributes.Size := LabelPos[i].Font.Size;
end;
//Apply Content font
for i := 0 to length(ContentPos)-1 do
with TntRichEdit1 do
begin
SelStart := ContentPos[i].Start;
SelLength := ContentPos[i].Len;
if ContentPos[i].Font.Name <> '' Then
SelAttributes.Name := ContentPos[i].Font.Name;
if length(ContentPos[i].Font.Style) = 3 Then
begin
if StrToIntDef(ContentPos[i].Font.Style[1], 0) = 1
Then SelAttributes.Style := SelAttributes.Style + [fsBold]
Else SelAttributes.Style := SelAttributes.Style - [fsBold];
if StrToIntDef(ContentPos[i].Font.Style[2], 0) = 1
Then SelAttributes.Style := SelAttributes.Style + [fsItalic]
Else SelAttributes.Style := SelAttributes.Style - [fsItalic];
if StrToIntDef(ContentPos[i].Font.Style[3], 0) = 1
Then SelAttributes.Style := SelAttributes.Style + [fsUnderline]
Else SelAttributes.Style := SelAttributes.Style - [fsUnderline];
end;
if ContentPos[i].Font.Size > 0 Then
SelAttributes.Size := ContentPos[i].Font.Size;
end;
end;
end;
end;
procedure TMARCDisplayForm.TntEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = 13 Then TntBitBtn5Click(Sender);
end;
procedure TMARCDisplayForm.SpeedButton1Click(Sender: TObject);
var
style : string[3];
enabled : char;
begin
if (Sender as TSpeedButton).Down Then enabled := '1'
Else enabled := '0';
if IsEmptyField(data.marcdisplay, 'l_style') Then
begin
EditTable(data.marcdisplay);
style := enabled + '00';
data.marcdisplay['l_style'] := style;
end
Else
begin
style := data.marcdisplay.FieldByName('l_style').AsString;
EditTable(data.marcdisplay);
if length(style)<>3 Then style := enabled + '00'
Else style[1] := enabled;
data.marcdisplay['l_style'] := style;
end;
end;
procedure TMARCDisplayForm.SpeedButton2Click(Sender: TObject);
var
style : string[3];
enabled : char;
begin
if (Sender as TSpeedButton).Down Then enabled := '1'
Else enabled := '0';
if IsEmptyField(data.marcdisplay, 'l_style') Then
begin
EditTable(data.marcdisplay);
style := '0' + enabled + '0';
data.marcdisplay['l_style'] := style;
end
Else
begin
style := data.marcdisplay.FieldByName('l_style').AsString;
EditTable(data.marcdisplay);
if length(style)<>3 Then style := '0' + enabled + '0'
Else style[2] := enabled;
data.marcdisplay['l_style'] := style;
end;
end;
procedure TMARCDisplayForm.SpeedButton3Click(Sender: TObject);
var
style : string[3];
enabled : char;
begin
if (Sender as TSpeedButton).Down Then enabled := '1'
Else enabled := '0';
if IsEmptyField(data.marcdisplay, 'l_style') Then
begin
EditTable(data.marcdisplay);
style := '00' + enabled;
data.marcdisplay['l_style'] := style;
end
Else
begin
style := data.marcdisplay.FieldByName('l_style').AsString;
EditTable(data.marcdisplay);
if length(style)<>3 Then style := '00' + enabled
Else style[3] := enabled;
data.marcdisplay['l_style'] := style;
end;
end;
procedure TMARCDisplayForm.SpeedButton4Click(Sender: TObject);
var
style : string[3];
enabled : char;
begin
if (Sender as TSpeedButton).Down Then enabled := '1'
Else enabled := '0';
if IsEmptyField(data.marcdisplay, 'c_style') Then
begin
EditTable(data.marcdisplay);
style := enabled + '00';
data.marcdisplay['c_style'] := style;
end
Else
begin
style := data.marcdisplay.FieldByName('c_style').AsString;
EditTable(data.marcdisplay);
if length(style)<>3 Then style := enabled + '00'
Else style[1] := enabled;
data.marcdisplay['c_style'] := style;
end;
end;
procedure TMARCDisplayForm.SpeedButton5Click(Sender: TObject);
var
style : string[3];
enabled : char;
begin
if (Sender as TSpeedButton).Down Then enabled := '1'
Else enabled := '0';
if IsEmptyField(data.marcdisplay, 'c_style') Then
begin
EditTable(data.marcdisplay);
style := '0' + enabled + '0';
data.marcdisplay['c_style'] := style;
end
Else
begin
style := data.marcdisplay.FieldByName('c_style').AsString;
EditTable(data.marcdisplay);
if length(style)<>3 Then style := '0' + enabled + '0'
Else style[2] := enabled;
data.marcdisplay['c_style'] := style;
end;
end;
procedure TMARCDisplayForm.SpeedButton6Click(Sender: TObject);
var
style : string[3];
enabled : char;
begin
if (Sender as TSpeedButton).Down Then enabled := '1'
Else enabled := '0';
if IsEmptyField(data.marcdisplay, 'c_style') Then
begin
EditTable(data.marcdisplay);
style := '00' + enabled;
data.marcdisplay['c_style'] := style;
end
Else
begin
style := data.marcdisplay.FieldByName('c_style').AsString;
EditTable(data.marcdisplay);
if length(style)<>3 Then style := '00' + enabled
Else style[3] := enabled;
data.marcdisplay['c_style'] := style;
end;
end;
end.