by ShumingWang » Sat Apr 20, 2013 7:59 am
1.FUNCTION fr3prn0(cid1,lpreview,obl1)
local cid2,ctable1,ctable2,i
local odbprn1,odbprn2,odb1,odb2
private myvar
if obl1<>nil
if __objhasdata(obl1,"odb1")
odb1:=obl1:odb1
odb2:=obl1:odb2
else
odb1:=obl1
odb2:=obl1
end
end
do case
case cid2=="sal02"
odbprn1:=oserver:Query(odb1:cquery)
odbprn2:=oserver:Query(odb2:cquery)
...
end case
if odbprn1<>nil.or.odbprn2<>nil
fr3prn(odbprn1,odbprn2,cid1,lpreview)
if odbprn1<>nil
odbprn1:end()
end
if odbprn2<>nil
odbprn2:end()
end
end
return
2. FUNCTION fr3prn(odbprn1,odbprn2,cid1,lpreview)
local FrPrn,odbprn0,odbprn13
local cid2,acompany1:={},n1:=1
FrPrn := frReportManager():new()
FrPrn:LoadLangRes("chinese.xml")
odbprn0:=oserver:query("select rtrim(ccompany) ccompany,rtrim(ecompany) ecompany,rtrim(addra) addra,rtrim(addrb) addrb,addrc,tel,fax,zip,email from company ")
odbprn0:SKIP()
if lpreview<>nil.and.(LEFT(cid1,3)=="sal".or.left(cid1,5)=="sub08".or.left(cid1,5)=="sub09" )
if odbprn0:LASTREC()>2
while !odbprn0:EOF()
AADD(acompany1,ALLTRIM(odbprn0:ccompany))
odbprn0:SKIP()
end
n1:= alert("请选择",acompany1,"选择打印公司抬头")
if n1==0; n1:=1; end
odbprn0:gotop()
odbprn0:SKIP(n1)
acompany1:=nil
end
end
FrPrn:SetUserDataSet("our",mysqlfields(odbprn0),;
{|| odbprn0:GoTop()} ,;
{|| odbprn0:SKIP(1)},;
{|| odbprn0:SKIP(-1) },;
{|| odbprn0:EOF() },;
{|aField|odbprn0:FIELDGET(afield)})
if odbprn1<>nil
FrPrn:SetUserDataSet("title",mysqlfields(odbprn1),;
{|| odbprn1:GoTop()} ,;
{|| odbprn1:SKIP(1)},;
{|| odbprn1:SKIP(-1) },;
{|| odbprn1:EOF() },;
{|aField|odbprn1:FIELDGET(afield)})
end
if odbprn2<>nil
FrPrn:SetUserDataSet("masterdata",mysqlfields(odbprn2),;
{|| odbprn2:GoTop()} ,;
{|| odbprn2:SKIP(1)},;
{|| odbprn2:SKIP(-1) },;
{|| odbprn2:EOF() },;
{|aField|odbprn2:FIELDGET(afield)})
end
odbprn13:=oserver:query("select cvalue from fr3 where id='"+cid1+"'")
for i:=1 TO LEN(cid1)
if SUBSTR(cid1,i,1)>="0".and.substr(cid1,i,1)<="9"
exit
end
next
if odbprn13:EOF()
odbprn13:cquery:="select cvalue from fr3 where id like '"+SUBSTR(cid1,1,i-1+2)+if(RIGHT(cid1,3)=="amt","amt","")+"%' limit 1"
odbprn13:refresh()
if odbprn13:EOF().and.lpreview==nil.and.RIGHT(cid1,3)=="amt"
odbprn13:cquery:="select cvalue from fr3 where id='"+SUBSTR(cid1,1,i-1+2)+"'"
odbprn13:refresh()
end
end
FrPrn:LoadFromString(odbprn13:cvalue)
odbprn13:end()
do case
case lpreview==nil
FrPrn:designReport()
if msgyesno("保存打印设置修改到ERP系统","save!")
if LEN(ALLTRIM(oserver:querydata("select id from fr3 where id='"+cid1+"'")))==0
oserver:query("insert into fr3 (id,cvalue) values ('"+cid1+"',' ')")
end
oserver:query("update fr3 set cvalue='"+MYSQL_ESCAPE_STRING(frprn:SaveToString())+"' where id='"+cid1+"'")
end
case lpreview==.t.
FrPrn:showReport()
case lpreview==.f.
// FrPrn:showReport()
FrPrn:SetProperty("Report", "ShowProgress", .f.)
FrPrn:PrepareReport()
FrPrn:Print(.f.)
FrPrn:SetProperty("Report", "ShowProgress", .t.)
end
FrPrn:DestroyFR()
odbprn0:end()
return
3.app:
DEFINE BUTTON ;
RESOURCE "printer" ;
top ;
PROMPT "打印" ;
TOOLTIP "F6打印";
of ::obar ;
NOBORDER ;
MENU ::omenu11;
ACTION fr3prn0("sto01",.f.,self)
DEFINE BUTTON ;
RESOURCE "preview" ;
top ;
PROMPT "预览" ;
TOOLTIP "打印预览";
of ::obar ;
MENU ::omenu12;
NOBORDER ;
ACTION fr3prn0("sto01",.t.,self)
DEFINE BUTTON ;
RESOURCE "preview" ;
top ;
PROMPT "set" ;
TOOLTIP "set report form";
of ::obar ;
NOBORDER ;
ACTION fr3prn0("sto01",,self)