w_fj_fileadd_p.srw 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. $PBExportHeader$w_fj_fileadd_p.srw
  2. forward
  3. global type w_fj_fileadd_p from window
  4. end type
  5. type dw_fileedit from u_dw_rbtnfilter within w_fj_fileadd_p
  6. end type
  7. type cb_3 from uo_imflatbutton within w_fj_fileadd_p
  8. end type
  9. type cb_2 from uo_imflatbutton within w_fj_fileadd_p
  10. end type
  11. type cb_1 from uo_imflatbutton within w_fj_fileadd_p
  12. end type
  13. type cb_read from uo_imflatbutton within w_fj_fileadd_p
  14. end type
  15. type r_bar from rectangle within w_fj_fileadd_p
  16. end type
  17. type ln_bar from line within w_fj_fileadd_p
  18. end type
  19. end forward
  20. global type w_fj_fileadd_p from window
  21. integer width = 3355
  22. integer height = 1288
  23. boolean titlebar = true
  24. string title = "Untitled"
  25. boolean controlmenu = true
  26. windowtype windowtype = response!
  27. long backcolor = 134217739
  28. string icon = "AppIcon!"
  29. boolean center = true
  30. event ue_selectfile ( )
  31. dw_fileedit dw_fileedit
  32. cb_3 cb_3
  33. cb_2 cb_2
  34. cb_1 cb_1
  35. cb_read cb_read
  36. r_bar r_bar
  37. ln_bar ln_bar
  38. end type
  39. global w_fj_fileadd_p w_fj_fileadd_p
  40. type variables
  41. s_fileinfo s_file
  42. boolean import = false
  43. boolean success = false
  44. long originallyheight,originallywidth
  45. end variables
  46. forward prototypes
  47. public function integer wf_getfiledata (string arg_filepath, ref blob arg_filedata, ref string arg_msg)
  48. end prototypes
  49. event ue_selectfile();// //ue_selectfile
  50. String Pathname,Filename[],FileType, ls_Pathname
  51. Integer i, li_cnt, poi, li_failcnt
  52. Long row
  53. String arg_msg
  54. long ll_FileLength
  55. row = 1 //dw_fileedit.getrow( )
  56. FileType = ''
  57. FileType = '所有文件(*.*),*.*,'
  58. // FileType += "配置文件(*.ini), *.ini,"
  59. FileType += "Zip压缩文件(*.Zip),*.Zip,"
  60. FileType += "RAR压缩文件(*.rar),*.rar,"
  61. // FileType += "XML文件(*.xml),*.xml,"
  62. FileType += "文本文件(*.txt),*.txt,"
  63. FileType += "Excel模版(*.xlt),*.xlt,"
  64. // FileType += "Excel文档(*.xls),*.xls,"
  65. // FileType += "Word模版(*.dot),*.dot,"
  66. FileType += "Word文档(*.doc),*.doc,"
  67. FileType += "JPG(*.JPG),*.JPG,"
  68. FileType += "位图文件(*.bmp),*.bmp,"
  69. FileType += "GIF文件(*.GIF),*.GIF"
  70. i = GetFileOpenName("请选择文件", Pathname,Filename, "All", FileType)
  71. IF i < 1 THEN RETURN
  72. li_cnt = UpperBound(Filename)
  73. IF li_cnt = 1 THEN
  74. ls_Pathname = Pathname
  75. ll_FileLength = FileLength(ls_Pathname)/1024
  76. IF ll_FileLength > 10240 THEN
  77. MessageBox('限制','附件文件大小不得大于10M')
  78. RETURN
  79. END IF
  80. IF dw_fileedit.GetRow() > 0 THEN
  81. IF dw_fileedit.Object.filepath[dw_fileedit.GetRow()] = '' THEN
  82. row = dw_fileedit.GetRow()
  83. ELSE
  84. row = dw_fileedit.InsertRow(0)
  85. END IF
  86. ELSE
  87. row = dw_fileedit.InsertRow(0)
  88. END IF
  89. dw_fileedit.Object.filepath[row] = ls_Pathname
  90. dw_fileedit.Object.filesize[row] = ll_FileLength
  91. poi = lastpos(Filename[1], '.')
  92. IF poi > 0 THEN
  93. dw_fileedit.Object.Filename[row] = Mid(Filename[1],1,poi -1)
  94. dw_fileedit.Object.DisplayName[row] = Mid(Filename[1],1,poi -1)
  95. dw_fileedit.Object.FileType[row] = Mid(Filename[1],poi +1,Len(Filename[1]) - poi)
  96. ELSE
  97. dw_fileedit.Object.Filename[row] = Filename[1]
  98. dw_fileedit.Object.DisplayName[row] = Filename[1]
  99. dw_fileedit.Object.FileType[row] = ''
  100. END IF
  101. ELSE
  102. FOR i = 1 To li_cnt
  103. ls_Pathname = String(Pathname) + "\" +(String(Filename[i]))
  104. ll_FileLength = FileLength(ls_Pathname)/1024
  105. IF ll_FileLength > 10240 THEN
  106. arg_msg = '附件文件大小不得大于10M'
  107. li_failcnt ++
  108. continue
  109. END IF
  110. IF dw_fileedit.GetRow() > 0 THEN
  111. IF dw_fileedit.Object.filepath[dw_fileedit.GetRow()] = '' THEN
  112. row = dw_fileedit.GetRow()
  113. ELSE
  114. row = dw_fileedit.InsertRow(0)
  115. END IF
  116. ELSE
  117. row = dw_fileedit.InsertRow(0)
  118. END IF
  119. dw_fileedit.Object.filepath[row] = ls_Pathname
  120. dw_fileedit.Object.filesize[row] = ll_FileLength
  121. poi = lastpos(Filename[i], '.')
  122. IF poi > 0 THEN
  123. dw_fileedit.Object.Filename[row] = Mid(Filename[i],1,poi -1)
  124. dw_fileedit.Object.DisplayName[row] = Mid(Filename[i],1,poi -1)
  125. dw_fileedit.Object.FileType[row] = Mid(Filename[i],poi +1,Len(Filename[i]) - poi)
  126. ELSE
  127. dw_fileedit.Object.Filename[row] = Filename[i]
  128. dw_fileedit.Object.DisplayName[row] = Filename[i]
  129. dw_fileedit.Object.FileType[row] = ''
  130. END IF
  131. NEXT
  132. IF li_failcnt > 0 THEN
  133. MessageBox('限制','附件文件大小不得大于10M,'+String(li_failcnt)+'个文件导入失败!')
  134. END IF
  135. END IF
  136. end event
  137. public function integer wf_getfiledata (string arg_filepath, ref blob arg_filedata, ref string arg_msg);
  138. Long rslt = 1,i
  139. Long ll_fileLength,li_FileNum,loops,bytes_read
  140. Blob b,temp
  141. IF arg_filepath = '' Or Not FileExists(arg_filepath) THEN
  142. rslt = 0
  143. arg_msg = '文件'+arg_filepath+'不存在'
  144. GOTO ext
  145. END IF
  146. ll_fileLength = FileLength(arg_filepath)
  147. IF ll_fileLength = 0 THEN
  148. rslt = 0
  149. arg_msg = '文件'+arg_filepath+'没有内容'
  150. GOTO ext
  151. END IF
  152. li_FileNum = FileOpen(arg_filepath, StreamMode!, Read!, LockRead!)
  153. IF ll_fileLength > 32765 THEN
  154. IF Mod(ll_fileLength, 32765) = 0 THEN
  155. loops = ll_fileLength/32765
  156. ELSE
  157. loops = (ll_fileLength/32765) + 1
  158. END IF
  159. ELSE
  160. loops = 1
  161. END IF
  162. IF li_FileNum = -1 THEN
  163. rslt = 0
  164. arg_msg = '读取文件'+arg_filepath+'出错,文件可能正在被使用'
  165. GOTO ext
  166. END IF
  167. FOR i = 1 To loops
  168. bytes_read = FileRead(li_FileNum, b)
  169. IF bytes_read < 0 THEN
  170. rslt = 0
  171. arg_msg = '读取文件'+arg_filepath+'出错'
  172. GOTO ext
  173. END IF
  174. temp = temp + b
  175. NEXT
  176. FileClose(li_FileNum)
  177. arg_filedata = temp
  178. rslt=ll_fileLength
  179. ext:
  180. RETURN rslt
  181. end function
  182. on w_fj_fileadd_p.create
  183. this.dw_fileedit=create dw_fileedit
  184. this.cb_3=create cb_3
  185. this.cb_2=create cb_2
  186. this.cb_1=create cb_1
  187. this.cb_read=create cb_read
  188. this.r_bar=create r_bar
  189. this.ln_bar=create ln_bar
  190. this.Control[]={this.dw_fileedit,&
  191. this.cb_3,&
  192. this.cb_2,&
  193. this.cb_1,&
  194. this.cb_read,&
  195. this.r_bar,&
  196. this.ln_bar}
  197. end on
  198. on w_fj_fileadd_p.destroy
  199. destroy(this.dw_fileedit)
  200. destroy(this.cb_3)
  201. destroy(this.cb_2)
  202. destroy(this.cb_1)
  203. destroy(this.cb_read)
  204. destroy(this.r_bar)
  205. destroy(this.ln_bar)
  206. end on
  207. event open;s_file = Message.PowerObjectParm
  208. Long ll_i_row
  209. ll_i_row = dw_fileedit.InsertRow(0)
  210. dw_fileedit.SetFocus()
  211. dw_fileedit.SetColumn('displayname')
  212. this.triggerevent( 'ue_selectfile')
  213. end event
  214. event resize;ln_bar.EndX = THIS.Width
  215. r_bar.Width = THIS.Width
  216. end event
  217. type dw_fileedit from u_dw_rbtnfilter within w_fj_fileadd_p
  218. integer y = 176
  219. integer width = 3323
  220. integer height = 1016
  221. integer taborder = 50
  222. string dataobject = "dw_fj_fileadd_p"
  223. boolean hscrollbar = true
  224. boolean vscrollbar = true
  225. boolean hsplitscroll = true
  226. boolean rbutton_setposition_use = true
  227. boolean titleclick_sort_use = true
  228. end type
  229. event rowfocuschanged;call super::rowfocuschanged;if IsNull(currentrow) then return
  230. if (currentrow <= 0) then return
  231. this.SelectRow(0, false)
  232. this.SelectRow(currentrow, true)
  233. end event
  234. type cb_3 from uo_imflatbutton within w_fj_fileadd_p
  235. integer x = 818
  236. integer width = 274
  237. integer height = 164
  238. integer taborder = 40
  239. boolean bringtotop = true
  240. string text = "取消"
  241. string normalpicname = "exit.bmp"
  242. integer picsize = 16
  243. toolbaralignment pic_align = alignattop!
  244. boolean border = false
  245. end type
  246. event clicked;call super::clicked;success = false
  247. close(parent)
  248. end event
  249. type cb_2 from uo_imflatbutton within w_fj_fileadd_p
  250. integer x = 544
  251. integer width = 274
  252. integer height = 164
  253. integer taborder = 30
  254. boolean bringtotop = true
  255. string text = "上传"
  256. string normalpicname = "preview.bmp"
  257. integer picsize = 16
  258. toolbaralignment pic_align = alignattop!
  259. boolean border = false
  260. end type
  261. event clicked;call super::clicked;Long row,rt_fileid, ll_succnt, ll_failcnt
  262. int rslt = 1
  263. Long cnt
  264. String arg_msg, ls_msg
  265. String filepath
  266. s_fileinfo_arr s_file_arr
  267. uo_fx_fj uo_fj
  268. uo_fj = create uo_fx_fj
  269. dw_fileedit.AcceptText( )
  270. FOR row = 1 To dw_fileedit.RowCount()
  271. IF dw_fileedit.Object.filepath[row] <> '' THEN
  272. IF dw_fileedit.Object.Filename[row] = '' THEN
  273. MessageBox('系统提示','行:'+String(row)+',请输入文件名称')
  274. RETURN
  275. END IF
  276. IF dw_fileedit.Object.DisplayName[row] = '' THEN
  277. MessageBox('系统提示','行:'+String(row)+',请输入档案名称')
  278. RETURN
  279. END IF
  280. END IF
  281. NEXT
  282. FOR row = 1 To dw_fileedit.RowCount()
  283. IF dw_fileedit.Object.filepath[row] <> '' and dw_fileedit.Object.fileid[row] = 0 THEN
  284. s_file.Fileid = 0
  285. s_file.Filename = dw_fileedit.Object.Filename[row]
  286. s_file.FileType = dw_fileedit.Object.FileType[row]
  287. s_file.dscrp = dw_fileedit.Object.dscrp[row]
  288. s_file.DisplayName = dw_fileedit.Object.DisplayName[row]
  289. s_file.filepath = dw_fileedit.Object.filepath[row]
  290. filepath = dw_fileedit.Object.filepath[row]
  291. IF wf_getfiledata(filepath,s_file.filedata,arg_msg) <= 0 THEN
  292. ll_failcnt++
  293. ls_msg += "行:"+String(row)+","+arg_msg+'~r~n'
  294. rslt = 0
  295. GOTO nxtfj
  296. END IF
  297. cnt++
  298. s_file_arr.fileid[cnt] = s_file.fileid
  299. s_file_arr.billtype[cnt] = s_file.billtype
  300. s_file_arr.displayName[cnt] = s_file.displayName
  301. s_file_arr.fileName[cnt] = s_file.fileName
  302. s_file_arr.fileType[cnt] = s_file.fileType
  303. s_file_arr.dscrp[cnt] = s_file.dscrp
  304. s_file_arr.opemp[cnt] = s_file.opemp
  305. s_file_arr.opdate[cnt] = s_file.opdate
  306. s_file_arr.fileData[cnt] = s_file.fileData
  307. s_file_arr.relid_mx[cnt] = s_file.relid_mx
  308. s_file_arr.relid[cnt] = s_file.relid
  309. s_file_arr.relcode[cnt] = s_file.relcode
  310. s_file_arr.filepath[cnt] = s_file.filepath
  311. END IF
  312. nxtfj:
  313. NEXT
  314. IF uo_fj.update_fxfj(s_file_arr,arg_msg) = 0 THEN
  315. MessageBox('失败',arg_msg )
  316. RETURN
  317. ELSE
  318. MessageBox('成功',"上传文件成功" )
  319. Close(Parent)
  320. END IF
  321. end event
  322. type cb_1 from uo_imflatbutton within w_fj_fileadd_p
  323. integer x = 270
  324. integer width = 274
  325. integer height = 164
  326. integer taborder = 20
  327. boolean bringtotop = true
  328. string text = "删明细"
  329. string normalpicname = "delete.bmp"
  330. integer picsize = 16
  331. toolbaralignment pic_align = alignattop!
  332. boolean border = false
  333. end type
  334. event clicked;call super::clicked;IF dw_fileedit.GetRow() <= 0 THEN RETURN
  335. IF MessageBox("系统提示", "是否确定删除当前明细行?", Question!, YesNo!) = 2 THEN RETURN
  336. dw_fileedit.DeleteRow(0)
  337. end event
  338. type cb_read from uo_imflatbutton within w_fj_fileadd_p
  339. integer width = 274
  340. integer height = 164
  341. integer taborder = 10
  342. boolean bringtotop = true
  343. string text = "选择文件"
  344. string normalpicname = "open.bmp"
  345. integer picsize = 16
  346. toolbaralignment pic_align = alignattop!
  347. boolean border = false
  348. end type
  349. event clicked;call super::clicked;// //ue_selectfile
  350. String Pathname,Filename[],FileType, ls_Pathname
  351. Integer i, li_cnt, poi, li_failcnt
  352. Long row
  353. String arg_msg
  354. long ll_FileLength
  355. row = 1 //dw_fileedit.getrow( )
  356. FileType = ''
  357. FileType = '所有文件(*.*),*.*,'
  358. // FileType += "配置文件(*.ini), *.ini,"
  359. FileType += "Zip压缩文件(*.Zip),*.Zip,"
  360. FileType += "RAR压缩文件(*.rar),*.rar,"
  361. // FileType += "XML文件(*.xml),*.xml,"
  362. FileType += "文本文件(*.txt),*.txt,"
  363. FileType += "Excel模版(*.xlt),*.xlt,"
  364. // FileType += "Excel文档(*.xls),*.xls,"
  365. // FileType += "Word模版(*.dot),*.dot,"
  366. FileType += "Word文档(*.doc),*.doc,"
  367. FileType += "JPG(*.JPG),*.JPG,"
  368. FileType += "位图文件(*.bmp),*.bmp,"
  369. FileType += "GIF文件(*.GIF),*.GIF"
  370. i = GetFileOpenName("请选择文件", Pathname,Filename, "All", FileType)
  371. IF i < 1 THEN RETURN
  372. li_cnt = UpperBound(Filename)
  373. IF li_cnt = 1 THEN
  374. ls_Pathname = Pathname
  375. ll_FileLength = FileLength(ls_Pathname)/1024
  376. IF ll_FileLength > 10240 THEN
  377. MessageBox('限制','附件文件大小不得大于10M')
  378. RETURN
  379. END IF
  380. IF dw_fileedit.GetRow() > 0 THEN
  381. IF dw_fileedit.Object.filepath[dw_fileedit.GetRow()] = '' THEN
  382. row = dw_fileedit.GetRow()
  383. ELSE
  384. row = dw_fileedit.InsertRow(0)
  385. END IF
  386. ELSE
  387. row = dw_fileedit.InsertRow(0)
  388. END IF
  389. dw_fileedit.Object.filepath[row] = ls_Pathname
  390. dw_fileedit.Object.filesize[row] = ll_FileLength
  391. poi = lastpos(Filename[1], '.')
  392. IF poi > 0 THEN
  393. dw_fileedit.Object.Filename[row] = Mid(Filename[1],1,poi -1)
  394. dw_fileedit.Object.DisplayName[row] = Mid(Filename[1],1,poi -1)
  395. dw_fileedit.Object.FileType[row] = Mid(Filename[1],poi +1,Len(Filename[1]) - poi)
  396. ELSE
  397. dw_fileedit.Object.Filename[row] = Filename[1]
  398. dw_fileedit.Object.DisplayName[row] = Filename[1]
  399. dw_fileedit.Object.FileType[row] = ''
  400. END IF
  401. ELSE
  402. FOR i = 1 To li_cnt
  403. ls_Pathname = String(Pathname) + "\" +(String(Filename[i]))
  404. ll_FileLength = FileLength(ls_Pathname)/1024
  405. IF ll_FileLength > 10240 THEN
  406. arg_msg = '附件文件大小不得大于10M'
  407. li_failcnt ++
  408. continue
  409. END IF
  410. IF dw_fileedit.GetRow() > 0 THEN
  411. IF dw_fileedit.Object.filepath[dw_fileedit.GetRow()] = '' THEN
  412. row = dw_fileedit.GetRow()
  413. ELSE
  414. row = dw_fileedit.InsertRow(0)
  415. END IF
  416. ELSE
  417. row = dw_fileedit.InsertRow(0)
  418. END IF
  419. dw_fileedit.Object.filepath[row] = ls_Pathname
  420. dw_fileedit.Object.filesize[row] = ll_FileLength
  421. poi = lastpos(Filename[i], '.')
  422. IF poi > 0 THEN
  423. dw_fileedit.Object.Filename[row] = Mid(Filename[i],1,poi -1)
  424. dw_fileedit.Object.DisplayName[row] = Mid(Filename[i],1,poi -1)
  425. dw_fileedit.Object.FileType[row] = Mid(Filename[i],poi +1,Len(Filename[i]) - poi)
  426. ELSE
  427. dw_fileedit.Object.Filename[row] = Filename[i]
  428. dw_fileedit.Object.DisplayName[row] = Filename[i]
  429. dw_fileedit.Object.FileType[row] = ''
  430. END IF
  431. NEXT
  432. IF li_failcnt > 0 THEN
  433. MessageBox('限制','附件文件大小不得大于10M,'+String(li_failcnt)+'个文件导入失败!')
  434. END IF
  435. END IF
  436. end event
  437. type r_bar from rectangle within w_fj_fileadd_p
  438. long linecolor = 16777215
  439. integer linethickness = 4
  440. long fillcolor = 1073741824
  441. integer x = 1687
  442. integer y = 40
  443. integer width = 87
  444. integer height = 52
  445. end type
  446. event constructor;THIS.FillColor = 14215660
  447. THIS.LineColor = 14215660
  448. THIS.X = -1
  449. THIS.Y = -1
  450. THIS.Height = ln_bar.BeginY - 5
  451. end event
  452. type ln_bar from line within w_fj_fileadd_p
  453. long linecolor = 268435456
  454. integer linethickness = 4
  455. integer beginy = 164
  456. integer endx = 2002
  457. integer endy = 164
  458. end type