$PBExportHeader$w_publ_preview.srw
forward
global type w_publ_preview from w_publ_base
end type
type cb_refresh from uo_imflatbutton within w_publ_preview
end type
type st_1 from statictext within w_publ_preview
end type
type cb_savestyle from uo_imflatbutton within w_publ_preview
end type
type cb_3 from uo_imflatbutton within w_publ_preview
end type
type ddlb_1 from dropdownlistbox within w_publ_preview
end type
type dw_1 from datawindow within w_publ_preview
end type
type ddlb_printerlist from dropdownlistbox within w_publ_preview
end type
type em_1 from editmask within w_publ_preview
end type
type st_2 from statictext within w_publ_preview
end type
type cbx_select_page from checkbox within w_publ_preview
end type
type cb_mdfmxrp from commandbutton within w_publ_preview
end type
type st_3 from statictext within w_publ_preview
end type
type st_4 from statictext within w_publ_preview
end type
type cb_1 from uo_imflatbutton within w_publ_preview
end type
type lb_1 from listbox within w_publ_preview
end type
type cbx_ifprint_xj from checkbox within w_publ_preview
end type
type cbx_ifprint_hj from checkbox within w_publ_preview
end type
type st_dataobject from statictext within w_publ_preview
end type
type sle_dw from singlelineedit within w_publ_preview
end type
type p_1 from picture within w_publ_preview
end type
type ln_bar from line within w_publ_preview
end type
type ln_bar2 from line within w_publ_preview
end type
type r_bar from rectangle within w_publ_preview
end type
type ln_1 from line within w_publ_preview
end type
type ln_2 from line within w_publ_preview
end type
end forward

global type w_publ_preview from w_publ_base
integer x = 9
integer y = 24
integer width = 3611
integer height = 2372
string title = "打印预览"
boolean minbox = false
windowtype windowtype = response!
windowstate windowstate = maximized!
event ue_filter ( )
event ue_sentdataout ( )
event ue_setprintpage_value ( )
event ue_spp ( )
event ue_snp ( )
cb_refresh cb_refresh
st_1 st_1
cb_savestyle cb_savestyle
cb_3 cb_3
ddlb_1 ddlb_1
dw_1 dw_1
ddlb_printerlist ddlb_printerlist
em_1 em_1
st_2 st_2
cbx_select_page cbx_select_page
cb_mdfmxrp cb_mdfmxrp
st_3 st_3
st_4 st_4
cb_1 cb_1
lb_1 lb_1
cbx_ifprint_xj cbx_ifprint_xj
cbx_ifprint_hj cbx_ifprint_hj
st_dataobject st_dataobject
sle_dw sle_dw
p_1 p_1
ln_bar ln_bar
ln_bar2 ln_bar2
r_bar r_bar
ln_1 ln_1
ln_2 ln_2
end type
global w_publ_preview w_publ_preview

type prototypes
//function boolean IsWindowsNT() library "PrintCtrl.dll"
//SUBROUTINE About() library "PrintCtrl.dll"
//function boolean GetDefaultPrinter(ref string PrinterName, int BufferLen) library "PrintCtrl.dll"
//function boolean GetPrinterPort(ref string PrinterName, ref string Port, int PortLen, ref string Driver, int DriverLen) library "PrintCtrl.dll"
//function boolean GetPrinterList(ref string PrinterList, ref long bufferLen) library "PrintCtrl.dll"
//function boolean GetPrinterStatus(ref string Printer, ref long status) library "PrintCtrl.dll"
//function boolean GetPaperList(ref string Printer, ref string PaperList, ref long bufferLen) library "PrintCtrl.dll"
//function boolean SetPrinterDefault(ref string Printer) library "PrintCtrl.dll"
//function boolean AddCustomPaper( ref string Printer, ref string PaperName, long pwidth, long pheight, long left, long right, long top, long bottom) library "PrintCtrl.dll"
//function boolean DeleteCustomPaper(ref string Printer, ref string PaperName) library "PrintCtrl.dll"
//function boolean SetUserDefinePaper(ref string Printer, ref long pWidth, ref long pHeight) library "PrintCtrl.dll"
//function boolean GetUserDefinePaperMinMax(ref string Printer, ref long minWidth, ref long minHeight, ref long maxWidth, ref long maxHeight) library "PrintCtrl.dll"
//function boolean GetDefaultPaper(ref string Printer, ref string PaperName, ref int nOrientation) library "PrintCtrl.dll"
//function boolean SetDefaultPaper(ref string Printer, ref string PaperName, int nOrientation) library "PrintCtrl.dll"
//function boolean GetDefaultPaper(ref string Printer, ref string PaperName,ref long nPapserSize, ref long nOrientation) library "PrintCtrl.dll"
//function boolean GetPaperName(ref string Printer, ref string PaperName, int PaperSize) library "PrintCtrl.dll"
//function boolean GetPaperSize(ref string Printer, ref string PaperName, ref int PaperSize) library "PrintCtrl.dll"
//function boolean GetBinNameList(ref string Printer, ref string BinNameList) library "PrintCtrl.dll"
//function boolean GetBin(ref string Printer, ref string BinName, ref int Bin) library "PrintCtrl.dll"
//function boolean GetBinName(ref string Printer, ref string BinName, int Bin) library "PrintCtrl.dll"
end prototypes

type variables
s_print_msg  fact_print_msg
String dwdataobject
datawindowchild ins_dwcld
s_childreportxwidth s_xwidth
dwobject dwod
Long retrieveid = 0,secondretrieveid = 0
String retrievestr = ''

uo_printer_setting  lnv_printer
String ins_printerlist [ ]
Int p_printerlist = 0
String dw_default_printer = '',default_printer = ''
String default_printer_info = ''

Long print_row
String default_dwname,default_dname


Int rslt_printnum = 0 

Boolean if_power_sendout = true
Boolean if_power_print = true

end variables

forward prototypes
public function integer dw_retrieve ()
public function integer wf_mdfmxreport (s_childreportxwidth s_xw)
public function integer wf_mdfx (s_childreportxwidth s_xw, integer pt)
public function integer wf_initprinterinfo ()
public function integer wf_setdefaultprinter ()
public function integer wf_write_childdw_pos (string arg_childdw_name, s_childreportxwidth arg_s_xwidth)
public function integer wf_read_childdw_pos (string arg_childdw_name, ref s_childreportxwidth arg_s_xwidth)
public subroutine wf_readini_begin ()
public function integer wf_trycreate_sys_dwnsyntax (ref string arg_msg)
public function integer wf_dwcreate (string arg_dwname, string arg_formatname, ref string arg_errmsg)
public subroutine wf_defdataobject ()
public subroutine wf_subdwpos_strutoblob (s_childreportxwidth arg_s_xwidth, ref blob subdwpos)
public subroutine wf_subdwpos_blobtostru (blob arg_blob, ref s_childreportxwidth arg_s_xwidth)
public subroutine wf_dowithm (integer commid)
public function integer wf_read_subdwpos (string arg_dwname, string arg_dname, ref s_childreportxwidth s_subdwwidth, ref string arg_msg)
public subroutine wf_nullrow (long arg_rowcnt, long arg_pagerow, ref long arg_nullrow)
public function integer f_export ()
public function integer f_inport ()
public function integer wf_check_mxreport ()
public subroutine wf_clear_temp ()
public function integer wf_retrieve_buybargain2 (long arg_billid)
public function integer wf_getprintout (string arg_dwname, string arg_dname, integer arg_default_flag, ref string arg_rs_dname, ref string arg_dwsyntax, ref string arg_msg)
end prototypes

event ue_filter();OPENWITHPARM(w_filter_query,dw_1)
STRING LS_EXPR
LS_EXPR=Message.StringParm	

if len(LS_EXPR)>2 and trim(LS_EXPR)='' then return

dw_1.setfilter(LS_EXPR)
dw_1.SetRedraw (false)
dw_1.filter()
dw_1.SetRedraw (TRUE)
end event

event ue_sentdataout;//单据单独设数据发送权限
//LS_PRMSG.sendout_flag = 1
//LS_PRMSG.if_power_sendout =  f_power_ind(3897,sys_msg_pow)
//IF NOT if_power_sendout THEN
//	MessageBox(publ_operator,'你没有发送数据权限')
//	RETURN
//END IF
//
//OPENWITHPARM(w_sentdataout_print,dw_1)
end event

event ue_setprintpage_value();s_print_value s_print

s_print.obj_dw = DW_1
s_print.dft_printername = ddlb_printerlist.text

OpenWithParm(w_sys_printpage_value,s_print)


end event

event ue_spp();dw_1.ScrollPriorPage()
end event

event ue_snp();dw_1.ScrollNextPage()
end event

public function integer dw_retrieve ();//dw_retrieve
CHOOSE CASE fact_print_msg.retr_pram_falg
	CASE 0 //SHARE DATAWINDOW
		datastore LS_DW
		LS_DW = fact_print_msg.SHARE_DW
		LS_DW.ShareData(DW_1)
	CASE 1 //ONE STRING PRAM
		DW_1.Retrieve(fact_print_msg.retr_pramstr)
	CASE 2 //ONE NUMBER PRAM
		DW_1.Retrieve(fact_print_msg.retr_pramnmb)
		retrieveid = fact_print_msg.retr_pramnmb
	CASE 3 //ONE DATE PRAM
		DW_1.Retrieve(fact_print_msg.retr_pramfd)
	CASE 4 //TWO DATE PRAM
		DW_1.Retrieve(fact_print_msg.retr_pramfd,fact_print_msg.retr_pramed)
	CASE 5 //TWO NUMBER PRAM
		DW_1.Retrieve(fact_print_msg.retr_pramnmb,fact_print_msg.b_long)
	CASE 6 //TWO DATETIME PRAM
		DW_1.Retrieve(fact_print_msg.retr_pramfdt,fact_print_msg.retr_pramedt)
	CASE 7 //scid and TWO DATETIME PRAM
		DW_1.Retrieve(fact_print_msg.retr_scid,fact_print_msg.retr_pramfdt,fact_print_msg.retr_pramedt)
	CASE 8 //scid,long and TWO DATETIME PRAM
		DW_1.Retrieve(fact_print_msg.retr_scid,fact_print_msg.retr_pramnmb,fact_print_msg.retr_pramfdt,fact_print_msg.retr_pramedt)
	CASE 9 //TWO NUMBER PRAM and one string pram
		DW_1.Retrieve(fact_print_msg.retr_pramnmb,fact_print_msg.retr_pramstr,fact_print_msg.b_long)
	CASE 11 //scid string
		DW_1.Retrieve(fact_print_msg.retr_scid,fact_print_msg.retr_pramstr)
	CASE 12 //scid long
		DW_1.Retrieve(fact_print_msg.retr_scid,fact_print_msg.retr_pramnmb)
	CASE 13 //scid long and TWO NUMBER PRAM
		DW_1.Retrieve(fact_print_msg.retr_scid,fact_print_msg.retr_pramnmb,fact_print_msg.b_long)
	CASE 14 //ONE NUMBER PRAM and ONE STRING PRAM
		DW_1.Retrieve(fact_print_msg.retr_pramnmb,fact_print_msg.retr_pramstr)
	CASE 15 //scid long and TWO NUMBER PRAM and null_row
		wf_nullrow(fact_print_msg.rowcnt,fact_print_msg.printrow,fact_print_msg.nullrow)
		DW_1.Retrieve(fact_print_msg.retr_scid,fact_print_msg.retr_pramnmb,fact_print_msg.printrow,fact_print_msg.nullrow)
	CASE 16
		wf_nullrow(fact_print_msg.rowcnt,fact_print_msg.printrow,fact_print_msg.nullrow)
		DW_1.Retrieve(fact_print_msg.retr_scid,fact_print_msg.a_string_arr,fact_print_msg.printrow,fact_print_msg.nullrow)
	CASE 17
		wf_nullrow(fact_print_msg.rowcnt,fact_print_msg.printrow,fact_print_msg.nullrow)
		DW_1.Retrieve(fact_print_msg.retr_scid,fact_print_msg.a_string_arr,fact_print_msg.printrow,fact_print_msg.nullrow)
	CASE 18
		DW_1.Retrieve(fact_print_msg.retr_scid,fact_print_msg.retr_pramnmb,fact_print_msg.b_long,fact_print_msg.c_long)
	CASE 19
		DW_1.Retrieve(fact_print_msg.a_string_arr)
	CASE 20
		DW_1.Retrieve(fact_print_msg.a_long_arr)	
	CASE 21
		DW_1.Retrieve(fact_print_msg.retr_pramstr,fact_print_msg.a_long_arr)		
	CASE 22 //YS特殊应用 20130304
		DW_1.Retrieve(fact_print_msg.retr_pramnmb, fact_print_msg.b_long, fact_print_msg.C_long , fact_print_msg.e_long   )	
		//wf_retrieve_buybargain2( fact_print_msg.retr_pramnmb)
	CASE 23 //YS特殊应用 20130427
		DW_1.Retrieve(fact_print_msg.retr_pramnmb)
