$PBExportHeader$w_publ_preview_billformatset.srw
forward
global type w_publ_preview_billformatset from w_publ_base
end type
type cb_open from uo_imflatbutton within w_publ_preview_billformatset
end type
type cb_1 from uo_imflatbutton within w_publ_preview_billformatset
end type
type cb_def from uo_imflatbutton within w_publ_preview_billformatset
end type
type cb_del from uo_imflatbutton within w_publ_preview_billformatset
end type
type dw_formatlist from datawindow within w_publ_preview_billformatset
end type
type sle_name from singlelineedit within w_publ_preview_billformatset
end type
type st_1 from statictext within w_publ_preview_billformatset
end type
type sle_1 from singlelineedit within w_publ_preview_billformatset
end type
type st_2 from statictext within w_publ_preview_billformatset
end type
type cb_2 from uo_imflatbutton within w_publ_preview_billformatset
end type
type cb_3 from uo_imflatbutton within w_publ_preview_billformatset
end type
type dw_1 from datawindow within w_publ_preview_billformatset
end type
type gb_1 from groupbox within w_publ_preview_billformatset
end type
end forward

global type w_publ_preview_billformatset from w_publ_base
integer width = 1769
integer height = 1172
string title = "单据格式"
boolean minbox = false
windowtype windowtype = response!
cb_open cb_open
cb_1 cb_1
cb_def cb_def
cb_del cb_del
dw_formatlist dw_formatlist
sle_name sle_name
st_1 st_1
sle_1 sle_1
st_2 st_2
cb_2 cb_2
cb_3 cb_3
dw_1 dw_1
gb_1 gb_1
end type
global w_publ_preview_billformatset w_publ_preview_billformatset

type variables
s_preview_billformatset_tran s_billformat
long defpos=0
boolean editmode=false,editname=false


end variables

forward prototypes
public subroutine wf_addformat (dropdownlistbox ddlb, string dwname)
public function integer wf_checkname (ref string arg_msg)
public subroutine wf_facechange ()
public subroutine wf_finddef ()
public function integer wf_readsubdwpos_blob (string dwname, string dname, blob dwpos)
public subroutine wf_setmode (datawindow dw, integer mode)
public function integer wf_retrieveformatlist (string dwname)
public function integer wf_sendprintout (integer arg_type, integer arg_default_flag, string arg_dwname, string arg_dname, string arg_dwsyntax, ref string arg_msg)
public function integer wf_getfilecontent (string arg_filename, ref string arg_content, ref string arg_msg)
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)
public subroutine wf_findformat (string arg_dname)
end prototypes

public subroutine wf_addformat (dropdownlistbox ddlb, string dwname);string formatname
int defflag
int ls_defpos=0
Declare getbillformat cursor for 
select dname,default_flag from sys_dwnSyntax where dwname=:dwname ;
open getbillformat;
Do While sqlca.sqlcode=0
	Fetch getbillformat into :formatname,:defflag;
	if sqlca.sqlcode<>0 then exit;
	ddlb.additem(formatname)
	ls_defpos++
	if defflag=1 then 
		defpos=ls_defpos
		
	end if
loop
Close getbillformat;
end subroutine

public function integer wf_checkname (ref string arg_msg);long findrow
if trim(dw_formatlist.object.dname[dw_formatlist.getrow()])=''  then
		arg_msg='格式名不能空！'
		return 0
end if

findrow=dw_formatlist.find("dwname='"+trim(dw_formatlist.object.dname[dw_formatlist.getrow()])+"'",1,dw_formatlist.rowcount())
messagebox('',findrow)
if findrow>0 then
	arg_msg='格式名称重复！'
	return 0
end if

return 1

end function

public subroutine wf_facechange ();cb_open.enabled= not editmode
cb_del.enabled= not  editmode
cb_def.enabled= not editmode
cb_def.enabled= not editmode

end subroutine

public subroutine wf_finddef ();long findrow,currow
if  dw_formatlist.rowcount()=1  then 	
 	 dw_formatlist.selectrow(0,false)
 	 dw_formatlist.selectrow(1,true)
  	 dw_formatlist.SETROW(1)
	 dw_formatlist.ScrollToRow (1)
	 dw_formatlist.object.default_flag[1]=1
	 return
