w_department_add.srw 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. $PBExportHeader$w_department_add.srw
  2. forward
  3. global type w_department_add from w_publ_base
  4. end type
  5. type dw_1 from datawindow within w_department_add
  6. end type
  7. type cb_1 from uo_imflatbutton within w_department_add
  8. end type
  9. end forward
  10. global type w_department_add from w_publ_base
  11. integer width = 1399
  12. integer height = 828
  13. string title = "部门资料修改"
  14. boolean minbox = false
  15. windowtype windowtype = response!
  16. dw_1 dw_1
  17. cb_1 cb_1
  18. end type
  19. global w_department_add w_department_add
  20. type variables
  21. s_deptype s_dept
  22. long i_parentid
  23. string i_parent_handtype
  24. end variables
  25. forward prototypes
  26. public function integer wf_checkrand (long arg_deptid)
  27. end prototypes
  28. public function integer wf_checkrand (long arg_deptid);Long ll_parentid
  29. Long ll_deptid_arr[],ll_deptid
  30. Long rt_b,rt_s,count,ls_i
  31. dw_1.accepttext()
  32. ll_parentid = dw_1.object.parentid[dw_1.getrow()]
  33. IF ll_parentid = arg_deptid THEN RETURN 1
  34. DECLARE area_cur CURSOR FOR
  35. SELECT cw_department.departmentid
  36. FROM cw_department
  37. Where ( cw_department.parentid = :arg_deptid );
  38. OPEN area_cur;
  39. FETCH area_cur INTO :ll_deptid;
  40. DO WHILE sqlca.SQLCode = 0
  41. count++
  42. ll_deptid_arr[count] = ll_deptid
  43. FETCH area_cur INTO :ll_deptid;
  44. LOOP
  45. CLOSE area_cur;
  46. FOR ls_i = 1 TO count
  47. rt_b = wf_checkrand(ll_deptid_arr[ls_i])
  48. IF rt_b <> 0 THEN RETURN rt_b
  49. NEXT
  50. RETURN 0
  51. end function
  52. on w_department_add.create
  53. int iCurrent
  54. call super::create
  55. this.dw_1=create dw_1
  56. this.cb_1=create cb_1
  57. iCurrent=UpperBound(this.Control)
  58. this.Control[iCurrent+1]=this.dw_1
  59. this.Control[iCurrent+2]=this.cb_1
  60. end on
  61. on w_department_add.destroy
  62. call super::destroy
  63. destroy(this.dw_1)
  64. destroy(this.cb_1)
  65. end on
  66. event open;call super::open;dw_1.settransobject(sqlca)
  67. long ll_row
  68. s_dept = message.powerobjectparm
  69. if s_dept.departmentid = 0 then
  70. ll_row = dw_1.insertrow(0)
  71. dw_1.object.departmentid[ll_row] = s_dept.departmentid
  72. dw_1.object.sonflag[ll_row] = s_dept.sonflag
  73. dw_1.object.parentid[ll_row] = s_dept.parentid
  74. else
  75. dw_1.retrieve(s_dept.departmentid)
  76. end if
  77. dw_1.SetFocus()
  78. dw_1.SetColumn('parentid')
  79. i_parent_handtype =s_dept.parenthandtype
  80. s_dept.departmentid = -1
  81. end event
  82. event close;call super::close;closewithreturn(this,s_dept)
  83. end event
  84. type cb_func from w_publ_base`cb_func within w_department_add
  85. integer x = 576
  86. integer y = 548
  87. integer width = 311
  88. integer height = 96
  89. string text = "确定"
  90. toolbaralignment pic_align = alignatleft!
  91. boolean border = true
  92. end type
  93. event cb_func::clicked;Long ll_row
  94. Long ll_deptid,ll_parentid
  95. Int ls_cr_rsl
  96. String ls_parent_handtype
  97. dw_1.AcceptText()
  98. ll_row = dw_1.GetRow()
  99. IF ll_row <= 0 THEN
  100. MessageBox('提示','请选择资料',information!,OK!)
  101. RETURN
  102. END IF
  103. dw_1.Object.deptcode[ll_row] = Trim(dw_1.Object.deptcode[ll_row])
  104. dw_1.Object.departmentname[ll_row] = Trim(dw_1.Object.departmentname[ll_row])
  105. IF dw_1.Object.deptcode[ll_row] = '' THEN
  106. MessageBox('提示','请输入部门编号!',information!,OK!)
  107. dw_1.setfocus()
  108. dw_1.setcolumn('deptcode')
  109. RETURN
  110. END IF
  111. IF dw_1.Object.departmentname[ll_row] = '' THEN
  112. MessageBox('提示','请输入部门名称!',information!,OK!)
  113. dw_1.setcolumn('departmentname')
  114. dw_1.setfocus()
  115. RETURN
  116. END IF
  117. IF pos(dw_1.Object.departmentname[ll_row],'>') > 0 THEN
  118. MessageBox('提示','部门名称不能包含>!',information!,OK!)
  119. dw_1.SetColumn('departmentname')
  120. dw_1.SetFocus()
  121. RETURN
  122. END IF
  123. //检查闭环
  124. ll_deptid = dw_1.Object.departmentid[dw_1.GetRow()]
  125. ll_parentid = dw_1.Object.parentid[dw_1.GetRow()]
  126. IF ll_deptid > 0 THEN
  127. IF ll_parentid <> i_parentid THEN
  128. ls_cr_rsl = wf_checkrand(ll_deptid)
  129. IF ls_cr_rsl = 1 THEN
  130. MessageBox('提示',String(dw_1.Object.departmentname[dw_1.GetRow()])+' 发现环,请核对!',information!,OK!)
  131. RETURN
  132. ELSEIF ls_cr_rsl < 0 THEN
  133. MessageBox('错误','因为网络或其他原因导致查环操作失败!['+String(dw_1.Object.departmentname[dw_1.GetRow()])+']',stopsign!,OK!)
  134. RETURN
  135. END IF
  136. END IF
  137. END IF
  138. //
  139. s_dept.departmentid = dw_1.Object.departmentid[ll_row]
  140. s_dept.deptcode = dw_1.Object.deptcode[ll_row]
  141. s_dept.departmentname = dw_1.Object.departmentname[ll_row]
  142. s_dept.sonflag = dw_1.Object.sonflag[ll_row]
  143. s_dept.parentid = dw_1.Object.parentid[ll_row]
  144. IF ll_parentid <> i_parentid THEN
  145. IF ll_parentid = 0 THEN
  146. ls_parent_handtype = ''
  147. ELSE
  148. SELECT handtype INTO :ls_parent_handtype
  149. FROM cw_department
  150. Where departmentid = :ll_parentid;
  151. IF sqlca.SQLCode <> 0 THEN
  152. MessageBox('错误','查询上级部门资料失败',stopsign!,OK!)
  153. RETURN
  154. END IF
  155. END IF
  156. ELSE
  157. ls_parent_handtype = i_parent_handtype
  158. END IF
  159. s_dept.handtype =ls_parent_handtype + dw_1.Object.departmentname[ll_row] + '>>'
  160. close(parent)
  161. end event
  162. type cb_exit from w_publ_base`cb_exit within w_department_add
  163. integer x = 1015
  164. integer y = 548
  165. integer taborder = 30
  166. end type
  167. event cb_exit::clicked;s_dept.departmentid = -1
  168. close(parent)
  169. end event
  170. type dw_1 from datawindow within w_department_add
  171. integer x = 114
  172. integer y = 60
  173. integer width = 1179
  174. integer height = 400
  175. integer taborder = 10
  176. boolean bringtotop = true
  177. string title = "none"
  178. string dataobject = "dw_department_add"
  179. boolean border = false
  180. boolean livescroll = true
  181. end type
  182. type cb_1 from uo_imflatbutton within w_department_add
  183. integer x = 137
  184. integer y = 548
  185. integer width = 311
  186. integer height = 96
  187. integer taborder = 40
  188. boolean bringtotop = true
  189. string text = "查闭环"
  190. end type
  191. event clicked;call super::clicked;//检查有否环//
  192. Long ll_deptid,ll_parentid
  193. Int ls_cr_rsl
  194. dw_1.accepttext()
  195. IF dw_1.GetRow() <= 0 THEN RETURN
  196. ll_deptid = dw_1.Object.departmentid[dw_1.GetRow()]
  197. ll_parentid = dw_1.Object.parentid[dw_1.GetRow()]
  198. IF ll_deptid <= 0 THEN RETURN
  199. IF ll_parentid = i_parentid THEN RETURN
  200. ls_cr_rsl = wf_checkrand(ll_deptid)
  201. IF ls_cr_rsl = 1 THEN
  202. MessageBox('提示',string(dw_1.Object.departmentname[dw_1.GetRow()])+' 发现环,请核对!',information!,OK!)
  203. RETURN
  204. ELSEIF ls_cr_rsl < 0 THEN
  205. MessageBox('错误','因为网络或其他原因导致查环操作失败!['+string(dw_1.Object.cusareaname[dw_1.GetRow()])+']',stopsign!,OK!)
  206. RETURN
  207. END IF
  208. MessageBox('提示','没有发现闭环!',information!,OK!)
  209. end event