w_emp_pic2.srw 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. $PBExportHeader$w_emp_pic2.srw
  2. forward
  3. global type w_emp_pic2 from window
  4. end type
  5. type cb_6 from uo_imflatbutton within w_emp_pic2
  6. end type
  7. type st_2 from statictext within w_emp_pic2
  8. end type
  9. type st_1 from statictext within w_emp_pic2
  10. end type
  11. type cb_5 from uo_imflatbutton within w_emp_pic2
  12. end type
  13. type p_2 from picture within w_emp_pic2
  14. end type
  15. type p_1 from picture within w_emp_pic2
  16. end type
  17. type cb_4 from uo_imflatbutton within w_emp_pic2
  18. end type
  19. type cb_3 from uo_imflatbutton within w_emp_pic2
  20. end type
  21. type cb_2 from uo_imflatbutton within w_emp_pic2
  22. end type
  23. type cb_1 from uo_imflatbutton within w_emp_pic2
  24. end type
  25. type gb_1 from groupbox within w_emp_pic2
  26. end type
  27. end forward
  28. global type w_emp_pic2 from window
  29. integer x = 2999
  30. integer y = 1408
  31. integer width = 987
  32. integer height = 996
  33. boolean titlebar = true
  34. string title = "员工图片管理"
  35. boolean controlmenu = true
  36. windowtype windowtype = response!
  37. long backcolor = 134217739
  38. string icon = "AppIcon!"
  39. event ue_destop ( )
  40. cb_6 cb_6
  41. st_2 st_2
  42. st_1 st_1
  43. cb_5 cb_5
  44. p_2 p_2
  45. p_1 p_1
  46. cb_4 cb_4
  47. cb_3 cb_3
  48. cb_2 cb_2
  49. cb_1 cb_1
  50. gb_1 gb_1
  51. end type
  52. global w_emp_pic2 w_emp_pic2
  53. type variables
  54. long cur_empid
  55. Blob lb_pic
  56. boolean import = false
  57. boolean success = false
  58. end variables
  59. forward prototypes
  60. public function long wf_picretrieve (long arg_empid)
  61. public function long wf_picsave (transaction pictrans, long arg_empid, ref string arg_msg)
  62. public subroutine wf_resize ()
  63. end prototypes
  64. event ue_destop();//附件下载并打开
  65. Integer i
  66. Blob ls_filedata
  67. String Pathname,ls_filename
  68. String errmsg,arg_msg
  69. IF ISNULL(lb_pic) THEN
  70. MessageBox('系统提示','图片不存在')
  71. RETURN
  72. END IF
  73. //取附件信息
  74. i = GetFileSaveName("另存为",Pathname,ls_filename,"*",".jpg,*.jpg")
  75. If i = 1 And Trim(Pathname) <> '' Then
  76. If f_saveblobtofile(lb_pic,Pathname,errmsg) = 0 Then
  77. MessageBox('系统提示',errmsg)
  78. Return
  79. Else
  80. MessageBox('系统提示','保存成功!'+'~r~n'+'保存路径:'+Pathname)
  81. End If
  82. End If
  83. end event
  84. public function long wf_picretrieve (long arg_empid);//Blob lb_pic_tmp
  85. Long ll_cnt
  86. Blob lb
  87. p_1.visible = false
  88. p_1.Width = 603
  89. p_1.Height = 704
  90. SetNull(lb)
  91. SELECT count(*) INTO :ll_cnt
  92. FROM u_rs_emppic
  93. Where empid = :arg_empid USING sqlca;
  94. IF sqlca.SQLCode <> 0 THEN
  95. SetNull(lb)
  96. p_1.SetPicture(lb)
  97. // p_1.PictureName = 'nullpic.bmp'
  98. p_1.visible = true
  99. RETURN 1
  100. END IF
  101. IF ll_cnt = 0 THEN
  102. SetNull(lb)
  103. p_1.SetPicture(lb)
  104. // p_1.PictureName = 'nullpic.bmp'
  105. p_1.visible = true
  106. RETURN 1
  107. END IF
  108. p_1.SetPicture(lb)
  109. SELECTBLOB picture
  110. INTO :lb_pic
  111. FROM u_rs_emppic
  112. Where empid = :arg_empid USING sqlca;
  113. IF sqlca.SQLCode <> 0 THEN
  114. SetNull(lb)
  115. // p_1.PictureName = 'nullpic.bmp'
  116. p_1.SetPicture(lb)
  117. p_1.visible = true
  118. END IF
  119. IF Len(String(lb_pic)) > 0 THEN
  120. p_1.SetPicture(lb_pic)
  121. p_2.SetPicture(lb_pic)
  122. p_1.X = 18
  123. p_1.Y = 56
  124. p_1.Width = 603
  125. p_1.Height = 704
  126. IF p_2.Width < 603 AND p_2.Height < 704 THEN
  127. p_1.Width = p_2.Width
  128. p_1.Height = p_2.Height
  129. wf_resize()
  130. p_1.visible = true
  131. RETURN 1
  132. END IF
  133. If (p_2.Width / p_2.Height) > (603/704) THEN
  134. p_1.Width = 603
  135. p_1.Height = 603 / (p_2.Width / p_2.Height )
  136. ELSE
  137. p_1.Width = 704 * (p_2.Width / p_2.Height )
  138. p_1.Height = 704
  139. p_1.X = 603 - p_1.Width
  140. END IF
  141. wf_resize()
  142. p_1.visible = true
  143. ELSE
  144. SetNull(lb)
  145. p_1.SetPicture(lb)
  146. // p_1.PictureName = 'nullpic.bmp'
  147. p_1.visible = true
  148. END IF
  149. RETURN 1
  150. end function
  151. public function long wf_picsave (transaction pictrans, long arg_empid, ref string arg_msg);//wf_picsave()
  152. blob lb,bl_mtrlpic,bl_jgpic,bl_packpic
  153. int li_piccount,rslt = 1
  154. //lb = ole_1.objectdata
  155. if not isnull(lb) and len(lb)>1 and len(lb)<>1536 then
  156. //showmsg('没有获取员工相片信息')
  157. select count(*) into :li_piccount from u_rs_emppic where empid = :arg_empid;
  158. if sqlca.sqlcode = -1 then
  159. rslt = 0
  160. arg_msg = '查询员工图片失败!原因:'+sqlca.sqlerrtext
  161. goto ext
  162. end if
  163. if li_piccount = 0 then
  164. insert into u_rs_emppic (empid) values(:arg_empid) using pictrans;
  165. if sqlca.sqlcode = -1 then
  166. rslt = 0
  167. arg_msg = '保存员工图片失败!原因:'+sqlca.sqlerrtext
  168. goto ext
  169. end if
  170. commit using pictrans;
  171. end if
  172. updateblob u_rs_emppic
  173. set picture = :lb
  174. where empid = :arg_empid using pictrans;
  175. if pictrans.sqlcode = -1 then
  176. rslt = 0
  177. arg_msg = '员工图片失败!原因:'+pictrans.sqlerrtext
  178. goto ext
  179. end if
  180. commit using pictrans;
  181. end if
  182. ext:
  183. if rslt = 0 then
  184. rollback using pictrans;
  185. end if
  186. return (rslt)
  187. end function
  188. public subroutine wf_resize ();long li_SW,li_SH
  189. long li_x = 1,li_y = 1
  190. li_SW = 603
  191. li_SH = 704
  192. li_x = (li_SW - p_1.Width)/2 + gb_1.x + 28
  193. li_y = (li_SH - p_1.Height)/2 + gb_1.y + 60
  194. p_1.Move(li_x,li_y)
  195. end subroutine
  196. on w_emp_pic2.create
  197. this.cb_6=create cb_6
  198. this.st_2=create st_2
  199. this.st_1=create st_1
  200. this.cb_5=create cb_5
  201. this.p_2=create p_2
  202. this.p_1=create p_1
  203. this.cb_4=create cb_4
  204. this.cb_3=create cb_3
  205. this.cb_2=create cb_2
  206. this.cb_1=create cb_1
  207. this.gb_1=create gb_1
  208. this.Control[]={this.cb_6,&
  209. this.st_2,&
  210. this.st_1,&
  211. this.cb_5,&
  212. this.p_2,&
  213. this.p_1,&
  214. this.cb_4,&
  215. this.cb_3,&
  216. this.cb_2,&
  217. this.cb_1,&
  218. this.gb_1}
  219. end on
  220. on w_emp_pic2.destroy
  221. destroy(this.cb_6)
  222. destroy(this.st_2)
  223. destroy(this.st_1)
  224. destroy(this.cb_5)
  225. destroy(this.p_2)
  226. destroy(this.p_1)
  227. destroy(this.cb_4)
  228. destroy(this.cb_3)
  229. destroy(this.cb_2)
  230. destroy(this.cb_1)
  231. destroy(this.gb_1)
  232. end on
  233. event open;cur_empid=Message.DoubleParm
  234. cb_1.triggerevent(clicked!)
  235. end event
  236. type cb_6 from uo_imflatbutton within w_emp_pic2
  237. integer x = 663
  238. integer y = 464
  239. integer width = 256
  240. integer height = 96
  241. integer taborder = 40
  242. string text = "另存图片"
  243. end type
  244. event clicked;call super::clicked;parent.triggerevent('ue_destop')
  245. end event
  246. type st_2 from statictext within w_emp_pic2
  247. integer x = 160
  248. integer y = 852
  249. integer width = 453
  250. integer height = 48
  251. integer textsize = -9
  252. integer weight = 400
  253. fontcharset fontcharset = gb2312charset!
  254. fontpitch fontpitch = variable!
  255. string facename = "宋体"
  256. long textcolor = 16711680
  257. long backcolor = 134217739
  258. string text = "可以获得最佳效果"
  259. boolean focusrectangle = false
  260. end type
  261. type st_1 from statictext within w_emp_pic2
  262. integer x = 27
  263. integer y = 796
  264. integer width = 1303
  265. integer height = 56
  266. integer textsize = -9
  267. integer weight = 400
  268. fontcharset fontcharset = gb2312charset!
  269. fontpitch fontpitch = variable!
  270. string facename = "宋体"
  271. long textcolor = 16711680
  272. long backcolor = 134217739
  273. string text = "提示:照片大小控制在130*170之内,"
  274. boolean focusrectangle = false
  275. end type
  276. type cb_5 from uo_imflatbutton within w_emp_pic2
  277. integer x = 663
  278. integer y = 560
  279. integer width = 256
  280. integer height = 96
  281. integer taborder = 40
  282. string text = "删除图片"
  283. end type
  284. event clicked;call super::clicked;IF MessageBox("询问", '是否删除该员工的图片资料?', question!, OKCancel!, 2) = 2 THEN RETURN
  285. DELETE FROM u_rs_emppic Where empid = :cur_empid;
  286. IF sqlca.SQLCode <> 0 THEN
  287. ROLLBACK;
  288. MessageBox('Error','删除员工图片失败!')
  289. RETURN
  290. END IF
  291. p_1.PictureName = 'graphics\nophoto.jpg'
  292. p_2.PictureName = 'graphics\nophoto.jpg'
  293. p_1.X = 46
  294. p_1.Y = 60
  295. p_1.Width = 603
  296. p_1.Height = 704
  297. IF p_2.Width < 603 AND p_2.Height < 704 THEN
  298. p_1.Width = p_2.Width
  299. p_1.Height = p_2.Height
  300. wf_resize()
  301. END IF
  302. COMMIT;
  303. MessageBox('系统提示','删除员工图片成功!')
  304. end event
  305. type p_2 from picture within w_emp_pic2
  306. boolean visible = false
  307. integer x = 480
  308. integer y = 428
  309. integer width = 375
  310. integer height = 192
  311. boolean originalsize = true
  312. boolean focusrectangle = false
  313. end type
  314. type p_1 from picture within w_emp_pic2
  315. integer x = 46
  316. integer y = 60
  317. integer width = 603
  318. integer height = 704
  319. boolean originalsize = true
  320. boolean focusrectangle = false
  321. end type
  322. type cb_4 from uo_imflatbutton within w_emp_pic2
  323. integer x = 663
  324. integer y = 652
  325. integer width = 256
  326. integer height = 96
  327. integer taborder = 30
  328. string text = "退出"
  329. string normalpicname = "exit.bmp"
  330. end type
  331. event clicked;call super::clicked;close(parent)
  332. end event
  333. type cb_3 from uo_imflatbutton within w_emp_pic2
  334. integer x = 663
  335. integer y = 340
  336. integer width = 256
  337. integer height = 96
  338. integer taborder = 30
  339. string text = "保存图片"
  340. end type
  341. event clicked;call super::clicked;IF NOT import THEN
  342. MessageBox('系统提示','请选择图片!')
  343. success = FALSE
  344. RETURN
  345. END IF
  346. Long ll_cnt
  347. SELECT count(*) INTO :ll_cnt
  348. FROM u_rs_emppic
  349. Where empid = :cur_empid;
  350. IF sqlca.SQLCode <> 0 THEN
  351. MessageBox('Error','查询员工照片资料失败')
  352. RETURN
  353. END IF
  354. IF ll_cnt = 0 THEN
  355. INSERT INTO u_rs_emppic (empid) Values (:cur_empid) ;
  356. IF sqlca.SQLCode <> 0 THEN
  357. ROLLBACK;
  358. MessageBox('Error','插入员工图片资料失败>>'+ sqlca.SQLErrText )
  359. success = FALSE
  360. RETURN
  361. END IF
  362. END IF
  363. UPDATEBLOB u_rs_emppic Set picture = :lb_pic
  364. Where empid = :cur_empid;
  365. IF sqlca.SQLCode = 0 THEN
  366. MessageBox('成功',"更新图片成功" )
  367. COMMIT USING sqlca;
  368. success = TRUE
  369. Close(PARENT)
  370. RETURN
  371. ELSE
  372. MessageBox('失败',"更新图片失败" + sqlca.SQLErrText )
  373. ROLLBACK USING sqlca;
  374. RETURN
  375. END IF
  376. end event
  377. type cb_2 from uo_imflatbutton within w_emp_pic2
  378. integer x = 663
  379. integer y = 248
  380. integer width = 256
  381. integer height = 96
  382. integer taborder = 30
  383. string text = "获取图片"
  384. end type
  385. event clicked;call super::clicked;String Pathname,Filename
  386. Integer i
  387. i = GetFileOpenName("请选择图片", Pathname, Filename, "PIC", "JPG(*.JPG),*.JPG,位图文件(*.bmp),*.bmp")
  388. If i = 1 And Trim(Pathname) <> '' And Trim(Filename) <> "" Then
  389. If Pathname = '' Or Not FileExists(Pathname) Then
  390. MessageBox('系统提示','请选择图片!')
  391. success = False
  392. import = False
  393. Return
  394. End If
  395. ///////////////////////////////////////////// //
  396. SetNull(lb_pic)
  397. Long ll_fileLength,li_FileNum,loops,new_pos,bytes_read
  398. Blob b,temp
  399. ll_fileLength = FileLength(Pathname)
  400. li_FileNum = FileOpen(Pathname, StreamMode!, Read!, LockRead!)
  401. If ll_fileLength > 32765 Then
  402. If Mod(ll_fileLength, 32765) = 0 Then
  403. loops = ll_fileLength/32765
  404. Else
  405. loops = (ll_fileLength/32765) + 1
  406. End If
  407. Else
  408. loops = 1
  409. End If
  410. // Read the file
  411. new_pos = 1
  412. For i = 1 To loops
  413. bytes_read = FileRead(li_FileNum, b)
  414. temp = temp + b
  415. Next
  416. FileClose(li_FileNum)
  417. lb_pic = temp
  418. p_1.PictureName = Filename
  419. p_1.SetPicture(lb_pic)
  420. p_2.PictureName = Filename
  421. p_2.SetPicture(lb_pic)
  422. Filename = Lower(Filename)
  423. import = True
  424. Else
  425. success = False
  426. End If
  427. p_1.X = 46
  428. p_1.Y = 60
  429. p_1.Width = 603
  430. p_1.Height = 704
  431. If p_2.Width < 603 And p_2.Height < 704 Then
  432. p_1.Width = p_2.Width
  433. p_1.Height = p_2.Height
  434. wf_resize()
  435. Return
  436. End If
  437. If (p_2.Width / p_2.Height) > (603/704) Then
  438. p_1.Width = 603
  439. p_1.Height = 603 / (p_2.Width / p_2.Height )
  440. Else
  441. p_1.Width = 704 * (p_2.Width / p_2.Height )
  442. p_1.Height = 704
  443. p_1.X = 603 - p_1.Width
  444. End If
  445. wf_resize()
  446. end event
  447. type cb_1 from uo_imflatbutton within w_emp_pic2
  448. integer x = 663
  449. integer y = 56
  450. integer width = 256
  451. integer height = 96
  452. integer taborder = 20
  453. string text = "刷新"
  454. end type
  455. event clicked;call super::clicked;
  456. wf_picretrieve(cur_empid)
  457. end event
  458. type gb_1 from groupbox within w_emp_pic2
  459. integer x = 18
  460. integer width = 937
  461. integer height = 784
  462. integer taborder = 10
  463. integer textsize = -12
  464. integer weight = 400
  465. fontcharset fontcharset = ansi!
  466. fontpitch fontpitch = variable!
  467. fontfamily fontfamily = swiss!
  468. string facename = "Arial"
  469. long textcolor = 33554432
  470. long backcolor = 134217739
  471. end type