//		f_getmtpic(fact_print_msg.retr_pramnmb,p_1,dw_1,'p_1')
//		f_getmtpic(fact_print_msg.retr_pramnmb,p_1,dw_1,'p_2')
	CASE 24 //long_arr,long and TWO DATETIME PRAM
		DW_1.Retrieve(fact_print_msg.a_long_arr,fact_print_msg.retr_pramnmb,fact_print_msg.retr_pramfdt,fact_print_msg.retr_pramedt)	
	CASE 25 //kjls特殊应用 20141228
		DW_1.Retrieve(fact_print_msg.retr_pramnmb,f_kjls_getfj(fact_print_msg.retr_pramnmb))
	CASE ELSE
		DW_1.Retrieve()
END CHOOSE
IF fact_print_msg.retr_pram_falg <> 0 THEN
	DW_1.SetFilter(fact_print_msg.FILTER_STRING)
	DW_1.Filter()
END IF
//dw_1.object.title.text=sys_message_report_title
//messagebox('',sys_message_report_title)
RETURN 0



end function

public function integer wf_mdfmxreport (s_childreportxwidth s_xw);//wf_mdfmxreport(s_childreportxwidth)


if s_xw.p=0 then 
	return 0
end if

if mod(s_xw.cmplp,2)=1 then
	if s_xw.cmplx[1]>0 then dwod.object.cmpl1.width=s_xw.cmplwidth[1]
end if
if s_xw.cmplp=2 or s_xw.cmplp=3 then
	if s_xw.cmplx[2]>0 then dwod.object.cmpl2.width= s_xw.cmplwidth[2]
end if
if s_xw.cmplp=4 or s_xw.cmplp=6 or s_xw.cmplp=7  then
	if s_xw.cmplx[3]>0 then dwod.object.cmpl3.width= s_xw.cmplwidth[3]
end if


if s_xw.x[1]>0 then dwod.object.#1.width=s_xw.width[1]
if s_xw.p<2 then goto mdfx
if s_xw.x[2]>0 then dwod.object.#2.width=s_xw.width[2]
if s_xw.p<3 then goto mdfx
if s_xw.x[3]>0 then dwod.object.#3.width=s_xw.width[3]
if s_xw.p<4 then goto mdfx
if s_xw.x[4]>0 then dwod.object.#4.width=s_xw.width[4]
if s_xw.p<5 then goto mdfx
if s_xw.x[5]>0 then dwod.object.#5.width=s_xw.width[5]
if s_xw.p<6 then goto mdfx
if s_xw.x[6]>0 then dwod.object.#6.width=s_xw.width[6]
if s_xw.p<7 then goto mdfx
if s_xw.x[7]>0 then dwod.object.#7.width=s_xw.width[7]
if s_xw.p<8 then goto mdfx
if s_xw.x[8]>0 then dwod.object.#8.width=s_xw.width[8]
if s_xw.p<9 then goto mdfx
if s_xw.x[9]>0 then dwod.object.#9.width=s_xw.width[9]
if s_xw.p<10 then goto mdfx
if s_xw.x[10]>0 then dwod.object.#10.width=s_xw.width[10]
if s_xw.p<11 then goto mdfx
if s_xw.x[11]>0 then dwod.object.#11.width=s_xw.width[11]
if s_xw.p<12 then goto mdfx
if s_xw.x[12]>0 then dwod.object.#12.width=s_xw.width[12]
if s_xw.p<13 then goto mdfx
if s_xw.x[13]>0 then dwod.object.#13.width=s_xw.width[13]
if s_xw.p<14 then goto mdfx
if s_xw.x[14]>0 then dwod.object.#14.width=s_xw.width[14]
if s_xw.p<15 then goto mdfx
if s_xw.x[15]>0 then dwod.object.#15.width=s_xw.width[15]
if s_xw.p<16 then goto mdfx
if s_xw.x[16]>0 then dwod.object.#16.width=s_xw.width[16]
if s_xw.p<17 then goto mdfx
if s_xw.x[17]>0 then dwod.object.#17.width=s_xw.width[17]
if s_xw.p<18 then goto mdfx
if s_xw.x[18]>0 then dwod.object.#18.width=s_xw.width[18]
if s_xw.p<19 then goto mdfx
if s_xw.x[19]>0 then dwod.object.#19.width=s_xw.width[19]
if s_xw.p<20 then goto mdfx
if s_xw.x[20]>0 then dwod.object.#20.width=s_xw.width[20]
if s_xw.p<21 then goto mdfx
if s_xw.x[21]>0 then dwod.object.#21.width=s_xw.width[21]
if s_xw.p<22 then goto mdfx
if s_xw.x[22]>0 then dwod.object.#22.width=s_xw.width[22]
if s_xw.p<23 then goto mdfx
if s_xw.x[23]>0 then dwod.object.#23.width=s_xw.width[23]
if s_xw.p<24 then goto mdfx
if s_xw.x[24]>0 then dwod.object.#24.width=s_xw.width[24]
if s_xw.p<25 then goto mdfx
if s_xw.x[25]>0 then dwod.object.#25.width=s_xw.width[25]
if s_xw.p<26 then goto mdfx
if s_xw.x[26]>0 then dwod.object.#26.width=s_xw.width[26]
if s_xw.p<27 then goto mdfx
if s_xw.x[27]>0 then dwod.object.#27.width=s_xw.width[27]
if s_xw.p<28 then goto mdfx
if s_xw.x[28]>0 then dwod.object.#28.width=s_xw.width[28]
if s_xw.p<29 then goto mdfx
if s_xw.x[29]>0 then dwod.object.#29.width=s_xw.width[29]



mdfx:
if mod(s_xw.cmplp,2)=1 then
	if s_xw.cmplx[1]>0 then dwod.object.cmpl1.x= s_xw.cmplx[1] - 9
end if
if s_xw.cmplp=2 or s_xw.cmplp=3 then
	if s_xw.cmplx[2]>0 then dwod.object.cmpl2.x= s_xw.cmplx[2] - 9
end if
if s_xw.cmplp=4 or s_xw.cmplp=6 or s_xw.cmplp=7  then
	if s_xw.cmplx[3]>0 then dwod.object.cmpl3.x= s_xw.cmplx[3] - 9
end if

long obp,bp,bi,bj,bk
obp=0
for bi=1 to s_xw.p
	bp=50000
	bk=0
	for bj=1 to s_xw.p
		if s_xw.x[bj]<bp and s_xw.x[bj]>obp and s_xw.x[bj]>0 then 
			bp=s_xw.x[bj]
			bk=bj
		end if
	next
	if mod(s_xw.cmplp,2)=1 then
		if s_xw.cmplx[1]<bp and s_xw.cmplx[1]>obp and s_xw.cmplx[1]>0 then 
			bp=s_xw.cmplx[1]
			bk=0
			bi = bi -1
			dwod.object.cmpl1.x= s_xw.cmplx[1] - 9
		end if
	end if

	wf_mdfx(s_xw,bk)
	obp=bp
next

if mod(s_xw.cmplp,2)=1 then
	if s_xw.cmplx[1]>0 then dwod.object.cmpl1.x= s_xw.cmplx[1] - 9
end if
if s_xw.cmplp=2 or s_xw.cmplp=3 then
	if s_xw.cmplx[2]>0 then dwod.object.cmpl2.x= s_xw.cmplx[2] - 9
end if
if s_xw.cmplp=4 or s_xw.cmplp=6 or s_xw.cmplp=7  then
	if s_xw.cmplx[3]>0 then dwod.object.cmpl3.x= s_xw.cmplx[3] - 9
end if




//if s_xw.x[1]>0 then dwod.object.#1.x=s_xw.x[1] - 1
//if s_xw.p<2 then goto ext
//if s_xw.x[2]>0 then dwod.object.#2.x=s_xw.x[2] - 1
//if s_xw.p<3 then goto ext
//if s_xw.x[3]>0 then dwod.object.#3.x=s_xw.x[3] - 1
//if s_xw.p<4 then goto ext
//if s_xw.x[4]>0 then dwod.object.#4.x=s_xw.x[4] - 1
//if s_xw.p<5 then goto ext
//if s_xw.x[5]>0 then dwod.object.#5.x=s_xw.x[5] - 1
//if s_xw.p<6 then goto ext
//if s_xw.x[6]>0 then dwod.object.#6.x=s_xw.x[6] - 1
//if s_xw.p<7 then goto ext
//if s_xw.x[7]>0 then dwod.object.#7.x=s_xw.x[7] - 1
//if s_xw.p<8 then goto ext
//if s_xw.x[8]>0 then dwod.object.#8.x=s_xw.x[8] - 1
//if s_xw.p<9 then goto ext
//if s_xw.x[9]>0 then dwod.object.#9.x=s_xw.x[9] - 1
//if s_xw.p<10 then goto ext
//if s_xw.x[10]>0 then dwod.object.#10.x=s_xw.x[10] - 1
//if s_xw.p<11 then goto ext
//if s_xw.x[11]>0 then dwod.object.#11.x=s_xw.x[11] - 1
//if s_xw.p<12 then goto ext
//if s_xw.x[12]>0 then dwod.object.#12.x=s_xw.x[12] - 1
//if s_xw.p<13 then goto ext
//if s_xw.x[13]>0 then dwod.object.#13.x=s_xw.x[13] - 1
//if s_xw.p<14 then goto ext
//if s_xw.x[14]>0 then dwod.object.#14.x=s_xw.x[14] - 1
//if s_xw.p<15 then goto ext
//if s_xw.x[15]>0 then dwod.object.#15.x=s_xw.x[15] - 1
//if s_xw.p<16 then goto ext
//if s_xw.x[16]>0 then dwod.object.#16.x=s_xw.x[16] - 1
//if s_xw.p<17 then goto ext
//if s_xw.x[17]>0 then dwod.object.#17.x=s_xw.x[17] - 1
//if s_xw.p<18 then goto ext
//if s_xw.x[18]>0 then dwod.object.#18.x=s_xw.x[18] - 1
//if s_xw.p<19 then goto ext
//if s_xw.x[19]>0 then dwod.object.#19.x=s_xw.x[19] - 1
//if s_xw.p<20 then goto ext
//if s_xw.x[20]>0 then dwod.object.#20.x=s_xw.x[20] - 1
//if s_xw.p<21 then goto ext
//if s_xw.x[21]>0 then dwod.object.#21.x=s_xw.x[21] - 1
//if s_xw.p<22 then goto ext
//if s_xw.x[22]>0 then dwod.object.#22.x=s_xw.x[22] - 1
//if s_xw.p<23 then goto ext
//if s_xw.x[23]>0 then dwod.object.#23.x=s_xw.x[23] - 1
//if s_xw.p<24 then goto ext
//if s_xw.x[24]>0 then dwod.object.#24.x=s_xw.x[24] - 1
//if s_xw.p<25 then goto ext
//if s_xw.x[25]>0 then dwod.object.#25.x=s_xw.x[25] - 1
//if s_xw.p<26 then goto ext
//if s_xw.x[26]>0 then dwod.object.#26.x=s_xw.x[26] - 1
//if s_xw.p<27 then goto ext
//if s_xw.x[27]>0 then dwod.object.#27.x=s_xw.x[27] - 1
//if s_xw.p<28 then goto ext
//if s_xw.x[28]>0 then dwod.object.#28.x=s_xw.x[28] - 1
//if s_xw.p<29 then goto ext
//if s_xw.x[29]>0 then dwod.object.#29.x=s_xw.x[29] - 1
//

