procedure
TfrmCardsIn
.
NewInvoiceIn;
var
mR :
integer
;
begin
SetEnebledControl(ATYPE);
DM
.
tblInvoiceIn
.
Append;
DM
.
tblInvoiceIn[
'TYPE'
] := ATYPE;
case
ATYPE
of
0
:
begin
DM
.
tblInvoiceIn[
'XDSTID'
]:=
'99999'
;
DM
.
tblInvoiceIn[
'XSRCID'
]:=
'0'
;
DM
.
tblInvoiceIn
.
FieldByName(
'GUID'
).Value := DM
.
tblInvoiceMax
.
FieldByName(
'AMAX'
).AsInteger +
1
;
DM
.
tblInvoiceIn
.
FieldByName(
'SERIES'
).Value := DM
.
tblMaxNumber
.
FieldByName(
'SERIES'
).AsString ;
DM
.
tblInvoiceIn
.
FieldByName(
'ANUMBER1'
).Value := DM
.
tblMaxNumber
.
FieldByName(
'ANUMBER'
).AsInteger +
1
;
DM
.
tblInvoiceIn
.
FieldByName(
'ANUMBER2'
).Value := DM
.
tblMaxNumber
.
FieldByName(
'ANUMBER'
).AsInteger +
1
;
DM
.
tblInvoiceIn
.
FieldByName(
'ADATE'
).Value := StrToDate(DM
.
ConfigParams
.
FindParam(
'WorkDate'
).Value);
DM
.
tblInvoiceIn
.
FieldByName(
'DSTAMOUNT'
).Value :=
0
;
DM
.
tblInvoiceIn
.
FieldByName(
'SRCAMOUNT'
).Value :=
0
;
end
;
1
:
begin
DM
.
tblInvoiceIn[
'XDSTID'
]:=
'0'
;
DM
.
tblInvoiceIn[
'XSRCID'
]:=
'0'
;
DM
.
tblInvoiceIn
.
FieldByName(
'GUID'
).Value := DM
.
tblInvoiceMax
.
FieldByName(
'AMAX'
).AsInteger +
1
;
DM
.
tblInvoiceIn
.
FieldByName(
'SERIES'
).Value := DM
.
tblMaxNumber
.
FieldByName(
'SERIES'
).AsString ;
DM
.
tblInvoiceIn
.
FieldByName(
'ANUMBER1'
).Value := DM
.
tblMaxNumber
.
FieldByName(
'ANUMBER'
).AsInteger +
1
;
DM
.
tblInvoiceIn
.
FieldByName(
'ANUMBER2'
).Value := DM
.
tblMaxNumber
.
FieldByName(
'ANUMBER'
).AsInteger +
1
;
DM
.
tblInvoiceIn
.
FieldByName(
'ADATE'
).Value := StrToDate(DM
.
ConfigParams
.
FindParam(
'WorkDate'
).Value);
DM
.
tblInvoiceIn
.
FieldByName(
'DSTAMOUNT'
).Value :=
0
;
DM
.
tblInvoiceIn
.
FieldByName(
'SRCAMOUNT'
).Value :=
0
;
DM
.
tblMinNumber
.
Parameters
.
ParamByName(
'@SELFDIRID'
).Value := DM
.
tblInvoiceIn
.
FieldByName(
'XDSTID'
).AsString;
DM
.
tblMinNumber
.
Open;
DM
.
tblInvoiceIn
.
FieldByName(
'SERIES'
).AsString := DM
.
tblMinNumber
.
FieldByName(
'SERIES'
).AsString;
DM
.
tblInvoiceIn
.
FieldByName(
'ANUMBER1'
).AsInteger := DM
.
tblMinNumber
.
FieldByName(
'ANUMBER'
).AsInteger;
DM
.
tblInvoiceIn
.
FieldByName(
'ANUMBER2'
).AsInteger := DM
.
tblMinNumber
.
FieldByName(
'ANUMBER'
).AsInteger;
DM
.
tblMinNumber
.
Close
end
;
2
:
begin
DM
.
tblInvoiceIn[
'XDSTID'
]:=
'0'
;
DM
.
tblInvoiceIn[
'XSRCID'
]:=
'99999'
;
DM
.
tblInvoiceIn
.
FieldByName(
'GUID'
).Value := DM
.
tblInvoiceMax
.
FieldByName(
'AMAX'
).AsInteger +
1
;
DM
.
tblInvoiceIn
.
FieldByName(
'SERIES'
).Value := DM
.
tblMaxNumber
.
FieldByName(
'SERIES'
).AsString ;
DM
.
tblInvoiceIn
.
FieldByName(
'ANUMBER1'
).Value :=
0
;
DM
.
tblInvoiceIn
.
FieldByName(
'ANUMBER2'
).Value :=
0
;
DM
.
tblInvoiceIn
.
FieldByName(
'ADATE'
).Value := StrToDate(DM
.
ConfigParams
.
FindParam(
'WorkDate'
).Value);
DM
.
tblInvoiceIn
.
FieldByName(
'DSTAMOUNT'
).Value :=
0
;
DM
.
tblInvoiceIn
.
FieldByName(
'SRCAMOUNT'
).Value :=
0
;
end
;
3
:
begin
DM
.
tblInvoiceIn[
'XDSTID'
]:=
'0'
;
DM
.
tblInvoiceIn[
'XSRCID'
]:=
'99999'
;
DM
.
tblInvoiceIn
.
FieldByName(
'GUID'
).Value := DM
.
tblInvoiceMax
.
FieldByName(
'AMAX'
).AsInteger +
1
;
DM
.
tblInvoiceIn
.
FieldByName(
'SERIES'
).Value := DM
.
tblMaxNumber
.
FieldByName(
'SERIES'
).AsString ;
DM
.
tblInvoiceIn
.
FieldByName(
'ANUMBER1'
).Value :=
0
;
DM
.
tblInvoiceIn
.
FieldByName(
'ANUMBER2'
).Value :=
0
;
DM
.
tblInvoiceIn
.
FieldByName(
'ADATE'
).Value := StrToDate(DM
.
ConfigParams
.
FindParam(
'WorkDate'
).Value);
DM
.
tblInvoiceIn
.
FieldByName(
'DSTAMOUNT'
).Value :=
0
;
DM
.
tblInvoiceIn
.
FieldByName(
'SRCAMOUNT'
).Value :=
0
;
end
;
end
;
Mr := frmEditCard
.
ShowModal;
if
mR = mrOK
then
begin
try
DM
.
tblInvoiceIn
.
Post;
case
ATYPE
of
0
: DM
.
qryInvoiceIn
.
Requery;
1
: DM
.
qryInvoiceReplace
.
Requery;
2
: DM
.
qryInvoiceRemove
.
Requery;
3
: DM
.
qryInvoiceSpoil
.
Requery;
end
;
dsCards
.
DataSet
.
Locate(
'GUID'
,DM
.
tblInvoiceIn[
'GUID'
],[])
except
on
E: Exception
do
begin
ShowMessage(E
.
Message);
DM
.
tblInvoiceIn
.
Cancel
end
end
;
end
else
DM
.
tblInvoiceIn
.
Cancel
end
;