end if
//findrow=dw_formatlist.find("dname='"+s_billformat.dname+"'",2,dw_formatlist.rowcount())
//if findrow=0  then
//	dw_formatlist.selectrow(0,false)
//	dw_formatlist.selectrow(1,true)
//	dw_formatlist.SETROW(1)
//	dw_formatlist.ScrollToRow (1)
//	dw_formatlist.object.default_flag[1]=1
//else
	findrow=dw_formatlist.find("default_flag=1",1,dw_formatlist.rowcount())
	if findrow>0 then  
		dw_formatlist.object.default_flag[findrow]=1
		currow=findrow
	else
		dw_formatlist.object.default_flag[1]=1
		currow=1
	end if
	dw_formatlist.selectrow(0,false)
	dw_formatlist.selectrow(currow,true)
	dw_formatlist.SETROW(currow)
	dw_formatlist.ScrollToRow (currow)
//end if
sle_name.text=s_billformat.dname
end subroutine

public function integer wf_readsubdwpos_blob (string dwname, string dname, blob dwpos);blob subdwpos
select subdwSyntaxB into :subdwpos from sys_dwnSyntax where dwname=:dwname and dname=:dname;
if sqlca.sqlcode=-1 then
	Messagebox('系统信息','读取明细格式失败!'+sqlca.sqlerrtext)
	return 0
end if

return 1
end function

public subroutine wf_setmode (datawindow dw, integer mode);dw.SetTabOrder('dname',mode*10)
//dw.SetTabOrder('default_flag',mode*20)
end subroutine

public function integer wf_retrieveformatlist (string dwname);integer rslt,i
oleobject request,response,list,item
string arg_msg

arg_msg= ''

request = FXAppCom.CreatePbDictionary()
request.SetString("token",app_token_fx)
request.SetString("dwname",dwname)

response = FXAppCom.DoExecute("GetPrintOutList", request)
arg_msg = response.GetString('ErrMsg')
if (arg_msg <> '') then
       rslt = 0
       MessageBox('提示', '获取打印格式列表有误:' + arg_msg)
       goto ext
end if
list = response.getpbarray("printoutList")

dw_formatlist.reset()
dw_formatlist.SetRedraw(false)
Long defaultRow
defaultRow = dw_formatlist.insertrow(1)
dw_formatlist.object.dwname[defaultRow] = '标准格式'
dw_formatlist.object.dname[defaultRow] = '标准格式'
dw_formatlist.Object.default_flag[defaultRow] = 1

Long currow
Int default_flag
for i = 1 to list.Count
    item = list.getpbdictionary(i - 1)
    currow = dw_formatlist.insertrow(-1)    
    dw_formatlist.Object.dname[currow] = item.getstring("aliase")
    default_flag = item.getint("default_flag")
    dw_formatlist.Object.default_flag[currow] = default_flag
    IF default_flag = 1 THEN
        dw_formatlist.Object.default_flag[defaultRow] = 0
    END IF
    dw_formatlist.Object.cuscomid[currow] = item.getint("cuscomid")
    dw_formatlist.Object.cussimplename[currow] = item.getstring("cussimplename")
next
dw_formatlist.SetRedraw(true)

ext:
return rslt
end function

public function integer wf_sendprintout (integer arg_type, integer arg_default_flag, string arg_dwname, string arg_dname, string arg_dwsyntax, ref string arg_msg);s_edit_index_tran s_rslt

IF app_iferpuser = 1 THEN
	Open(w_company_ch_mutil)
	s_rslt = Message.PowerObjectParm

	IF s_rslt.b_long <> 1 THEN
		arg_msg = 'CANCLE'
		goto ext
	END IF

END IF


oleobject request,response,list
integer rslt
rslt = 0

request = FXAppCom.CreatePbDictionary()
request.SetString("token",app_token_fx)
request.SetString("dwname",arg_dwname)
request.SetString("aliase",arg_dname)
request.SetString("dwSyntax",arg_dwSyntax)
request.SetInt("type",arg_type)
request.SetInt("default_flag",arg_default_flag)

