w_department_edit.srw 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. $PBExportHeader$w_department_edit.srw
  2. forward
  3. global type w_department_edit from w_publ_base
  4. end type
  5. type cb_refresh from uo_imflatbutton within w_department_edit
  6. end type
  7. type cb_add from uo_imflatbutton within w_department_edit
  8. end type
  9. type cb_add_next from uo_imflatbutton within w_department_edit
  10. end type
  11. type cb_mod from uo_imflatbutton within w_department_edit
  12. end type
  13. type cb_del from uo_imflatbutton within w_department_edit
  14. end type
  15. type tv_1 from uo_tv_deptype within w_department_edit
  16. end type
  17. type cb_help from uo_imflatbutton within w_department_edit
  18. end type
  19. type r_bar from rectangle within w_department_edit
  20. end type
  21. type ln_bar from line within w_department_edit
  22. end type
  23. type ln_bar2 from line within w_department_edit
  24. end type
  25. end forward
  26. global type w_department_edit from w_publ_base
  27. integer width = 2153
  28. integer height = 2380
  29. string title = "部门"
  30. cb_refresh cb_refresh
  31. cb_add cb_add
  32. cb_add_next cb_add_next
  33. cb_mod cb_mod
  34. cb_del cb_del
  35. tv_1 tv_1
  36. cb_help cb_help
  37. r_bar r_bar
  38. ln_bar ln_bar
  39. ln_bar2 ln_bar2
  40. end type
  41. global w_department_edit w_department_edit
  42. type variables
  43. long il_hand
  44. end variables
  45. forward prototypes
  46. public function integer wf_cnt_dot (string arg_mtrltype)
  47. end prototypes
  48. public function integer wf_cnt_dot (string arg_mtrltype);long rst_cnt
  49. string ls_mtrltype
  50. long pos_dot
  51. ls_mtrltype = arg_mtrltype
  52. again:
  53. pos_dot = pos(ls_mtrltype,'>>')
  54. if pos_dot > 0 then
  55. rst_cnt++
  56. ls_mtrltype = mid( ls_mtrltype,pos_dot + 2 )
  57. goto again
  58. else
  59. goto ext
  60. end if
  61. ext:
  62. return rst_cnt
  63. end function
  64. on w_department_edit.create
  65. int iCurrent
  66. call super::create
  67. this.cb_refresh=create cb_refresh
  68. this.cb_add=create cb_add
  69. this.cb_add_next=create cb_add_next
  70. this.cb_mod=create cb_mod
  71. this.cb_del=create cb_del
  72. this.tv_1=create tv_1
  73. this.cb_help=create cb_help
  74. this.r_bar=create r_bar
  75. this.ln_bar=create ln_bar
  76. this.ln_bar2=create ln_bar2
  77. iCurrent=UpperBound(this.Control)
  78. this.Control[iCurrent+1]=this.cb_refresh
  79. this.Control[iCurrent+2]=this.cb_add
  80. this.Control[iCurrent+3]=this.cb_add_next
  81. this.Control[iCurrent+4]=this.cb_mod
  82. this.Control[iCurrent+5]=this.cb_del
  83. this.Control[iCurrent+6]=this.tv_1
  84. this.Control[iCurrent+7]=this.cb_help
  85. this.Control[iCurrent+8]=this.r_bar
  86. this.Control[iCurrent+9]=this.ln_bar
  87. this.Control[iCurrent+10]=this.ln_bar2
  88. end on
  89. on w_department_edit.destroy
  90. call super::destroy
  91. destroy(this.cb_refresh)
  92. destroy(this.cb_add)
  93. destroy(this.cb_add_next)
  94. destroy(this.cb_mod)
  95. destroy(this.cb_del)
  96. destroy(this.tv_1)
  97. destroy(this.cb_help)
  98. destroy(this.r_bar)
  99. destroy(this.ln_bar)
  100. destroy(this.ln_bar2)
  101. end on
  102. event resize;call super::resize;ln_bar.endx = this.width
  103. ln_bar2.endx = this.width
  104. r_bar.width = this.width
  105. tv_1.height = this.height - tv_1.y - 100
  106. end event
  107. type cb_func from w_publ_base`cb_func within w_department_edit
  108. boolean visible = false
  109. integer x = 1701
  110. integer y = 8
  111. integer width = 219
  112. end type
  113. type cb_exit from w_publ_base`cb_exit within w_department_edit
  114. integer x = 1024
  115. integer width = 151
  116. integer height = 172
  117. integer picsize = 16
  118. toolbaralignment pic_align = alignattop!
  119. boolean border = false
  120. end type
  121. event cb_exit::clicked;close(parent)
  122. end event
  123. type cb_refresh from uo_imflatbutton within w_department_edit
  124. integer width = 151
  125. integer height = 172
  126. integer taborder = 80
  127. boolean bringtotop = true
  128. string text = "重查"
  129. string normalpicname = "refresh.bmp"
  130. integer picsize = 16
  131. toolbaralignment pic_align = alignattop!
  132. boolean border = false
  133. end type
  134. event clicked;call super::clicked;tv_1.f_maketree()
  135. end event
  136. type cb_add from uo_imflatbutton within w_department_edit
  137. integer x = 151
  138. integer width = 210
  139. integer height = 172
  140. integer taborder = 80
  141. boolean bringtotop = true
  142. string text = "增同级"
  143. string normalpicname = "mx1.bmp"
  144. integer picsize = 16
  145. toolbaralignment pic_align = alignattop!
  146. boolean border = false
  147. end type
  148. event clicked;call super::clicked;IF NOT f_power_ind(192) THEN
  149. MessageBox('提示','你没有使用权限!',information!,OK!)
  150. RETURN
  151. END IF
  152. IF tv_1.uo_cur_info.departmentid = 0 THEN
  153. MessageBox("提示",'不能建立部门',information!,OK!)
  154. RETURN
  155. END IF
  156. s_deptype s_dept,s_r_dept
  157. Long ll_departmentid,ll_parentid
  158. String ls_deptcode,ls_departmentname,ls_handtype
  159. Int li_sonflag
  160. String arg_msg
  161. String ls_parent_handtype
  162. s_dept.departmentid = 0
  163. s_dept.deptcode = tv_1.uo_cur_info.deptcode
  164. s_dept.departmentname = tv_1.uo_cur_info.departmentname
  165. s_dept.sonflag = 1
  166. s_dept.parentid = tv_1.uo_cur_info.parentid
  167. IF tv_1.uo_cur_info.parentid = 0 THEN
  168. s_dept.parenthandtype = ''
  169. ELSE
  170. SELECT handtype INTO :ls_parent_handtype
  171. FROM cw_department
  172. Where departmentid = :tv_1.uo_cur_info.parentid;
  173. IF sqlca.SQLCode <> 0 THEN
  174. MessageBox('错误','查询上级部门资料失败',stopsign!,OK!)
  175. RETURN
  176. END IF
  177. s_dept.parenthandtype = ls_parent_handtype
  178. END IF
  179. OpenWithParm(w_department_add,s_dept)
  180. s_r_dept = Message.PowerObjectParm
  181. IF s_r_dept.departmentid = -1 THEN RETURN
  182. ls_deptcode = s_r_dept.deptcode
  183. ls_departmentname = s_r_dept.departmentname
  184. ls_handtype = s_r_dept.handtype
  185. ll_parentid = s_r_dept.parentid
  186. li_sonflag = s_r_dept.sonflag
  187. ll_departmentid = f_sys_scidentity(0,"cw_department","departmentid",arg_msg,TRUE,sqlca)
  188. IF ll_departmentid <= 0 THEN
  189. MessageBox('错误',arg_msg,stopsign!,OK!)
  190. RETURN
  191. END IF
  192. INSERT INTO cw_department
  193. (departmentid,
  194. deptcode,
  195. departmentname,
  196. handtype,
  197. sonflag,
  198. parentid)
  199. VALUES
  200. (:ll_departmentid,
  201. :ls_deptcode,
  202. :ls_departmentname,
  203. :ls_handtype,
  204. :li_sonflag,
  205. :ll_parentid) ;
  206. IF sqlca.SQLCode <> 0 THEN
  207. ROLLBACK;
  208. MessageBox('错误','新建部门"'+ls_departmentname+'"失败,可能是编号或名称已经存在或网络故障!',stopsign!,OK!)
  209. RETURN
  210. END IF
  211. UPDATE cw_department
  212. SET sonflag = 0
  213. Where cw_department.departmentid = :ll_parentid;
  214. IF sqlca.SQLCode <> 0 THEN
  215. ROLLBACK;
  216. MessageBox('错误','新建部门"'+ls_departmentname+'"失败,可能是名称已经存在或网络故障!',stopsign!,OK!)
  217. RETURN
  218. END IF
  219. COMMIT;
  220. MessageBox('提示','新建部门操作成功!',information!,OK!)
  221. Long ll_hand,ll_handl
  222. TreeViewItem l_tvi
  223. ll_hand = tv_1.FindItem(parenttreeitem!,il_hand)
  224. ll_handl = tv_1.InsertItemSort(ll_hand,ls_deptcode+'-'+ls_departmentname,2)
  225. IF tv_1.GetItem ( ll_handl, l_tvi) = 1 THEN
  226. l_tvi.Label = ls_deptcode+'-'+ls_departmentname
  227. l_tvi.Data = ll_departmentid
  228. tv_1.SetItem(ll_handl, l_tvi)
  229. tv_1.SetFocus()
  230. tv_1.SelectItem ( ll_handl )
  231. END IF
  232. end event
  233. type cb_add_next from uo_imflatbutton within w_department_edit
  234. integer x = 361
  235. integer width = 210
  236. integer height = 172
  237. integer taborder = 90
  238. boolean bringtotop = true
  239. string text = "增下级"
  240. string normalpicname = "mx2.bmp"
  241. integer picsize = 16
  242. toolbaralignment pic_align = alignattop!
  243. boolean border = false
  244. end type
  245. event clicked;call super::clicked;if not f_power_ind(192) then
  246. messagebox('提示','你没有使用权限!',information!,OK!)
  247. return
  248. end if
  249. s_deptype s_dept,s_r_dept
  250. Long ll_departmentid,ll_parentid
  251. String ls_deptcode,ls_departmentname,ls_handtype
  252. Int li_sonflag
  253. String arg_msg
  254. s_dept.departmentid = 0
  255. s_dept.deptcode = tv_1.uo_cur_info.deptcode
  256. s_dept.departmentname = tv_1.uo_cur_info.departmentname
  257. s_dept.sonflag = 1
  258. IF tv_1.uo_cur_info.departmentid = 0 THEN
  259. s_dept.parentid = 0
  260. s_dept.parenthandtype = ''
  261. ELSE
  262. s_dept.parentid = tv_1.uo_cur_info.departmentid
  263. s_dept.parenthandtype = tv_1.uo_cur_info.handtype
  264. END IF
  265. OpenWithParm(w_department_add,s_dept)
  266. s_r_dept = Message.PowerObjectParm
  267. IF s_r_dept.departmentid = -1 THEN RETURN
  268. ls_deptcode = s_r_dept.deptcode
  269. ls_departmentname = s_r_dept.departmentname
  270. ls_handtype = s_r_dept.handtype
  271. ll_parentid = s_r_dept.parentid
  272. li_sonflag = s_r_dept.sonflag
  273. ll_departmentid = f_sys_scidentity(0,"cw_department","departmentid",arg_msg,TRUE,sqlca)
  274. IF ll_departmentid <= 0 THEN
  275. MessageBox('提示',arg_msg,stopsign!,OK!)
  276. RETURN
  277. END IF
  278. INSERT INTO cw_department
  279. (departmentid,
  280. deptcode,
  281. departmentname,
  282. handtype,
  283. sonflag,
  284. parentid)
  285. Values
  286. (:ll_departmentid,
  287. :ls_deptcode,
  288. :ls_departmentname,
  289. :ls_handtype,
  290. :li_sonflag,
  291. :ll_parentid) ;
  292. IF sqlca.SQLCode <> 0 THEN
  293. ROLLBACK;
  294. MessageBox('错误','新建部门"'+ls_departmentname+'"失败,可能是编号或名称已经存在或网络故障!',stopsign!,OK!)
  295. RETURN
  296. END IF
  297. UPDATE cw_department
  298. SET sonflag = 0
  299. Where cw_department.departmentid = :ll_parentid;
  300. IF sqlca.SQLCode <> 0 THEN
  301. ROLLBACK;
  302. MessageBox('错误','新建部门"'+ls_departmentname+'"失败,可能是编号或名称已经存在或网络故障!',stopsign!,OK!)
  303. RETURN
  304. END IF
  305. COMMIT;
  306. MessageBox('提示','新建部门操作成功!',information!,OK!)
  307. Long ll_handl
  308. TreeViewItem l_tvi
  309. ll_handl = tv_1.InsertItemSort(il_hand,ls_deptcode+'-'+ls_departmentname,2)
  310. IF tv_1.GetItem ( ll_handl, l_tvi) = 1 THEN
  311. l_tvi.Label = ls_deptcode+'-'+ls_departmentname
  312. l_tvi.Data = ll_departmentid
  313. tv_1.SetItem(ll_handl, l_tvi)
  314. tv_1.SetFocus()
  315. tv_1.SelectItem ( ll_handl )
  316. END IF
  317. end event
  318. type cb_mod from uo_imflatbutton within w_department_edit
  319. integer x = 571
  320. integer width = 151
  321. integer height = 172
  322. integer taborder = 90
  323. boolean bringtotop = true
  324. string text = "修改"
  325. string normalpicname = "open.bmp"
  326. integer picsize = 16
  327. toolbaralignment pic_align = alignattop!
  328. boolean border = false
  329. end type
  330. event clicked;call super::clicked;IF NOT f_power_ind(192) THEN
  331. MessageBox('提示','你没有使用权限!',information!,OK!)
  332. RETURN
  333. END IF
  334. IF tv_1.uo_cur_info.departmentid = 0 THEN
  335. MessageBox('提示','请选择要修改当前部门!',information!,OK!)
  336. RETURN
  337. END IF
  338. s_deptype s_dept,s_r_dept
  339. Long cnt
  340. Long ll_departmentid
  341. Long ll_old_parentid
  342. Long ll_new_parentid
  343. String ls_deptcode
  344. String ls_new_departmentname
  345. String ls_old_departmentname
  346. String ls_new_handtype
  347. String ls_old_handtype
  348. String ls_update_handtype
  349. Int li_sonflag
  350. s_dept.departmentid = tv_1.uo_cur_info.departmentid
  351. s_dept.deptcode = tv_1.uo_cur_info.deptcode
  352. s_dept.departmentname = tv_1.uo_cur_info.departmentname
  353. s_dept.sonflag = tv_1.uo_cur_info.sonflag
  354. s_dept.parentid = tv_1.uo_cur_info.parentid
  355. s_dept.parenthandtype = tv_1.uo_cur_info.parenthandtype
  356. ll_departmentid = tv_1.uo_cur_info.departmentid
  357. ll_old_parentid = tv_1.uo_cur_info.parentid
  358. ls_old_departmentname = tv_1.uo_cur_info.departmentname
  359. ls_old_handtype = tv_1.uo_cur_info.handtype
  360. ls_update_handtype = ls_old_handtype + '%'
  361. OpenWithParm(w_department_add,s_dept)
  362. s_r_dept = Message.PowerObjectParm
  363. IF s_r_dept.departmentid = - 1 THEN RETURN
  364. ls_deptcode = s_r_dept.deptcode
  365. ls_new_departmentname = s_r_dept.departmentname
  366. ls_new_handtype = s_r_dept.handtype
  367. ll_new_parentid = s_r_dept.parentid
  368. li_sonflag = s_r_dept.sonflag
  369. UPDATE cw_department
  370. SET deptcode = :ls_deptcode,
  371. departmentname = :ls_new_departmentname,
  372. sonflag = :li_sonflag,
  373. parentid = :ll_new_parentid,
  374. handtype = :ls_new_handtype
  375. Where (departmentid = :ll_departmentid ) ;
  376. IF sqlca.SQLCode <> 0 THEN
  377. ROLLBACK;
  378. MessageBox('错误','修改名称操作失败,可能是新名称已经存在或网络故障!',stopsign!,OK!)
  379. RETURN
  380. END IF
  381. UPDATE cw_department
  382. SET handtype = replace(handtype,:ls_old_handtype,:ls_new_handtype)
  383. Where handtype Like :ls_update_handtype;
  384. IF sqlca.SQLCode <> 0 THEN
  385. ROLLBACK;
  386. MessageBox('错误','修改部门资料操作失败,可能是新名称已经存在或网络故障!',stopsign!,OK!)
  387. RETURN
  388. END IF
  389. UPDATE u_rs_empinfo
  390. SET deptype = :ls_new_departmentname
  391. Where deptid = :ll_departmentid;
  392. IF sqlca.SQLCode <> 0 THEN
  393. ROLLBACK;
  394. MessageBox('错误','修改部门资料(人事)操作失败,可能是新名称已经存在或网络故障!',stopsign!,OK!)
  395. RETURN
  396. END IF
  397. UPDATE u_rs_empinfo
  398. SET handtype = replace(handtype,:ls_old_handtype,:ls_new_handtype)
  399. Where handtype Like :ls_update_handtype;
  400. IF sqlca.SQLCode <> 0 THEN
  401. ROLLBACK;
  402. MessageBox('错误','修改部门资料(人事)操作失败,可能是新名称已经存在或网络故障!',stopsign!,OK!)
  403. RETURN
  404. END IF
  405. UPDATE cw_department
  406. SET sonflag = 0
  407. Where cw_department.departmentid = :ll_new_parentid;
  408. IF sqlca.SQLCode <> 0 THEN
  409. ROLLBACK;
  410. MessageBox('错误','更新部门"'+ls_new_departmentname+'"上级部门失败',stopsign!,OK!)
  411. RETURN
  412. END IF
  413. IF ll_old_parentid <> ll_new_parentid THEN
  414. SELECT count(*) INTO :cnt
  415. FROM cw_department
  416. Where parentid = :ll_old_parentid;
  417. IF sqlca.SQLCode <> 0 THEN
  418. ROLLBACK;
  419. MessageBox('错误','查询上级部门是否还存在下级部门失败',stopsign!,OK!)
  420. RETURN
  421. END IF
  422. IF cnt = 0 THEN
  423. UPDATE cw_department SET sonflag = 1
  424. Where departmentid = :ll_old_parentid;
  425. IF sqlca.SQLCode <> 0 THEN
  426. ROLLBACK;
  427. MessageBox('错误','更新上级部门资料失败',stopsign!,OK!)
  428. RETURN
  429. END IF
  430. END IF
  431. END IF
  432. COMMIT;
  433. MessageBox('提示','部门修改成功!',information!,OK!)
  434. TreeViewItem l_tvi
  435. IF tv_1.GetItem(il_hand,l_tvi) > 0 THEN
  436. l_tvi.Label = ls_deptcode + '-'+ls_new_departmentname
  437. l_tvi.Data = ll_departmentid
  438. tv_1.SetItem(il_hand, l_tvi)
  439. tv_1.SetFocus()
  440. tv_1.SelectItem ( il_hand )
  441. END IF
  442. end event
  443. type cb_del from uo_imflatbutton within w_department_edit
  444. integer x = 722
  445. integer width = 151
  446. integer height = 172
  447. integer taborder = 100
  448. boolean bringtotop = true
  449. string text = "删除"
  450. string normalpicname = "delete.bmp"
  451. integer picsize = 16
  452. toolbaralignment pic_align = alignattop!
  453. boolean border = false
  454. end type
  455. event clicked;call super::clicked;long cnt
  456. if not f_power_ind(192) then
  457. messagebox('提示','你没有使用权限!',information!,OK!)
  458. return
  459. end if
  460. if MessageBox('询问','是否要确定删除当前部门', Exclamation!, YesNo!, 2)=2 then
  461. return
  462. end if
  463. if tv_1.uo_cur_info.sonflag = 0 then
  464. messagebox('提示','不是明细部门,不能删除',information!,OK!)
  465. return
  466. end if
  467. cnt = 0
  468. select count(*) into :cnt
  469. from u_rs_empinfo
  470. where deptid = :tv_1.uo_cur_info.departmentid;
  471. if sqlca.sqlcode <> 0 then
  472. messagebox('错误','查询部门是否已用失败,不能删除',stopsign!,OK!)
  473. return
  474. end if
  475. if cnt > 0 then
  476. messagebox('提示','部门已用于人员信息管理,不能删除',information!,OK!)
  477. return
  478. end if
  479. cnt = 0
  480. select count(*) into :cnt
  481. from cw_department
  482. where parentid = :tv_1.uo_cur_info.parentid;
  483. if sqlca.sqlcode <> 0 then
  484. messagebox('错误','查询部门资料失败,不能删除',stopsign!,OK!)
  485. return
  486. end if
  487. if cnt = 1 then
  488. update cw_department
  489. set sonflag = 1
  490. where departmentid = :tv_1.uo_cur_info.parentid;
  491. if sqlca.sqlcode <> 0 then
  492. messagebox('错误','更新上级部门资料失败,不能删除',stopsign!,OK!)
  493. rollback;
  494. return
  495. end if
  496. end if
  497. delete from cw_department
  498. where departmentid = :tv_1.uo_cur_info.departmentid;
  499. if sqlca.sqlcode <> 0 then
  500. messagebox('错误','删除部门失败>>'+sqlca.sqlerrtext,stopsign!,OK!)
  501. rollback;
  502. return
  503. end if
  504. commit;
  505. messagebox('提示','删除部门成功',information!,OK!)
  506. tv_1.f_maketree()
  507. end event
  508. type tv_1 from uo_tv_deptype within w_department_edit
  509. integer y = 188
  510. integer width = 2098
  511. integer height = 1368
  512. integer taborder = 30
  513. integer textsize = -9
  514. fontcharset fontcharset = gb2312charset!
  515. fontfamily fontfamily = anyfont!
  516. string facename = "宋体"
  517. end type
  518. event selectionchanged;call super::selectionchanged;il_hand = newhandle
  519. end event
  520. type cb_help from uo_imflatbutton within w_department_edit
  521. string tag = "帮助[F1]"
  522. integer x = 873
  523. integer width = 151
  524. integer height = 172
  525. integer taborder = 110
  526. boolean bringtotop = true
  527. string text = "帮助"
  528. string normalpicname = "help.bmp"
  529. integer picsize = 16
  530. toolbaralignment pic_align = alignattop!
  531. boolean border = false
  532. end type
  533. type r_bar from rectangle within w_department_edit
  534. long linecolor = 16777215
  535. long fillcolor = 1073741824
  536. integer x = 1929
  537. integer width = 73
  538. integer height = 172
  539. end type
  540. event constructor;this.fillcolor = 14215660
  541. this.linecolor = 14215660
  542. this.x = -1
  543. this.y = -1
  544. this.height = ln_bar2.beginy
  545. end event
  546. type ln_bar from line within w_department_edit
  547. long linecolor = 268435456
  548. integer linethickness = 4
  549. integer beginx = -5
  550. integer beginy = 176
  551. integer endx = 2094
  552. integer endy = 176
  553. end type
  554. type ln_bar2 from line within w_department_edit
  555. long linecolor = 16777215
  556. integer linethickness = 4
  557. integer beginx = -5
  558. integer beginy = 180
  559. integer endx = 2094
  560. integer endy = 180
  561. end type