Код: Выделить всё
interface dinam_cen_realizVip '' EscClose;
form dinam_cen_realizp ('Динамика цен реализации') with novisual;
var
co: comp;
fpco_name: string;
itog_k: double;
itog_s: double;
orgmarker: longint;
datn,datk :date;
fpco_nrec: comp;
orgnames: string;
mid: longint;
kat_name1,naim1,tip1 : string;
price1, kolfakt1,sum1 : double;
function OrgCount: string;
var
cnt: integer;
begin
cnt:= 0;
cnt:= GetMarkerCount(orgmarker);
case cnt of
1: OrgCount:= '1 организация';
2,3,4: OrgCount:= cnt+' организации';
else
OrgCount:= cnt+' организаций';
end;
end;
table struct tmain
(
kat_name : string,
naim :string,
tip :string,
price :double,
kolfakt :double,
sum :double
)
with index
(
i0 = kat_name
);
create view vmain
as where
(( '201' /== katsopr.vidsopr
and datn <<= katsopr.dsopr
and datk >>= katsopr.dsopr
and katsopr.cotvpodr/==fpco.nrec
and '1109' /== ttndoc.wtable
and katsopr.nrec /== ttndoc.cdoc
and ttndoc.cshipment /== shipment.nrec
and katsopr.cnazna /== katnazna.nrec
and katsopr.nrec /==spsopr.csopr
and katsopr.corg /==katorg.nrec
and spsopr.CMCUSL /==katmc.nrec
and katmc.CGROUPMC /==GROUPMC.nrec
and (if(fpco_nrec<>0h, fpco_nrec, fpco.nrec) = fpco.nrec)))
and if(searchmarker(orgmarker, katsopr.corg, mid), 1, 0)=1
and upcase(katnazna.name)= upcase(shipment.name) ;
create view vdop
as from tmain (memory)
order by kat_name,naim,tip;
create view vfpco
as where ((co /== fpco.nrec));
screen smain; // видимая область экрана с элементами управления
show at ();
fields
datn:pickbutton,noprotect; //описание кнопок
datk:pickbutton,noprotect;
fpco_name:pickbutton,protect;
orgnames:pickbutton,protect;
buttons
cmprint;
<<
Начальная дата: .@@@@@@@@@@
Конечная дата : .@@@@@@@@@@
Центр ответственности .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Контрагенты .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
<. Отчет .>
>>
end;
handleevent
cmpick:
{
if curfield = #orgnames
{
runinterface('orgmark', orgmarker);
set OrgNames:= OrgCount;
}
if curfield = #fpco_name
if runinterface('getco', 1, 0, 0, co)=cmdefault
{
fpco_nrec:= co;
if vfpco.getfirst fpco=tsok
fpco_name:= vfpco.fpco.name;
}
}
cmInit:
{
datn:= cur_date;
datk:= cur_date;
co:= 0h;
fpco_nrec:= 0h;
set fpco_name:= 'Комбинат';
orgmarker:= initmarker('orgmarker',8,0,1);
}
cmDelOnProtect:
{
if curfield=#fpco_name
{
co:= 0h;
fpco_nrec:= 0h;
set fpco_name:= 'Комбинат';
}
}
cmPrint:
{
//setorder (tiorg);
vdop.delete all tmain;
if vmain.getfirst katsopr=tsok
vmain._loop katsopr
{
vdop.insert into tmain set
kat_name := vmain.katorg.name,
naim := vmain.katmc.name,
tip := if (vmain.GROUPMC.kod=4302,'Тара','Навал'),
price := vmain.spsopr.price,
kolfakt := vmain.spsopr.KOLFACT,
sum := vmain.spsopr.price*vmain.spsopr.KOLFACT;
}
dinam_cen_realizP.reinit;
dinam_cen_realizP.write('По центру ответственности - ' + fpco_name);
dinam_cen_realizP.write(datn);
dinam_cen_realizP.write(datk);
itog_k:=0;
itog_s:=0;
kat_name1:='-';
sum1:=0;
kolfakt1:=0;
if vdop.getfirst tmain=tsok
vdop._loop tmain
{
if ((kat_name1=vdop.kat_name) and (naim1=vdop.naim) and (trunc(price1,2)=trunc(vdop.price,2)) and (tip1=vdop.tip))
{
kolfakt1:=vdop.kolfakt+kolfakt1;
sum1:=sum1+vdop.sum;
}
else
{
if (kat_name1<>'-')
{
dinam_cen_realizP.write(kat_name1);
dinam_cen_realizP.write(naim1);
dinam_cen_realizP.write(tip1);
dinam_cen_realizP.write(price1);
dinam_cen_realizP.write(KOLFAkT1);
dinam_cen_realizP.write(sum1);
}
itog_k:=itog_k+KOLFAkT1;
itog_s:=itog_s+sum1;
kat_name1:=vdop.kat_name;
naim1:=vdop.naim;
tip1:=vdop.tip;
price1:=vdop.price;
kolfakt1:=vdop.kolfakt;
sum1:=vdop.sum;
}
}
dinam_cen_realizP.write(kat_name1);
dinam_cen_realizP.write(naim1);
dinam_cen_realizP.write(tip1);
dinam_cen_realizP.write(price1);
dinam_cen_realizP.write(KOLFAkT1);
dinam_cen_realizP.write(sum1);
itog_k:=itog_k+KOLFAkT1;
itog_s:=itog_s+sum1;
dinam_cen_realizP.PutEvent(feBreak);
dinam_cen_realizP.write(itog_k);
dinam_cen_realizP.write(itog_s);
dinam_cen_realizP.showfile('');
}
end;
end.
Проблема в том, что условие if ((kat_name1=vdop.kat_name) and (naim1=vdop.naim) and (trunc(price1,2)=trunc(vdop.price,2)) and (tip1=vdop.tip)) работает через раз, т.е. в некоторых случаях сраббатывает, а в некоторых нет.....