long i
IF app_iferpuser = 1 THEN
	list = FXAppCom.newpbarray()
	FOR i = 1 TO UPPERBOUND(s_rslt.arr_long)
		list.addint(s_rslt.arr_long[i])
	NEXT
	request.setobject("SptcomidList", list)
END IF


response = FXAppCom.DoExecute("SavePrintOut", request)
arg_msg = response.GetString('ErrMsg')
if (arg_msg <> '') then
	rslt = 0
	MessageBox('提示', '保存打印格式列表失败:' + arg_msg)
	goto ext
end if

ext:
return 0
end function

public function integer wf_getfilecontent (string arg_filename, ref string arg_content, ref string arg_msg);integer rslt,position
rslt = 0
blob arg_b

rslt = f_filetoblob(arg_filename,arg_b,arg_msg)
arg_content = string(arg_b)

//rslt = f_filetostring(arg_filename,arg_content,arg_msg)

position = pos(arg_content,"~n")
arg_content = right(arg_content,len(arg_content) - position)
return rslt
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)

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

public subroutine wf_findformat (string arg_dname);long findrow,currow
if  dw_formatlist.rowcount()=1 or trim(arg_dname) = ""  then 	
	wf_finddef()
	return
end if
//findrow=dw_formatlist.find("dname='"+s_billformat.dname+"'",2,dw_formatlist.rowcount())
//if findrow=0  then
//	dw_formatlist.selectrow(0,false)
//	dw_formatlist.selectrow(1,true)
//	dw_formatlist.SETROW(1)
//	dw_formatlist.ScrollToRow (1)
//	dw_formatlist.object.default_flag[1]=1
//else
	findrow=dw_formatlist.find("dname='"+arg_dname+"'",1,dw_formatlist.rowcount())
	if findrow>0 then  
		currow=findrow
	else
		wf_finddef()
		return
	end if
	dw_formatlist.selectrow(0,false)
	dw_formatlist.selectrow(currow,true)
	dw_formatlist.SETROW(currow)
	dw_formatlist.ScrollToRow (currow)
//end if
sle_name.text=arg_dname
end subroutine

on w_publ_preview_billformatset.create
int iCurrent
call super::create
this.cb_open=create cb_open
this.cb_1=create cb_1
this.cb_def=create cb_def
this.cb_del=create cb_del
this.dw_formatlist=create dw_formatlist
this.sle_name=create sle_name
this.st_1=create st_1
this.sle_1=create sle_1
this.st_2=create st_2
this.cb_2=create cb_2
this.cb_3=create cb_3
this.dw_1=create dw_1
this.gb_1=create gb_1
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.cb_open
this.Control[iCurrent+2]=this.cb_1
this.Control[iCurrent+3]=this.cb_def
this.Control[iCurrent+4]=this.cb_del
this.Control[iCurrent+5]=this.dw_formatlist
this.Control[iCurrent+6]=this.sle_name
this.Control[iCurrent+7]=this.st_1
this.Control[iCurrent+8]=this.sle_1
this.Control[iCurrent+9]=this.st_2
this.Control[iCurrent+10]=this.cb_2
this.Control[iCurrent+11]=this.cb_3
this.Control[iCurrent+12]=this.dw_1
this.Control[iCurrent+13]=this.gb_1
end on

on w_publ_preview_billformatset.destroy
call super::destroy
destroy(this.cb_open)
destroy(this.cb_1)
destroy(this.cb_def)
destroy(this.cb_del)
destroy(this.dw_formatlist)
destroy(this.sle_name)
destroy(this.st_1)
destroy(this.sle_1)
destroy(this.st_2)
destroy(this.cb_2)
destroy(this.cb_3)
destroy(this.dw_1)
destroy(this.gb_1)
end on

event open;call super::open;Long currow,findrow

s_billformat = Message.PowerObjectParm
//dw_formatlist.SetTransObject(sqlca)
//dw_formatlist.Retrieve(s_billformat.dwname)
wf_retrieveformatlist(s_billformat.dwname)
wf_findformat(s_billformat.dname)
sle_name.SetFocus()
sle_name.SelectText(1, Len(sle_name.Text))

