Код: Выделить всё
interface _kor_astifarm escclose;
Table struct tKatPodr
(
nrec:comp,
name:string[40]
)
with index
(idx1=nrec, idx2=name);
create view as
select * from
klprice
,prices
, teksaldo
, katmc
, klreshr
, exclassname
,katotped
,grnal
,SPGRNAL
, tkatpodr _katpodr
, katpodr
, tkatpodr
where
((
klprice.nrec==prices.cklprice
and prices.cthing==teksaldo.cmc
and KatPodr.nrec==teksaldo.cpodr
and katpodr.nrec==_katpodr.nrec
and teksaldo.cmc==katmc.nrec
and katmc.creshr==klreshr.nrec
and katmc.nrec==katotped.cmcusl
and teksaldo.cparty==katparty.nrec
and katmc.cgrnal==grnal.nrec
and Grnal.nrec==SPGRNAL.cGrNal
and 'Страна происхождения'==exclassname.name
and word(1430)==exclassname.wtable
and katparty.nrec==exclassval.crec
and exclassname.classcode==exclassval.classcode
and exclassval.cclassseg==exclassseg.nrec
));
File F;
WIndow wPriceSel escclose;
show(1,1,50,30)
panel P1
show at(,,,);
browse Bro1 ;
table klprice;
fields
klprice.name 'Прайс-листы':[30],protect;
end;
end;
handleevent
cminit:
{
getfirst klprice;
}
cmDefault:
{
CloseWindow(wPriceSel);
}
end;
end;
WIndow wScladSel (,,sci178InsPM) escclose;
show(1,1,50,30)
panel P3
show at(,,,);
browse Bro3 ;
table katpodr;
fields
if (isValid(#_katpodr), 'v', ''):[1],skip, {FONT = { Italic = IF( isvalid(tn_katpodr),True, false)}}, {FONT = { COLOR = IF( isvalid(tn_katpodr), 3, 0)}};
katpodr.name 'Наименование склада':[30],protect, {FONT = { COLOR = IF( isvalid(tn_katpodr), 3, 0)}};
end;
end;
handleevent
cmInit:
{
getfirst katpodr;
}
cmMarkUnMark:
{ // message ('cmMarkUnMark');
if not isValid(#_katpodr)
{
insert in tkatpodr set
nrec:=katpodr.nrec,
name:=katpodr.name;
if getnext katpodr = tsOk {}
}
else
{
delete from tkatpodr where ((katpodr.nrec==tkatpodr.nrec));
if getnext katpodr = tsOk {}
}
RescanPanel (#katpodr);
}
cmSelectAll: //message ('cmSelectAll');
{
PushPos(tnkatpodr);
_loop katpodr if not isValid(#_katpodr) insert in tkatpodr set tkatpodr.nrec:=katpodr.nrec,
name:=katpodr.name;
PopPos(tnkatpodr);
RescanPanel (#katpodr);
}
cmUnSelectAll:// message ('cmUnSelectAll');
{
PushPos(tnkatpodr);
// _loop katpodr if isValid(#_katpodr) delete from _katpodr where ((katpodr.nrec==nrec));
delete all from tkatpodr;
PopPos(tnkatpodr);
RescanPanel (#katpodr);
}
cmInvertAll: //message ('cmInvertAll');
{ // Обработка клавиши "Gray *"
PushPos(tnkatpodr);
_loop katpodr
if not isValid(#_katpodr)
{
insert in tkatpodr set nrec:=katpodr.nrec,
name:=katpodr.name;
}
else
{
delete from tkatpodr where ((katpodr.nrec==tkatpodr.nrec));
}
PopPos(tnkatpodr);
RescanPanel (#katpodr);
};
cmDefault:
{
CloseWindow(wScladSel);
}
end;
end;
handleevent
cminit:
{
Var filename, filenamemail:string;
var hDBFh, hDBFhmail:longint;
filename:=GetStringParameter('Files','OutputFilesDirectory',0) + 'price_ASTI'+DatetoStr(cur_date,'YYYYMMDD')+'.dbf';
hDBFh:=DBFOpen(filename, stCreate)
if hDBFh<1 then message ('Ошибка создания файла выгрузки!');
else
{
DBFAddField(hDBFh,'KOD' ,dbNum, 15 ,0);
DBFAddField(hDBFh,'NAME' ,dbChar, 20 ,0);
DBFAddField(hDBFh,'PROIZ' ,dbChar, 30 ,0);
DBFAddField(hDBFh,'PACK' ,dbChar, 5 ,0);
DBFAddField(hDBFh,'PRICE' ,dbNum, 15 ,2);
DBFAddField(hDBFh,'OSTAT' ,dbNum, 15 ,2);
DBFAddField(hDBFh,'GODN' ,dbDate, 10 ,0);
DBFAddField(hDBFh,'ISK' ,dbChar, 15 ,2);
DBFAddField(hDBFh,'PRICEN' ,dbNum, 15 ,2);
RunWindowModal(wPriceSel);
RunWindowModal(wScladSel);
StartNewVisual(vtRotateVisual, vfTimer+vfBreak+vfConfirm,'Подождите, идет выгрузка ...', 100000);
_loop prices
// КАК ТУТ ПОСТРОИТЬ ЦЕПОЧКУ
_loop teksaldo
_loop katparty {
getfirst katmc;
DBFPutFieldValue(hDBFh,'KOD' ,katmc.barkod);
DBFPutFieldValue(hDBFh,'NAME' ,katmc.name);
DBFPutFieldValue(hDBFh,'PROIZ' ,katmc.remmc);
DBFPutFieldValue(hDBFh,'PACK' ,katotped.name);
DBFPutFieldValue(hDBFh,'PRICE' ,string(round(prices.price,2)));
DBFPutFieldValue(hDBFh,'OSTAT' ,string(round(teksaldo.kol,2)));
DBFPutFieldValue(hDBFh,'GODN' ,DateToStr(KATPARTY.DGODN, 'YYYYMMDD'));
DBFPutFieldValue(hDBFh,'ISK' ,string(KATMC.BARKOD2));
DBFPutFieldValue(hDBFh,'PRICEN' ,(prices.price+(prices.price*Spgrnal.nalog/100)));
DBFInsertRecord (hDBFh);
if (not nextvisual) break;
}
StopVisual('Выгрузка произведена',0);
DBFClose(hDBFh);
message('Прайс успешно выгружен в файл '+FileName);
//ProcessText(FileName,vfDefault Or vfEscable Or vfNewTitle Or vfMacroSize,'Отчет о проданных в розницу товарах');
}
abort;
}
cmdefault:
{
CloseInterface ( cmDefault );
}
end;
end.