-
Notifications
You must be signed in to change notification settings - Fork 2
/
MARCEditor.pas
executable file
·1438 lines (1240 loc) · 42.5 KB
/
MARCEditor.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
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit MARCEditor;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, common, mycharconversion, TntStdCtrls, ComCtrls,
Mask, IniFiles, DBCtrls, TntDBCtrls, dbcgrids, ExtCtrls, Grids, DBGrids, DateUtils,
TntDBGrids, TntClasses, DB, TntComCtrls, Buttons, TntButtons, TntDialogs,
TntMenus, TntForms, ActnList, cUnicodeCodecs;
type Tlink =
record
start : integer;
len : integer;
typ : Integer;
holdon : integer;
recno : integer;
aa : integer;
name : string;
end;
TCoord =
record
start : integer;
len : integer;
end;
type
TMARCEditorform = class(TTntForm)
MainMenu1: TTntMainMenu;
File1: TTntMenuItem;
Save1: TTntMenuItem;
Delete1: TTntMenuItem;
Return1: TTntMenuItem;
Edit0081: TTntMenuItem;
Loadrecordfromfile1: TTntMenuItem;
EditLeader1: TTntMenuItem;
N1: TTntMenuItem;
N2: TTntMenuItem;
Saveastemplate1: TTntMenuItem;
Editrecord1: TTntMenuItem;
StatusBar1: TTntStatusBar;
ComboBox1: TTntComboBox;
Label2: TTntLabel;
full: TTntMemo;
TntRichEditME: TTntRichEdit;
New: TTntBitBtn;
TntBitBtn1: TTntBitBtn;
TntBitBtn5: TTntBitBtn;
TntBitBtn6: TTntBitBtn;
TntBitBtn7: TTntBitBtn;
TntPopupMenu1: TTntPopupMenu;
Editleader2: TTntMenuItem;
Edit0082: TTntMenuItem;
N3: TTntMenuItem;
Loadfromtemplate1: TTntMenuItem;
Saveastemplate2: TTntMenuItem;
N4: TTntMenuItem;
Arrangetags1: TTntMenuItem;
ToolsBtn: TTntBitBtn;
Edittag1: TTntMenuItem;
DBText1: TTntDBText;
DBText2: TTntDBText;
TntBitBtn2: TTntBitBtn;
TntBitBtn3: TTntBitBtn;
N5: TTntMenuItem;
Locate1: TTntMenuItem;
Splitter1: TSplitter;
Panel1: TPanel;
Panel2: TPanel;
FixHollis1: TTntMenuItem;
ActionList1: TActionList;
ActFixHollis: TAction;
prevrec: TTntBitBtn;
nextrec: TTntBitBtn;
TntBitBtn4: TTntBitBtn;
AuthorityLookup1: TTntMenuItem;
TntBitBtn8: TTntBitBtn;
procedure Return1Click(Sender: TObject);
procedure Save1Click(Sender: TObject);
procedure Delete1Click(Sender: TObject);
procedure Edit0081Click(Sender: TObject);
procedure Loadrecordfromfile1Click(Sender: TObject);
procedure EditLeader1Click(Sender: TObject);
procedure Saveastemplate1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Editrecord1Click(Sender: TObject);
procedure NewClick(Sender: TObject);
procedure DBCtrlGrid1DblClick(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure fullDblClick(Sender: TObject);
procedure fullClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure TntRichEditMEMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure MakeReadOnly;
procedure MakeEdit;
procedure Refresh_Holdings(var richedit : TTntRichEdit);
procedure SetTextInRichEdit(TntRichEdit1 : TTntRichEdit);
Procedure SetHoldInRichEdit(RichEdit : TTntRichEdit);
procedure ToolsBtnClick(Sender: TObject);
procedure Arrangetags1Click(Sender: TObject);
procedure TntRichEditMEDblClick(Sender: TObject);
procedure fullKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure TntFormShow(Sender: TObject);
procedure TntBitBtn2Click(Sender: TObject);
procedure TntBitBtn3Click(Sender: TObject);
procedure Locate1Click(Sender: TObject);
procedure ActFixHollisExecute(Sender: TObject);
procedure TntFormActivate(Sender: TObject);
procedure prevrecClick(Sender: TObject);
procedure nextrecClick(Sender: TObject);
procedure TntBitBtn4Click(Sender: TObject);
procedure AuthorityLookup1Click(Sender: TObject);
procedure TntRichEditMEMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure TntBitBtn8Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
holdings_moved,
saved : boolean;
edit_from_result_set : boolean;
record_index, previous_record, next_record : integer;
function SaveData : boolean;
end;
var
MARCEditorform: TMARCEditorform;
reclock, inbasket, newrec : boolean;//saved,
linenr : integer;
myrecno:integer;
links : array of Tlink;
templatename : string;
procedure Refresh_SafeBasket;
implementation
uses zoomit, form008, MyAccess, ldr, MainUnit, DataUnit, Math, EditMarcUnit,
StrUtils, WideIniClass, ProgresBarUnit, utility,
GlobalProcedures, HoldingsUnit, ShowHoldMemoUnit, DigitalUnit, zlocate,
HoldingsRangeUnit,
zauthlookup,
MoveHoldings;
{$R *.dfm}
procedure TMARCEditorform.Return1Click(Sender: TObject);
begin
ModalResult := mrCancel;
end;
procedure load_from_template(filename : string);
var
f : TextFile;
rec : UTF8String;
begin
AssignFile(F, FastRecordCreator.OpenDialog1.FileName);
Reset(F);
readln(f,rec);
if (rec='MARC TEMPLATE') then
begin
while( not (eof(f))) do
begin
readln(f,rec);
if (copy(rec,1,5) <> '[936]') then
if (copy(rec,1,5) <> '[001]') then MARCEditorForm.full.Lines.Add(UTF8StringToWideString(rec));
end;
end;
CloseFile(f);
// templatename := '';
end;
procedure TMARCEditorform.Save1Click(Sender: TObject);
begin
SaveData;
end;
procedure TMARCEditorform.Delete1Click(Sender: TObject);
var
res, recno: integer;
text : UTF8String;
begin
if not newrec then
begin
if Data.hold.RecordCount = 0 Then
begin
if Data.digital.RecordCount = 0 Then
begin
res := WideMessageDlg('Do you want to delete this record from the database?',
mtConfirmation, [mbYes, mbNo], 0);
if res = mrYes Then
begin
recno := data.SecureBasket.FieldByName('recno').AsInteger;
text := WideStringToString(data.SecureBasket.GetBlob('text').AsWideString, Greek_codepage);
data.Securebasket.Delete;
append_move(UserCode, 6, today, CurrentUserName + ' deleted recno=' + Data.auth.FieldByName('recno').AsString );
RecordUpdated(myzebrahost, 'delete', recno, text);
full.Modified := False;
ModalResult := mrOk;
end;
end
Else WideShowMessage('There are digital objects for this record. Please delete them first');
end
Else WideShowMessage('There are holdings for this record. Please delete them first');
end
Else
begin
full.Modified := False;
Close;
end;
end;
procedure TMARCEditorform.Edit0081Click(Sender: TObject);
var
cl,i : integer;
mater : string;
begin
cl := -1;
for i:=0 to full.Lines.Count-1 do
if copy(full.Lines[i],1,5) = '[008]' then begin cl := i; break; end;
for i:=0 to full.Lines.Count-1 do
if copy(full.Lines[i],1,5) = '[LDR]' then begin mater:=type_of_material(copy(full.Lines[i],7,100)); break; end;
if ((mater<>'MP') and (mater<>'VM') and (mater <> 'SE') and (mater <> 'AM')and (mater <> 'MA')and (mater <> 'MU')) then mater :='BK';
if cl <> -1 then
begin
eight.Edit1.text:=copy(full.Lines[cl],7,length(full.Lines[cl]));
eight.typeofmaterial:=mater;
eight.showmodal;
full.Lines[cl] :='[008] '+eight.Edit1.text;
end;
end;
procedure TMARCEditorform.Loadrecordfromfile1Click(Sender: TObject);
begin
load_and_merge_record(FastrecordCreator.Opendialog1, Full);
end;
procedure TMARCEditorform.EditLeader1Click(Sender: TObject);
var
cl,i : integer;
begin
cl := -1;
for i:=0 to full.Lines.Count-1 do
if copy(full.Lines[i],1,5) = '[LDR]' then begin cl := i; break; end;
if cl <> -1 then
begin
leaderform.record_type := 'bib';
leaderform.Edit1.text:=copy(full.Lines[cl],7,length(full.Lines[cl]));
leaderform.showmodal;
full.Lines[cl] :='[LDR] '+leaderform.Edit1.text;
end;
end;
procedure TMARCEditorform.Saveastemplate1Click(Sender: TObject);
var
i: integer;
f: textfile;
begin
FastRecordCreator.SaveDialog1.FileName := '';
FastRecordCreator.SaveDialog1.Filter := 'TMPL files (*.tmpl)|*.tmpl';
FastRecordCreator.SaveDialog1.FilterIndex := 1; { start the dialog showing all files }
if FastRecordCreator.SaveDialog1.Execute then
begin
Assignfile(f,FastRecordCreator.Savedialog1.FileName);
rewrite(f);
writeln(f,'MARC TEMPLATE');
for i:=0 to full.Lines.Count-1 do
writeln(f,WideStringToUTF8String(full.lines[i]));
CloseFile(f);
end;
end;
procedure unlock_record;
begin
if reclock Then
begin
EditTable(data.Securebasket);
data.Securebasket['lockcode'] := -1;
PostTable(data.Securebasket);
reclock := False;
end;
end;
function TMARCEditorform.SaveData: boolean;
var
action: string;
rec: UTF8String;
recnr : integer;
begin
result :=true;
FixMemo(full);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if disp2mrc(full.Lines,rec) = 0 then //If the record was transformed successfully from Lines to MARC
begin
if SyntaxCheck(full.Lines,'bib') <> true then result := false;
if result = true then
begin
with data.secureBasket do
begin
action:='update';
EditTable(data.SecureBasket);
EnhanceMARC(FieldByName('recno').AsInteger, rec);
Refresh084(FieldByName('recno').AsInteger, rec);
//FIXME : Refresh856(FieldByName('recno').AsInteger, rec);
FieldByName('level').AsInteger := ComboBox1.ItemIndex;
GetBlob('text').AsWideString := StringToWideString(rec, Greek_codepage);
TBlobField(FieldByName('text')).Modified := True;
if templatename = '' then
begin
FieldByName('Modified').Value := Today;
FieldByName('Modifier').Value := UserCode;
end;
PostTable(data.secureBasket);
append_move(UserCode, 6,today, CurrentUserName + ' changed recno=' + Data.SecureBasket.FieldByName('recno').AsString);
if not Data.securebasket.FieldByName('creator').IsNull then
MARCEditorform.StatusBar1.Panels[1].Text := 'Created by: ' + return_username(Data.securebasket.FieldByName('creator').AsInteger) +
' on ' + Data.securebasket.FieldByName('created').AsString;
if not Data.securebasket.FieldByName('modifier').IsNull then
MARCEditorform.StatusBar1.Panels[2].Text := 'Modified by: ' + return_username(Data.securebasket.FieldByName('modifier').AsInteger) +
' on ' + Data.securebasket.FieldByName('modified').AsString;
end;
full.Lines.Clear;
marcrecord2memo(rec, full);
full.Modified := False;
saved:=true;
holdings_moved:=false;
newrec := False;
recnr := Data.SecureBasket.FieldByName('recno').AsInteger;
RecordUpdated(myzebrahost, action, recnr, MakeMRCFromSecureBasket(recnr));
unlock_record;
end;
end
Else
result := false;
if result = false then
WideShowMessage('You have a syntax error in this record. Please check.');
end;
procedure TMARCEditorform.FormClose(Sender: TObject;
var Action: TCloseAction);
var
res: integer;
begin
if Full.Modified then
begin
res := WideMessageDlg('Record has not been saved.'+#10#13+'Do you want to save?',
mtConfirmation, [mbYes, mbNo, mbCancel], 0);
case res of
mrYes: if not SaveData Then Action := caNone;
mrCancel: Action := caNone;
end;
end
else if (holdings_moved = true) then
begin
res := WideMessageDlg('Record must be saved because holdings have been moved.',
mtConfirmation, [mbYes, mbCancel], 0);
if res = mrYes then
begin
if not SaveData Then Action := caNone;
end
else
Action := caNone;
end;
if (Action <> caNone) then
begin
data.freeparams(data.loancategories);
data.freeparams(data.processstatuses);
if (data.securebasket.RecordCount > 0)then unlock_record;
end;
end;
function take_lock : boolean;
begin
data.Securebasket.RefreshRecord;
if (UserCode = 0) or //User is an administrator
(data.Securebasket.FieldByName('lockcode').AsInteger = -1) or //The record is not edited by any user
(data.Securebasket.FieldByName('lockcode').IsNull) or
(data.Securebasket.FieldByName('lockcode').AsInteger = UserCode) or //The record is editing by me
(MinutesBetween(now, data.Securebasket.FieldByName('locktime').AsDateTime)>60) //The lock is taken for more than 60 mins
Then
begin
//Lock table
EditTable(data.Securebasket);
data.Securebasket['lockcode'] := UserCode;
data.Securebasket['locktime'] := now;
PostTable(data.Securebasket);
reclock := True;
end;
Result := reclock;
end;
procedure TMARCEditorform.MakeEdit;
begin
if ((current_user_access = 6) and (UserCode <> Data.securebasket.FieldByName('creator').AsInteger) ) then
begin
WideShowMessage('You do not have permission to modify this record.');
end
else
begin
if take_lock Then
begin
full.ReadOnly := False;
ToolsBtn.Enabled := True;
TntBitBtn5.Enabled := True;
TntBitBtn6.Enabled := True;
ComboBox1.Enabled := True;
full.OnDblClick := fullDblClick;
end
Else
ShowMessage('This record is being edited by another user');
end;
end;
procedure TMARCEditorform.MakeReadOnly;
begin
full.ReadOnly := True;
ToolsBtn.Enabled := False;
TntBitBtn5.Enabled := False;
TntBitBtn6.Enabled := False;
ComboBox1.Enabled := False;
full.OnDblClick := nil;
end;
procedure TMARCEditorform.Editrecord1Click(Sender: TObject);
begin
MakeEdit;
end;
procedure TMARCEditorform.NewClick(Sender: TObject);
begin
if ((current_user_access = 6) and (UserCode <> Data.securebasket.FieldByName('creator').AsInteger) ) then
begin
WideShowMessage('You do not have permission to add holdings for this record.');
end
else
begin
if (SyntaxCheck(full.Lines,'bib') <> true) then
begin
showmessage('There are syntax errors. Please correct them first.');
exit;
end;
if newrec Then
begin
if WideMessageDlg('This will save current record. Do you want to continue?',
mtConfirmation, [mbYes, mbNo], 0) = mrYes Then
if SaveData Then
begin
data.hold.Append;
Holdings.ShowModal;
end;
end
Else
begin
data.hold.Append;
Holdings.ShowModal;
end;
SetHoldInRichEdit(TntRichEditME);
end;
end;
procedure TMARCEditorform.DBCtrlGrid1DblClick(Sender: TObject);
begin
if not Data.hold.IsEmpty Then
Holdings.Showmodal;
end;
procedure TMARCEditorform.ComboBox1Change(Sender: TObject);
begin
full.Modified := True;
end;
procedure TMARCEditorform.fullDblClick(Sender: TObject);
var
strr : string;
begin
strr := LeftStr(full.Lines.Strings[linenr], 5);
if strr='' then exit;
if (strr='[LDR]') then MainMenu1.Items[0].Items[1].Click
else if (strr='[008]') then MainMenu1.Items[0].Items[2].Click
else
begin
EditMarcForm.str := full.Lines.Strings[linenr];
if length(full.Lines.Strings[linenr])>6 then
begin
EditMarcForm.StatusBar1.SimpleText := StatusBar1.Panels[0].Text;
EditMarcForm.record_type := 'bib';
EditMarcForm.ShowModal;
if EditMarcForm.ModalResult = mrOk then
begin
full.Lines.Delete(linenr);
full.Lines.Insert(linenr, EditMarcForm.str);
end;
end;
end;
end;
procedure TMARCEditorform.fullClick(Sender: TObject);
begin
linenr := full.CaretPos.Y;
end;
procedure TMARCEditorform.FormCreate(Sender: TObject);
begin
PopulateComboFromIni('RecordLevel', ComboBox1);
end;
procedure TMARCEditorform.SetTextInRichEdit(TntRichEdit1: TTntRichEdit);
const items_threshold = 30;
var
ItemCount, i : integer;
AllText, LabelText, ValueText : WideString;
begin
TntRichEdit1.Font.Style :=[fsBold];
TntRichEdit1.Font.Color := clBlack;
AllText := '';
//Branch
if (not Data.hold.fieldbyname('Branch').IsNull) then
begin
ValueText:=data.lookupparam(data.brancheslist,Data.hold.fieldbyname('Branch').AsString, '');
if ValueText='' then ValueText:=Data.hold.fieldbyname('Branch').AsString;
LabelText := 'Branch ';
AllText := AllText + LabelText + ValueText;
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clBlue;
TntRichEdit1.SelText := ValueText;
end;
//Collection
if not Data.hold.fieldbyname('collection').IsNull then
begin
ValueText:=data.lookupparam(data.collectionlist,Data.hold.fieldbyname('collection').AsString,Data.hold.fieldbyname('Branch').AsString);
if ValueText='' then ValueText:=Data.hold.fieldbyname('collection').AsString;
if AllText<>'' then LabelText := ' Collection '
else LabelText := 'Collection ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clBlue;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
//Classification
if not Data.hold.fieldbyname('cln').IsNull then
begin
ValueText := Data.hold.fieldbyname('cln').Value;
if not Data.hold.fieldbyname('cln_ip').IsNull then
begin
ValueText := ValueText+' '+Data.hold.fieldbyname('cln_ip').Value;
end;
if AllText<>'' then LabelText := ' Cln '
else LabelText := 'Cln ';
AllText := AllText + LabelText + ValueText;
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clBlue;
TntRichEdit1.SelText := ValueText;
end;
if AllText <> '' Then TntRichEdit1.SelText:=#13#10;
AllText := '';
if ((not Data.hold.FieldByName('enum1').IsNull) and (trim(Data.hold.FieldByName('enum1').Value)<>'')) then
begin
ValueText := Data.hold.FieldByName('enum1').Value+' ';
LabelText := GetIniMappings('enumeration','1')+' ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clBlue;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
if ((not Data.hold.FieldByName('enum2').IsNull) and (trim(Data.hold.FieldByName('enum2').Value)<>'')) then
begin
ValueText := Data.hold.FieldByName('enum2').Value+' ';
LabelText := GetIniMappings('enumeration','2')+' ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clBlue;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
if ((not Data.hold.FieldByName('enum3').IsNull) and (trim(Data.hold.FieldByName('enum3').Value)<>'')) then
begin
ValueText := Data.hold.FieldByName('enum3').Value+' ';
LabelText := GetIniMappings('enumeration','3')+' ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clBlue;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
if ((not Data.hold.FieldByName('enum4').IsNull) and (trim(Data.hold.FieldByName('enum4').Value)<>'')) then
begin
ValueText := Data.hold.FieldByName('enum4').Value+' ';
LabelText := GetIniMappings('enumeration','4')+' ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clBlue;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
if ((not Data.hold.FieldByName('enum5').IsNull) and (trim(Data.hold.FieldByName('enum5').Value)<>'')) then
begin
ValueText := Data.hold.FieldByName('enum5').Value+' ';
LabelText := GetIniMappings('enumeration','5')+' ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clBlue;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
if ((not Data.hold.FieldByName('enum6').IsNull) and (trim(Data.hold.FieldByName('enum6').Value)<>'')) then
begin
ValueText := Data.hold.FieldByName('enum6').Value+' ';
LabelText := GetIniMappings('enumeration','6')+' ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clBlue;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
if ((not Data.hold.FieldByName('chrono1').IsNull) and (trim(Data.hold.FieldByName('chrono1').Value)<>'')) then
begin
ValueText := Data.hold.FieldByName('chrono1').Value+' ';
LabelText := GetIniMappings('chronology','1')+' ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clBlue;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
if ((not Data.hold.FieldByName('chrono2').IsNull) and (trim(Data.hold.FieldByName('chrono2').Value)<>'')) then
begin
ValueText := Data.hold.FieldByName('chrono2').Value+' ';
LabelText := GetIniMappings('chronology','2')+' ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clBlue;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
if ((not Data.hold.FieldByName('chrono3').IsNull) and (trim(Data.hold.FieldByName('chrono3').Value)<>'')) then
begin
ValueText := Data.hold.FieldByName('chrono3').Value+' ';
LabelText := GetIniMappings('chronology','3')+' ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clBlue;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
if ((not Data.hold.FieldByName('chrono4').IsNull) and (trim(Data.hold.FieldByName('chrono4').Value)<>'')) then
begin
ValueText := Data.hold.FieldByName('chrono4').Value+' ';
LabelText := GetIniMappings('chronology','4')+' ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clBlue;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
//FIXME Add Volume info etc...
if AllText <> '' Then TntRichEdit1.SelText := #13#10;
AllText := '';
//Textual Holdings - Basic Bibliographic Unit
if not Data.hold.fieldbyname('F866').IsNull then
begin
ValueText := Data.hold.GetBlob('F866').AsWideString;
LabelText := 'Textual Holdings - Basic Bibliographic Unit ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clBlue;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
if AllText <> '' Then TntRichEdit1.SelText := #13#10;
AllText := '';
//Textual Holdings - Supplementary Material
if not Data.hold.fieldbyname('F867').IsNull then
begin
ValueText := Data.hold.GetBlob('F867').AsWideString;
LabelText := 'Textual Holdings - Supplementary Material ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clBlue;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
if AllText <> '' Then TntRichEdit1.SelText := #13#10;
AllText := '';
//Textual Holdings - Indexes
if Data.hold.fieldbyname('F868').Value <> '' then
begin
ValueText := Data.hold.GetBlob('F868').AsWideString;
LabelText := 'Textual Holdings - Indexes ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clBlue;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
if AllText <> '' Then TntRichEdit1.SelText := #13#10;
//ITEMS
ItemCount := data.Items.RecordCount;
if ItemCount > 0 Then
begin
data.Items.First;
LabelText := ' Total Items = ' + IntToStr(ItemCount);
TntRichEdit1.SelAttributes.Color := clGreen;
TntRichEdit1.SelText := LabelText+#13#10;
for i := 1 to ItemCount do
begin
AllText := '';
LabelText := ' ';
TntRichEdit1.SelText := LabelText;
ValueText := IntToStr(i)+'.';
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
//Barcode
if not IsEmptyField(Data.items, 'barcode') then
begin
LabelText := ' Barcode ';
ValueText := Data.items.fieldbyname('barcode').Value; //barcode
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clGreen;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
//Copy
if not IsEmptyField(Data.items, 'copy') then
begin
ValueText := Data.items.fieldbyname('copy').Value;
LabelText := ' Copy ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clGreen;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
// Loan category
if not IsEmptyField(data.items, 'loan_category') then
begin
ValueText:=data.lookupparam(data.loancategories,data.items.FieldByname('loan_category').AsString, '');
if ValueText='' then ValueText:=data.items.FieldByname('loan_category').AsString;
LabelText := ' Loan category ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clGreen;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
//Process status
if not IsEmptyField(data.items, 'process_status') then
begin
ValueText:=data.lookupparam(data.processstatuses,data.items.FieldByname('process_status').AsString, '');
if ValueText='' then ValueText:=data.items.FieldByname('process_status').AsString;
LabelText := ' Process status ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clGreen;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
//Date Arrived
if not IsEmptyField(Data.items, 'datearrived') then
begin
ValueText := Data.items.FieldByName('datearrived').AsString;
LabelText := ' Date Arrived ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clGreen;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
//Note opac
if not IsEmptyField(Data.items, 'note_opac') then
begin
ValueText := Data.items.fieldbyname('note_opac').Value;
LabelText := ' Note opac ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clGreen;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
//Note internal
if not IsEmptyField(Data.items, 'note_internal') then
begin
ValueText := Data.items.fieldbyname('note_internal').Value;
LabelText := ' Note internal ';
TntRichEdit1.SelAttributes.Color := clBlack;
TntRichEdit1.SelText := LabelText;
TntRichEdit1.SelAttributes.Color := clGreen;
TntRichEdit1.SelText := ValueText;
AllText := AllText + LabelText + ValueText;
end;
TntRichEdit1.SelText :=#13#10;
data.Items.Next;
end;
end;
end;
Procedure TMARCEditorform.SetHoldInRichEdit(RichEdit : TTntRichEdit);
var
NrOrd,
KLength,k1, u1, d1, holdcnt, Cnt :integer;
u,d,TexFirstCount : WideString;
begin
RichEdit.SelAttributes.Color := clBlack;
RichEdit.SelAttributes.Style := [fsBold];
RichEdit.SelAttributes.Size := 8;
NrOrd := 0;
Data.hold.First;
RichEdit.Lines.BeginUpdate;
RichEdit.Clear;
SetLength(links, 0);
holdcnt := Data.hold.RecordCount;
RichEdit.SelStart := RichEdit.GetTextLen;
//RichEdit.SelText:= #13#10;
RichEdit.SelAttributes.Color := clGreen;
RichEdit.SelAttributes.Style := [fsBold];
RichEdit.SelAttributes.Size := 10;
TexFirstCount := 'Total Holdings = '+ IntToStr(holdcnt);
RichEdit.SelText := ' '+TexFirstCount+ ' ';
while Not Data.hold.Eof do
begin
inc(NrOrd);
RichEdit.SelText:= #13#10;
cnt := length(RichEdit.Text)+1; // add one for the leading space
SetLength(links, Length(links) + 1);
KLength := length('Holding '+ inttostr(NrOrd));
links[Length(links)-1].start := cnt-RichEdit.Lines.Count;
links[Length(links)-1].len := KLength;
links[Length(links)-1].holdon := Data.hold.FieldByName('holdon').AsInteger;
links[Length(links)-1].recno := Data.hold.FieldByName('recno').AsInteger;
links[Length(links)-1].aa := Data.hold.FieldByName('aa').AsInteger;
links[Length(links)-1].name := 'open';
k1 := length(RichEdit.Text)+1; // add one for the trailing space
u:='';
d:='';
if (current_user_access >= 8) then
begin
//up
if (NrOrd >1 ) then
begin
SetLength(links, Length(links) + 1);
links[Length(links)-1].holdon := Data.hold.FieldByName('holdon').AsInteger;
links[Length(links)-1].recno := Data.hold.FieldByName('recno').AsInteger;
links[Length(links)-1].aa := Data.hold.FieldByName('aa').AsInteger;
links[Length(links)-1].name := 'up';
links[Length(links)-1].len := 4;
u:=' [UP] ';
u1:=k1+KLength+2;
links[Length(links)-1].start:=u1-RichEdit.Lines.Count;
end;
// down
if (NrOrd < holdcnt) then
begin
SetLength(links, Length(links) + 1);
links[Length(links)-1].holdon := Data.hold.FieldByName('holdon').AsInteger;
links[Length(links)-1].recno := Data.hold.FieldByName('recno').AsInteger;
links[Length(links)-1].aa := Data.hold.FieldByName('aa').AsInteger;
links[Length(links)-1].name := 'down';
links[Length(links)-1].len := 6;
d:=' [DOWN] ';
d1:=k1+KLength+2+length(u);
links[Length(links)-1].start:=d1-RichEdit.Lines.Count;
end;
end;
RichEdit.SelAttributes.Color := clBlue;
RichEdit.SelAttributes.Style := [fsBold,fsUnderline];
RichEdit.SelText :=' '+'Holding '+ inttostr(NrOrd) + ' ';
if (u <> '') then
begin
RichEdit.SelAttributes.Color := clPurple;
RichEdit.SelAttributes.Style := [fsBold,fsUnderline];
RichEdit.SelText :=u;
end;
if (d <> '') then
begin
RichEdit.SelAttributes.Color := clFuchsia;
RichEdit.SelAttributes.Style := [fsBold,fsUnderline];
RichEdit.SelText :=d;
end;
RichEdit.SelText :=#13#10;
RichEdit.SelAttributes.Color := clBlack;
RichEdit.SelAttributes.Style := [fsBold];
RichEdit.SelAttributes.Size := 8;
SetTextInRichEdit(RichEdit);
Data.hold.Next;
end;
RichEdit.SelStart := 1;
RichEdit.Lines.EndUpdate;