end event

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

type cb_func from w_publ_base`cb_func within w_publ_preview_billformatset
boolean visible = false
integer x = 1207
integer y = 912
integer width = 146
integer height = 92
boolean enabled = false
end type

type cb_exit from w_publ_base`cb_exit within w_publ_preview_billformatset
integer x = 1458
integer y = 976
integer width = 274
integer height = 92
end type

type cb_open from uo_imflatbutton within w_publ_preview_billformatset
integer x = 23
integer y = 976
integer width = 274
integer height = 92
integer taborder = 50
string text = "打开格式"
end type

event clicked;call super::clicked;if dw_formatlist.getrow()<=0 then
	messagebox('系统提示','没有可打开的格式!')
	return
end if

s_billformat.dname=dw_formatlist.object.dname[dw_formatlist.getrow()]
cb_exit.triggerevent(clicked!)

end event

type cb_1 from uo_imflatbutton within w_publ_preview_billformatset
integer x = 325
integer y = 976
integer width = 274
integer height = 92
integer taborder = 50
string text = "保存格式"
end type

event clicked;call super::clicked;long findrow,currow,defflag,updaterow
string dwname,dname,errmsg,dwsyntax
if trim(sle_name.text) = '' then
	messagebox('系统信息','格式名不能为空！')
	return
end if
findrow = dw_formatlist.find("dname='"+trim(sle_name.text)+"'",1,dw_formatlist.rowcount())
	if Trim(sle_1.text) = "" then
		messagebox('系统信息','请先选择格式文件！')
		cb_2.setfocus()
		return
	end if
wf_getfilecontent(sle_1.text,dwsyntax, errmsg)

if findrow = 0 then	
	if Trim(dwsyntax) = "" then
		messagebox('系统信息','请先选择格式文件！')
		cb_2.setfocus()
		return
	end if
	dwname = s_billformat.dwname
	dname = sle_name.text
	defflag = 0
	//新增
	wf_sendprintout(1, defflag,dwname, dname, dwsyntax, ref errmsg)
	IF errmsg = 'CANCEL' THEN RETURN
//	insert into sys_dwnsyntax (dwname,dname,default_flag) values (:dwname,:dname,:defflag);
//	if sqlca.sqlcode = -1 then
//		errmsg = sqlca.sqlerrtext
//		rollback;
//		messagebox('系统提示','保存格式名称出错！'+errmsg)
//		return
//	end if
//	commit;
else
	if dw_formatlist.getrow() = 1 then
		messagebox('系统信息','不能保存到标准格式！')
		return
	end if
	if Trim(dwsyntax) = "" then
		messagebox('系统信息','请先选择格式文件！')
		cb_2.setfocus()
		return
	end if
	if messagebox ("全部","是否确定要覆盖当前单式吗?",question!,yesno! ) = 2 then return
	dwname = s_billformat.dwname
	dname = dw_formatlist.object.dname[dw_formatlist.getrow()]
	defflag = 0
	//保存
	wf_sendprintout(2, defflag,dwname, dname, dwsyntax, ref errmsg)
	IF errmsg = 'CANCEL' THEN RETURN
end if
//updateblob sys_dwnsyntax set  dwsyntaxb = :s_billformat.dwsyntaxb   where dwname = :dwname and dname = :dname;
//if sqlca.sqlcode = -1 then
//	messagebox('系统提示','保存单据格式失败！原因：'+sqlca.sqlerrtext)
//	rollback;
//	return
//else
//	commit;
//end if
//messagebox('sb',len(s_billformat.subdwsyntaxb))
//if len(s_billformat.subdwsyntaxb) > 0 then
//	updateblob sys_dwnsyntax set subdwsyntaxb = :s_billformat.subdwsyntaxb   where dwname = :dwname and dname = :dname;
//	if sqlca.sqlcode = -1 then
//		messagebox('系统提示','保存单据格式失败！原因：'+sqlca.sqlerrtext)
//		rollback;
//		return
//	else
//		commit;
//	end if
//end if
messagebox('系统信息','保存格式成功！')
wf_retrieveformatlist(s_billformat.dwname)
wf_findformat(dname)
//dw_formatlist.retrieve(s_billformat.dwname)
//currow = dw_formatlist.insertrow(1)
//dw_formatlist.object.dwname[currow] = '标准格式'
//dw_formatlist.object.dname[currow] = '标准格式'
//	cb_exit.triggerevent(clicked!)