//ext:
return 0

end function

public function integer wf_mdfx (s_childreportxwidth s_xw, integer pt);//wf_mdfx(s_childreportxwidth,int)

if s_xw.p=0 or pt=0 then 
	return 0
end if

CHOOSE CASE pt
	CASE 1
	if s_xw.p>=1 and s_xw.x[1]>0 then dwod.object.#1.x=s_xw.x[1] - 9
	CASE 2
	if s_xw.p>=2 and s_xw.x[2]>0 then dwod.object.#2.x=s_xw.x[2] - 9
	CASE 3
	if s_xw.p>=3 and s_xw.x[3]>0 then dwod.object.#3.x=s_xw.x[3] - 9
	CASE 4
	if s_xw.p>=4 and s_xw.x[4]>0 then dwod.object.#4.x=s_xw.x[4] - 9
	CASE 5
	if s_xw.p>=5 and s_xw.x[5]>0 then dwod.object.#5.x=s_xw.x[5] - 9
	CASE 6
	if s_xw.p>=6 and s_xw.x[6]>0 then dwod.object.#6.x=s_xw.x[6] - 9
	CASE 7
	if s_xw.p>=7 and s_xw.x[7]>0 then dwod.object.#7.x=s_xw.x[7] - 9
	CASE 8
	if s_xw.p>=8 and s_xw.x[8]>0 then dwod.object.#8.x=s_xw.x[8] - 9
	CASE 9
	if s_xw.p>=9 and s_xw.x[9]>0 then dwod.object.#9.x=s_xw.x[9] - 9
	CASE 10
	if s_xw.p>=10 and s_xw.x[10]>0 then dwod.object.#10.x=s_xw.x[10] - 9
	CASE 11
	if s_xw.p>=11 and s_xw.x[11]>0 then dwod.object.#11.x=s_xw.x[11] - 9
	CASE 12
	if s_xw.p>=12 and s_xw.x[12]>0 then dwod.object.#12.x=s_xw.x[12] - 9
	CASE 13
	if s_xw.p>=13 and s_xw.x[13]>0 then dwod.object.#13.x=s_xw.x[13] - 9
	CASE 14
	if s_xw.p>=14 and s_xw.x[14]>0 then dwod.object.#14.x=s_xw.x[14] - 9
	CASE 15
	if s_xw.p>=15 and s_xw.x[15]>0 then dwod.object.#15.x=s_xw.x[15] - 9
	CASE 16
	if s_xw.p>=16 and s_xw.x[16]>0 then dwod.object.#16.x=s_xw.x[16] - 9
	CASE 17
	if s_xw.p>=17 and s_xw.x[17]>0 then dwod.object.#17.x=s_xw.x[17] - 9
	CASE 18
	if s_xw.p>=18 and s_xw.x[18]>0 then dwod.object.#18.x=s_xw.x[18] - 9
	CASE 19
	if s_xw.p>=19 and s_xw.x[19]>0 then dwod.object.#19.x=s_xw.x[19] - 9
	CASE 20
	if s_xw.p>=20 and s_xw.x[20]>0 then dwod.object.#20.x=s_xw.x[20] - 9
	CASE 21
	if s_xw.p>=21 and s_xw.x[21]>0 then dwod.object.#21.x=s_xw.x[21] - 9
	CASE 22
	if s_xw.p>=22 and s_xw.x[22]>0 then dwod.object.#22.x=s_xw.x[22] - 9
	CASE 23
	if s_xw.p>=23 and s_xw.x[23]>0 then dwod.object.#23.x=s_xw.x[23] - 9
	CASE 24
	if s_xw.p>=24 and s_xw.x[24]>0 then dwod.object.#24.x=s_xw.x[24] - 9
	CASE 25
	if s_xw.p>=25 and s_xw.x[25]>0 then dwod.object.#25.x=s_xw.x[25] - 9
	CASE 26
	if s_xw.p>=26 and s_xw.x[26]>0 then dwod.object.#26.x=s_xw.x[26] - 9
	CASE 27
	if s_xw.p>=27 and s_xw.x[27]>0 then dwod.object.#27.x=s_xw.x[27] - 9
	CASE 28
	if s_xw.p>=28 and s_xw.x[28]>0 then dwod.object.#28.x=s_xw.x[28] - 9
	CASE 29
	if s_xw.p>=29 and s_xw.x[29]>0 then dwod.object.#29.x=s_xw.x[29] - 9
	
END CHOOSE


return 0

end function

public function integer wf_initprinterinfo ();///////////////////////读取打印机信息

//// 用uo取打印机列表
//int ls_ii
//p_printerlist = lnv_printer.of_GetPrinterList ( ins_printerlist )
//
//for ls_ii=1 to p_printerlist
//	ddlb_printerlist.additem(ins_printerlist[ls_ii])
//next

////用dll取打印机列表
//String printerlist = Space(512)
//Long bufferlen = 512
//Boolean rt
//ddlb_printerlist.Reset()
//Long p1,p2
//p1 = 1
//p2 = 0
//rt = GetPrinterList(REF printerlist, REF bufferlen)
//IF rt THEN
//	p2 = Pos(printerlist,"~t",p1)
//	DO WHILE p2 > 0
//		ddlb_printerlist.AddItem(Mid(printerlist,p1,p2 - p1))
//		p1 = p2+1
//		p2 = Pos(printerlist,"~t",p1)
//	LOOP
//END IF

//用pb取打印机列表
String ls_left, ls_prntrs,ls_printername
Long ll_pos_n,ll_pos_t

ddlb_printerlist.Reset()
ls_prntrs  = PrintGetPrinters()

DO WHILE Len(Trim(ls_prntrs)) > 0
	ll_pos_n = Pos (ls_prntrs, "~n" )
	IF ll_pos_n > 0 THEN		
		ls_left = Left (ls_prntrs, ll_pos_n - 1)		
		ll_pos_t = Pos (ls_left, "~t" )
		ls_printername = Left (ls_left, ll_pos_t - 1)		
		ddlb_printerlist.AddItem(ls_printername)
		ls_prntrs = Mid (ls_prntrs, ll_pos_n + 1)
	ELSE
		ll_pos_t = Pos (ls_prntrs, "~t" )
		ls_printername = Left (ls_prntrs, ll_pos_t - 1)		
		ddlb_printerlist.AddItem(ls_printername)
		ls_prntrs = ''
	END IF
LOOP

// 取PB缺省打印机
default_printer = lnv_printer.of_GetPBPrinter ( )

//// 取dll缺省打印机
//String printerName
//Boolean rt_1
//printerName = Space(255)
//rt_1 = GetDefaultPrinter(REF printerName, 255)
//IF rt_1 THEN
//	default_printer = Trim(printerName)
//ELSE
//	default_printer = ''
//END IF

//取PB缺省打印机设置字符串
default_printer_info=ProfileString ( "win.ini", "windows", "device", "" )

return 0

end function

public function integer wf_setdefaultprinter ();///wf_setdefaultprinter
if default_printer_info='' or pos(default_printer_info,',')=0 then return 0

setProfileString ( "win.ini", "windows", "device", default_printer_info )

return 1
end function

public function integer wf_write_childdw_pos (string arg_childdw_name, s_childreportxwidth arg_s_xwidth);//wf_write_childdw_pos(string arg_childdw_name,s_childreportxwidth arg_s_xwidth)
//
long ls_clmxp,ls_clm_cmplxp
long i,j
//列数
ls_clmxp=arg_s_xwidth.p
if ls_clmxp > 0 then
	for i=1 to ls_clmxp
		f_SetProfileString (sys_empid,arg_childdw_name, string(i)+".x",string(arg_s_xwidth.x[i]))
		f_SetProfileString (sys_empid,arg_childdw_name, string(i)+".width",string(arg_s_xwidth.width[i]))
	next
end if
//计算列数量
ls_clm_cmplxp=arg_s_xwidth.cmplp

choose case ls_clm_cmplxp 
	case 1 
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(1)+".x",string(arg_s_xwidth.cmplx[1]))
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(1)+".width",string(arg_s_xwidth.cmplwidth[1]))
	case 2 
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(2)+".x",string(arg_s_xwidth.cmplx[2]))
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(2)+".width",string(arg_s_xwidth.cmplwidth[2]))
	case 3 
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(1)+".x",string(arg_s_xwidth.cmplx[1]))
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(1)+".width",string(arg_s_xwidth.cmplwidth[1]))
		
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(2)+".x",string(arg_s_xwidth.cmplx[2]))
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(2)+".width",string(arg_s_xwidth.cmplwidth[2]))
	case 4 
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(4)+".x",string(arg_s_xwidth.cmplx[4]))
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(4)+".width",string(arg_s_xwidth.cmplwidth[4]))
	case 5 
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(2)+".x",string(arg_s_xwidth.cmplx[2]))
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(2)+".width",string(arg_s_xwidth.cmplwidth[2]))
		
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(3)+".x",string(arg_s_xwidth.cmplx[3]))
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(3)+".width",string(arg_s_xwidth.cmplwidth[3]))
	case 6   
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(2)+".x",string(arg_s_xwidth.cmplx[2]))
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(2)+".width",string(arg_s_xwidth.cmplwidth[2]))
		
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(4)+".x",string(arg_s_xwidth.cmplx[3]))
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(4)+".width",string(arg_s_xwidth.cmplwidth[3]))
   case 7 
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(1)+".x",string(arg_s_xwidth.cmplx[1]))
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(1)+".width",string(arg_s_xwidth.cmplwidth[1]))
	
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(2)+".x",string(arg_s_xwidth.cmplx[2]))
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(2)+".width",string(arg_s_xwidth.cmplwidth[2]))
		
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(4)+".x",string(arg_s_xwidth.cmplx[3]))
		f_SetProfileString (sys_empid,arg_childdw_name, "cmpl"+string(4)+".width",string(arg_s_xwidth.cmplwidth[3]))
