123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361 |
- $PBExportHeader$w_report_inexport.srw
- forward
- global type w_report_inexport from w_publ_base
- end type
- type sle_filename from singlelineedit within w_report_inexport
- end type
- type cb_1 from uo_imflatbutton within w_report_inexport
- end type
- type cb_2 from uo_imflatbutton within w_report_inexport
- end type
- type gb_1 from groupbox within w_report_inexport
- end type
- end forward
- global type w_report_inexport from w_publ_base
- integer width = 1993
- integer height = 520
- string title = "导入导出报表格式"
- boolean minbox = false
- windowtype windowtype = response!
- sle_filename sle_filename
- cb_1 cb_1
- cb_2 cb_2
- gb_1 gb_1
- end type
- global w_report_inexport w_report_inexport
- type variables
- //u_report_imex uo_imex
- //
- s_rpt_inexport s_imexport_reposts
- s_preview_billformatset_tran s_billformat
- end variables
- forward prototypes
- public function integer f_expout (string arg_filename, blob arg_bdata, ref string arg_msg)
- public function integer f_inexp (string arg_filename, ref blob arg_bdata, ref string arg_msg)
- public function integer wf_save (ref string arg_msg, transaction pictrans)
- public function integer wf_in_outport (ref string arg_msg)
- end prototypes
- public function integer f_expout (string arg_filename, blob arg_bdata, ref string arg_msg);int rslt=1
- long fend,li_FileNum,fend_t,ls_i,ls_jh
- blob b_dtdata_p
-
- if FileExists(arg_filename) then
- if not FileDelete(arg_filename) then
- rslt=0
- arg_msg="删除临时文件失败("+arg_filename+"),请先手动清除!"
- goto ext
- end if
- end if
- fend=len(arg_bdata)
- if fend<=32765 then
- fend_t=1
- else
- fend_t=fend/32765
- if mod(fend,32765)<>0 then
- fend_t=fend_t+1
- end if
- end if
- li_FileNum = FileOpen( arg_filename,StreamMode!, Write!, LockWrite!)
- if li_FileNum<=0 then
- arg_msg="打开文件"+arg_filename+"失败"
- rslt=0
- fileclose(li_FileNum)
- goto ext
- end if
- for ls_i = 1 to fend_t
- b_dtdata_p=blobmid(arg_bdata,1+(ls_i - 1 )*32765,32765)
- ls_jh=FileWrite(li_FileNum, b_dtdata_p)
- if ls_jh<=0 then
- arg_msg="写文件"+arg_filename+"失败"
- rslt=0
- fileclose(li_FileNum)
- goto ext
- end if
- next
- fileclose(li_FileNum)
- ext:
- return rslt
- end function
- public function integer f_inexp (string arg_filename, ref blob arg_bdata, ref string arg_msg);//f_inexp(arg_bdata,arg_filename,arg_msg)
- long rslt=1
- long flen,li_FileNum,loops,ls_i,bytes_read,new_pos
- blob b_dtdata_p,tot_b
- SetPointer(HourGlass!)
- // Get the file length, and open the file
- flen = FileLength(arg_filename)
- li_FileNum = FileOpen(arg_filename, StreamMode!, Read!, LockRead!)
- if li_FileNum=-1 then
- rslt=0
- arg_msg='打开文件'+arg_filename+'操作失败!'
- fileclose(li_FileNum)
- goto ext
- end if
- // Determine how many times to call FileRead
- IF flen > 32765 THEN
- IF Mod(flen, 32765) = 0 THEN
- loops = flen/32765
- ELSE
- loops = (flen/32765) + 1
- END IF
- ELSE
- loops = 1
- END IF
- // Read the file
- new_pos = 1
- FOR ls_i = 1 to loops
- bytes_read = FileRead(li_FileNum, b_dtdata_p)
- if bytes_read=0 then
- rslt=0
- arg_msg='读取文件'+arg_filename+'操作失败!'
- fileclose(li_FileNum)
- goto ext
- end if
- tot_b = tot_b + b_dtdata_p
-
- NEXT
- arg_bdata=tot_b
-
- fileclose(li_FileNum)
- ext:
- return rslt
- end function
- public function integer wf_save (ref string arg_msg, transaction pictrans);//wf_save()
- int rslt=1
-
- updateblob sys_dwnSyntax set dwsyntaxb=:s_imexport_reposts.dwsyntaxb where dwname = :s_imexport_reposts.dwname and dname =:s_imexport_reposts.dname using pictrans;
- if pictrans.sqlcode=-1 then
- rslt=0
- arg_msg='更新格式失败!原因:'+pictrans.sqlerrtext
- goto ext
- end if
-
- commit using pictrans;
-
- updateblob sys_dwnSyntax set subdwsyntaxb =:s_imexport_reposts.subdwsyntaxb where dwname = :s_imexport_reposts.dwname and dname =:s_imexport_reposts.dname using pictrans;
- if pictrans.sqlcode=-1 then
- rslt=0
- arg_msg='更新格式失败!原因:'+pictrans.sqlerrtext
- goto ext
- end if
-
- commit using pictrans;
- ext:
- if rslt=0 then
- rollback using pictrans;
- end if
- return (rslt)
- end function
- public function integer wf_in_outport (ref string arg_msg);//wf_in_outport(arg_msg)
- String ls_1
- Blob arg_allblob
- Long cnt = 0,rslt = 1
- Blob ll_blob
- Transaction sqlca_blob
- sqlca_blob = CREATE Transaction
- ls_1 = ""
- rslt = 1
- IF s_billformat.ifimporflag = 0 THEN
-
- IF f_inexp(sle_filename.Text,arg_allblob,arg_msg) = 0 THEN
- arg_msg = "系统提示:"+"错误!"+arg_msg
- rslt = 0
- GOTO ext
- END IF
-
- IF Pos(String(arg_allblob),"***") > 0 THEN
- s_imexport_reposts.dwname = Left(String(arg_allblob),Pos(String(arg_allblob),"***") -1)
- ls_1 = Mid(String(arg_allblob),Pos(String(arg_allblob),"***")+3,Len(String(arg_allblob)) - Pos(String(arg_allblob),"***") - 2)
- IF Pos(ls_1,"***") > 0 THEN
- s_imexport_reposts.dname = Left(ls_1,Pos(ls_1,"***") - 1)
- ls_1 = Mid(ls_1,Pos(ls_1,"***")+3,Len(ls_1) - Pos(ls_1,"***") - 2)
-
- IF Pos(ls_1,"*sheng*") > 0 THEN
- s_imexport_reposts.dwsyntaxb = Blob(Left(ls_1,Pos(ls_1,"*sheng*") - 1))
- s_imexport_reposts.subdwsyntaxb = Blob(Mid(ls_1,Pos(ls_1,"*sheng*")+7,Len(ls_1) - Pos(ls_1,"*sheng*") - 6))
- END IF
- END IF
- ELSE
- arg_msg = "系统提示:"+"查询单据格式失败!"
- rslt = 0
- GOTO ext
- END IF
-
- cnt = 0
- SELECT count(*)
- INTO:cnt
- FROM sys_dwnSyntax
- WHERE dwname = :s_imexport_reposts.dwname AND
- dname = :s_imexport_reposts.dname;
-
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = "系统提示:"+"查询单据格式失败!"
- rslt = 0
- GOTO ext
- END IF
-
- IF cnt = 0 THEN
-
- INSERT INTO sys_dwnSyntax (dwname,dname)
- Values (:s_imexport_reposts.dwname,:s_imexport_reposts.dname);
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = "系统提示:"+"插入单据格式失败!"
- ROLLBACK;
- rslt = 0
- GOTO ext
- END IF
- COMMIT;
-
- END IF
-
- IF wf_save(arg_msg,sqlca) = 0 THEN
- arg_msg = '系统提示:'+arg_msg
- rslt = 0
- GOTO ext
- END IF
-
- arg_msg = "导入单据格式成功!"
-
- ELSEIF s_billformat.ifimporflag = 1 THEN
-
- IF f_expout(sle_filename.Text,Blob(s_billformat.dwname+"***"+s_billformat.dname+"***"+String(s_billformat.dwsyntaxb)+"*sheng*"+String(s_billformat.subdwsyntaxb)),arg_msg) = 0 THEN
- arg_msg = "系统提示:"+"错误!"+arg_msg
- rslt = 0
- GOTO ext
- END IF
- arg_msg = "导出单据格式成功!"
- END IF
- ext:
- Return(rslt)
- end function
- on w_report_inexport.create
- int iCurrent
- call super::create
- this.sle_filename=create sle_filename
- this.cb_1=create cb_1
- this.cb_2=create cb_2
- this.gb_1=create gb_1
- iCurrent=UpperBound(this.Control)
- this.Control[iCurrent+1]=this.sle_filename
- this.Control[iCurrent+2]=this.cb_1
- this.Control[iCurrent+3]=this.cb_2
- this.Control[iCurrent+4]=this.gb_1
- end on
- on w_report_inexport.destroy
- call super::destroy
- destroy(this.sle_filename)
- destroy(this.cb_1)
- destroy(this.cb_2)
- destroy(this.gb_1)
- end on
- event open;call super::open;s_billformat = message.powerobjectparm
-
- end event
- event close;call super::close;CloseWithReturn(this,s_imexport_reposts)
- end event
- type cb_func from w_publ_base`cb_func within w_report_inexport
- boolean visible = false
- end type
- type cb_exit from w_publ_base`cb_exit within w_report_inexport
- integer x = 1463
- integer y = 296
- integer width = 302
- integer height = 100
- end type
- type sle_filename from singlelineedit within w_report_inexport
- integer x = 110
- integer y = 124
- integer width = 1655
- integer height = 92
- integer taborder = 30
- boolean bringtotop = true
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- long textcolor = 33554432
- string text = " "
- borderstyle borderstyle = stylelowered!
- end type
- type cb_1 from uo_imflatbutton within w_report_inexport
- integer x = 1774
- integer y = 120
- integer width = 128
- integer taborder = 40
- boolean bringtotop = true
- string text = "..."
- end type
- event clicked;call super::clicked;integer i
- string pathname,filename
- i=getfilesavename("单据表格式文件",pathname,filename,"ljdw","单据表格式文件ljdw,*.ljdw")
- IF i=1 AND TRIM(pathname)<>'' AND TRIM(FILENAME)<>"" THEN
- sle_filename.text=pathname
- END IF
- end event
- type cb_2 from uo_imflatbutton within w_report_inexport
- integer x = 1010
- integer y = 296
- integer taborder = 20
- boolean bringtotop = true
- end type
- event clicked;call super::clicked;string arg_msg=""
- if wf_in_outport(arg_msg)=0 then
- messagebox('系统提示:',arg_msg)
- return
- else
- messagebox('系统提示:',arg_msg)
- end if
- end event
- type gb_1 from groupbox within w_report_inexport
- integer x = 82
- integer y = 64
- integer width = 1861
- integer height = 204
- integer taborder = 40
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- long textcolor = 33554432
- long backcolor = 134217739
- end type
|