end event

type cb_def from uo_imflatbutton within w_publ_preview_billformatset
integer x = 1166
integer y = 976
integer width = 274
integer height = 92
integer taborder = 50
string text = "设为默认"
end type

event clicked;call super::clicked;IF dw_formatlist.GetRow() <= 0 THEN
	MessageBox('系统提示','请选择格式！')
END IF
Long i,currow,rslt = 0
String dwname,dname,arg_msg


dwname = s_billformat.dwname
dname = dw_formatlist.Object.dname[dw_formatlist.GetRow()]

IF dw_formatlist.GetRow() > 0 THEN
	rslt = wf_sendprintout(3,1,dwname,dname,"",arg_msg)
	IF arg_msg = 'CANCEL' THEN RETURN
	if rslt = 1 then
		MessageBox('系统提示','设置默认值失败:' + arg_msg)
		return
	end if
		
END IF

IF rslt = 0 THEN
	MessageBox('系统提示','设置默认值成功！')
END IF

wf_retrieveformatlist(dwname)
wf_finddef()

end event

type cb_del from uo_imflatbutton within w_publ_preview_billformatset
integer x = 594
integer y = 976
integer width = 274
integer height = 92
integer taborder = 50
string text = "删除格式"
end type

event clicked;call super::clicked;String dwname,dname,arg_msg
integer rslt
rslt = 0
IF dw_formatlist.GetRow() = 1 OR Trim(sle_name.Text) = '标准格式' THEN
	MessageBox('系统提示','该格式为标准格式，不能删除!')
	RETURN
END IF

If (dw_formatlist.RowCount() = 0) Or (dw_formatlist.GetRow() <= 0)  THEN
	MessageBox('系统提示','没有可删除的格式!')
	RETURN
END IF

IF MessageBox ("全部","是否确定要删除当前单式吗?",Question!,YesNo! ) = 2 THEN RETURN

dwname = s_billformat.dwname
dname = dw_formatlist.Object.dname[dw_formatlist.GetRow()]

rslt = wf_sendprintout(4,0, dwname, dname, "", arg_msg)
IF arg_msg = 'CANCEL' THEN RETURN
if rslt = 1 then
	MessageBox("系统提示","删除格式失败:" + arg_msg)
	return
end if
	
//DELETE FROM sys_dwnSyntax Where dwname = :dwname AND dname = :dname;
//IF sqlca.SQLCode <> 0 THEN
//	MessageBox('系统提示','删除格式失败！')
//	ROLLBACK;
//	RETURN
//END IF

MessageBox('系统提示','删除格式成功！')

wf_retrieveformatlist(dwname)
wf_finddef()




end event

type dw_formatlist from datawindow within w_publ_preview_billformatset
integer x = 32
integer y = 176
integer width = 1710
integer height = 668
integer taborder = 20
string dataobject = "dw_publ_preview_formatlist"
boolean hscrollbar = true
boolean vscrollbar = true
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

event doubleclicked;IF row > 0 THEN
	IF dwo.Name = 'cussimplename' THEN
		string arg_msg
		s_fx_company s_tran, s_ret
		OpenWithParm(w_cus_ch_fx, s_tran)
		s_ret = Message.PowerObjectParm
		IF not IsNull(s_ret) then
			IF (s_ret.ifselect) then
				oleobject request,response,list
				
				request = FXAppCom.CreatePbDictionary()
				request.SetString("token",app_token_fx)
				request.SetString("dwname",s_billformat.dwname)
				request.SetString("aliase",this.Object.dname[row])
				request.SetInt("type", 5)
				request.SetInt("cuscomid",s_ret.comid[1])

				response = FXAppCom.DoExecute("SavePrintOut", request)
				arg_msg = response.GetString('ErrMsg')
				if (arg_msg <> '') then
					MessageBox('提示', '保存打印格式列表失败:' + arg_msg)
					RETURN
				end if
				
				this.Object.cuscomid[row] = s_ret.comid[1]
				this.Object.cussimplename[row] = s_ret.comname[1]
				this.AcceptText()
				MessageBox('提示', '保存成功')
			END IF
		END IF
	ELSE
		cb_open.TriggerEvent(Clicked!)
	END IF
