uo_usergroup.sru 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. $PBExportHeader$uo_usergroup.sru
  2. forward
  3. global type uo_usergroup from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_usergroup from nonvisualobject
  7. end type
  8. global uo_usergroup uo_usergroup
  9. forward prototypes
  10. public function integer check_closeloop (long arg_objid, long arg_checkid, integer arg_grouptype)
  11. public function integer deluser (boolean if_delall, long arg_scid, long arg_empid, ref string arg_msg, boolean arg_ifcommit)
  12. public function integer reset_userpwd (long arg_scid, long arg_empid, string arg_userid, ref string arg_msg)
  13. public function integer savegroup (long arg_scid, long arg_groupid, string arg_usergroup, ref string arg_msg, boolean arg_ifcommit)
  14. public function integer delgroup (long arg_scid, long arg_groupid, ref string arg_msg, boolean arg_ifcommit)
  15. public function integer f_rst_empid_arr (long arg_scid, long arg_usergpid, ref long arg_arr[])
  16. public function integer f_rst_msgemp_arr (long arg_scid, string arg_objpdm, ref long arg_arr[])
  17. public function integer check_psw (string arg_psw, ref string arg_msg)
  18. public function integer saveuser (boolean arg_ifmodify, long arg_scid, long arg_empid, string arg_userid, string arg_username, string arg_cardno, string arg_dscrp, string arg_powerstring, string arg_storagestr, string arg_scstr, string arg_areastr, string arg_classeditstr, string arg_classviewstr, string arg_xls_printstr, string arg_xls_sendstr, string arg_spttypestr, string arg_pluginsstr, string arg_reportstr, integer arg_ifnotin, integer arg_dlflag, ref string arg_msg, boolean arg_ifcommit, string arg_accountstr, string arg_outrepstr, integer arg_ifphone)
  19. end prototypes
  20. public function integer check_closeloop (long arg_objid, long arg_checkid, integer arg_grouptype);//查闭环
  21. //check_closeloop
  22. int rslt=1
  23. if arg_checkid=arg_objid and arg_grouptype=1 then return 1
  24. if arg_grouptype=0 then return 0
  25. long relid[],ls_i,count,rt_b
  26. int grouptype[]
  27. DECLARE ug_cur CURSOR FOR
  28. SELECT u_usergroup.empid,
  29. u_usergroup.grouptype
  30. FROM u_usergroup
  31. WHERE ( u_usergroup.usergroupid = :arg_checkid);
  32. open ug_cur;
  33. count=1
  34. fetch ug_cur into :relid[count],:grouptype[count];
  35. do while sqlca.sqlcode=0
  36. count++
  37. fetch ug_cur into :relid[count],:grouptype[count];
  38. loop
  39. count=count - 1
  40. close ug_cur;
  41. for ls_i=1 to count
  42. rt_b=check_closeloop(arg_objid,relid[ls_i],grouptype[count])
  43. if rt_b<>0 then return rt_b
  44. next
  45. return 0
  46. return rslt
  47. end function
  48. public function integer deluser (boolean if_delall, long arg_scid, long arg_empid, ref string arg_msg, boolean arg_ifcommit);//删除用户
  49. int rslt=1
  50. if if_delall then
  51. delete from u_user where empid <> 0 and scid=:arg_scid;
  52. else
  53. delete from u_user where empid=:arg_empid and scid=:arg_scid;
  54. end if
  55. if sqlca.sqlcode<>0 then
  56. arg_msg='删除用户基本资料失败'
  57. rslt=0
  58. goto ext
  59. end if
  60. ext:
  61. if rslt=0 then
  62. rollback;
  63. elseif rslt=1 and arg_ifcommit then
  64. commit;
  65. end if
  66. return rslt
  67. end function
  68. public function integer reset_userpwd (long arg_scid, long arg_empid, string arg_userid, ref string arg_msg);//重设用户密码
  69. //reset_userpwd(arg_scid,arg_empid,arg_userid,arg_msg)
  70. string ls_pwd=''
  71. ls_pwd=f_psw_bczh(lower(arg_userid),0,sys_power_key)
  72. UPDATE u_user SET psw = :ls_pwd where empid=:arg_empid and scid=:arg_scid;
  73. if sqlca.sqlcode<>0 then
  74. arg_msg="恢复密码失败"
  75. rollback;
  76. return 0
  77. else
  78. commit;
  79. arg_msg="恢复密码成功"
  80. return 1
  81. end if
  82. end function
  83. public function integer savegroup (long arg_scid, long arg_groupid, string arg_usergroup, ref string arg_msg, boolean arg_ifcommit);//新建组
  84. //savegroup(arg_scid,arg_groupid,arg_usergroup,arg_msg,arg_ifcommit)
  85. //arg_groupid 0:新建,>0:修改
  86. int rslt=1
  87. long ls_newid
  88. if arg_groupid=0 then
  89. ls_newid=f_sys_scidentity(arg_scid,"u_usergroupdef","UsergroupID",arg_msg,false,sqlca)
  90. if ls_newid<0 then
  91. rslt=0
  92. goto ext
  93. end if
  94. INSERT INTO u_usergroupdef (scid,UsergroupID,usergroup ) VALUES (:arg_scid,:ls_newid, :arg_usergroup );
  95. if sqlca.sqlcode<>0 then
  96. rslt=0
  97. arg_msg='新建组"'+arg_usergroup+'"失败,可能是名称已经存在或网络故障!'
  98. goto ext
  99. end if
  100. else
  101. update u_usergroupdef set usergroup =:arg_usergroup
  102. where UsergroupID =:arg_groupid and scid=:arg_scid ;
  103. if sqlca.sqlcode<>0 then
  104. rslt=0
  105. arg_msg='修改名称操作失败,可能是新名称已经存在或网络故障!'
  106. goto ext
  107. end if
  108. end if
  109. ext:
  110. if rslt=0 then
  111. rollback;
  112. elseif rslt=1 and arg_ifcommit then
  113. commit;
  114. end if
  115. return rslt
  116. end function
  117. public function integer delgroup (long arg_scid, long arg_groupid, ref string arg_msg, boolean arg_ifcommit);//删除组
  118. //delgroup(arg_scid,arg_groupid,arg_msg,arg_ifcommit)
  119. int rslt=1
  120. long cnt
  121. select count(*) into :cnt
  122. from u_usergroup
  123. where ( u_usergroup.empid=:arg_groupid and Grouptype=1 )
  124. and ( u_usergroup.UsergroupID=:arg_groupid )
  125. and ( u_usergroup.scid=:arg_scid);
  126. if sqlca.sqlcode<>0 then
  127. arg_msg='查询组成员明细失败!'
  128. rslt=0
  129. goto ext
  130. end if
  131. if cnt > 0 then
  132. arg_msg='该组已用于组成员管理,不能删除!如果要删除请在成员列表中先删除'
  133. rslt=0
  134. goto ext
  135. end if
  136. DELETE u_usergroupdef where u_usergroupdef.UsergroupID=:arg_groupid and scid=:arg_scid;
  137. if sqlca.sqlcode<>0 then
  138. rslt=0
  139. arg_msg='删除组操作失败>>'+sqlca.sqlerrtext
  140. goto ext
  141. end if
  142. ext:
  143. if rslt=0 then
  144. rollback;
  145. elseif rslt=1 and arg_ifcommit then
  146. commit;
  147. end if
  148. return rslt
  149. end function
  150. public function integer f_rst_empid_arr (long arg_scid, long arg_usergpid, ref long arg_arr[]);//递归调用返回empid[]
  151. //f_rst_empid_arr(arg_scid,arg_usergpid,arg_arr[])
  152. long ls_empgpid[],tmp_empgpid,itmxt,arr_mxt,it_arr_mxt
  153. int ls_gptype[],tmp_gptype
  154. long i,j
  155. boolean if_exist=false
  156. DECLARE usergp CURSOR FOR
  157. SELECT u_usergroup.Empid,
  158. u_usergroup.Grouptype
  159. FROM u_usergroup
  160. WHERE u_usergroup.scid=:arg_scid
  161. AND u_usergroup.UsergroupID=:arg_usergpid;
  162. open usergp;
  163. fetch usergp into :tmp_empgpid,:tmp_gptype;
  164. do while sqlca.sqlcode = 0
  165. itmxt++
  166. ls_empgpid[itmxt]=tmp_empgpid
  167. ls_gptype[itmxt]=tmp_gptype
  168. fetch usergp into :tmp_empgpid,:tmp_gptype;
  169. loop
  170. close usergp;
  171. arr_mxt=upperbound(arg_arr)
  172. if itmxt > 0 then
  173. for i=1 to itmxt
  174. if ls_gptype[i]=0 then //用户
  175. if_exist=false
  176. for j=1 to arr_mxt
  177. if ls_empgpid[i]=arg_arr[j] then if_exist=true
  178. next
  179. if not if_exist then
  180. arr_mxt++
  181. arg_arr[arr_mxt]=ls_empgpid[i]
  182. end if
  183. else
  184. f_rst_empid_arr(arg_scid,ls_empgpid[i],arg_arr[])
  185. end if
  186. next
  187. end if
  188. return 1
  189. end function
  190. public function integer f_rst_msgemp_arr (long arg_scid, string arg_objpdm, ref long arg_arr[]);//返回消息用户列表
  191. //f_rst_msgemp_arr(arg_scid,arg_objpdm,arg_arr[])
  192. long it_mxt,ls_usergrpid,i
  193. string ls_usergpname,ls_objpdm
  194. long dot_pos
  195. boolean if_exist=false
  196. ls_objpdm=arg_objpdm
  197. do while ls_objpdm <> ''
  198. dot_pos=pos(ls_objpdm,';')
  199. if dot_pos<=0 then
  200. ls_usergpname=ls_objpdm
  201. ls_objpdm=''
  202. else
  203. ls_usergpname = left(ls_objpdm,dot_pos - 1)
  204. ls_objpdm=mid(ls_objpdm,dot_pos + 1)
  205. end if
  206. select usergroupid into :ls_usergrpid from u_usergroupdef
  207. where usergroup=:ls_usergpname and scid = :arg_scid;
  208. if sqlca.sqlcode<>0 then
  209. select empid into :ls_usergrpid from u_user
  210. where username=:ls_usergpname and scid = :arg_scid;
  211. if sqlca.sqlcode=0 then
  212. it_mxt=upperbound(arg_arr)
  213. if_exist=false
  214. for i=1 to it_mxt
  215. if arg_arr[i]=ls_usergrpid then if_exist=true
  216. next
  217. if not if_exist then
  218. it_mxt++
  219. arg_arr[it_mxt]=ls_usergrpid
  220. end if
  221. end if
  222. else
  223. f_rst_empid_arr(arg_scid,ls_usergrpid,arg_arr[])
  224. end if
  225. loop
  226. return 1
  227. end function
  228. public function integer check_psw (string arg_psw, ref string arg_msg);int rslt = 1
  229. if arg_psw = sys_superpsw then
  230. arg_msg = '密码错误,不能设置密码,重新输入新密码'
  231. rslt = 0
  232. goto ext
  233. end if
  234. ext:
  235. return rslt
  236. end function
  237. public function integer saveuser (boolean arg_ifmodify, long arg_scid, long arg_empid, string arg_userid, string arg_username, string arg_cardno, string arg_dscrp, string arg_powerstring, string arg_storagestr, string arg_scstr, string arg_areastr, string arg_classeditstr, string arg_classviewstr, string arg_xls_printstr, string arg_xls_sendstr, string arg_spttypestr, string arg_pluginsstr, string arg_reportstr, integer arg_ifnotin, integer arg_dlflag, ref string arg_msg, boolean arg_ifcommit, string arg_accountstr, string arg_outrepstr, integer arg_ifphone);//====================================================================
  238. // Function: saveuser()
  239. //--------------------------------------------------------------------
  240. // Description:
  241. //--------------------------------------------------------------------
  242. // Arguments:
  243. // value boolean arg_ifmodify
  244. // value long arg_scid
  245. // value long arg_empid
  246. // value string arg_userid
  247. // value string arg_username
  248. // value string arg_dscrp
  249. // value string arg_powerstring
  250. // value string arg_storagestr
  251. // value string arg_scstr
  252. //....
  253. // value string arg_reportstr
  254. // reference string arg_msg
  255. // value boolean arg_ifcommit
  256. //--------------------------------------------------------------------
  257. // Returns: integer
  258. //--------------------------------------------------------------------
  259. // Author: yyx Date: 2004.10.21
  260. //--------------------------------------------------------------------
  261. // Modify History:
  262. //
  263. //====================================================================
  264. Int rslt = 1
  265. String ls_pass,ls_cardno
  266. IF arg_userid <> 'super' THEN
  267. IF arg_empid = 0 THEN
  268. arg_msg = "请选择人员!"
  269. rslt = 0
  270. GOTO ext
  271. END IF
  272. END IF
  273. IF arg_userid = "" THEN
  274. arg_msg = "必须填写用户代码!"
  275. rslt = 0
  276. GOTO ext
  277. END IF
  278. IF arg_username = "" THEN
  279. arg_msg = "必须填写用户姓名!"
  280. rslt = 0
  281. GOTO ext
  282. END IF
  283. IF arg_ifphone = 1 THEN
  284. Int nowPhoneCnt = 0
  285. SELECT COUNT(0) INTO :nowPhoneCnt
  286. FROM u_user
  287. WHERE ifphone = 1
  288. AND userid <> :arg_userid;
  289. IF sqlca.SQLCode <> 0 THEN
  290. arg_msg = '校验移动端站点失败,'+sqlca.sqlerrtext
  291. rslt = 0
  292. GOTO ext
  293. END IF
  294. IF nowPhoneCnt >= sys_phonecount THEN
  295. arg_msg = "当前移动端用户数已超出注册站点数,不能新增移动端用户!"
  296. rslt = 0
  297. GOTO ext
  298. END IF
  299. END IF
  300. ls_cardno = f_psw_bczh(arg_cardno,0,sys_power_key) //加密
  301. IF NOT arg_ifmodify THEN
  302. IF check_psw(arg_userid,arg_msg) = 0 THEN
  303. rslt = 0
  304. GOTO ext
  305. END IF
  306. ls_pass = f_psw_bczh(arg_userid,0,sys_power_key) //加密
  307. INSERT INTO u_user(scid,
  308. empid,
  309. userid,
  310. username,
  311. descrp,
  312. storagestr,
  313. scstr,
  314. psw,
  315. Rightstring,
  316. areastr,
  317. cardno,
  318. classeditstr,
  319. classviewstr,
  320. xls_printstr,
  321. xls_sendstr,
  322. spttypestr,
  323. pluginsstr,
  324. reportstr,
  325. ifnotin,
  326. dlflag,
  327. accountstr,
  328. outrepstr,
  329. ifphone)
  330. Values (:arg_scid,:arg_empid,:arg_userid,:arg_username,:arg_dscrp,:arg_storagestr,:arg_scstr,:ls_pass,:arg_powerstring,:arg_areastr,:ls_cardno,:arg_classeditstr,:arg_classviewstr,:arg_xls_printstr,:arg_xls_sendstr,:arg_spttypestr,:arg_pluginsstr,:arg_reportstr,:arg_ifnotin,:arg_dlflag,:arg_accountstr,:arg_outrepstr,:arg_ifphone);
  331. IF sqlca.SQLCode <> 0 THEN
  332. arg_msg = '新建用户基本资料失败>>'+sqlca.SQLErrText
  333. rslt = 0
  334. GOTO ext
  335. END IF
  336. ELSE
  337. UPDATE u_user
  338. SET userid = :arg_userid,
  339. username = :arg_username,
  340. descrp = :arg_dscrp,
  341. storagestr = :arg_storagestr,
  342. Rightstring = :arg_powerstring,
  343. scstr = :arg_scstr,
  344. areastr = :arg_areastr,
  345. cardno = :ls_cardno,
  346. classeditstr = :arg_classeditstr,
  347. classviewstr = :arg_classviewstr,
  348. xls_printstr = :arg_xls_printstr,
  349. xls_sendstr = :arg_xls_sendstr,
  350. spttypestr = :arg_spttypestr,
  351. pluginsstr = :arg_pluginsstr,
  352. reportstr = :arg_reportstr,
  353. ifnotin = :arg_ifnotin,
  354. dlflag = :arg_dlflag,
  355. accountstr = :arg_accountstr,
  356. outrepstr = :arg_outrepstr,
  357. ifphone = :arg_ifphone
  358. Where empid = :arg_empid AND scid = :arg_scid;
  359. IF sqlca.SQLCode <> 0 THEN
  360. arg_msg = '更新用户基本资料失败,'+sqlca.sqlerrtext
  361. rslt = 0
  362. GOTO ext
  363. END IF
  364. END IF
  365. IF rslt = 0 THEN
  366. ROLLBACK;
  367. ELSEIF rslt = 1 AND arg_ifcommit THEN
  368. COMMIT;
  369. END IF
  370. ext:
  371. RETURN rslt
  372. end function
  373. on uo_usergroup.create
  374. call super::create
  375. TriggerEvent( this, "constructor" )
  376. end on
  377. on uo_usergroup.destroy
  378. TriggerEvent( this, "destructor" )
  379. call super::destroy
  380. end on