$PBExportHeader$uo_userpwr.sru forward global type uo_userpwr from nonvisualobject end type end forward global type uo_userpwr from nonvisualobject end type global uo_userpwr uo_userpwr forward prototypes public function integer check_closeloop (long arg_objid, long arg_checkid, integer arg_grouptype) public function integer deluser (boolean if_delall, long arg_scid, long arg_empid, ref string arg_msg, boolean arg_ifcommit) public function integer reset_userpwd (long arg_scid, long arg_empid, string arg_userid, ref string arg_msg) public function integer savegroup (long arg_scid, long arg_groupid, string arg_usergroup, ref string arg_msg, boolean arg_ifcommit) public function integer delgroup (long arg_scid, long arg_groupid, ref string arg_msg, boolean arg_ifcommit) public function integer f_rst_empid_arr (long arg_scid, long arg_usergpid, ref long arg_arr[]) public function integer f_rst_msgemp_arr (long arg_scid, string arg_objpdm, ref long arg_arr[]) public function integer saveuser (boolean arg_ifmodify, long arg_scid, long arg_empid, string arg_userid, string arg_username, string arg_dscrp, string arg_powerstring, string arg_storagestr, string arg_scstr, ref string arg_msg, boolean arg_ifcommit) public function integer add_shortcut (long arg_scid, long arg_empid, long arg_funcid, ref string arg_msg, boolean arg_ifcommit) public function integer del_shortcut (long arg_scid, long arg_empid, long arg_funcid, ref string arg_msg, boolean arg_ifcommit) end prototypes public function integer check_closeloop (long arg_objid, long arg_checkid, integer arg_grouptype);//查闭环 //check_closeloop int rslt=1 if arg_checkid=arg_objid and arg_grouptype=1 then return 1 if arg_grouptype=0 then return 0 long relid[],ls_i,count,rt_b int grouptype[] DECLARE ug_cur CURSOR FOR SELECT u_usergroup.empid, u_usergroup.grouptype FROM u_usergroup WHERE ( u_usergroup.usergroupid = :arg_checkid); open ug_cur; count=1 fetch ug_cur into :relid[count],:grouptype[count]; do while sqlca.sqlcode=0 count++ fetch ug_cur into :relid[count],:grouptype[count]; loop count=count - 1 close ug_cur; for ls_i=1 to count rt_b=check_closeloop(arg_objid,relid[ls_i],grouptype[count]) if rt_b<>0 then return rt_b next return 0 return rslt end function public function integer deluser (boolean if_delall, long arg_scid, long arg_empid, ref string arg_msg, boolean arg_ifcommit);//删除用户 int rslt=1 if if_delall then delete from u_user where empid <> 0 and scid=:arg_scid; else delete from u_user where empid=:arg_empid and scid=:arg_scid; end if if sqlca.sqlcode<>0 then arg_msg='删除用户基本资料失败' rslt=0 goto ext end if ext: if rslt=0 then rollback; elseif rslt=1 and arg_ifcommit then commit; end if return rslt end function public function integer reset_userpwd (long arg_scid, long arg_empid, string arg_userid, ref string arg_msg);//重设用户密码 //reset_userpwd(arg_scid,arg_empid,arg_userid,arg_msg) string ls_pwd='' ls_pwd=f_psw_bczh(lower(arg_userid),0,sys_power_key) UPDATE u_user SET psw = :ls_pwd where empid=:arg_empid and scid=:arg_scid; if sqlca.sqlcode<>0 then arg_msg="恢复密码失败" rollback; return 0 else commit; arg_msg="恢复密码成功" return 1 end if end function public function integer savegroup (long arg_scid, long arg_groupid, string arg_usergroup, ref string arg_msg, boolean arg_ifcommit);//新建组 //savegroup(arg_scid,arg_groupid,arg_usergroup,arg_msg,arg_ifcommit) //arg_groupid 0:新建,>0:修改 int rslt=1 long ls_newid if arg_groupid=0 then ls_newid=f_sys_scidentity(arg_scid,"u_usergroupdef","UsergroupID",arg_msg,false,sqlca) if ls_newid<0 then rslt=0 goto ext end if INSERT INTO u_usergroupdef (scid,UsergroupID,usergroup ) VALUES (:arg_scid,:ls_newid, :arg_usergroup ); if sqlca.sqlcode<>0 then rslt=0 arg_msg='新建组"'+arg_usergroup+'"失败,可能是名称已经存在或网络故障!' goto ext end if else update u_usergroupdef set usergroup =:arg_usergroup where UsergroupID =:arg_groupid and scid=:arg_scid ; if sqlca.sqlcode<>0 then rslt=0 arg_msg='修改名称操作失败,可能是新名称已经存在或网络故障!' goto ext end if end if ext: if rslt=0 then rollback; elseif rslt=1 and arg_ifcommit then commit; end if return rslt end function public function integer delgroup (long arg_scid, long arg_groupid, ref string arg_msg, boolean arg_ifcommit);//删除组 //delgroup(arg_scid,arg_groupid,arg_msg,arg_ifcommit) int rslt=1 long cnt select count(*) into :cnt from u_usergroup where ( u_usergroup.empid=:arg_groupid and Grouptype=1 ) and ( u_usergroup.UsergroupID=:arg_groupid ) and ( u_usergroup.scid=:arg_scid); if sqlca.sqlcode<>0 then arg_msg='查询组成员明细失败!' rslt=0 goto ext end if if cnt > 0 then arg_msg='该组已用于组成员管理,不能删除!如果要删除请在成员列表中先删除' rslt=0 goto ext end if DELETE u_usergroupdef where u_usergroupdef.UsergroupID=:arg_groupid and scid=:arg_scid; if sqlca.sqlcode<>0 then rslt=0 arg_msg='删除组操作失败>>'+sqlca.sqlerrtext goto ext end if ext: if rslt=0 then rollback; elseif rslt=1 and arg_ifcommit then commit; end if return rslt end function public function integer f_rst_empid_arr (long arg_scid, long arg_usergpid, ref long arg_arr[]);//递归调用返回empid[] //f_rst_empid_arr(arg_scid,arg_usergpid,arg_arr[]) long ls_empgpid[],tmp_empgpid,itmxt,arr_mxt,it_arr_mxt int ls_gptype[],tmp_gptype long i,j boolean if_exist=false DECLARE usergp CURSOR FOR SELECT u_usergroup.Empid, u_usergroup.Grouptype FROM u_usergroup WHERE u_usergroup.scid=:arg_scid AND u_usergroup.UsergroupID=:arg_usergpid; open usergp; fetch usergp into :tmp_empgpid,:tmp_gptype; do while sqlca.sqlcode = 0 itmxt++ ls_empgpid[itmxt]=tmp_empgpid ls_gptype[itmxt]=tmp_gptype fetch usergp into :tmp_empgpid,:tmp_gptype; loop close usergp; arr_mxt=upperbound(arg_arr) if itmxt > 0 then for i=1 to itmxt if ls_gptype[i]=0 then //用户 if_exist=false for j=1 to arr_mxt if ls_empgpid[i]=arg_arr[j] then if_exist=true next if not if_exist then arr_mxt++ arg_arr[arr_mxt]=ls_empgpid[i] end if else f_rst_empid_arr(arg_scid,ls_empgpid[i],arg_arr[]) end if next end if return 1 end function public function integer f_rst_msgemp_arr (long arg_scid, string arg_objpdm, ref long arg_arr[]);//返回消息用户列表 //f_rst_msgemp_arr(arg_scid,arg_objpdm,arg_arr[]) long it_mxt,ls_usergrpid,i string ls_usergpname,ls_objpdm long dot_pos boolean if_exist=false ls_objpdm=arg_objpdm do while ls_objpdm <> '' dot_pos=pos(ls_objpdm,';') if dot_pos<=0 then ls_usergpname=ls_objpdm ls_objpdm='' else ls_usergpname = left(ls_objpdm,dot_pos - 1) ls_objpdm=mid(ls_objpdm,dot_pos + 1) end if select usergroupid into :ls_usergrpid from u_usergroupdef where usergroup=:ls_usergpname and scid = :arg_scid; if sqlca.sqlcode<>0 then select empid into :ls_usergrpid from u_user where username=:ls_usergpname and scid = :arg_scid; if sqlca.sqlcode=0 then it_mxt=upperbound(arg_arr) if_exist=false for i=1 to it_mxt if arg_arr[i]=ls_usergrpid then if_exist=true next if not if_exist then it_mxt++ arg_arr[it_mxt]=ls_usergrpid end if end if else f_rst_empid_arr(arg_scid,ls_usergrpid,arg_arr[]) end if loop return 1 end function public function integer saveuser (boolean arg_ifmodify, long arg_scid, long arg_empid, string arg_userid, string arg_username, string arg_dscrp, string arg_powerstring, string arg_storagestr, string arg_scstr, ref string arg_msg, boolean arg_ifcommit);//==================================================================== // Function: saveuser() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value boolean arg_ifmodify // value long arg_scid // value long arg_empid // value string arg_userid // value string arg_username // value string arg_dscrp // value string arg_powerstring // value string arg_storagestr // value string arg_scstr // reference string arg_msg // value boolean arg_ifcommit //-------------------------------------------------------------------- // Returns: integer //-------------------------------------------------------------------- // Author: yyx Date: 2004.10.21 //-------------------------------------------------------------------- // Modify History: // //==================================================================== int rslt=1 string ls_pass if arg_userid <> 'super' then if arg_empid=0 then arg_msg="请选择人员!" rslt=0 goto ext end if end if if arg_userid="" then arg_msg="必须填写用户代码!" rslt=0 goto ext end if if arg_username="" then arg_msg="必须填写用户姓名!" rslt=0 goto ext end if if not arg_ifmodify then ls_pass=f_psw_bczh(arg_userid,0,sys_power_key) //加密 insert into u_user(scid,empid,userid,username,descrp,storagestr,scstr,psw,Rightstring) values (:arg_scid,:arg_empid,:arg_userid,:arg_username,:arg_dscrp,:arg_storagestr,:arg_scstr,:ls_pass,:arg_powerstring); if sqlca.sqlcode<>0 then arg_msg='新建用户基本资料失败>>'+sqlca.sqlerrtext rslt=0 goto ext end if else update u_user set userid=:arg_userid, username=:arg_username, descrp=:arg_dscrp, storagestr=:arg_storagestr, Rightstring=:arg_powerstring, scstr=:arg_scstr where empid = :arg_empid and scid=:arg_scid; if sqlca.sqlcode<>0 then arg_msg='更新用户基本资料失败' rslt=0 goto ext end if end if if rslt=0 then rollback; elseif rslt=1 and arg_ifcommit then commit; end if ext: return rslt end function public function integer add_shortcut (long arg_scid, long arg_empid, long arg_funcid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 String ls_shortcutstr,ls_funstr SELECT shortcutstr INTO :ls_shortcutstr FROM u_user Where scid = :arg_scid And empid = :arg_empid; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询快捷方式失败!' GOTO ext END IF ls_funstr = String(arg_funcid)+',' IF Pos(ls_shortcutstr,ls_funstr) = 0 THEN ls_shortcutstr = ls_shortcutstr+ls_funstr END IF UPDATE u_user SET shortcutstr = :ls_shortcutstr Where scid = :arg_scid And empid = :arg_empid; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = '添加快捷方式失败!' GOTO ext END IF ext: IF rslt = 0 THEN ROLLBACK; ELSEIF rslt = 1 And arg_ifcommit THEN COMMIT; END IF RETURN rslt end function public function integer del_shortcut (long arg_scid, long arg_empid, long arg_funcid, ref string arg_msg, boolean arg_ifcommit);int rslt = 1 string str_shortcutstr,str_funstr,str_tmp,str_leftstr,str_rightstr select shortcutstr into :str_shortcutstr from u_user where scid = :arg_scid and empid = :arg_empid; if sqlca.sqlcode <> 0 then rslt = 0 arg_msg = '查询快捷方式失败!' goto ext end if str_funstr =string(arg_funcid) do while pos(str_shortcutstr,',') <> 0 str_tmp = trim(left(str_shortcutstr,pos(str_shortcutstr,',') - 1 )) str_rightstr= right(str_shortcutstr,len(str_shortcutstr) - pos(str_shortcutstr,',')) if str_tmp=str_funstr then str_shortcutstr=str_leftstr+str_rightstr exit end if str_leftstr=str_leftstr+str_tmp+',' str_shortcutstr =str_rightstr loop update u_user set shortcutstr = :str_shortcutstr where scid = :arg_scid and empid = :arg_empid; if sqlca.sqlcode <> 0 then rslt = 0 arg_msg = '删除快捷方式失败!' goto ext end if ext: if rslt = 0 then rollback; elseif rslt = 1 and arg_ifcommit then commit; end if return rslt end function on uo_userpwr.create call super::create TriggerEvent( this, "constructor" ) end on on uo_userpwr.destroy TriggerEvent( this, "destructor" ) call super::destroy end on