Откорректировать отчеты на fastReport написанные на PasсalScript
Const NoForm = 0;
ReportFileName='этикетки A4.fp3';
Var CurForm, TJ, i, j , k:integer;
PType:String;
CurNo:integer;
CurCQ,CurCel,CurRCel,CurPanes,CurArmL,CurID,CurFO,CurArmN:string;
CurAngles:string;
BO:String;
FileName, SInfo, SDim : string;
LastCID:integer;
Item : TXmlItem;
IDIM,CurPosRem,CurBarCode:string;
B:boolean;
MS : TMemoryStream;
Function FindPosInCalc(CID:integer; ID, FS : string; K : integer) : boolean;
Var i:integer;
begin
result := false;
constructions_calculationU_opt.first;
while not constructions_calculationU_opt.eof do
begin
if constructions_calculationU_opt['CID'].asinteger = CID then
if (constructions_calculationU_opt['MAT_TYPE'].asinteger = K) OR (K = 0) then
if constructions_calculationU_opt['VALUE'].asfloat * constructions_calculationU_opt['QTY'].asfloat > 0 then
if (pos(AnsiUpperCase(FS),AnsiUppercase(constructions_calculationU_opt['Name'].asstring))>0) or (FS='') then
if (pos(AnsiUpperCase(ID),AnsiUppercase(constructions_calculationU_opt['IDS'].asstring))>0) or (ID='') then
begin
result := true;
break;
end;
constructions_calculationU_opt.next;
end;
end;
Procedure UpdateSInfo(BT:string);
Var j:integer;
begin
SInfo:='';
SDim:='';
if BT='1' then SInfo:='лево';
if BT='2' then SInfo:='верх';
if BT='3' then SInfo:='право';
if BT='4' then SInfo:='низ';
if profiles_table['nos'].asinteger <> 0 then
begin
for j:=0 to CurrInfo.Root.NamedItem['Stvorki'].Count-1 do
if profiles_table['nos'].asstring = CurrInfo.Root.NamedItem['Stvorki'][j].NamedItem['NOS'].asstring then
SDim := CurrInfo.Root.NamedItem['Stvorki'][j].NamedItem['ШСФ'].asstring+'x'+CurrInfo.Root.NamedItem['Stvorki'][j].NamedItem['ВСФ'].asstring+#13;
if profiles_table['Shtulp'].asinteger=1 then // помечаем штульповую створку
begin
if BT='1' then
if profiles_table['TP'].asinteger=2 then SInfo:=SInfo+' штульп';
if BT='3' then
if profiles_table['TP'].asinteger=1 then SInfo:=SInfo+' штульп';
end else
begin
if BT='2' then
if profiles_table['TP'].asinteger=4 then SInfo:=SInfo+' ручка';
if BT='4' then
if profiles_table['TP'].asinteger=4 then SInfo:=SInfo+' петли';
if BT='1' then
if (profiles_table['TP'].asinteger=2)or(profiles_table['TP'].asinteger=10) then SInfo:=SInfo+' ручка';
if BT='3' then
if (profiles_table['TP'].asinteger=1)or(profiles_table['TP'].asinteger=9) then SInfo:=SInfo+' ручка';
end;
if BT='1' then
if (profiles_table['TP'].asinteger=1)or(profiles_table['TP'].asinteger=9) then SInfo:=SInfo+' петли';
if BT='3' then
if (profiles_table['TP'].asinteger=2)or(profiles_table['TP'].asinteger=10) then SInfo:=SInfo+' петли';
end else
begin
if FindPosInCalc(constructions_table['ID'].asinteger,'','штульп',1000) then
SInfo:=SInfo+' штульп';
end;
end;
function GetQtyValues(qty:integer; SL:TECXMLParser; FN:string; SD : boolean = true; DS : string = ',' ):string;
Var s:string;
o:integer;
begin
result:='';
for o := 1 to qty do
begin
s := SL.Root.NamedItem[FN].NamedItem[profiles_table['ID'].asstring].asstring;
if s = '' then s := profiles_table[FN].asstring;
result := AddStrValue(result, copy(s,1,pos(DS, s + DS)-1), DS);
delete(s, 1, pos(DS, s + DS) + 1);
if SD then SL.Root.NamedItem[FN].NamedItem[profiles_table['ID'].asstring].asstring := s;
end;
end;
procedure MasterDataOPTOnBeforePrint(Sender: TfrxComponent);
Var i,j,k:integer;
PType:string;
begin
VX5.Root.Clear;
Item := OPT.Root.NamedItem['OptData'][VT1_Table['I'].asinteger];
goods_table.locate('ID', Item.NamedItem['ID'].asinteger, loCaseInsensitive);
VX2.Root.Clear;
if goods_table['OptIndRec'].asstring <> '' then
begin
profiles_table.first;
while not profiles_table.eof do
begin
if profiles_table['GID'].asinteger = goods_table['ID'].asinteger then
VX2.Root.NamedItem[profiles_table['CID'].asstring].New.LoadrecordFromDataSet(profiles_table.dataset);
profiles_table.next;
end;
for i := 0 to VX2.Root.Count - 1 do
begin
ExecQueryO('delete from constructions_user_data where constructions_id = ' + VX2.Root[i].Name + ' and i = ' + goods_table['ID'].asstring);
VX3.Root.Clear;
VX3.Root.AddFrom(VX2.Root[i]);
try
MS := TmemoryStream.Create;
iwqo_table.dataset.close;
iwqo_table.dataset.commandtext := 'insert into constructions_user_data (constructions_id, i, b) values (:constructions_id, :i, :b)';
iwqo_table.dataset.params.parambyname('constructions_id').asstring := VX2.Root[i].Name;
iwqo_table.dataset.params.parambyname('i').asstring := goods_table['id'].asstring;
VX3.SaveToStreamCompressed(MS);
MS.Position := 0;
iwqo_table.dataset.params.parambyname('b').LoadFromStream(MS);
iwqo_table.dataset.execquery;
finally
MS.free;
end;
VX3.Root.Clear;
end;
end;
FileName := DefaultPartDir + PartName + '-' + ReportFileName + '_' + goods_table['mat_name'].asstring + '.fp3';
CurForm := goods_table['OptLN'].asinteger mod 100;
VX2.Root.Clear;
for i := 0 to Item.NamedItem['BARS'].count - 1 do
begin
for j := 0 to Item.NamedItem['BARS'][i].NamedItem['CUTS'].count - 1 do
for k:= 1 to Item.NamedItem['BARS'][i].NamedItem['QTY'].asinteger do
begin
profiles_table.locate('ID', Item.NamedItem['BARS'][i].NamedItem['CUTS'][j].NamedItem['ID'].asinteger, loCaseInsensitive);
PType := GetQtyValues(1, VX5, 'TYPES');
with VX2.Root.New do
begin
NamedItem['ID'].asinteger := profiles_table['ID'].asinteger;
NamedItem['BARID'].asinteger := i;
NamedItem['CUTID'].asinteger := j;
end;
if PType = '1' then //Лево
if (CurForm div 10 = 1) or (CurForm div 10 = 3) then
with VX2.Root.New do
begin
NamedItem['ID'].asinteger := -3;
end;
if PType = '3' then //Право
if (CurForm div 10 = 2)or(CurForm div 10 = 3) then
with VX2.Root.New do
begin
NamedItem['ID'].asinteger := -3;
end;
end;
if Item.NamedItem['BARS'][i].NamedItem['RecLength1'].asinteger > 0 then
for k:= 1 to Item.NamedItem['BARS'][i].NamedItem['QTY'].asinteger do
with VX2.Root.New do
begin
NamedItem['ID'].asinteger := -1;
NamedItem['BARID'].asinteger := i;
end;
if Item.NamedItem['BARS'][i].NamedItem['RecLength2'].asinteger > 0 then
for k := 1 to Item.NamedItem['BARS'].SubItems[i].NamedItem['QTY'].asinteger do
with VX2.Root.New do
begin
NamedItem['ID'].asinteger := -2;
NamedItem['BARID'].asinteger := i;
end;
end;
VX2.Root.StoreToDataSet(VT2_Table.DataSet);
VX5.Root.clear;
end;
Procedure UpdatebarInfo;
begin
if <VT2_Table."ID"> < 0 then exit;
profiles_table.locate('ID', VT2_Table['ID'].asinteger, loCaseInsensitive);
goods_table.locate('ID', profiles_table['GID'].asinteger, loCaseInsensitive);
offers_table.locate('ID', profiles_table.dataset['OID'].asinteger, loCaseInsensitive);
constructions_table.locate('ID', profiles_table['CID'].asinteger, loCaseInsensitive);
utypes_table.locate('ID', constructions_table['UTypeID'].asinteger, loCaseInsensitive);
furnsys_table.locate('ID', constructions_table['FSID'].asinteger, loCaseInsensitive);
profsys_table.locate('ID', constructions_table['PSID'].asinteger, loCaseInsensitive);
LoadCurrOffer;
LoadCurrInfo;
PType := GetQtyValues(1, VX5, 'TYPES');
CurID := GetQtyValues(1, VX5, 'IDS');
CurCel := GetQtyValues(1, VX5, 'CELLS');
CurRCel := GetQtyValues(1, VX5, 'RCELLS');
CurFO := GetQtyValues(1, VX5, 'FOPTIONS', true, '/');
CurCQ := GetQtyValues(1, VX5, 'NUMCONSTRS');
LoadIDImageToIMG(CurID);
CurPanes := VX6.Root.NamedItem[constructions_table['ID'].asstring +'_' + CurCQ].asstring;
CurPanes := StrReplace(',', ', ', CurPanes);
CurArmL:='';
CurArmN:='';
if FindPosInCalc(constructions_table['ID'].asinteger,CurID,'сталь',0) then
begin
CurArmN := constructions_calculationU_opt['NAME'].asstring;
if constructions_calculationU_opt['MAT_TYPE'].asfloat = 1000 then
CurArmL:=formatfloat('0', constructions_calculationU_opt['VALUE'].asfloat)
else CurArmL := constructions_calculationU_opt['NAME'].asstring;
end;
UpdateSInfo(PType);
goods_table.dataset.locate('ID',OPT.Root.NamedItem['OptData'].SubItems[<VT1_Table."I">].NamedItem['ID'].asinteger,loCaseInsensitive);
PTYPE:=StrReplace('1','ЛВ',PTYPE);
PTYPE:=StrReplace('2','ВХ',PTYPE);
PTYPE:=StrReplace('3','ПР',PTYPE);
PTYPE:=StrReplace('4','НЗ',PTYPE);
BO:=OPT.Root.NamedItem['OptData'].SubItems[<VT1_Table."I">].NamedItem['BARS'].SubItems[<VT2_Table."BARID">].NamedItem['LENGTH'].asstring;
if <VT2_Table."CUTID">>0 then BO:='';
profiles_table.dataset.locate('ID',<VT2_Table."ID">,locaseinsensitive);
CurBarCode := '';
if CurCQ <> '' then
begin
CurBarCode := IdToBarCode( CurId, StrToInt(CurCQ) );
CurBarCode := '6'+IntTo26z(constructions_table['ID'].asinteger,1) + IntTo26z(profiles_table['NOR'].asinteger,1) + IntTo26z(strtoint(CurCQ),2);
end;
CurPosRem:='';
if (constructions_table['QQ'].asinteger<>constructions_table['Q'].asinteger) then
CurPosRem:='-'+inttostr(profiles_table['NOR'].asinteger);
IDIM:='';
if profiles_table['NOS'].asinteger=0 then
for i:=0 to CurrInfo.Root.NamedItem['IMPOSTS'].Count-1 do
if pos(CurID,CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['IDS'].asstring)>0 then
for j:=0 to CurrInfo.Root.NamedItem['CONSTRS'].Count-1 do
if CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['NOR'].asinteger=CurrInfo.Root.NamedItem['CONSTRS'][j].NamedItem['NOR'].asinteger then
begin
IDIM:='-';
TJ:=J;
if CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['X1'].asfloat=CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['X2'].asfloat then
IDIM:=#13+floattostr(CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['X1'].asfloat-CurrInfo.Root.NamedItem['CONSTRS'][TJ].NamedItem['X1'].asfloat)+'::'+floattostr(CurrInfo.Root.NamedItem['CONSTRS'][TJ].NamedItem['X2'].asfloat-CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['X1'].asfloat);
if CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['Y1'].asfloat=CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['Y2'].asfloat then
IDIM:=#13+floattostr(CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['Y1'].asfloat-CurrInfo.Root.NamedItem['CONSTRS'][TJ].NamedItem['Y1'].asfloat)+'::'+floattostr(CurrInfo.Root.NamedItem['CONSTRS'][TJ].NamedItem['Y2'].asfloat-CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['Y1'].asfloat);
end;
if profiles_table['NOS'].asinteger > 0 then
for i:=0 to CurrInfo.Root.NamedItem['IMPOSTS'].Count-1 do
if pos(CurID,CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['IDS'].asstring)>0 then
for j:=0 to CurrInfo.Root.NamedItem['STVORKI'].Count-1 do
if CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['NOS'].asinteger=CurrInfo.Root.NamedItem['STVORKI'][j].NamedItem['NOS'].asinteger then
begin
IDIM:='-';
TJ:=J;
if CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['X1'].asfloat=CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['X2'].asfloat then
IDIM:=#13+floattostr(CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['X1'].asfloat-CurrInfo.Root.NamedItem['STVORKI'][TJ].NamedItem['X1'].asfloat)+'::'+floattostr(CurrInfo.Root.NamedItem['STVORKI'][TJ].NamedItem['X2'].asfloat-CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['X1'].asfloat);
if CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['Y1'].asfloat=CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['Y2'].asfloat then
IDIM:=#13+floattostr(CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['Y1'].asfloat-CurrInfo.Root.NamedItem['STVORKI'][TJ].NamedItem['Y1'].asfloat)+'::'+floattostr(CurrInfo.Root.NamedItem['STVORKI'][TJ].NamedItem['Y2'].asfloat-CurrInfo.Root.NamedItem['IMPOSTS'][i].NamedItem['Y1'].asfloat);
end;
end;
procedure AutoCalcHeigth(MemoAS:TfrxMemoView);
Var i:integer;
begin
MemoAS.Font.Size:=1;
while MemoAS.CalcHeight<=MemoAS.Height-MemoAS.GapY*2 do
MemoAS.Font.Size:=MemoAS.Font.Size+1;
MemoAS.Font.Size:=MemoAS.Font.Size-1;
// MemoAS.Font.Size=MemoAS.Tag;
// if MemoAS.CalcHeight>MemoAS.Height-MemoAS.GapY*2 then
// MemoAS.Font.Size:=Round(MemoAS.Font.Size*((MemoAS.height-MemoAS.GapY*2)/MemoAS.CalcHeight))+0;
end;
procedure MasterDataLBOnBeforePrint(Sender: TfrxComponent);
begin
DetailDataCut1.Visible:=(<VT2_Table."ID">>0) and (CurForm mod 10 = 1);
DetailDataCut2.Visible:=(<VT2_Table."ID">>0) and (CurForm mod 10 = 2);
DetailDataCut3.Visible:=(<VT2_Table."ID">>0) and (CurForm mod 10 = 3);
DetailDataCut4.Visible:=(<VT2_Table."ID">>0) and (CurForm mod 10 = 4);
DetailDataCut5.Visible:=(<VT2_Table."ID">>0) and (CurForm mod 10 = 5);
DetailDataRec.Visible:=(<VT2_Table."ID"> = -1) or (<VT2_Table."ID"> = -2);
DetailDataOffer.Visible:=(<VT2_Table."ID"> = -3);
UpdateBarInfo;
end;
procedure MemoASOnAfterData(Sender: TfrxComponent);
begin
AutoCalcHeigth(TfrxMemoView(Sender));
end;
begin
VX1.Root.Clear;
for i := 0 to OPT.Root.NamedItem['OptData'].Count - 1 do
begin
goods_table.locate('ID', OPT.Root.NamedItem['OptData'][i].NamedItem['ID'].asinteger, loCaseInsensitive);
if goods_table['OptLN'].asinteger div 100 = NoForm then
if goods_table['OptLN'].asinteger mod 10 in [1,2,3,4,5] then
begin
if OPT.Root.NamedItem['OptData'][i].NamedItem['BARS'].Count > 0 then
VX1.Root.New.NamedItem['I'].asinteger:=i;
end;
end;
Page1.visible := VX1.Root.Count > 0;
if not Page1.visible then exit;
VX1.Root.StoreToDataSet(VT1_Table.DataSet);
VX6.Root.Clear;
CurNo:=0;
panes_table.first;
while not panes_table.eof do
begin
offers_table.locate('ID',panes_table['OID'].asinteger, loCaseInsensitive);
constructions_table.locate('ID',panes_table['CID'].asinteger, loCaseInsensitive);
j:=0;
for i := 1 to panes_table['Q'].asinteger do
begin
inc(j);
inc(CurNo);
if j > constructions_table['Q'].asinteger then j := 1;
VX6.Root.NamedItem[ inttostr(constructions_table['ID'].asinteger) + '_' + inttostr(j)].asstring := AddStrValue( VX6.Root.NamedItem[ inttostr(constructions_table['ID'].asinteger) + '_' + inttostr(j)].asstring, inttostr(CurNo), ',');
end;
panes_table.next;
end;
AddReportFileToSave('', DefaultPartDir + PartName +'-' + ReportFileName, true, true);
end.