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. IF i=1 AND TRIM(pathname)<>'' AND TRIM(FILENAME)<>"" THEN
  272. sle_filename.text=pathname
  273. END IF
  274. end event
  275. type cb_2 from uo_imflatbutton within w_report_inexport
  276. integer x = 1010
  277. integer y = 296
  278. integer taborder = 20
  279. boolean bringtotop = true
  280. end type
  281. event clicked;call super::clicked;string arg_msg=""
  282. if wf_in_outport(arg_msg)=0 then
  283. messagebox('系统提示:',arg_msg)
  284. return
  285. else
  286. messagebox('系统提示:',arg_msg)
  287. end if
  288. end event
  289. type gb_1 from groupbox within w_report_inexport
  290. integer x = 82
  291. integer y = 64
  292. integer width = 1861
  293. integer height = 204
  294. integer taborder = 40
  295. integer textsize = -9
  296. integer weight = 400
  297. fontcharset fontcharset = gb2312charset!
  298. fontpitch fontpitch = variable!
  299. string facename = "宋体"
  300. long textcolor = 33554432
  301. long backcolor = 134217739
  302. end type