w_fj_fileadd.srw 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. $PBExportHeader$w_fj_fileadd.srw
  2. forward
  3. global type w_fj_fileadd from w_publ_base
  4. end type
  5. type cb_save from uo_xls_imflatbutton within w_fj_fileadd
  6. end type
  7. type dw_fileedit from datawindow within w_fj_fileadd
  8. end type
  9. type ln_bar2 from line within w_fj_fileadd
  10. end type
  11. type ln_bar from line within w_fj_fileadd
  12. end type
  13. type r_bar from rectangle within w_fj_fileadd
  14. end type
  15. end forward
  16. global type w_fj_fileadd from w_publ_base
  17. integer width = 2734
  18. integer height = 976
  19. string title = "文件上传"
  20. boolean minbox = false
  21. windowtype windowtype = response!
  22. event ue_selectfile ( )
  23. cb_save cb_save
  24. dw_fileedit dw_fileedit
  25. ln_bar2 ln_bar2
  26. ln_bar ln_bar
  27. r_bar r_bar
  28. end type
  29. global w_fj_fileadd w_fj_fileadd
  30. type variables
  31. s_fileinfo s_file
  32. boolean import = false
  33. boolean success = false
  34. uo_fileview obj_fileview
  35. Transaction Transaction_pic
  36. long originallyheight,originallywidth
  37. end variables
  38. forward prototypes
  39. public subroutine wf_priview ()
  40. public function long wf_getfiledata (string arg_filepath, ref blob arg_filedata, ref string arg_msg)
  41. end prototypes
  42. event ue_selectfile();// //ue_selectfile
  43. String Pathname,Filename,FileType
  44. Integer i
  45. Long row
  46. row = 1 //dw_fileedit.getrow( )
  47. FileType = ''
  48. FileType = '所有文件(*.*),*.*,'
  49. // FileType += "配置文件(*.ini), *.ini,"
  50. FileType += "Zip压缩文件(*.Zip),*.Zip,"
  51. FileType += "RAR压缩文件(*.rar),*.rar,"
  52. // FileType += "XML文件(*.xml),*.xml,"
  53. FileType += "文本文件(*.txt),*.txt,"
  54. FileType += "Excel模版(*.xlt),*.xlt,"
  55. // FileType += "Excel文档(*.xls),*.xls,"
  56. // FileType += "Word模版(*.dot),*.dot,"
  57. FileType += "Word文档(*.doc),*.doc,"
  58. FileType += "JPG(*.JPG),*.JPG,"
  59. FileType += "位图文件(*.bmp),*.bmp,"
  60. FileType += "GIF文件(*.GIF),*.GIF"
  61. i = GetFileOpenName("请选择文件", Pathname,Filename, "All", FileType)
  62. IF i = 1 And Trim(Pathname) <> '' And Trim(Filename) <> "" THEN
  63. IF Pathname = '' Or Not FileExists(Pathname) THEN
  64. MessageBox('提示','请选择文件!',information!,OK!)
  65. success = False
  66. import = False
  67. RETURN
  68. END IF
  69. IF FileLength(Pathname)/1024 > 10240 THEN
  70. // messagebox('提示','附件文件大小不得大于10M',information!,OK!)
  71. IF MessageBox ("询问","附件文件大小大于10M,是否继续?",question!,yesno! ) = 2 THEN RETURN
  72. END IF
  73. dw_fileedit.Object.filepath[row] = Pathname
  74. Long poi = 0,Begin = 1
  75. Begin = Pos(Filename,'.',1)
  76. DO WHILE Begin > 0
  77. poi = Begin
  78. Begin = Pos(Filename,'.',Begin + 1)
  79. LOOP
  80. IF poi > 0 THEN
  81. dw_fileedit.Object.Filename[row] = Mid(Filename,1,poi -1)
  82. dw_fileedit.Object.DisplayName[row] = Mid(Filename,1,poi -1)
  83. dw_fileedit.Object.FileType[row] = Mid(Filename,poi +1,Len(Filename) - poi)
  84. ELSE
  85. dw_fileedit.Object.Filename[row] = Filename
  86. dw_fileedit.Object.DisplayName[row] = Filename
  87. dw_fileedit.Object.FileType[row] = ''
  88. END IF
  89. END IF
  90. //wf_priview()
  91. dw_fileedit.Object.filesize[row] = FileLength(Pathname)/1024
  92. end event
  93. public subroutine wf_priview ();//IF cbx_pv.Checked THEN
  94. // String arg_msg
  95. // String Pathname
  96. // String Filename
  97. // Pathname = dw_fileedit.Object.filepath[dw_fileedit.GetRow()]
  98. // Filename = dw_fileedit.Object.Filename[dw_fileedit.GetRow()]
  99. //
  100. // IF wf_getfiledata(Pathname,s_file.filedata,arg_msg) <> 1 THEN
  101. // MessageBox('系统提示',arg_msg)
  102. // RETURN
  103. // END IF
  104. //
  105. // IF NOT IsValid(obj_fileview) THEN
  106. // obj_fileview = CREATE uo_fileview_pic
  107. // OpenUserObject(obj_fileview)
  108. // END IF
  109. //
  110. // IF obj_fileview.of_showfile( s_file.filedata,Filename, arg_msg) <> 1 THEN
  111. // IF IsValid(obj_fileview) THEN
  112. // CloseUserObject(obj_fileview)
  113. // END IF
  114. // THIS.Height = THIS.originallyheight
  115. // THIS.Width = THIS.originallywidth
  116. // cbx_pv.Checked = FALSE
  117. // MessageBox('系统提示',arg_msg)
  118. // RETURN
  119. // END IF
  120. //
  121. // THIS.Height = obj_fileview.ii_screenheight - 570
  122. // THIS.Width = obj_fileview.ii_screenwidth
  123. // obj_fileview.X = 0
  124. // obj_fileview.Y = dw_fileedit.Y + dw_fileedit.Height+10
  125. // obj_fileview.Width = THIS.Width - 20
  126. // obj_fileview.Height = THIS.Height - obj_fileview.Y
  127. // obj_fileview.OriginalSize = cbx_originalsize.Checked
  128. //
  129. //
  130. // THIS.X = 0
  131. // THIS.Y = 0
  132. // obj_fileview.of_setfilesize( )
  133. //ELSE
  134. // IF IsValid(obj_fileview) THEN
  135. // CloseUserObject(obj_fileview)
  136. // END IF
  137. // THIS.Height = THIS.originallyheight
  138. // THIS.Width = THIS.originallywidth
  139. // wf_movetocenter()
  140. //END IF
  141. //
  142. //
  143. //RETURN
  144. //
  145. //
  146. //
  147. //
  148. //
  149. end subroutine
  150. public function long wf_getfiledata (string arg_filepath, ref blob arg_filedata, ref string arg_msg);
  151. Long rslt = 1,i
  152. Long ll_fileLength,li_FileNum,loops,bytes_read
  153. Blob b,temp
  154. IF arg_filepath = '' Or Not FileExists(arg_filepath) THEN
  155. rslt = 0
  156. arg_msg = '文件'+arg_filepath+'不存在'
  157. GOTO ext
  158. END IF
  159. ll_fileLength = FileLength(arg_filepath)
  160. IF ll_fileLength = 0 THEN
  161. rslt = 0
  162. arg_msg = '文件'+arg_filepath+'没有内容'
  163. GOTO ext
  164. END IF
  165. li_FileNum = FileOpen(arg_filepath, StreamMode!, Read!, LockRead!)
  166. IF ll_fileLength > 32765 THEN
  167. IF Mod(ll_fileLength, 32765) = 0 THEN
  168. loops = ll_fileLength/32765
  169. ELSE
  170. loops = (ll_fileLength/32765) + 1
  171. END IF
  172. ELSE
  173. loops = 1
  174. END IF
  175. IF li_FileNum = -1 THEN
  176. rslt = 0
  177. arg_msg = '读取文件'+arg_filepath+'出错,文件可能正在被使用'
  178. GOTO ext
  179. END IF
  180. FOR i = 1 To loops
  181. bytes_read = FileRead(li_FileNum, b)
  182. IF bytes_read < 0 THEN
  183. rslt = 0
  184. arg_msg = '读取文件'+arg_filepath+'出错'
  185. GOTO ext
  186. END IF
  187. temp = temp + b
  188. NEXT
  189. FileClose(li_FileNum)
  190. arg_filedata = temp
  191. rslt=ll_fileLength
  192. ext:
  193. RETURN rslt
  194. end function
  195. on w_fj_fileadd.create
  196. int iCurrent
  197. call super::create
  198. this.cb_save=create cb_save
  199. this.dw_fileedit=create dw_fileedit
  200. this.ln_bar2=create ln_bar2
  201. this.ln_bar=create ln_bar
  202. this.r_bar=create r_bar
  203. iCurrent=UpperBound(this.Control)
  204. this.Control[iCurrent+1]=this.cb_save
  205. this.Control[iCurrent+2]=this.dw_fileedit
  206. this.Control[iCurrent+3]=this.ln_bar2
  207. this.Control[iCurrent+4]=this.ln_bar
  208. this.Control[iCurrent+5]=this.r_bar
  209. end on
  210. on w_fj_fileadd.destroy
  211. call super::destroy
  212. destroy(this.cb_save)
  213. destroy(this.dw_fileedit)
  214. destroy(this.ln_bar2)
  215. destroy(this.ln_bar)
  216. destroy(this.r_bar)
  217. end on
  218. event open;call super::open;s_file = Message.PowerObjectParm
  219. Long ll_i_row
  220. ll_i_row = dw_fileedit.InsertRow(0)
  221. dw_fileedit.SetFocus()
  222. dw_fileedit.SetColumn('displayname')
  223. this.triggerevent( 'ue_selectfile')
  224. end event
  225. event close;call super::close;
  226. if not success then
  227. //s_file.classid = 0
  228. s_file.fileid = 0
  229. s_file.filename = ''
  230. s_file.dscrp = ''
  231. s_file.encrypted = 0
  232. s_file.compressed = 0
  233. s_file.filetype = ''
  234. setnull(s_file.filedata )
  235. end if
  236. CloseWithReturn(THIS,s_file)
  237. end event
  238. event ue_before_open;call super::ue_before_open;s_file = message.powerobjectparm
  239. IF Not IsNull(s_file.sqltransaction ) THEN
  240. Transaction_pic = s_file.sqltransaction
  241. ELSE
  242. MessageBox('提示','没有数据库事务',information!,OK!)
  243. Close(This)
  244. RETURN
  245. END IF
  246. this.originallyheight = this.height
  247. this.originallywidth = this.width
  248. dw_fileedit.settransobject( Transaction_pic)
  249. DataWindowChild dw_c
  250. dw_fileedit.getchild( "classid", dw_c)
  251. dw_c.settransobject( sqlca)
  252. dw_c.retrieve( )
  253. end event
  254. event resize;call super::resize;ln_bar.endx = this.width
  255. ln_bar2.endx = this.width
  256. r_bar.width = this.width
  257. end event
  258. type cb_func from w_publ_base`cb_func within w_fj_fileadd
  259. boolean visible = false
  260. integer x = 3099
  261. integer y = 744
  262. end type
  263. type cb_exit from w_publ_base`cb_exit within w_fj_fileadd
  264. integer x = 151
  265. integer width = 151
  266. integer height = 164
  267. string text = "取消"
  268. integer picsize = 16
  269. toolbaralignment pic_align = alignattop!
  270. boolean border = false
  271. boolean havefocusrect = false
  272. end type
  273. event cb_exit::clicked;success = false
  274. close(parent)
  275. end event
  276. type cb_save from uo_xls_imflatbutton within w_fj_fileadd
  277. integer width = 151
  278. integer height = 164
  279. integer taborder = 50
  280. boolean bringtotop = true
  281. string text = "上传"
  282. string normalpicname = "save.bmp"
  283. integer picsize = 16
  284. toolbaralignment pic_align = alignattop!
  285. boolean border = false
  286. boolean havefocusrect = false
  287. end type
  288. event clicked;Long row,rt_fileid
  289. uo_fj_mng_billtype ls_uo_btfj
  290. ls_uo_btfj= create uo_fj_mng_billtype
  291. dw_fileedit.AcceptText( )
  292. String arg_msg
  293. row = dw_fileedit.GetRow( )
  294. IF row <= 0 THEN RETURN
  295. String filepath
  296. s_file.Filename = dw_fileedit.Object.Filename[row]
  297. s_file.FileType = dw_fileedit.Object.FileType[row]
  298. s_file.opemp = publ_operator
  299. s_file.opdate = DateTime(Today())
  300. //s_file.encrypted = dw_fileedit.Object.encrypted[row]
  301. //s_file.compressed = dw_fileedit.Object.compressed[row]
  302. //s_file.classid = dw_fileedit.Object.classid[row]
  303. s_file.dscrp = dw_fileedit.Object.dscrp[row]
  304. s_file.DisplayName = dw_fileedit.Object.DisplayName[row]
  305. filepath = dw_fileedit.Object.filepath[row]
  306. IF s_file.Filename = '' THEN
  307. MessageBox('提示','请输入文件名称',information!,OK!)
  308. dw_fileedit.SetColumn('Filename')
  309. dw_fileedit.SetFocus( )
  310. RETURN
  311. END IF
  312. IF s_file.DisplayName = '' THEN
  313. MessageBox('提示','请输入档案名称',information!,OK!)
  314. dw_fileedit.SetColumn('DisplayName')
  315. dw_fileedit.SetFocus( )
  316. RETURN
  317. END IF
  318. IF filepath = '' THEN
  319. MessageBox('提示','请选择文件',information!,OK!)
  320. dw_fileedit.SetColumn('b_ch')
  321. dw_fileedit.SetFocus( )
  322. RETURN
  323. END IF
  324. IF wf_getfiledata(filepath,s_file.filedata,arg_msg) <=0 THEN
  325. MessageBox('错误',arg_msg,stopsign!,OK!)
  326. RETURN
  327. END IF
  328. if ls_uo_btfj.uf_save_fj( s_file, rt_fileid, Transaction_pic , arg_msg )=1 then
  329. MessageBox('提示',"更新文件成功",information!,OK! )
  330. Close(Parent)
  331. RETURN
  332. ELSE
  333. MessageBox('错误','请重试>'+arg_msg,stopsign!,OK! )
  334. RETURN
  335. END IF
  336. end event
  337. type dw_fileedit from datawindow within w_fj_fileadd
  338. integer y = 184
  339. integer width = 2665
  340. integer height = 660
  341. integer taborder = 20
  342. boolean bringtotop = true
  343. string title = "none"
  344. string dataobject = "dw_fj_file_edit"
  345. boolean livescroll = true
  346. borderstyle borderstyle = stylelowered!
  347. end type
  348. event clicked;IF dwo.Name = 'b_ch' THEN
  349. parent.triggerevent( 'ue_selectfile')
  350. END IF
  351. end event
  352. type ln_bar2 from line within w_fj_fileadd
  353. long linecolor = 16777215
  354. integer linethickness = 4
  355. integer beginy = 172
  356. integer endx = 2039
  357. integer endy = 172
  358. end type
  359. type ln_bar from line within w_fj_fileadd
  360. long linecolor = 268435456
  361. integer linethickness = 4
  362. integer beginy = 168
  363. integer endx = 2469
  364. integer endy = 168
  365. end type
  366. type r_bar from rectangle within w_fj_fileadd
  367. long linecolor = 16777215
  368. integer linethickness = 4
  369. long fillcolor = 1073741824
  370. integer x = 1531
  371. integer width = 146
  372. integer height = 68
  373. end type
  374. event constructor;this.fillcolor = 14215660
  375. this.linecolor = 14215660
  376. this.x = -1
  377. this.y = -1
  378. this.height = ln_bar.beginy - 5
  379. end event