END IF

end event

event rowfocuschanged;IF editmode THEN RETURN
IF this.getrow() <= 0 THEN RETURN
THIS.SelectRow(0,FALSE)
THIS.SelectRow(this.getrow(),TRUE)
dw_formatlist.SetRow(this.getrow())
dw_formatlist.ScrollToRow (this.getrow())

sle_name.Text = dw_formatlist.Object.dname[this.getrow()]


end event

type sle_name from singlelineedit within w_publ_preview_billformatset
integer x = 242
integer y = 68
integer width = 1490
integer height = 84
integer taborder = 10
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean autohscroll = false
borderstyle borderstyle = stylelowered!
boolean hideselection = false
end type

type st_1 from statictext within w_publ_preview_billformatset
integer x = 55
integer y = 80
integer width = 174
integer height = 60
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

type sle_1 from singlelineedit within w_publ_preview_billformatset
integer x = 270
integer y = 856
integer width = 1344
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 autohscroll = false
borderstyle borderstyle = stylelowered!
boolean hideselection = false
end type

type st_2 from statictext within w_publ_preview_billformatset
integer x = 37
integer y = 864
integer width = 233
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

type cb_2 from uo_imflatbutton within w_publ_preview_billformatset
integer x = 1627
integer y = 848
integer width = 114
integer taborder = 30
boolean bringtotop = true
string text = "..."
end type

event clicked;call super::clicked;integer i
string pathname,filename
//i=getfilesavename("单据表格式文件",pathname,filename,"ljdw","单据表格式文件ljdw,*.ljdw")
i=getfilesavename("datawindow文件",pathname,filename,"srd","srd,*.srd")
IF i=1 AND TRIM(pathname)<>'' AND TRIM(FILENAME)<>"" THEN
	sle_1.text=pathname
END IF
end event

type cb_3 from uo_imflatbutton within w_publ_preview_billformatset
integer x = 864
integer y = 976
integer width = 274
integer height = 92
integer taborder = 20
boolean bringtotop = true
string text = "导出格式"
end type

event clicked;call super::clicked;integer i
string pathname,filename,dwname,dname,dwsyntax,rs_dname,arg_msg
blob b_data
dwname = s_billformat.dwname
dname = dw_formatlist.object.dname[dw_formatlist.getrow()]
if dw_formatlist.getrow() = 1 then
	dw_1.dataobject = dwname
	dwsyntax = dw_1.Describe("DataWindow.Syntax")
else
	i = wf_getprintout(dwname,dname,0,rs_dname,dwsyntax,arg_msg)
	if i = 0 then
		return
	end if
end if
dwsyntax = "$PBExportHeader$" + dwname + "_export.srd~n" + dwsyntax
pathname = dwname + "_export.srd"
i=getfilesavename("datawindow文件",pathname,filename,"srd","srd,*.srd")
IF i=1 AND TRIM(pathname)<>'' AND TRIM(FILENAME)<>"" THEN
	IF FileExists(pathname) then
		if messagebox ("全部","文件已存在，是否覆盖?",question!,yesno! ) = 2 then return
		FileDelete(pathname)
	END IF
	i = f_stringtofile(pathname,dwsyntax,arg_msg)
//	b_data = blob(dwsyntax)
//	i = f_blobtofile(pathname,b_data,arg_msg)
	IF i = 0 THEN
		messagebox ("系统提示","格式导出失败:" + arg_msg)
	ELSE
		messagebox ("系统提示","格式导出成功")
	END IF
END IF
end event

type dw_1 from datawindow within w_publ_preview_billformatset
integer x = 1925
integer y = 392
integer width = 686
integer height = 400
integer taborder = 30
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

type gb_1 from groupbox within w_publ_preview_billformatset
integer width = 1760
integer height = 960
integer taborder = 10
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 134217739
string text = "格式设置"
end type

