w_report_inexport.srw 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. $PBExportHeader$w_report_inexport.srw
  2. forward
  3. global type w_report_inexport from w_publ_base
  4. end type
  5. type sle_filename from singlelineedit within w_report_inexport
  6. end type
  7. type cb_1 from uo_imflatbutton within w_report_inexport
  8. end type
  9. type cb_2 from uo_imflatbutton within w_report_inexport
  10. end type
  11. type gb_1 from groupbox within w_report_inexport
  12. end type
  13. end forward
  14. global type w_report_inexport from w_publ_base
  15. integer width = 1993
  16. integer height = 520
  17. string title = "导入导出报表格式"
  18. boolean minbox = false
  19. windowtype windowtype = response!
  20. sle_filename sle_filename
  21. cb_1 cb_1
  22. cb_2 cb_2
  23. gb_1 gb_1
  24. end type
  25. global w_report_inexport w_report_inexport
  26. type variables
  27. //u_report_imex uo_imex
  28. //
  29. s_rpt_inexport s_imexport_reposts
  30. s_preview_billformatset_tran s_billformat
  31. end variables
  32. forward prototypes
  33. public function integer f_expout (string arg_filename, blob arg_bdata, ref string arg_msg)
  34. public function integer f_inexp (string arg_filename, ref blob arg_bdata, ref string arg_msg)
  35. public function integer wf_save (ref string arg_msg, transaction pictrans)
  36. public function integer wf_in_outport (ref string arg_msg)
  37. end prototypes
  38. public function integer f_expout (string arg_filename, blob arg_bdata, ref string arg_msg);int rslt=1
  39. long fend,li_FileNum,fend_t,ls_i,ls_jh
  40. blob b_dtdata_p
  41. if FileExists(arg_filename) then
  42. if not FileDelete(arg_filename) then
  43. rslt=0
  44. arg_msg="删除临时文件失败("+arg_filename+"),请先手动清除!"
  45. goto ext
  46. end if
  47. end if
  48. fend=len(arg_bdata)
  49. if fend<=32765 then
  50. fend_t=1
  51. else
  52. fend_t=fend/32765
  53. if mod(fend,32765)<>0 then
  54. fend_t=fend_t+1
  55. end if
  56. end if
  57. li_FileNum = FileOpen( arg_filename,StreamMode!, Write!, LockWrite!)
  58. if li_FileNum<=0 then
  59. arg_msg="打开文件"+arg_filename+"失败"
  60. rslt=0
  61. fileclose(li_FileNum)
  62. goto ext
  63. end if
  64. for ls_i = 1 to fend_t
  65. b_dtdata_p=blobmid(arg_bdata,1+(ls_i - 1 )*32765,32765)
  66. ls_jh=FileWrite(li_FileNum, b_dtdata_p)
  67. if ls_jh<=0 then
  68. arg_msg="写文件"+arg_filename+"失败"
  69. rslt=0
  70. fileclose(li_FileNum)
  71. goto ext
  72. end if
  73. next
  74. fileclose(li_FileNum)
  75. ext:
  76. return rslt
  77. end function
  78. public function integer f_inexp (string arg_filename, ref blob arg_bdata, ref string arg_msg);//f_inexp(arg_bdata,arg_filename,arg_msg)
  79. long rslt=1
  80. long flen,li_FileNum,loops,ls_i,bytes_read,new_pos
  81. blob b_dtdata_p,tot_b
  82. SetPointer(HourGlass!)
  83. // Get the file length, and open the file
  84. flen = FileLength(arg_filename)
  85. li_FileNum = FileOpen(arg_filename, StreamMode!, Read!, LockRead!)
  86. if li_FileNum=-1 then
  87. rslt=0
  88. arg_msg='打开文件'+arg_filename+'操作失败!'
  89. fileclose(li_FileNum)
  90. goto ext
  91. end if
  92. // Determine how many times to call FileRead
  93. IF flen > 32765 THEN
  94. IF Mod(flen, 32765) = 0 THEN
  95. loops = flen/32765
  96. ELSE
  97. loops = (flen/32765) + 1
  98. END IF
  99. ELSE
  100. loops = 1
  101. END IF
  102. // Read the file
  103. new_pos = 1
  104. FOR ls_i = 1 to loops
  105. bytes_read = FileRead(li_FileNum, b_dtdata_p)
  106. if bytes_read=0 then
  107. rslt=0
  108. arg_msg='读取文件'+arg_filename+'操作失败!'
  109. fileclose(li_FileNum)
  110. goto ext
  111. end if
  112. tot_b = tot_b + b_dtdata_p
  113. NEXT
  114. arg_bdata=tot_b
  115. fileclose(li_FileNum)
  116. ext:
  117. return rslt
  118. end function
  119. public function integer wf_save (ref string arg_msg, transaction pictrans);//wf_save()
  120. int rslt=1
  121. updateblob sys_dwnSyntax set dwsyntaxb=:s_imexport_reposts.dwsyntaxb where dwname = :s_imexport_reposts.dwname and dname =:s_imexport_reposts.dname using pictrans;
  122. if pictrans.sqlcode=-1 then
  123. rslt=0
  124. arg_msg='更新格式失败!原因:'+pictrans.sqlerrtext
  125. goto ext
  126. end if
  127. commit using pictrans;
  128. updateblob sys_dwnSyntax set subdwsyntaxb =:s_imexport_reposts.subdwsyntaxb where dwname = :s_imexport_reposts.dwname and dname =:s_imexport_reposts.dname using pictrans;
  129. if pictrans.sqlcode=-1 then
  130. rslt=0
  131. arg_msg='更新格式失败!原因:'+pictrans.sqlerrtext
  132. goto ext
  133. end if
  134. commit using pictrans;
  135. ext:
  136. if rslt=0 then
  137. rollback using pictrans;
  138. end if
  139. return (rslt)
  140. end function
  141. public function integer wf_in_outport (ref string arg_msg);//wf_in_outport(arg_msg)
  142. string ls_1
  143. blob arg_allblob
  144. long cnt=0,rslt=1
  145. blob ll_blob
  146. Transaction sqlca_blob
  147. sqlca_blob=create Transaction
  148. ls_1=""
  149. rslt=1
  150. if s_billformat.ifimporflag=0 then
  151. if f_inexp(sle_filename.text,arg_allblob,arg_msg)=0 then
  152. arg_msg="系统提示:"+"错误!"+arg_msg
  153. rslt=0
  154. goto ext
  155. end if
  156. if pos(string(arg_allblob),"***")>0 then
  157. s_imexport_reposts.dwname= left(string(arg_allblob),pos(string(arg_allblob),"***") -1)
  158. ls_1=mid(string(arg_allblob),pos(string(arg_allblob),"***")+3,len(string(arg_allblob)) - pos(string(arg_allblob),"***") - 2)
  159. if pos(ls_1,"***")>0 then
  160. s_imexport_reposts.dname=left(ls_1,pos(ls_1,"***") - 1)
  161. ls_1=mid(ls_1,pos(ls_1,"***")+3,len(ls_1) - pos(ls_1,"***") - 2)
  162. if pos(ls_1,"*sheng*")>0 then
  163. s_imexport_reposts.dwsyntaxb=blob(left(ls_1,pos(ls_1,"*sheng*") - 1))
  164. s_imexport_reposts.subdwsyntaxb=blob(mid(ls_1,pos(ls_1,"*sheng*")+7,len(ls_1) - pos(ls_1,"*sheng*") - 6))
  165. end if
  166. end if
  167. else
  168. arg_msg="系统提示:"+"查询单据格式失败!"
  169. rslt=0
  170. goto ext
  171. end if
  172. cnt=0
  173. select count(*)
  174. into:cnt
  175. from sys_dwnSyntax
  176. where dwname=:s_imexport_reposts.dwname and
  177. dname=:s_imexport_reposts.dname;
  178. if sqlca.sqlcode<>0 then
  179. arg_msg="系统提示:"+"查询单据格式失败!"
  180. rslt=0
  181. goto ext
  182. end if
  183. if cnt=0 then
  184. insert into sys_dwnSyntax (dwname,dname)
  185. values (:s_imexport_reposts.dwname,:s_imexport_reposts.dname);
  186. if sqlca.sqlcode<>0 then
  187. arg_msg="系统提示:"+"插入单据格式失败!"
  188. rollback;
  189. rslt=0
  190. goto ext
  191. end if
  192. commit;
  193. end if
  194. if wf_save(arg_msg,sqlca)=0 then
  195. arg_msg='系统提示:'+arg_msg
  196. rslt=0
  197. goto ext
  198. end if
  199. arg_msg="导入单据格式成功!"
  200. elseif s_billformat.ifimporflag=1 then
  201. 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
  202. arg_msg="系统提示:"+"错误!"+arg_msg
  203. rslt=0
  204. goto ext
  205. end if
  206. arg_msg="导出单据格式成功!"
  207. end if
  208. ext:
  209. return(rslt)
  210. end function
  211. on w_report_inexport.create
  212. int iCurrent
  213. call super::create
  214. this.sle_filename=create sle_filename
  215. this.cb_1=create cb_1
  216. this.cb_2=create cb_2
  217. this.gb_1=create gb_1
  218. iCurrent=UpperBound(this.Control)
  219. this.Control[iCurrent+1]=this.sle_filename
  220. this.Control[iCurrent+2]=this.cb_1
  221. this.Control[iCurrent+3]=this.cb_2
  222. this.Control[iCurrent+4]=this.gb_1
  223. end on
  224. on w_report_inexport.destroy
  225. call super::destroy
  226. destroy(this.sle_filename)
  227. destroy(this.cb_1)
  228. destroy(this.cb_2)
  229. destroy(this.gb_1)
  230. end on
  231. event open;call super::open;s_billformat = message.powerobjectparm
  232. end event
  233. event close;call super::close;CloseWithReturn(this,s_imexport_reposts)
  234. end event
  235. type cb_func from w_publ_base`cb_func within w_report_inexport
  236. boolean visible = false
  237. end type
  238. type cb_exit from w_publ_base`cb_exit within w_report_inexport
  239. integer x = 1463
  240. integer y = 296
  241. integer width = 302
  242. integer height = 100
  243. end type
  244. type sle_filename from singlelineedit within w_report_inexport
  245. integer x = 110
  246. integer y = 124
  247. integer width = 1655
  248. integer height = 92
  249. integer taborder = 30
  250. boolean bringtotop = true
  251. integer textsize = -9
  252. integer weight = 400
  253. fontcharset fontcharset = gb2312charset!
  254. fontpitch fontpitch = variable!
  255. string facename = "宋体"
  256. long textcolor = 33554432
  257. string text = " "
  258. borderstyle borderstyle = stylelowered!
  259. end type
  260. type cb_1 from uo_imflatbutton within w_report_inexport
  261. integer x = 1774
  262. integer y = 120
  263. integer width = 128
  264. integer taborder = 40
  265. boolean bringtotop = true
  266. string text = "..."
  267. end type
  268. event clicked;call super::clicked;integer i
  269. string pathname,filename
  270. //i=getfilesavename("单据表格式文件",pathname,filename,"ljdw","单据表格式文件ljdw,*.ljdw")
  271. i=getfilesavename("单据表格式文件",pathname,filename,"srd","srd,*.srd")
  272. IF i=1 AND TRIM(pathname)<>'' AND TRIM(FILENAME)<>"" THEN
  273. sle_filename.text=pathname
  274. END IF
  275. end event
  276. type cb_2 from uo_imflatbutton within w_report_inexport
  277. integer x = 1010
  278. integer y = 296
  279. integer taborder = 20
  280. boolean bringtotop = true
  281. end type
  282. event clicked;call super::clicked;string arg_msg=""
  283. if wf_in_outport(arg_msg)=0 then
  284. messagebox('系统提示:',arg_msg)
  285. return
  286. else
  287. messagebox('系统提示:',arg_msg)
  288. end if
  289. end event
  290. type gb_1 from groupbox within w_report_inexport
  291. integer x = 82
  292. integer y = 64
  293. integer width = 1861
  294. integer height = 204
  295. integer taborder = 40
  296. integer textsize = -9
  297. integer weight = 400
  298. fontcharset fontcharset = gb2312charset!
  299. fontpitch fontpitch = variable!
  300. string facename = "宋体"
  301. long textcolor = 33554432
  302. long backcolor = 134217739
  303. end type