end choose


return 1
end function

public function integer wf_read_childdw_pos (string arg_childdw_name, ref s_childreportxwidth arg_s_xwidth);//f_read_childdw_pos(string arg_childdw_name,s_childreportxwidth arg_s_xwidth)

//

int ls_i,ls_clmno
int rslt=1
datastore obj_dw

obj_dw =create datastore
obj_dw.dataobject=arg_childdw_name
obj_dw.settransobject(sqlca)

ls_clmno=integer(obj_dw.Describe('DataWindow.Column.Count'))
if ls_clmno=0 then 
	rslt=0  
	goto ext
end if

for ls_i=1 to ls_clmno
	long column_xpos,column_width
	column_xpos=long(f_ProfileString(sys_empid,arg_childdw_name, string(ls_i)+".x",'-1'))
	column_width=long(f_ProfileString(sys_empid,arg_childdw_name, string(ls_i)+".width",'-1'))	
	if column_xpos = -1 or column_width = -1 then
		rslt=0
		goto ext
	end if
	arg_s_xwidth.width[ls_i]=column_width
	arg_s_xwidth.x[ls_i]=column_xpos	
next

arg_s_xwidth.p=ls_clmno

if obj_dw.Describe('cmpl1.name')='cmpl1' then
	arg_s_xwidth.cmplwidth[1]=long(f_ProfileString(sys_empid,arg_childdw_name, "cmpl1.width",'-1'))
	arg_s_xwidth.cmplx[1]=long(f_ProfileString(sys_empid,arg_childdw_name, "cmpl1.x",'-1'))
	if arg_s_xwidth.cmplx[1] = -1 or arg_s_xwidth.cmplwidth[1] = -1 then
		rslt=0
		goto ext
	end if
	arg_s_xwidth.cmplp=1
end if
if obj_dw.Describe('cmpl2.name')='cmpl2' then
	arg_s_xwidth.cmplwidth[2]=long(f_ProfileString(sys_empid,arg_childdw_name, "cmpl2.width",'-1'))
	arg_s_xwidth.cmplx[2]=long(f_ProfileString(sys_empid,arg_childdw_name, "cmpl2.x",'-1'))
	if arg_s_xwidth.cmplx[2] = -1 or arg_s_xwidth.cmplwidth[2] = -1 then
		rslt=0
		goto ext
	end if
	arg_s_xwidth.cmplp=arg_s_xwidth.cmplp+2
end if
if obj_dw.Describe('cmpl3.name')='cmpl3' then
	arg_s_xwidth.cmplwidth[3]=long(f_ProfileString(sys_empid,arg_childdw_name, "cmpl3.width",'-1'))
	arg_s_xwidth.cmplx[3]=long(f_ProfileString(sys_empid,arg_childdw_name, "cmpl3.x",'-1'))
	if arg_s_xwidth.cmplx[3] = -1 or arg_s_xwidth.cmplwidth[3] = -1 then
		rslt=0
		goto ext
	end if	
	arg_s_xwidth.cmplp=arg_s_xwidth.cmplp+4
end if

ext:
return rslt





end function

public subroutine wf_readini_begin ();dwod=dw_1.object.mxreport

s_mdfxwidth_tran  s_mdfxw_tran

s_mdfxw_tran.retrieveid=retrieveid
if em_1.enabled then
	secondretrieveid=long(em_1.text)
end if
s_mdfxw_tran.secondretrieveid=secondretrieveid
s_mdfxw_tran.dataobject=dwod.dataobject


if wf_read_childdw_pos(dwod.dataobject,s_xwidth)=0 then	
	return
end if


wf_mdfmxreport(s_xwidth)

end subroutine

public function integer wf_trycreate_sys_dwnsyntax (ref string arg_msg);//wf_trycreate_sys_dwnsyntax

long rslt=1
//long cnt
//string createsql_string,t_str
//createsql_string="CREATE TABLE sys_dwnSyntax (	dwname char (50) NOT NULL,dname char (50) NOT NULL,default_flag tinyint not null default (0),dwSyntaxB image not NULL DEFAULT (''),subdwSyntaxB image not NULL DEFAULT ('')) "+&
//      " ~n ALTER TABLE sys_dwnSyntax WITH NOCHECK ADD CONSTRAINT PK_sys_dwnSyntax PRIMARY KEY  CLUSTERED (dwname,dname)"
//
//t_str="select count(*) from sys_dwnSyntax"
//
//Execute immediate :t_str;  
//if sqlca.sqlcode=0 then //已经存在该表
//	rslt=1
//	goto ext	
//end if
//
//Execute immediate :createsql_string ;  
//		
//if sqlca.sqlcode<>0 then
//	arg_msg='建立表sys_dwnSyntax失败>>'+sqlca.sqlerrtext
//	rollback ;
//	rslt=0
//	goto ext	
//end if
//commit ;
//
//ext:
return rslt


return 0
end function

public function integer wf_dwcreate (string arg_dwname, string arg_formatname, ref string arg_errmsg);//blob dwSyntax

int rslt=1
//selectblob dwSyntaxB into :dwSyntax from sys_dwnSyntax where dwname=:arg_dwname and dname=:arg_formatname;
//	if sqlca.sqlcode=-1 then
//		Messagebox('系统提示','查询单据格式失败,原因:'+sqlca.sqlerrtext)
//		rslt=0
//		goto ext
//	end if
	//Messagebox('string(dwSyntax)',string(dwSyntax))
	string dwSyntax,rs_dname
	integer arg_default_flag
	if trim(arg_formatname) = "" then
		arg_default_flag = 1
	else
		arg_default_flag = 0
	end if
	if arg_dwname <> '标准格式' and  wf_getprintout(dw_1.DataObject,arg_formatname,arg_default_flag,rs_dname,dwSyntax,arg_errmsg) = 0 then
		rslt = 0
		st_4.text = "标准格式"
		goto ext
	else
		if trim(rs_dname) = '' then
			st_4.text = '标准格式' 
			rs_dname = '标准格式' 
		else
			st_4.text = rs_dname
		end if
	end if
	if trim(rs_dname) <> '' and rs_dname <> '标准格式' then
		if dw_1.create(string(dwSyntax),arg_errmsg)<>1 then
			rslt = 0
			Messagebox('系统提示',arg_errmsg)
			goto ext
		end if
		dw_1.object.DataWindow.Print.Preview = 'yes'
	//	dw_1.Object.DataWindow.Print.Duplex = 2
		dw_1.Object.DataWindow.Print.Preview.Rulers = "yes"
	else
		dw_1.dataobject=dw_1.dataobject
	end if

uo_string lo_str
string ls_dwname

IF Trim(dw_1.DataObject) <> '' THEN
	lo_str = create uo_string
	ls_dwname = dw_1.DataObject + st_4.text

	ls_dwname = lo_str.uof_replace(ls_dwname, '[', '')
	ls_dwname = lo_str.uof_replace(ls_dwname, ']', '')

	dw_1.Object.datawindow.Print.margin.Top = Integer(f_ProfileString(sys_empid,ls_dwname, "margin_top",   "110"))
	dw_1.Object.datawindow.Print.margin.Left = Integer(f_ProfileString(sys_empid,ls_dwname, "margin_left", "96" ))
	
	dw_1.Object.datawindow.Print.margin.bottom = Integer(f_ProfileString(sys_empid,ls_dwname, "margin_bottom",   "110"))
	dw_1.Object.datawindow.Print.margin.Right = Integer(f_ProfileString(sys_empid,ls_dwname, "margin_right", "96" ))

	dw_1.Object.datawindow.Print.paper.size = Integer(f_ProfileString(sys_empid,ls_dwname, "paper_size",   "0"  ))
	dw_1.Object.datawindow.Print.orientation = Integer(f_ProfileString(sys_empid,ls_dwname, "orientation", "0"  ))
	
	dw_default_printer  = f_ProfileString(sys_empid,ls_dwname, "dw_default_printer ", ""  )
	IF dw_default_printer = '' THEN
		ddlb_printerlist.Text = default_printer
	ELSE
		ddlb_printerlist.Text = dw_default_printer
	END IF

	destroy lo_str
END IF
	
ext:
return rslt

end function

public subroutine wf_defdataobject ();String errmsg
Long ls_count,rslt = 1
Blob sqlblob

//SELECT count(*) INTO :ls_count FROM sys_dwnSyntax Where dwname = :fact_print_msg.obj_dwname AND default_flag = 1 ;
//IF sqlca.SQLCode = -1 THEN
//	MessageBox('系统提示','查询单据格式失败'+sqlca.SQLErrText)
//	RETURN
//END IF
//
//IF ls_count = 1 THEN
//	SELECT dwname,dname INTO :default_dwname,:default_dname FROM sys_dwnSyntax Where dwname = :fact_print_msg.obj_dwname AND default_flag = 1 ;
//	IF sqlca.SQLCode = -1 THEN
//		MessageBox('系统提示','查询单据格式失败'+sqlca.SQLErrText)
//		RETURN
//	END IF
//	IF wf_dwcreate(default_dwname,default_dname,errmsg) = 0 THEN
//		MessageBox('系统提示','打开单据格式失败！原因：'+errmsg)
//		RETURN
//	END IF
//	st_4.Text = default_dname
//	dw_1.SetTransObject(sqlca)
//ELSEIF ls_count = 0 THEN
//	st_4.Text = '标准格式'
//END IF

wf_dwcreate(default_dwname,"",errmsg)


end subroutine

public subroutine wf_subdwpos_strutoblob (s_childreportxwidth arg_s_xwidth, ref blob subdwpos);long ls_clmxp,ls_cmplxp
long i,j
string x_str,width_str,clmxp_str,cmpx_str,cmpwidth_str,cmp_str,subdwstr
//列数
ls_clmxp=arg_s_xwidth.p
if ls_clmxp > 0 then
	for i=1 to ls_clmxp
		x_str=x_str+string(arg_s_xwidth.x[i])+','
		width_str=width_str+string(arg_s_xwidth.width[i])+','
	next
	x_str=left(x_str,len(x_str) - 1)+';'
	width_str=left(width_str,len(width_str) - 1)+';'
	clmxp_str='P:'+string(ls_clmxp)+';x:'+x_str+'width:'+width_str
end if
//Messagebox('clmxp_str',clmxp_str)

ls_cmplxp=arg_s_xwidth.cmplp
if ls_cmplxp>0 then
	for i= 1 to upperbound(arg_s_xwidth.cmplx)
		cmpwidth_str=cmpwidth_str+string(arg_s_xwidth.cmplwidth[i])+','
		cmpx_str=cmpx_str+string(arg_s_xwidth.cmplx[i])+','	
	next
	cmpx_str=left(cmpx_str,len(cmpx_str) - 1)+';'
	cmpwidth_str=left(cmpwidth_str,len(cmpwidth_str) - 1)+';'
	cmp_str='cmplp:'+string(ls_cmplxp)+';x:'+cmpx_str+'width:'+cmpwidth_str
end if
//Messagebox('cmp_str',cmp_str)
//Messagebox('',clmxp_str+cmp_str)
subdwpos=blob(clmxp_str+cmp_str)



//s_subdwxwidth
end subroutine

public subroutine wf_subdwpos_blobtostru (blob arg_blob, ref s_childreportxwidth arg_s_xwidth);//wf_subdwpos_blobtostru(arg_blob,arg_s_xwidth)
string subdwpos_str,clm_str,cmp_str,clm_strx,clm_strwidth,cmplp_x,cmplp_width
long clm_p,cmplp,i
subdwpos_str=string(arg_blob)
if pos(subdwpos_str,'cmplp:') > 0 then
	clm_str=mid(subdwpos_str,1,pos(subdwpos_str,'cmplp:') - 1)	
