-
Notifications
You must be signed in to change notification settings - Fork 2
/
EditDigitalObject.pas
executable file
·192 lines (168 loc) · 5.45 KB
/
EditDigitalObject.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
unit EditDigitalObject;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
DateUtils, Dialogs, TntDialogs, TntForms, Dropper, StdCtrls, TntStdCtrls, ExtCtrls, TntExtCtrls,
DB, DataUnit, Mask, DBCtrls, TntDBCtrls, Buttons, TntButtons, ShellApi,
utility, common, GlobalProcedures, mainunit;
type
TEditDigital = class(TTntForm)
TntLabel1: TTntLabel;
FileDropper1: TFileDropper;
TntDBEdit1: TTntDBEdit;
TntDBMemo1: TTntDBMemo;
TntLabel2: TTntLabel;
TntLabel3: TTntLabel;
TntLabel4: TTntLabel;
TntDBMemo2: TTntDBMemo;
TntDBMemo3: TTntDBMemo;
OK: TTntBitBtn;
Cancel: TTntBitBtn;
DeleteBtn: TTntBitBtn;
TntBitBtn1: TTntBitBtn;
TntBitBtn2: TTntBitBtn;
procedure FileDropper1Drop(Sender: TObject; Filename: String);
procedure TntFormActivate(Sender: TObject);
procedure OKClick(Sender: TObject);
procedure DeleteBtnClick(Sender: TObject);
procedure TntFormClose(Sender: TObject; var Action: TCloseAction);
procedure TntBitBtn1Click(Sender: TObject);
procedure SaveDigital;
procedure TntBitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
prefix, origfilename, finalfilename : string;
over : boolean;
modifiedflag : boolean;
{ Public declarations }
end;
var
EditDigital: TEditDigital;
implementation
uses zoomit, MARCEditor;
{$R *.DFM}
procedure TEditDigital.FileDropper1Drop(Sender: TObject; Filename: String);
var s: string;
res : integer;
begin
s:=extractfilename(filename);
over:=true;
if filename <> prefix+s then
begin
if fileexists(prefix+s) then
begin
res := WideMessageDlg('Overwrite existing file?', mtConfirmation, [mbYes, mbNo], 0);
if res = mrYes then over:=true
else over:=false;
end;
tntdbedit1.Text:=s;
finalfilename:=filename;
end;
end;
procedure TEditDigital.TntFormActivate(Sender: TObject);
begin
over := true;
origfilename:=tntdbedit1.Text;
prefix:='C:\';
prefix:=trim(DO_Windows_storage_location);
prefix:=maprecno2dir(prefix,data.digital.fieldbyname('recno').asinteger, 3, true);
if prefix[length(prefix)] <> '\' then prefix:=prefix+'\';
modifiedflag := false;
end;
procedure TEditDigital.OKClick(Sender: TObject);
var s : string;
begin
if trim(tntdbedit1.Text) = '' then
begin
wideshowmessage('Please specify a valid file');
Modalresult:=mrNone;
modifiedflag:=false;
exit;
end;
s:= prefix + trim(tntdbedit1.Text);
if origfilename <> '' then
if fileexists(prefix+origfilename) then
DeleteFile(prefix+origfilename);
CopyFile(Pchar(finalfilename), Pchar(s), over);
modifiedflag:=true;
end;
procedure TEditDigital.DeleteBtnClick(Sender: TObject);
var res: integer;
begin
if not data.digital.IsEmpty then
begin
res := WideMessageDlg('Do you want to delete this digital object from the database?',
mtConfirmation, [mbYes, mbNo], 0);
if res = mrYes then
begin
if fileexists(prefix+origfilename) then
DeleteFile(prefix+origfilename);
append_move(UserCode, 83,today, CurrentUserName + ' deleted D.O. '+prefix+origfilename+' for recno=' +
Data.SecureBasket.FieldByName('recno').AsString);
data.digital.delete;
modifiedflag := true;
ModalResult:=mrOK;
end;
end;
end;
procedure TEditDigital.SaveDigital;
var rec : UTF8String;
begin
if data.digital.State = dsInsert
Then append_move(UserCode, 80,today, CurrentUserName + ' added a new D.O. for recno=' +
Data.SecureBasket.FieldByName('recno').AsString)
Else append_move(UserCode, 81,today, CurrentUserName + ' changed the D.O. for recno=' +
Data.SecureBasket.FieldByName('recno').AsString);
PostTable(data.digital);
with Data.SecureBasket do
begin
EditTable(data.SecureBasket);
disp2mrc(MarcEditorForm.full.Lines, rec);
Refresh084(FieldByName('recno').AsInteger, rec);
Refresh856(FieldByName('recno').AsInteger,DO_BaseURL, rec);
GetBlob('text').AsWideString := StringToWideString(rec, Greek_codepage);
TBlobField(FieldByName('text')).Modified := True;
MarcEditorForm.full.Lines.Clear;
marcrecord2memo(rec, MarcEditorForm.full);
MARCEditorform.SaveData;
end;
close;
end;
procedure TEditDigital.TntFormClose(Sender: TObject;
var Action: TCloseAction);
//var recnr : integer;
begin
case ModalResult of
mrOK: if modifiedflag then
begin
SaveDigital;
//recnr := Data.Securebasket.FieldByName('recno').AsInteger;
//RecordUpdated(myzebrahost, 'update', recnr, MakeMRCFromSecureBasket(recnr));
end;
mrCancel: CancelTable(data.digital);
end;
end;
procedure TEditDigital.TntBitBtn1Click(Sender: TObject);
var s : Widestring;
x : Widestring;
n : integer;
begin
if tntdbedit1.Text <> '' then
begin
s:=prefix+tntdbedit1.Text;
ShellExecuteW(handle,'Open', PWideChar(s), NiL, NiL, SW_SHOWNORMAL);
x:=copy(prefix,length(DO_Windows_storage_location)+1,length(prefix));
for n := 1 to length(x) do
if x[n]='\' then x[n]:='/';
x:=DO_BaseURL+x+URLEncode(tntdbedit1.Text,false);
// showmessage(x);
end;
end;
procedure TEditDigital.TntBitBtn2Click(Sender: TObject);
var s : widestring;
begin
s:='c:\';
ShellExecuteW(handle,'Open', PWideChar(s) , NiL, NiL, SW_SHOWNORMAL);
end;
end.