w_aifmb_erpfj_ch.srw 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. $PBExportHeader$w_aifmb_erpfj_ch.srw
  2. forward
  3. global type w_aifmb_erpfj_ch from window
  4. end type
  5. type cb_2 from uo_imflatbutton within w_aifmb_erpfj_ch
  6. end type
  7. type cbx_showpic from checkbox within w_aifmb_erpfj_ch
  8. end type
  9. type cb_5 from uo_imflatbutton within w_aifmb_erpfj_ch
  10. end type
  11. type dw_fileclass from u_dw_rbtnfilter within w_aifmb_erpfj_ch
  12. end type
  13. type cb_6 from uo_imflatbutton within w_aifmb_erpfj_ch
  14. end type
  15. type dw_fj from datawindow within w_aifmb_erpfj_ch
  16. end type
  17. type cb_1 from uo_imflatbutton within w_aifmb_erpfj_ch
  18. end type
  19. type cb_4 from uo_imflatbutton within w_aifmb_erpfj_ch
  20. end type
  21. type cb_open from uo_imflatbutton within w_aifmb_erpfj_ch
  22. end type
  23. type ln_bar2 from line within w_aifmb_erpfj_ch
  24. end type
  25. type ln_bar from line within w_aifmb_erpfj_ch
  26. end type
  27. type r_bar from rectangle within w_aifmb_erpfj_ch
  28. end type
  29. end forward
  30. global type w_aifmb_erpfj_ch from window
  31. integer width = 2999
  32. integer height = 1372
  33. boolean titlebar = true
  34. string title = "附件管理"
  35. boolean controlmenu = true
  36. windowtype windowtype = response!
  37. long backcolor = 67108864
  38. string icon = "AppIcon!"
  39. boolean center = true
  40. event retrieve_file ( )
  41. event retrieve_fileclass ( )
  42. cb_2 cb_2
  43. cbx_showpic cbx_showpic
  44. cb_5 cb_5
  45. dw_fileclass dw_fileclass
  46. cb_6 cb_6
  47. dw_fj dw_fj
  48. cb_1 cb_1
  49. cb_4 cb_4
  50. cb_open cb_open
  51. ln_bar2 ln_bar2
  52. ln_bar ln_bar
  53. r_bar r_bar
  54. end type
  55. global w_aifmb_erpfj_ch w_aifmb_erpfj_ch
  56. type variables
  57. long ins_billtype //当前单据类型
  58. //
  59. //
  60. //
  61. //long ins_relid //当前单据ID
  62. //string ins_relcode //当前单据号码
  63. //long ins_relid_mx //当前明细ID
  64. //string ins_relcode_mx //当前明细号码
  65. //long ins_scid //分部ID
  66. //
  67. Blob ins_lbimage
  68. string ori_title
  69. datastore ins_ds_fileclass
  70. Transaction Transaction_pic
  71. string ins_openfile_log[] //用于退出后删除
  72. long ins_openfile_log_p=0 //用于退出后删除
  73. s_aifmb_erpfj_ch ins_rslt
  74. end variables
  75. forward prototypes
  76. public subroutine wf_addlog_tempfilepathname (string arg_filepathname)
  77. public subroutine wf_del_tempfilepathname ()
  78. public subroutine wf_fileopen_pic (long arg_fileid)
  79. public subroutine wf_retrfile (long arg_mtrlid)
  80. end prototypes
  81. event retrieve_file();long lrow
  82. lrow=dw_fileclass.getrow( )
  83. if lrow>0 then
  84. dw_fj.Retrieve(dw_fileclass.object.classid[lrow])
  85. else
  86. dw_fj.reset()
  87. end if
  88. //201 //物料定义-附件
  89. //102 //销售订单-附件
  90. //202 //物料清单-附件
  91. // >.. 按main函数上的ID
  92. end event
  93. event retrieve_fileclass();Long i,ls_row,ls_rowcount,nrow
  94. Long ls_classid,ls_filecount,ls_allowedit
  95. ls_rowcount = ins_ds_fileclass.Retrieve( ins_billtype)
  96. //messagebox(string(ins_billtype),ls_rowcount)
  97. dw_fileclass.Reset()
  98. dw_fileclass.Enabled = FALSE
  99. FOR i = 1 TO ls_rowcount
  100. ls_allowedit = 0
  101. ls_filecount = 0
  102. ls_classid = ins_ds_fileclass.Object.classid[i]
  103. IF f_power_ind_fileclassview(ls_classid) THEN
  104. SELECT count(*) INTO :ls_filecount
  105. FROM u_file
  106. WHERE classid = :ls_classid
  107. USING Transaction_pic;
  108. IF Transaction_pic.SQLCode <> 0 THEN
  109. MessageBox('错误','统计附件数量失败>'+Transaction_pic.SQLErrText,stopsign!,OK!)
  110. RETURN
  111. END IF
  112. IF f_power_ind_fileclassedit(ls_classid) THEN
  113. ls_allowedit = 1
  114. ELSE
  115. ls_allowedit = 0
  116. END IF
  117. nrow = dw_fileclass.InsertRow(0)
  118. dw_fileclass.Object.classid[nrow] = ls_classid
  119. dw_fileclass.Object.ClassName[nrow] = ins_ds_fileclass.Object.ClassName[i]
  120. dw_fileclass.Object.dscrp[nrow] = ins_ds_fileclass.Object.dscrp[i]
  121. dw_fileclass.Object.filecount[nrow] = ls_filecount
  122. dw_fileclass.Object.allow_edit[nrow] = ls_allowedit
  123. END IF
  124. NEXT
  125. IF dw_fileclass.RowCount() > 0 THEN
  126. dw_fileclass.SetSort('classname')
  127. dw_fileclass.Sort()
  128. dw_fileclass.SelectRow( 0, FALSE)
  129. dw_fileclass.SelectRow( 1, TRUE)
  130. dw_fileclass.ScrollToRow( 1)
  131. THIS.TriggerEvent( 'retrieve_file')
  132. END IF
  133. dw_fileclass.Enabled = TRUE
  134. //dw_fileclass.Retrieve( ins_billtype)
  135. end event
  136. public subroutine wf_addlog_tempfilepathname (string arg_filepathname);//wf_addlog_tempfilepathname
  137. if isnull(arg_filepathname) or len(trim(arg_filepathname))<3 then return
  138. ins_openfile_log_p++
  139. ins_openfile_log[ins_openfile_log_p]=arg_filepathname
  140. // string ins_openfile_log[] //用于退出后删除
  141. // long ins_openfile_log_p=0 //用于退出后删除
  142. //
  143. end subroutine
  144. public subroutine wf_del_tempfilepathname ();//wf_del_tempfilepathname
  145. // 删除临时文件
  146. long li
  147. for li=1 to ins_openfile_log_p
  148. if len(trim(ins_openfile_log[li]))<=0 then
  149. else
  150. FileDelete(ins_openfile_log[li])
  151. end if
  152. next
  153. end subroutine
  154. public subroutine wf_fileopen_pic (long arg_fileid);
  155. s_edit_index_tran s_pic
  156. s_pic.f_long= arg_fileid
  157. s_pic.sqltransaction = sys_filedb_sqlca
  158. OpenWithParm(w_fj_fileopen,s_pic)
  159. end subroutine
  160. public subroutine wf_retrfile (long arg_mtrlid);Long lrow
  161. lrow = dw_fileclass.GetRow( )
  162. IF lrow > 0 THEN
  163. dw_fj.Retrieve(dw_fileclass.Object.classid[lrow])
  164. ELSE
  165. dw_fj.Reset()
  166. END IF
  167. String ls_mtrlcode
  168. SELECT mtrlcode
  169. INTO :ls_mtrlcode
  170. FROM u_mtrldef
  171. Where mtrlid = :arg_mtrlid;
  172. IF sqlca.SQLCode = 0 THEN
  173. THIS.Title = ls_mtrlcode
  174. ELSE
  175. THIS.Title = ''
  176. END IF
  177. end subroutine
  178. on w_aifmb_erpfj_ch.create
  179. this.cb_2=create cb_2
  180. this.cbx_showpic=create cbx_showpic
  181. this.cb_5=create cb_5
  182. this.dw_fileclass=create dw_fileclass
  183. this.cb_6=create cb_6
  184. this.dw_fj=create dw_fj
  185. this.cb_1=create cb_1
  186. this.cb_4=create cb_4
  187. this.cb_open=create cb_open
  188. this.ln_bar2=create ln_bar2
  189. this.ln_bar=create ln_bar
  190. this.r_bar=create r_bar
  191. this.Control[]={this.cb_2,&
  192. this.cbx_showpic,&
  193. this.cb_5,&
  194. this.dw_fileclass,&
  195. this.cb_6,&
  196. this.dw_fj,&
  197. this.cb_1,&
  198. this.cb_4,&
  199. this.cb_open,&
  200. this.ln_bar2,&
  201. this.ln_bar,&
  202. this.r_bar}
  203. end on
  204. on w_aifmb_erpfj_ch.destroy
  205. destroy(this.cb_2)
  206. destroy(this.cbx_showpic)
  207. destroy(this.cb_5)
  208. destroy(this.dw_fileclass)
  209. destroy(this.cb_6)
  210. destroy(this.dw_fj)
  211. destroy(this.cb_1)
  212. destroy(this.cb_4)
  213. destroy(this.cb_open)
  214. destroy(this.ln_bar2)
  215. destroy(this.ln_bar)
  216. destroy(this.r_bar)
  217. end on
  218. event resize;ln_bar.EndX = THIS.Width
  219. ln_bar2.EndX = THIS.Width
  220. r_bar.Width = THIS.Width
  221. end event
  222. event open;//
  223. //IF NOT IsNull(s_tran.sqltransaction ) THEN
  224. // Transaction_pic = s_tran.sqltransaction
  225. //ELSE
  226. // MessageBox('提示','没有数据库事务',information!,OK!)
  227. // Close(THIS)
  228. // RETURN
  229. //END IF
  230. IF sys_fileDB_sqlca.DBHandle() > 0 THEN
  231. Transaction_pic = sys_fileDB_sqlca
  232. ELSE
  233. MessageBox('提示','没有数据库事务',information!,OK!)
  234. Close(This)
  235. RETURN
  236. END IF
  237. ins_ds_fileclass = Create datastore
  238. ins_ds_fileclass.DataObject = dw_fileclass.DataObject
  239. ins_ds_fileclass.SetTransObject(sqlca)
  240. //dw_fileclass.SetTransObject(sqlca)
  241. dw_fj.SetTransObject(Transaction_pic)
  242. This.TriggerEvent('retrieve_fileclass')
  243. end event
  244. event close;// 删除临时文件
  245. wf_del_tempfilepathname()
  246. closewithreturn(this, ins_rslt)
  247. end event
  248. type cb_2 from uo_imflatbutton within w_aifmb_erpfj_ch
  249. integer x = 1856
  250. integer width = 151
  251. integer height = 164
  252. integer taborder = 40
  253. string text = "选定"
  254. string normalpicname = "ok.bmp"
  255. integer picsize = 16
  256. toolbaralignment pic_align = alignattop!
  257. boolean border = false
  258. end type
  259. event clicked;call super::clicked;s_piclistview_parm s_pics[]
  260. Long cnt = 0
  261. Long i
  262. uo_fj_mng_billtype ls_uo_fjbt
  263. ls_uo_fjbt = Create uo_fj_mng_billtype
  264. Int rslt = 1
  265. String arg_msg
  266. FOR i = 1 To dw_fj.RowCount()
  267. IF dw_fj.IsSelected(i) THEN
  268. cnt++
  269. s_pics[cnt].a_any = dw_fj.Object.fileid[i]
  270. s_pics[cnt].Label = dw_fj.Object.DisplayName[i]
  271. s_pics[cnt].tmppath = sys_cur_path + 'aifmb_tmp\u_file_' + String(dw_fj.Object.fileid[i]) + '.' + dw_fj.Object.FileType[i]
  272. IF ls_uo_fjbt.uf_getfjbolb_fromdb( dw_fj.Object.fileid[i], s_pics[cnt].Data, Transaction_pic, arg_msg) = 0 THEN
  273. rslt = 0
  274. GOTO ext
  275. END IF
  276. END IF
  277. NEXT
  278. ext:
  279. Destroy ls_uo_fjbt
  280. IF rslt = 1 THEN
  281. ins_rslt.pics = s_pics
  282. Close(Parent)
  283. ELSE
  284. MessageBox('ERROR', arg_msg)
  285. END IF
  286. end event
  287. type cbx_showpic from checkbox within w_aifmb_erpfj_ch
  288. integer x = 192
  289. integer y = 92
  290. integer width = 425
  291. integer height = 56
  292. integer textsize = -9
  293. integer weight = 400
  294. fontcharset fontcharset = gb2312charset!
  295. fontpitch fontpitch = variable!
  296. string facename = "宋体"
  297. long textcolor = 33554432
  298. long backcolor = 67108864
  299. string text = "直接查看图片"
  300. boolean checked = true
  301. end type
  302. event clicked;if this.checked then
  303. f_SetProfileString (sys_empid, "w_fj_bill_mng", "cbx_showpic", '1')
  304. else
  305. f_SetProfileString (sys_empid, "w_fj_bill_mng", "cbx_showpic", '0')
  306. end if
  307. end event
  308. event constructor;THIS.BackColor = 14215660
  309. String showpic
  310. showpic = f_ProfileString (sys_empid, "w_fj_bill_mng", "cbx_showpic", "1")
  311. IF showpic = '1' THEN
  312. THIS.Checked = TRUE
  313. ELSE
  314. THIS.Checked = FALSE
  315. END IF
  316. end event
  317. type cb_5 from uo_imflatbutton within w_aifmb_erpfj_ch
  318. integer width = 151
  319. integer height = 164
  320. integer taborder = 10
  321. string text = "刷新"
  322. string normalpicname = "refresh.bmp"
  323. integer picsize = 16
  324. toolbaralignment pic_align = alignattop!
  325. boolean border = false
  326. end type
  327. event clicked;call super::clicked;PARENT.TriggerEvent('retrieve_fileclass')
  328. end event
  329. type dw_fileclass from u_dw_rbtnfilter within w_aifmb_erpfj_ch
  330. integer y = 184
  331. integer height = 1056
  332. integer taborder = 80
  333. string dataobject = "dw_fj_fileclass_list"
  334. boolean hscrollbar = true
  335. boolean vscrollbar = true
  336. end type
  337. event rowfocuschanged;call super::rowfocuschanged;IF currentrow > 0 THEN
  338. this.SelectRow( 0, FALSE)
  339. this.SelectRow( currentrow, TRUE)
  340. this.ScrollToRow( currentrow)
  341. parent.triggerevent( 'retrieve_file')
  342. END IF
  343. end event
  344. type cb_6 from uo_imflatbutton within w_aifmb_erpfj_ch
  345. integer x = 1435
  346. integer width = 274
  347. integer height = 164
  348. integer taborder = 30
  349. string text = "另存文件"
  350. string normalpicname = "save.BMP"
  351. integer picsize = 16
  352. toolbaralignment pic_align = alignattop!
  353. boolean border = false
  354. end type
  355. event clicked;call super::clicked;//附件下载并打开
  356. Integer i
  357. Long ls_i,ls_j,ls_newrow,ls_filesize
  358. Blob ls_filedata
  359. String Pathname,ls_filename
  360. String errmsg,arg_msg
  361. Long pos1,lrow,rslt,ls_fileid
  362. String ls_para,ls_downarg[],ls_filetype
  363. SetNull(ls_filedata)
  364. uo_fj_mng_billtype ls_uo_fjbt
  365. ls_uo_fjbt=create uo_fj_mng_billtype
  366. long ls_row
  367. ls_row=dw_fj.getrow()
  368. if ls_row<=0 then
  369. messagebox('提示','当前没有文件',information!,OK!)
  370. return
  371. end if
  372. //取附件信息
  373. ls_fileid = dw_fj.object.fileid[ls_row]
  374. ls_filename = dw_fj.object.filename[ls_row]
  375. ls_filetype = dw_fj.object.filetype[ls_row]
  376. IF len(ls_filetype) > 0 THEN
  377. i = GetFileSaveName("另存为",Pathname,ls_filename,"*","*."+ls_filetype+",*."+ls_filetype)
  378. ELSE
  379. i = GetFileSaveName("另存为",Pathname,ls_filename,"*","*.*,*.*")
  380. END IF
  381. IF i = 1 AND Trim(Pathname) <> '' THEN
  382. if ls_uo_fjbt.uf_getfjbolb_fromdb( ls_fileid, ls_filedata, Transaction_pic, arg_msg)=0 THEN
  383. MessageBox('错误',arg_msg,stopsign!,OK!)
  384. RETURN
  385. END IF
  386. IF f_saveblobtofile(ls_filedata,Pathname,errmsg) = 0 THEN
  387. MessageBox('错误',errmsg,stopsign!,OK!)
  388. RETURN
  389. ELSE
  390. MessageBox('提示','附件保存成功!'+'~r~n'+'保存路径:'+Pathname,information!,OK!)
  391. END IF
  392. END IF
  393. //
  394. end event
  395. type dw_fj from datawindow within w_aifmb_erpfj_ch
  396. integer x = 1015
  397. integer y = 184
  398. integer width = 1925
  399. integer height = 1056
  400. integer taborder = 70
  401. string title = "none"
  402. string dataobject = "dw_fj_file_list"
  403. boolean hscrollbar = true
  404. boolean vscrollbar = true
  405. boolean livescroll = true
  406. borderstyle borderstyle = stylelowered!
  407. end type
  408. event doubleclicked;IF row <= 0 THEN RETURN
  409. cb_open.triggerevent(clicked!)
  410. end event
  411. event clicked;IF row > 0 THEN
  412. This.SelectRow(row, Not This.IsSelected(row))
  413. END IF
  414. end event
  415. type cb_1 from uo_imflatbutton within w_aifmb_erpfj_ch
  416. integer x = 1010
  417. integer width = 151
  418. integer height = 164
  419. integer taborder = 10
  420. string text = "刷新"
  421. string normalpicname = "refresh.bmp"
  422. integer picsize = 16
  423. toolbaralignment pic_align = alignattop!
  424. boolean border = false
  425. end type
  426. event clicked;call super::clicked;PARENT.TriggerEvent('retrieve_file')
  427. end event
  428. type cb_4 from uo_imflatbutton within w_aifmb_erpfj_ch
  429. integer x = 2011
  430. integer width = 151
  431. integer height = 164
  432. integer taborder = 60
  433. string text = "退出"
  434. string normalpicname = "exit.bmp"
  435. integer picsize = 16
  436. toolbaralignment pic_align = alignattop!
  437. boolean border = false
  438. end type
  439. event clicked;call super::clicked;close(parent)
  440. end event
  441. type cb_open from uo_imflatbutton within w_aifmb_erpfj_ch
  442. integer x = 1161
  443. integer width = 274
  444. integer height = 164
  445. integer taborder = 20
  446. string text = "查看文件"
  447. string normalpicname = "audit.BMP"
  448. integer picsize = 16
  449. toolbaralignment pic_align = alignattop!
  450. boolean border = false
  451. end type
  452. event clicked;call super::clicked;//附件下载并打开
  453. Integer i
  454. Long ls_i,ls_j,ls_newrow,ls_filesize
  455. Blob ls_filedata
  456. String Pathname,ls_filename,ls_filetype
  457. String errmsg,arg_msg
  458. Long pos1,lrow,rslt,ls_fileid
  459. String ls_para,ls_downarg[]
  460. SetNull(ls_filedata)
  461. uo_fj_mng_billtype ls_uo_fjbt
  462. ls_uo_fjbt = CREATE uo_fj_mng_billtype
  463. Long ls_row
  464. ls_row = dw_fj.GetRow()
  465. IF ls_row <= 0 THEN
  466. MessageBox('提示','当前没有文件',information!,OK!)
  467. RETURN
  468. END IF
  469. //取附件信息
  470. ls_fileid = dw_fj.Object.fileid[ls_row]
  471. ls_filename = dw_fj.Object.Filename[ls_row]
  472. ls_filetype = Lower(Trim(dw_fj.Object.FileType[ls_row]))
  473. IF cbx_showpic.Checked THEN
  474. IF ls_filetype = 'bmp' OR ls_filetype = 'rle' OR ls_filetype = 'wmf' OR ls_filetype = 'tif' OR ls_filetype = 'jpg' OR ls_filetype = 'gif' OR ls_filetype = 'jpeg' THEN
  475. wf_fileopen_pic(ls_fileid)
  476. RETURN
  477. END IF
  478. END IF
  479. //下载附件并打开
  480. Pathname = sys_cur_path+ins_fjtemppath+'\'+String(Today(),'yymmdd')+String(Now(),'hhmmss')+'_'+ls_filename+'.'+ls_filetype
  481. IF Trim(Pathname) <> '' THEN
  482. IF ls_uo_fjbt.uf_getfjbolb_fromdb( ls_fileid, ls_filedata, Transaction_pic, arg_msg) = 0 THEN
  483. MessageBox('错误',arg_msg,stopsign!,OK!)
  484. RETURN 0
  485. END IF
  486. IF f_saveblobtofile(ls_filedata,Pathname,errmsg) = 0 THEN
  487. MessageBox('错误',errmsg,stopsign!,OK!)
  488. RETURN
  489. ELSE
  490. //记录临时文件位置,本窗口退出后删除
  491. wf_addlog_tempfilepathname(Pathname)
  492. //打开附件
  493. String lsNull
  494. ShellExecute32( Handle(THIS), lsNull, Pathname, lsNull, lsNull, 1 )
  495. END IF
  496. END IF
  497. DESTROY ls_uo_fjbt
  498. end event
  499. type ln_bar2 from line within w_aifmb_erpfj_ch
  500. long linecolor = 16777215
  501. integer linethickness = 4
  502. integer beginx = -23
  503. integer beginy = 172
  504. integer endx = 2016
  505. integer endy = 172
  506. end type
  507. type ln_bar from line within w_aifmb_erpfj_ch
  508. long linecolor = 268435456
  509. integer linethickness = 4
  510. integer beginx = -23
  511. integer beginy = 168
  512. integer endx = 1984
  513. integer endy = 168
  514. end type
  515. type r_bar from rectangle within w_aifmb_erpfj_ch
  516. long linecolor = 16777215
  517. integer linethickness = 4
  518. long fillcolor = 1073741824
  519. integer x = 2642
  520. integer y = 48
  521. integer width = 146
  522. integer height = 68
  523. end type
  524. event constructor;THIS.FillColor = 14215660
  525. THIS.LineColor = 14215660
  526. THIS.X = -1
  527. THIS.Y = -1
  528. THIS.Height = ln_bar.BeginY - 5
  529. end event