else
	clm_str=mid(subdwpos_str,1)
end if	
cmp_str=mid(subdwpos_str,pos(subdwpos_str,'cmplp:'))

clm_strx=mid(clm_str,pos(clm_str,'x:')+2,pos(clm_str,';width:') - pos(clm_str,'x:') - 1 ) //x_str
clm_strwidth=mid(clm_str,pos(clm_str,'width:') + 6)   //width_str

cmplp_x=mid(cmp_str,pos(cmp_str,'x:')+2,pos(cmp_str,';width:') - pos(cmp_str,'x:') - 1 )
cmplp_width=mid(cmp_str,pos(cmp_str,'width:') + 6)   //cmplpwidth_str

clm_p=long(mid(clm_str,3,pos(clm_str,';') - 3)) //P
cmplp=long(mid(cmp_str,7,pos(cmp_str,';') - 7)) //cmplp

arg_s_xwidth.p=clm_p
arg_s_xwidth.cmplp=cmplp
//messagebox('all',subdwpos_str)
//MEssagebox('clm_str',clm_str)
//MEssagebox('cmp_str',cmp_str)
//
//MEssagebox('clm_p',clm_p)
//MEssagebox('cmplp',cmplp)
//
//MEssagebox('clm_strx',clm_strx)
//MEssagebox('clm_strwidth',clm_strwidth)



long xmx
string xstr
xmx=0
xstr=''
for i =1 to len(clm_strx)        //x
	if mid(clm_strx,i,1)<>',' and mid(clm_strx,i,1)<>';' then
		xstr=xstr+mid(clm_strx,i,1)
	else
		xmx++
		arg_s_xwidth.x[xmx]=long(xstr)
		xstr=''
	end if
next
	
xmx=0
xstr=''
for i =1 to len(clm_strwidth)        //width
	if mid(clm_strwidth,i,1)<>',' and mid(clm_strwidth,i,1)<>';' then
		xstr=xstr+mid(clm_strwidth,i,1)
	else
		xmx++
		arg_s_xwidth.width[xmx]=long(xstr)
		xstr=''
	end if
next
	
xmx=0
xstr=''
for i =1 to len(cmplp_x)        //cmplp_x
	if mid(cmplp_x,i,1)<>',' and mid(cmplp_x,i,1)<>';' then
		xstr=xstr+mid(cmplp_x,i,1)
	else
		xmx++
		arg_s_xwidth.cmplx[xmx]=long(xstr)
		xstr=''
	end if
next
	
xmx=0
xstr=''
for i =1 to len(cmplp_width)        //cmplp_width
	if mid(cmplp_width,i,1)<>',' and mid(cmplp_width,i,1)<>';' then
		xstr=xstr+mid(cmplp_width,i,1)
	else
		xmx++
		arg_s_xwidth.cmplwidth[xmx]=long(xstr)
		xstr=''
	end if
next
	
	

//messagebox('','sdfsdf')
	
	
	
	
	
	

end subroutine

public subroutine wf_dowithm (integer commid);//wf_dowithm
string errmsg
blob subdwpos
s_childreportxwidth s_subdwpos
choose case commid
	case 1
		cb_mdfmxrp.triggerevent(clicked!)
	case 21
		string ls_STR,ls_subsy
		ls_STR=dw_1.Describe("DataWindow.Syntax")
		s_preview_billformatset_tran s_billformat
		s_billformat.dwname=dw_1.dataobject
		s_billformat.dname=st_4.text
		s_billformat.dwsyntaxb=blob(ls_STR)
		wf_subdwpos_strutoblob(s_xwidth,subdwpos)	
		s_billformat.subdwsyntaxb=subdwpos
		openwithparm(w_publ_preview_billformatset,s_billformat)
		s_billformat=message.PowerObjectParm
		if s_billformat.dname<>'' then
			if wf_dwcreate(s_billformat.dwname,s_billformat.dname,errmsg)=0 then
				MEssagebox('系统提示','打开单据格式失败！原因：'+errmsg)
				return
			end if
		end if
		
		if s_billformat.dname<>'' then 
			s_childreportxwidth s_subdw
			st_4.text=s_billformat.dname
//			wf_subdwpos_blobtostru(s_billformat.subdwsyntaxb,s_subdw)
//			wf_mdfmxreport(s_subdw)
			dw_1.object.DataWindow.Print.Preview = 'yes'
//			dw_1.Object.DataWindow.Print.Duplex = 2
			dw_1.Object.DataWindow.Print.Preview.Rulers = "yes"
			dw_1.settransobject(sqlca)
			cb_refresh.triggerevent(clicked!)
		end if
		
		if  wf_read_subdwpos(dw_1.dataobject,s_billformat.dname,s_subdwpos,errmsg)=0 then
			Messagebox('系统信息',errmsg)
			return
		else
			wf_mdfmxreport(s_subdwpos)	
   	end if
		
		 
	case 22
		st_4.text='标准格式'
		dw_1.dataobject=dw_1.dataobject
		dw_1.object.DataWindow.Print.Preview = 'yes'
//		dw_1.Object.DataWindow.Print.Duplex = 2
		dw_1.Object.DataWindow.Print.Preview.Rulers = "yes"
		dw_1.settransobject(sqlca)
		dw_retrieve()
		
end choose

end subroutine

public function integer wf_read_subdwpos (string arg_dwname, string arg_dname, ref s_childreportxwidth s_subdwwidth, ref string arg_msg);//wf_read_subdwpos(arg_dwname,arg_dname,arg_msg)
Blob ls_subdwSyntaxB
Int rslt = 1
s_childreportxwidth s_empty

//SelectBlob subdwSyntaxB Into :ls_subdwSyntaxB From sys_dwnSyntax  Where dwname = :arg_dwname And dname = :arg_dname;
//IF sqlca.SQLCode = -1 THEN
//	arg_msg = '读取单据明细表格式失败,'+sqlca.SQLErrText
//	rslt = 0
//	GOTO ext
//END IF
//
//IF Len(Trim(String(ls_subdwSyntaxB))) > 0 THEN
//	dwod = dw_1.Object.mxreport
//	wf_subdwpos_blobtostru(ls_subdwSyntaxB,s_subdwwidth)
//ELSE
	s_subdwwidth = s_empty
//END IF

//ext:
RETURN rslt


end function

public subroutine wf_nullrow (long arg_rowcnt, long arg_pagerow, ref long arg_nullrow);//====================================================================
// Function: wf_nullrow()
//--------------------------------------------------------------------
// Description:返回加空行数
//--------------------------------------------------------------------
// Arguments: 
//		value    	long	arg_rowcnt 		
//		value    	long	arg_pagerow		
//		reference	long	arg_nullrow		
//--------------------------------------------------------------------
// Returns:  (none)
//--------------------------------------------------------------------
// Author:	yyx		Date: 2004.09.13
//--------------------------------------------------------------------
// Modify History: 
//	
//====================================================================
Long pagecnt,tal_rowcnt

pagecnt = Long(arg_rowcnt / arg_pagerow)

tal_rowcnt += arg_rowcnt
//小计
IF cbx_ifprint_xj.Checked THEN
	tal_rowcnt += pagecnt
END IF

//合计
IF cbx_ifprint_hj.Checked THEN
	tal_rowcnt += 1
END IF

IF Mod(tal_rowcnt,arg_pagerow) <> 0 THEN
	arg_nullrow = arg_pagerow - Mod(tal_rowcnt,arg_pagerow)
ELSE
	arg_nullrow = 0
END IF




end subroutine

public function integer f_export ();Blob subdwpos
String ls_STR,ls_subsy
s_childreportxwidth s_subdwpos
ls_STR = dw_1.Describe("DataWindow.Syntax")
s_preview_billformatset_tran s_billformat
s_billformat.dwname = dw_1.DataObject
s_billformat.dname = st_4.Text
s_billformat.dwsyntaxb = Blob(ls_STR)
wf_subdwpos_strutoblob(s_xwidth,subdwpos)
s_billformat.subdwsyntaxb = subdwpos
s_billformat.ifimporflag = 1
OpenWithParm(w_report_inexport,s_billformat)

RETURN 1


end function

public function integer f_inport ();Blob subdwpos
String ls_STR,ls_subsy
s_childreportxwidth s_subdwpos
//  ls_STR=dw_1.Describe("DataWindow.Syntax")
s_preview_billformatset_tran s_billformat
//		s_billformat.dwname=dw_1.dataobject
//		s_billformat.dname=st_4.text
//		s_billformat.dwsyntaxb=blob(ls_STR)
//      wf_subdwpos_strutoblob(s_xwidth,subdwpos)		
//    	s_billformat.subdwsyntaxb=subdwpos
s_billformat.ifimporflag = 0
OpenWithParm(w_report_inexport,s_billformat)

//s_billformat = message.powerobjectparm


RETURN 1

end function

public function integer wf_check_mxreport ();Int rslt = 1


//datawindowchild childdw
//
//dw_uc.GetChild("u_outware_storageid",childdw)
//childdw.SetTransObject (sqlca)
//IF childdw.Retrieve(cur_scid,sys_user_storageid) = 0 THEN
//	childdw.InsertRow(0)
//END IF
//

RETURN rslt

end function

public subroutine wf_clear_temp ();String ls_label
String ls_type,LS_PATH
Int li_count,i = 1
ls_type = "*.*"

