forked from layerfsd/Roomer-PMS-1
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuFrmHandleBookKeepingException.pas
192 lines (166 loc) · 5.33 KB
/
uFrmHandleBookKeepingException.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 uFrmHandleBookKeepingException;
interface
uses
Winapi.Windows
, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, sListBox, sButton, sRadioButton, Vcl.ExtCtrls, sPanel, sLabel, sMemo,uAppGlobal;
type
TFrmHandleBookKeepingException = class(TForm)
sLabel1: TsLabel;
sPanel1: TsPanel;
sPanel2: TsPanel;
rbRetry: TsRadioButton;
sLabel2: TsLabel;
sLabel3: TsLabel;
rbIgnore: TsRadioButton;
sButton1: TsButton;
sLabel5: TsLabel;
sButton2: TsButton;
sLabel6: TsLabel;
sButton3: TsButton;
sLabel7: TsLabel;
panBtn: TsPanel;
BtnOk: TsButton;
sLabel4: TsLabel;
sLabel8: TsLabel;
memExplanations: TsMemo;
procedure sButton1Click(Sender: TObject);
procedure sButton2Click(Sender: TObject);
procedure sButton3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure rbRetryClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
procedure ProcessExplanations;
{ Private declarations }
public
{ Public declarations }
invoiceNumber : Integer;
errors : String;
end;
var
FrmHandleBookKeepingException: TFrmHandleBookKeepingException;
procedure HandleFinanceBookKeepingExceptions(invoiceNumber : Integer; errors : String);
implementation
{$R *.dfm}
uses hData,
uG,
uRoomerLanguage,
uD,
uStringUtils,
uCustomers2,
uItems2,
uPayTypes,
uUtils, uVCLUtils;
const ERR_PRODUCT = 'PRODUCT';
ERR_CUSTOMER = 'CUSTOMER';
ERR_PAYTYPE = 'PAYTYPE';
ERR_REMOTE_EXCEPTION = 'REMOTE_EXCEPTION';
ERR_INTERNAL_EXCEPTION = 'INTERNAL_EXCEPTION';
INVOICE_ALREADY_SENT = 'INVOICE_ALREADY_SENT';
function HandleError(invoiceNumber : Integer; var errors : String) : Boolean;
begin
errors := d.roomerMainDataSet.SystemSendInvoiceToBookkeeping(invoiceNumber);
result := errors = '';
end;
procedure HandleFinanceBookKeepingExceptions(invoiceNumber : Integer; errors : String);
var
_FrmHandleBookKeepingException: TFrmHandleBookKeepingException;
begin
repeat
_FrmHandleBookKeepingException := TFrmHandleBookKeepingException.Create(nil);
try
_FrmHandleBookKeepingException.invoiceNumber := invoiceNumber;
_FrmHandleBookKeepingException.errors := errors;
_FrmHandleBookKeepingException.ShowModal;
if _FrmHandleBookKeepingException.rbIgnore.Checked OR (_FrmHandleBookKeepingException.rbRetry.Checked AND HandleError(invoiceNumber, errors)) then
Break;
finally
FreeAndNil(_FrmHandleBookKeepingException);
end;
until (False);
end;
procedure TFrmHandleBookKeepingException.FormCreate(Sender: TObject);
begin
RoomerLanguage.TranslateThisForm(self);
glb.PerformAuthenticationAssertion(self); PlaceFormOnVisibleMonitor(self);
end;
procedure TFrmHandleBookKeepingException.sButton1Click(Sender: TObject);
var
theData: recCustomerHolder;
begin
openCustomers(actNone, false, theData);
end;
procedure TFrmHandleBookKeepingException.sButton2Click(Sender: TObject);
var
theData: recItemHolder;
begin
OpenItems(actNone, false, theData);
end;
procedure TFrmHandleBookKeepingException.sButton3Click(Sender: TObject);
var
theData: recPayTypeHolder;
begin
payType(actNone, false, theData);
end;
procedure TFrmHandleBookKeepingException.FormShow(Sender: TObject);
begin
SetCloseButtonEnabled(self, false);
ProcessExplanations;
end;
procedure TFrmHandleBookKeepingException.ProcessExplanations;
var list, parts : TStrings;
i : Integer;
ErrorType,
ErrorDescription,
ErrorSystemName,
ErrorCode : String;
Msg : String;
begin
memExplanations.Lines.Clear;
list := SplitStringToTStrings(#13#10, errors);
try
for i := 0 to list.count - 1 do
begin
parts := SplitStringToTStrings(',', list[i]);
try
ErrorType := parts[0];
ErrorDescription := parts[1];
ErrorSystemName := parts[2];
ErrorCode := parts[3];
if (ErrorType = ERR_CUSTOMER) OR
(ErrorType = ERR_PRODUCT) OR
(ErrorType = ERR_PAYTYPE)
then
Msg := format('%s ''%s'' was not found in ''%s''.' + #13#10 + 'Please either correct in Roomer or create the missing code in ''%s''.',
[ErrorType, ErrorCode, ErrorSystemName, ErrorSystemName])
else
if ErrorType = ERR_REMOTE_EXCEPTION then
Msg := format('Remote system ''%s'' answered with an error: ''%s''.' + #13#10 + 'Please contact the support agent of the remote system.',
[ErrorSystemName, ErrorDescription])
else
if ErrorType = ERR_INTERNAL_EXCEPTION then
Msg := format('Roomer system gave an error: ''%s''.' + #13#10 + 'Please contact our support department and tell them about this error.',
[ErrorDescription])
else
if ErrorType = INVOICE_ALREADY_SENT then
begin
Msg := format('Roomer system said: ''%s''.' + #13#10 + '.',
[ErrorDescription]);
rbIgnore.Checked := True;
btnOK.Enabled := True;
end;
finally
parts.Free;
end;
memExplanations.Lines.Add(Msg + #13#10);
end;
finally
list.Free;
end;
end;
procedure TFrmHandleBookKeepingException.rbRetryClick(Sender: TObject);
begin
btnOK.Enabled := True;
end;
end.