LS_PATH = sys_cur_path+ins_fjtemppath
lb_1.Reset()
lb_1.DirList(LS_PATH+'\'+ls_type, 0)
li_count = lb_1.TotalItems()

IF li_count > 0 THEN
	FOR i = li_count To 1 Step -1
		ls_label = lb_1.Text(i)
		IF Pos(ls_label,String(sys_empid) + '_' + fact_print_msg.obj_dwname) > 0 THEN
			FileDelete(LS_PATH+'\' + ls_label)
		END IF
	NEXT
END IF

end subroutine

public function integer wf_retrieve_buybargain2 (long arg_billid);Int rslt = 1
Long cnt1,cnt2,i,j,ls_rowcnt,ls_row,ls_cnt
String ls_find
String ls_hdtitle[]
Decimal ls_hd[]
ls_hdtitle[1] = 'hd19'
ls_hdtitle[2] = 'hd15'
ls_hdtitle[3] = 'hd12'
ls_hdtitle[4] = 'hd10'
ls_hdtitle[5] = 'hd92'
ls_hdtitle[6] = 'hd8'
ls_hdtitle[7] = 'hd4'
ls_hdtitle[8] = 'hd25'
ls_hdtitle[9] = 'hd5'
ls_hdtitle[10] = 'hd6'

ls_hd[1] = 19
ls_hd[2] = 15
ls_hd[3] = 12
ls_hd[4] = 10
ls_hd[5] = 9.2
ls_hd[6] = 8
ls_hd[7] = 4
ls_hd[8] = 25
ls_hd[9] = 5
ls_hd[10] = 6

dwobject childdw
childdw = dw_1.Object.mxreport2



datastore ds
ds = CREATE datastore
ds.DataObject = 'ds_buybargaintech_editmx'
ds.SetTransObject( sqlca)
cnt1 = ds.Retrieve( arg_billid)

datastore ds2
ds2 = CREATE datastore
ds2.DataObject = 'ds_buybargaintech_edit'
ds2.SetTransObject( sqlca)
cnt2 = ds2.Retrieve( arg_billid)


datastore ds3
ds3 = CREATE datastore
ds3.DataObject = 'dw_buybargain_preview_mx_ys3_1'
ds3.SetTransObject( sqlca)
cnt2 = ds3.Retrieve( fact_print_msg.b_long)

SELECT count( printid) INTO :ls_cnt
	FROM u_buybargaintech
	WHERE billid = :arg_billid
	AND techtype = 0
	;
	
IF ls_cnt <> cnt1 THEN
	rslt = 0
	MessageBox('查询','查询数据失败,数据明细不相等')
	GOTO ext
END IF

SELECT count(distinct printid) INTO :ls_rowcnt
	FROM u_buybargaintech
	WHERE billid = :arg_billid
	AND techtype = 0
	;
	
IF ls_rowcnt <> cnt2 THEN
	rslt = 0
	MessageBox('查询','查询数据失败,行数不相等')
	GOTO ext
END IF

FOR i = 1 TO ls_rowcnt
	ls_row = i  
	ds3.Object.u_techdef_techname[ls_row] = ds2.Object.u_techdef_techname[i]
	ds3.Object.u_buybargaintech_techid[ls_row] = ds2.Object.u_buybargaintech_techid[i]
	ds3.Object.u_buybargaintech_techtype[ls_row] = ds2.Object.u_buybargaintech_techtype[i]
	ds3.Object.u_techdef_formular[ls_row] = ds2.Object.u_techdef_formular[i]
	ds3.Object.u_buybargaintech_lastdate[ls_row] = ds2.Object.u_buybargaintech_lastdate[i]
	ds3.Object.u_buybargaintech_lastformular[ls_row] = ds2.Object.u_buybargaintech_lastformular[i]
	ds3.Object.u_buybargaintech_relcode[ls_row] = ds2.Object.u_buybargaintech_relcode[i]
	ds3.Object.u_buybargaintech_dscrp[ls_row] = ds2.Object.u_buybargaintech_dscrp[i]
	ds3.Object.u_buybargaintech_printid[ls_row] = ds2.Object.u_buybargaintech_printid[i]
	ds3.Object.u_buybargaintech_unit[ls_row] = ds2.Object.u_buybargaintech_unit[i]
	


	
	FOR j = 1 TO upperbound(ls_hdtitle[])
		ls_find=''
		ls_find='u_buybargaintech_billid='+string(ds2.Object.u_buybargaintech_billid[i])
		ls_find=ls_find+' and u_buybargaintech_techid='+string(ds2.Object.u_buybargaintech_techid[i])
		ls_find=ls_find+' and u_buybargaintech_printid='+string(ds2.Object.u_buybargaintech_printid[i])
		ls_find=ls_find+' and u_buybargaintech_heightdegree='+string(ls_hd[j])
		ls_cnt=ds.find( ls_find,1,cnt1)
		IF ls_cnt > 0 THEN
		//	messagebox('',String(ls_hd[j])+','+string(ds.Object.u_buybargaintech_price[i]))
			
			CHOOSE CASE ls_hdtitle[j]
				CASE 'hd19'
					ds3.Object.hd19[ls_row] = ds.Object.u_buybargaintech_price[ls_cnt]
				CASE 'hd15'
					ds3.Object.hd15[ls_row] = ds.Object.u_buybargaintech_price[ls_cnt]
				CASE 'hd12'
					ds3.Object.hd12[ls_row] = ds.Object.u_buybargaintech_price[ls_cnt]
				CASE 'hd10'
					ds3.Object.hd10[ls_row] = ds.Object.u_buybargaintech_price[ls_cnt]
				CASE 'hd92'
					ds3.Object.hd92[ls_row] = ds.Object.u_buybargaintech_price[ls_cnt]
				CASE 'hd8'
					ds3.Object.hd8[ls_row] = ds.Object.u_buybargaintech_price[ls_cnt]
				CASE 'hd6'
					ds3.Object.hd6[ls_row] = ds.Object.u_buybargaintech_price[ls_cnt]	
				CASE 'hd4'
					ds3.Object.hd4[ls_row] = ds.Object.u_buybargaintech_price[ls_cnt]
				CASE 'hd25'
					ds3.Object.hd25[ls_row] = ds.Object.u_buybargaintech_price[ls_cnt]
				CASE 'hd5'
					ds3.Object.hd5[ls_row] = ds.Object.u_buybargaintech_price[ls_cnt]	
			END CHOOSE
			
			
			
		END IF
	NEXT
	

NEXT

//childdw.Object.data=ds3.object.data

dw_1.Object.mxreport2.Object.data=ds3.object.data

destroy ds
destroy ds2
destroy ds3
DESTROY   childdw   
ext:
RETURN rslt

/*



FOR i = 1 TO ls_rowcnt
	ls_row = childdw.InsertRow(0)
	childdw.Object.u_buybargaintech_techid[ls_row] = ds2.Object.u_buybargaintech_techid[i]
	childdw.Object.u_buybargaintech_techtype[ls_row] = ds2.Object.u_buybargaintech_techtype[i]
	childdw.Object.u_techdef_formular[ls_row] = ds2.Object.u_techdef_formular[i]
	childdw.Object.u_buybargaintech_lastdate[ls_row] = ds2.Object.u_buybargaintech_lastdate[i]
	childdw.Object.u_buybargaintech_lastformular[ls_row] = ds2.Object.u_buybargaintech_lastformular[i]
	childdw.Object.u_buybargaintech_relcode[ls_row] = ds2.Object.u_buybargaintech_relcode[i]
	childdw.Object.u_buybargaintech_dscrp[ls_row] = ds2.Object.u_buybargaintech_dscrp[i]
	childdw.Object.u_buybargaintech_printid[ls_row] = ds2.Object.u_buybargaintech_printid[i]
	childdw.Object.u_buybargaintech_unit[ls_row] = ds2.Object.u_buybargaintech_unit[i]
	
	FOR j = 1 TO 8
		ls_find = ''
		ls_find = 'u_buybargaintech_billid='+String(ds2.Object.u_buybargaintech_billid[i])
		ls_find = ls_find+' and u_buybargaintech_billid='+String(ds2.Object.u_buybargaintech_billid[i])
		ls_find = ls_find+' and u_buybargaintech_techid='+String(ds2.Object.u_buybargaintech_techid[i])
		ls_find = ls_find+' and u_buybargaintech_printid='+String(ds2.Object.u_buybargaintech_printid[i])
		ls_find = ls_find+' and u_buybargaintech_heightdegree='+String(ls_hd[j])
		ls_cnt = ds.Find( ls_find,1,cnt1)
		IF ls_cnt > 0 THEN
			childdw.SetItem(ls_row,ls_hdtitle[j],ds.Object .u_buybargaintech_price[ls_cnt])
		END IF
	NEXT
	
	
NEXT
*/


end function

public function integer wf_getprintout (string arg_dwname, string arg_dname, integer arg_default_flag, ref string arg_rs_dname, ref string arg_dwsyntax, ref string arg_msg);integer rslt,i
oleobject request,response,list
string defaultalise,alise 
Long currow,findrow

rslt = 1
arg_msg= ''

request = FXAppCom.CreatePbDictionary()
request.SetString("token",app_token_fx)
request.SetString("dwname",arg_dwname)
request.SetString("aliase",arg_dname)
request.SetInt("default_flag",arg_default_flag)
request.SetInt("cuscomid",fact_print_msg.cuscomid)

response = FXAppCom.DoExecute("GetPrintOut", request)
arg_msg = response.GetString('ErrMsg')
if (arg_msg <> '') then
	rslt = 0
	arg_dwsyntax = ""
	MessageBox('提示', '获取打印格式有误:' + arg_msg)
	goto ext
end if
arg_rs_dname = response.getstring("aliase")
arg_dwsyntax = response.getstring("dwSyntax")

ext:
return rslt
end function

on w_publ_preview.create
int iCurrent
call super::create
this.cb_refresh=create cb_refresh
this.st_1=create st_1
this.cb_savestyle=create cb_savestyle
this.cb_3=create cb_3
this.ddlb_1=create ddlb_1
this.dw_1=create dw_1
this.ddlb_printerlist=create ddlb_printerlist
this.em_1=create em_1
this.st_2=create st_2
this.cbx_select_page=create cbx_select_page
this.cb_mdfmxrp=create cb_mdfmxrp
this.st_3=create st_3
this.st_4=create st_4
this.cb_1=create cb_1
this.lb_1=create lb_1
this.cbx_ifprint_xj=create cbx_ifprint_xj
this.cbx_ifprint_hj=create cbx_ifprint_hj
this.st_dataobject=create st_dataobject
this.sle_dw=create sle_dw
this.p_1=create p_1
this.ln_bar=create ln_bar
this.ln_bar2=create ln_bar2
this.r_bar=create r_bar
this.ln_1=create ln_1
this.ln_2=create ln_2
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.cb_refresh
this.Control[iCurrent+2]=this.st_1
this.Control[iCurrent+3]=this.cb_savestyle
this.Control[iCurrent+4]=this.cb_3
this.Control[iCurrent+5]=this.ddlb_1
this.Control[iCurrent+6]=this.dw_1
this.Control[iCurrent+7]=this.ddlb_printerlist
this.Control[iCurrent+8]=this.em_1
this.Control[iCurrent+9]=this.st_2
this.Control[iCurrent+10]=this.cbx_select_page
this.Control[iCurrent+11]=this.cb_mdfmxrp
this.Control[iCurrent+12]=this.st_3
this.Control[iCurrent+13]=this.st_4
this.Control[iCurrent+14]=this.cb_1
this.Control[iCurrent+15]=this.lb_1
this.Control[iCurrent+16]=this.cbx_ifprint_xj
this.Control[iCurrent+17]=this.cbx_ifprint_hj
this.Control[iCurrent+18]=this.st_dataobject
this.Control[iCurrent+19]=this.sle_dw
this.Control[iCurrent+20]=this.p_1
this.Control[iCurrent+21]=this.ln_bar
this.Control[iCurrent+22]=this.ln_bar2
this.Control[iCurrent+23]=this.r_bar
this.Control[iCurrent+24]=this.ln_1
this.Control[iCurrent+25]=this.ln_2
end on

on w_publ_preview.destroy
call super::destroy
destroy(this.cb_refresh)
destroy(this.st_1)
destroy(this.cb_savestyle)
destroy(this.cb_3)
destroy(this.ddlb_1)
destroy(this.dw_1)
destroy(this.ddlb_printerlist)
destroy(this.em_1)
destroy(this.st_2)
destroy(this.cbx_select_page)
destroy(this.cb_mdfmxrp)
destroy(this.st_3)
destroy(this.st_4)
destroy(this.cb_1)
destroy(this.lb_1)
destroy(this.cbx_ifprint_xj)
destroy(this.cbx_ifprint_hj)
destroy(this.st_dataobject)
destroy(this.sle_dw)
destroy(this.p_1)
destroy(this.ln_bar)
destroy(this.ln_bar2)
destroy(this.r_bar)
destroy(this.ln_1)
destroy(this.ln_2)
end on

event open;call super::open;//初始化打印机
wf_initprinterinfo()
///////////////////////
String errmsg
fact_print_msg = Message.PowerObjectParm
dw_1.DataObject = fact_print_msg.obj_dwname

sle_dw.text = fact_print_msg.obj_dwname

st_1.Text = fact_print_msg.tag_text
IF fact_print_msg.printrow = 0  THEN
	em_1.Enabled = TRUE
	em_1.Text = f_ProfileString (sys_empid,dw_1.DataObject, "printrow", '10')
	fact_print_msg.printrow = Long(em_1.Text)
ELSE
	em_1.Enabled = FALSE
	em_1.Text = String(fact_print_msg.printrow)
END IF


IF f_ProfileString (sys_empid,dw_1.DataObject, "cbx_ifprint_xj", '1') = '1' THEN
	cbx_ifprint_xj.Checked = True
ELSE
	cbx_ifprint_xj.Checked = False
END IF

IF f_ProfileString (sys_empid,dw_1.DataObject, "cbx_ifprint_hj", '1') = '1' THEN
	cbx_ifprint_hj.Checked = True
ELSE
	cbx_ifprint_hj.Checked = False
END IF

retrieveid = fact_print_msg.retr_pramnmb
retrievestr =  fact_print_msg.retr_pramstr

//********************

//设置打印，发送权限
if fact_print_msg.sendout_flag = 0 then 
	if_power_sendout = false // f_power_ind(1413,sys_msg_pow) //通用权限
else
	if_power_sendout = fact_print_msg.if_power_sendout
end if
if_power_print = true

//====================================================================
// script - w_publ_preview inherited from w_publ_base for open 
// reason: 
//--------------------------------------------------------------------
// modified by: yyx		date: 2004.05.09
//--------------------------------------------------------------------
IF fact_print_msg.obj_dwname = 'dw_rp_mtrlprocode_lsx' OR fact_print_msg.obj_dwname = 'dw_rp_mtrlprocode_lsx_mg' THEN
	cbx_select_page.Checked = TRUE
ELSE
	cbx_select_page.Checked = FALSE
END IF
//====================================================================

try

dw_1.SetTransObject(sqlca)
IF wf_trycreate_sys_dwnsyntax(errmsg) = 0 THEN
	MessageBox('系统提示',errmsg)
END IF

IF fact_print_msg.share_dw_title <> '' THEN
	dw_1.Object.rp_title.text = fact_print_msg.share_dw_title
END IF

wf_defdataobject()

dw_retrieve()



IF wf_read_subdwpos(default_dwname,default_dname,s_xwidth,errmsg) = 0 THEN
	MessageBox('系统信息',errmsg)
ELSE
	wf_mdfmxreport(s_xwidth)
END IF

dw_1.SetRedraw(FALSE)
//IF NOT IsNull(fact_print_msg.ini_group) AND Trim(dw_1.DataObject) <> '' THEN
//	dw_1.Object.datawindow.Print.margin.Top = Integer(f_ProfileString(sys_empid,dw_1.DataObject + st_4.text, "margin_top",   "110"))
//	dw_1.Object.datawindow.Print.margin.Left = Integer(f_ProfileString(sys_empid,dw_1.DataObject + st_4.text, "margin_left", "96" ))
//	
//	dw_1.Object.datawindow.Print.margin.bottom = Integer(f_ProfileString(sys_empid,dw_1.DataObject + st_4.text, "margin_bottom",   "110"))
//	dw_1.Object.datawindow.Print.margin.Right = Integer(f_ProfileString(sys_empid,dw_1.DataObject + st_4.text, "margin_right", "96" ))
//	
//	dw_1.Object.datawindow.Print.paper.size = Integer(f_ProfileString(sys_empid,dw_1.DataObject + st_4.text, "paper_size",   "0"  ))
//	dw_1.Object.datawindow.Print.orientation = Integer(f_ProfileString(sys_empid,dw_1.DataObject + st_4.text, "orientation", "0"  ))
//	
//	dw_default_printer  = f_ProfileString(sys_empid,dw_1.DataObject + st_4.text, "dw_default_printer ", ""  )
//	IF dw_default_printer = '' THEN
//		ddlb_printerlist.Text = default_printer
//	ELSE
//		ddlb_printerlist.Text = dw_default_printer
//	END IF
//END IF
dw_1.SetRedraw(TRUE)


dw_1.Object.datawindow.Print.Preview = 'yes'
dw_1.Object.datawindow.Print.Preview.rulers = "yes"

IF NOT dw_1.Describe('mxreport.type') = 'report' OR retrieveid = 0 AND retrievestr = '' THEN  cb_mdfmxrp.Enabled = FALSE //检查是否存在名为mxreport的report没有则此功能不可以用

	
Catch( runtimeerror err)
	MessageBox('错误',err.Text)
END TRY


///read ini
//if cb_mdfmxrp.enabled then
//	wf_readini_begin()
//end if
///


/*
使用调整子dw的列宽及序列功能的约定：
1.明细内嵌dw的名称必须为'mxreport'
2.mxreport的retrieve参数必须为主dw的第一列值,必须是一个,且必须是long
3.mxreport必须是grid
4.显示的列必须都是selete列,不可以是dw计算列
5.一般(14cm宽打印纸)mxreport.width=3287
6.mxreport中的计算列必须命名为(最多支持三个):cmpl1,cmpl2,cmpl3
*/


//dw_1.modify('title.text="'+trim(fact_print_msg.tag_text)+'"')
//dw_1.object.datawindow.print.preview.zoom	= 100

/*structure: s_print_msg
obj_dwname: retrieve datawindow 名称
share_dw  : 目标 share datawindow 名称
retr_pram_falg :int 参数传递形式
	case 0 //share datawindow
	datawindow ls_dw
	ls_dw=fact_print_msg.share_dw
	ls_dw.sharedata(dw_1)
	case 1 //one string pram
	dw_1.retrieve(fact_print_msg.retr_pramstr)
	case 2 //one number pram
	dw_1.retrieve(fact_print_msg.retr_pramnmb)
	case 3 //one date pram
	dw_1.retrieve(fact_print_msg.retr_pramfd)
	case 4 //two date pram
	dw_1.retrieve(fact_print_msg.retr_pramfd,fact_print_msg.retr_pramed)
	case else
	dw_1.retrieve()
	
retr_pramstr
retr_pramnmb
retr_pramfd
retr_pramed

tag_text
filter_string  : filter 表达式
title  :datawindow title
titleobjectname :datawindow title
setup_flag  :0- printsetup enabled 1- printsetup disabled
pagech_flag : 1 打印时提示选页打印
ini_group   : 存取普通打印设置的系统 ini 文件组名,为空时不存取
*/


end event

event resize;dw_1.setredraw(false)

ln_bar.endx = this.width
ln_bar2.endx = this.width

ln_1.endx = this.width
ln_2.endx = this.width
r_bar.width = this.width

DW_1.WIDTH=THIS.WIDTH - DW_1.X - 40
DW_1.HEIGHT=THIS.HEIGHT - DW_1.Y - 150

dw_1.setredraw(true)

end event

event activate;try
dw_1.object.DataWindow.Print.Preview = 'yes'

	
Catch( runtimeerror err)
close(this)
//	MessageBox('错误',err.Text)
END TRY

end event

event close;call super::close;wf_clear_temp()
closewithreturn(this,rslt_printnum)
end event

type cb_func from w_publ_base`cb_func within w_publ_preview
boolean visible = false
integer x = 155
integer y = 452
integer width = 265
integer height = 92
boolean enabled = false
end type

type cb_exit from w_publ_base`cb_exit within w_publ_preview
integer x = 709
integer width = 151
integer height = 164
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

type cb_refresh from uo_imflatbutton within w_publ_preview
integer width = 151
integer height = 164
integer taborder = 110
string text = "刷新"
string normalpicname = "refresh.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;f_SetProfileString (sys_empid,dw_1.DataObject, "printrow", em_1.text)
fact_print_msg.printrow = Long(em_1.Text)
dw_retrieve()

String errmsg
IF wf_read_subdwpos(default_dwname,default_dname,s_xwidth,errmsg) = 0 THEN
	MessageBox('系统信息',errmsg)
ELSE
	wf_mdfmxreport(s_xwidth)
END IF
dw_1.SetRedraw(TRUE)








end event

type st_1 from statictext within w_publ_preview
integer x = 928
integer y = 12
integer width = 1120
integer height = 60
integer textsize = -9
integer weight = 700
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long backcolor = 134217739
string text = "标题"
boolean focusrectangle = false
end type

event constructor;this.backcolor = 14215660
end event

type cb_savestyle from uo_imflatbutton within w_publ_preview
integer x = 302
integer width = 256
integer height = 164
integer taborder = 120
string text = "单据格式"
string normalpicname = "other.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;m_publ_preview_dnset m_dnset
m_dnset = CREATE m_publ_preview_dnset
IF NOT dw_1.Describe('mxreport.type') = 'report' or retrieveid = 0 and retrievestr = ''  THEN  m_dnset.m_main.m_mxd.Enabled = FALSE //检查是否存在名为mxreport的report没有则此功能不可以用
m_dnset.m_main.PopMenu(THIS.X+50,THIS.Y+50)

end event

type cb_3 from uo_imflatbutton within w_publ_preview
integer x = 151
integer width = 151
integer height = 164
integer taborder = 110
string text = "功能"
string normalpicname = "setting.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;m_publ_preview_func m_func
m_func=create m_publ_preview_func
m_func.m_0.popmenu(this.x+50,this.y+50)
end event

type ddlb_1 from dropdownlistbox within w_publ_preview
integer x = 411
integer y = 184
integer width = 283
integer height = 632
integer taborder = 100
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
string text = "适当大小"
boolean vscrollbar = true
string item[] = {"100%","150%","200%","75%","50%","25%"}
borderstyle borderstyle = stylelowered!
end type

event selectionchanged;dw_1.Object.DataWindow.Print.Preview.Zoom	= INTEGER(LEFT(TRIM(this.text),LEN(TRIM(this.text)) - 1))

dw_1.object.DataWindow.Print.Preview = 'yes'

end event

event constructor;if THIS.TotalItems ( )>=1 then THIS.SelectItem(1)
end event

type dw_1 from datawindow within w_publ_preview
integer y = 292
integer width = 2848
integer height = 1284
integer taborder = 90
boolean bringtotop = true
string dataobject = "dw_uptown_report"
boolean hscrollbar = true
boolean vscrollbar = true
boolean hsplitscroll = true
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

event rbuttondown;//if not f_power_ind(666,sys_msg_pow) THEN
//	MessageBox(publ_operator,sys_msg_pow)
	RETURN
//END IF


if LOWER(LEFT(dwo.type,4))='text'  then
 s_inputbox S_SREU
 STRING LS_STR,column_name
 S_SREU.TITLE='目前标题为: '+dwo.TEXT+' 。请输入新标题: '
 S_SREU.OLD_TEXT=dwo.TEXT
 column_name=DWO.NAME

	openwithparm(w_inputbox,S_SREU)
	LS_STR=Message.StringParm
	if trim(LS_STR)<>'' AND dwo.TEXT<>LS_STR then
 		THIS.Modify(column_name+'.text="'+LS_STR+'"')
	END IF

end if

//if string(dwo.type)='report' then
//	messagebox('report',string(DWO.NAME))
//string str_mdf='',str_mdf_width='',str_mdf_x='',str_ls=''
//int ls_i,ls_clmno,ls_rslt
//
////ins_dwcld=create DataWindowChild
//ls_rslt=dw_1.getchild(string(DWO.NAME),ins_dwcld)
//messagebox('',string(ls_rslt))
//	if ls_rslt =1 then 
//		ls_clmno=integer(ins_dwcld.Describe('DataWindow.Column.Count'))
//		messagebox('DataWindow.Column.Count',string(ls_clmno))
//		//integer(ins_dwcld.Object.DataWindow.Column.Count)
//		for ls_i=1 to ls_clmno
//			str_ls= '#'+string(ls_i)+'.width='+ins_dwcld.Describe('#'+string(ls_i)+'.width')
//			str_mdf_width=str_mdf_width+'~n'+str_ls
//			
//			str_ls= '#'+string(ls_i)+'.x='+ins_dwcld.Describe('#'+string(ls_i)+'.x')
//			str_mdf_x=str_mdf_x+'~n'+str_ls
//
//		next
//		str_mdf=str_mdf_width+'~n'+str_mdf_x
//		
//		messagebox('str_mdf',str_mdf)
//	end if
//end if
//
////1.取子dw，及类型，是grid则处理
////2.取dataobject,
////3.弹出窗口,设dataobject,sharedata
////4.记录语句descrp(列宽,列系列)
////5.修改原子dw(Modify)
////
////
end event

event doubleclicked;//IF f_power_ind(666,sys_msg_pow) AND NOT sys_power_issuper THEN
//	MessageBox(publ_operator,sys_msg_pow)
	RETURN
////END IF
//
//IF dwo.TYPE = 'datawindow' THEN RETURN
//IF dwo.TYPE = 'line' THEN RETURN
//
//s_preview_dwoprp_tran S_SREU
//S_SREU.yn = 0
//S_SREU.X = Integer(dwo.X)
//S_SREU.Y = Integer(dwo.Y)
//S_SREU.Width = Integer(dwo.Width)
//S_SREU.Height = Integer(dwo.Height)
//
//S_SREU.dwotype = dwo.TYPE
//S_SREU.dwoname = dwo.Name
//
//IF Lower(Left(dwo.TYPE,4)) = 'text'  THEN
//	S_SREU.dwotext = dwo.Text
//ELSE
//	S_SREU.dwotext = ''
//END IF
//
//OpenWithParm(w_publ_preview_setdwoprp,S_SREU)
//S_SREU = Message.PowerObjectParm
//IF S_SREU.yn = 1 THEN
//	dwo.X = S_SREU.X
//	dwo.Y = S_SREU.Y
//	dwo.Width = S_SREU.Width
//	dwo.Height = S_SREU.Height
//	
//	IF Lower(Left(dwo.TYPE,4)) = 'text' THEN
//		
//		THIS.Modify(dwo.Name+'.text="'+S_SREU.dwotext+'"')
//		//		dwo.TEXT=S_SREU.dwotext
//		
//	END IF
//END IF



end event

type ddlb_printerlist from dropdownlistbox within w_publ_preview
integer x = 1088
integer y = 184
integer width = 1376
integer height = 1380
integer taborder = 110
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean autohscroll = true
boolean vscrollbar = true
borderstyle borderstyle = stylelowered!
end type

type em_1 from editmask within w_publ_preview
integer x = 256
integer y = 184
integer width = 151
integer height = 92
integer taborder = 120
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
alignment alignment = right!
borderstyle borderstyle = stylelowered!
string mask = "######"
end type

event constructor;//messagebox("",ProfileString (sys_inifilename,dw_1.DATAOBJECT, "printrow", '18'))
//
//this.text=ProfileString (sys_inifilename,dw_1.DATAOBJECT, "printrow", '18')

//cb_6.triggerevent(clicked!)

end event

event modified;if long(trim(em_1.text))<=2 then
	em_1.text='2'
end if

f_SetProfileString (sys_empid,dw_1.DATAOBJECT, "printrow", trim(em_1.text))
end event

type st_2 from statictext within w_publ_preview
integer x = 5
integer y = 204
integer width = 238
integer height = 52
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
boolean enabled = false
string text = "每页行数"
alignment alignment = right!
boolean focusrectangle = false
end type

type cbx_select_page from checkbox within w_publ_preview
integer x = 718
integer y = 192
integer width = 343
integer height = 72
boolean bringtotop = true
integer textsize = -9
integer weight = 700
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 16711680
long backcolor = 134217739
string text = "选页打印"
end type

type cb_mdfmxrp from commandbutton within w_publ_preview
boolean visible = false
integer x = 421
integer y = 456
integer width = 379
integer height = 92
integer taborder = 40
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "明细网格调整"
end type

event clicked;//dwod=dw_1.object.mxreport
//
//s_mdfxwidth_tran  s_mdfxw_tran
//s_mdfxw_tran.retrievetype = fact_print_msg.retr_pram_falg
//s_mdfxw_tran.retrieveid=retrieveid
/////////////yyx0821
//if em_1.enabled then
//	secondretrieveid=long(em_1.text)
//else
//	secondretrieveid = sys_scid
//end if
/////////////
//s_mdfxw_tran.secondretrieveid=secondretrieveid
//s_mdfxw_tran.retrievestr=fact_print_msg.retr_pramstr
//s_mdfxw_tran.dataobject=dwod.dataobject
//
//openwithparm(w_publ_preview_mdfcrptxwidth,s_mdfxw_tran)
//
//
//s_xwidth=message.powerobjectparm	
////write ini
////wf_write_childdw_pos(s_mdfxw_tran.dataobject,s_xwidth)
////
//wf_mdfmxreport(s_xwidth)
//
//
//



end event

type st_3 from statictext within w_publ_preview
integer x = 2075
integer y = 12
integer width = 288
integer height = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
boolean enabled = false
string text = "单据格式："
boolean focusrectangle = false
end type

event constructor;this.backcolor = 14215660
end event

type st_4 from statictext within w_publ_preview
integer x = 2368
integer y = 12
integer width = 677
integer height = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
boolean enabled = false
boolean focusrectangle = false
end type

event constructor;this.backcolor = 14215660
end event

type cb_1 from uo_imflatbutton within w_publ_preview
integer x = 558
integer width = 151
integer height = 164
integer taborder = 130
boolean bringtotop = true
string text = "打印"
boolean default = true
string normalpicname = "print.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;IF cbx_select_page.Checked THEN
	dw_default_printer = ddlb_printerlist.Text
	
	IF dw_default_printer = '' THEN
		MessageBox('提示','请选择打印机')
		RETURN
	END IF
	
	lnv_printer.of_setdefault ( dw_default_printer )
	OpenWithParm(w_sys_printpagesetting,dw_1)
	wf_setdefaultprinter()
ELSE
	dw_default_printer = ddlb_printerlist.Text
	
	IF dw_default_printer = '' THEN
		MessageBox('提示','请选择打印机')
		RETURN
	END IF
	
	lnv_printer.of_setdefault ( dw_default_printer )
	dw_1.Print()
	wf_setdefaultprinter()
END IF


IF IsNull(fact_print_msg.ini_group) OR Trim(dw_1.DataObject) = '' THEN RETURN

uo_string lo_str
string ls_dwname

lo_str = create uo_string
ls_dwname = dw_1.DataObject + st_4.text

ls_dwname = lo_str.uof_replace(ls_dwname, '[', '')
ls_dwname = lo_str.uof_replace(ls_dwname, ']', '')

f_SetProfileString (sys_empid,ls_dwname, "margin_top",   String(dw_1.Object.datawindow.Print.margin.Top))
f_SetProfileString (sys_empid,ls_dwname, "margin_left", String(dw_1.Object.datawindow.Print.margin.Left))

f_SetProfileString (sys_empid,ls_dwname, "margin_bottom",   String(dw_1.Object.datawindow.Print.margin.bottom))
f_SetProfileString (sys_empid,ls_dwname, "margin_right", String(dw_1.Object.datawindow.Print.margin.Right))

f_SetProfileString (sys_empid,ls_dwname, "paper_size",  String(dw_1.Object.datawindow.Print.paper.size) )
f_SetProfileString (sys_empid,ls_dwname, "orientation", String(dw_1.Object.datawindow.Print.orientation))

f_SetProfileString(sys_empid,ls_dwname, "dw_default_printer ", dw_default_printer   )

destroy lo_str

rslt_printnum++

IF fact_print_msg.obj_dwname = 'dw_rp_order_ml_lsx' OR fact_print_msg.obj_dwname = 'dw_rp_order_ml_lsx_mg' THEN
ELSE
	cb_exit.TriggerEvent(Clicked!)
END IF




end event

type lb_1 from listbox within w_publ_preview
boolean visible = false
integer x = 2766
integer y = 192
integer width = 549
integer height = 452
integer taborder = 20
boolean bringtotop = true
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
borderstyle borderstyle = stylelowered!
end type

type cbx_ifprint_xj from checkbox within w_publ_preview
integer x = 2510
integer y = 200
integer width = 411
integer height = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
string text = "每页有小计行"
end type

event clicked;Int li_cbx_ifprint_xj
IF Checked THEN
	li_cbx_ifprint_xj = 1
ELSE
	li_cbx_ifprint_xj = 0
END IF

f_SetProfileString (sys_empid,dw_1.DataObject,"cbx_ifprint_xj",String(li_cbx_ifprint_xj))


end event

type cbx_ifprint_hj from checkbox within w_publ_preview
integer x = 2949
integer y = 200
integer width = 411
integer height = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
string text = "最后有合计行"
end type

event clicked;Int li_cbx_ifprint_hj
IF Checked THEN
	li_cbx_ifprint_hj = 1
ELSE
	li_cbx_ifprint_hj = 0
END IF

f_SetProfileString (sys_empid,dw_1.DataObject,"cbx_ifprint_hj",String(li_cbx_ifprint_hj))


end event

type st_dataobject from statictext within w_publ_preview
integer x = 891
integer y = 100
integer width = 471
integer height = 56
boolean bringtotop = true
integer textsize = -9
integer weight = 700
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long backcolor = 134217739
string text = "Datawindow名称:"
alignment alignment = right!
boolean focusrectangle = false
end type

event constructor;if not sys_power_issuper then this.visible = false

this.backcolor = 14215660
end event

type sle_dw from singlelineedit within w_publ_preview
integer x = 1358
integer y = 80
integer width = 1129
integer height = 84
integer taborder = 20
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean displayonly = true
borderstyle borderstyle = stylelowered!
end type

event constructor;if not sys_power_issuper then this.visible = false

end event

type p_1 from picture within w_publ_preview
boolean visible = false
integer x = 2958
integer y = 552
integer width = 375
integer height = 192
boolean bringtotop = true
boolean originalsize = true
boolean focusrectangle = false
end type

type ln_bar from line within w_publ_preview
long linecolor = 268435456
integer linethickness = 4
integer beginy = 172
integer endx = 2007
integer endy = 172
end type

type ln_bar2 from line within w_publ_preview
long linecolor = 16777215
integer linethickness = 4
integer beginy = 176
integer endx = 2039
integer endy = 176
end type

type r_bar from rectangle within w_publ_preview
long linecolor = 16777215
integer linethickness = 4
long fillcolor = 1073741824
integer x = 2711
integer y = 12
integer width = 146
integer height = 68
end type

event constructor;this.fillcolor = 14215660
this.linecolor = 14215660
this.x = -1
this.y = -1
this.height = ln_bar.beginy - 5

end event

type ln_1 from line within w_publ_preview
long linecolor = 268435456
integer linethickness = 4
integer beginy = 284
integer endx = 2016
integer endy = 284
end type

type ln_2 from line within w_publ_preview
long linecolor = 16777215
integer linethickness = 4
integer beginy = 288
integer endx = 2048
integer endy = 288
end type

