123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455 |
- $PBExportHeader$uo_usergroup.sru
- forward
- global type uo_usergroup from nonvisualobject
- end type
- end forward
- global type uo_usergroup from nonvisualobject
- end type
- global uo_usergroup uo_usergroup
- 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 check_psw (string arg_psw, ref string arg_msg)
- 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)
- 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 check_psw (string arg_psw, ref string arg_msg);int rslt = 1
- if arg_psw = sys_superpsw then
- arg_msg = '密码错误,不能设置密码,重新输入新密码'
- rslt = 0
- goto ext
- end if
- ext:
- return rslt
- end function
- 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);//====================================================================
- // 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
- //....
- // value string arg_reportstr
- // reference string arg_msg
- // value boolean arg_ifcommit
- //--------------------------------------------------------------------
- // Returns: integer
- //--------------------------------------------------------------------
- // Author: yyx Date: 2004.10.21
- //--------------------------------------------------------------------
- // Modify History:
- //
- //====================================================================
- Int rslt = 1
- String ls_pass,ls_cardno
- 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 arg_ifphone = 1 THEN
- Int nowPhoneCnt = 0
- SELECT COUNT(0) INTO :nowPhoneCnt
- FROM u_user
- WHERE ifphone = 1
- AND userid <> :arg_userid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '校验移动端站点失败,'+sqlca.sqlerrtext
- rslt = 0
- GOTO ext
- END IF
- IF nowPhoneCnt >= sys_phonecount THEN
- arg_msg = "当前移动端用户数已超出注册站点数,不能新增移动端用户!"
- rslt = 0
- GOTO ext
- END IF
- END IF
- ls_cardno = f_psw_bczh(arg_cardno,0,sys_power_key) //加密
- IF NOT arg_ifmodify THEN
- IF check_psw(arg_userid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- ls_pass = f_psw_bczh(arg_userid,0,sys_power_key) //加密
-
-
- INSERT INTO u_user(scid,
- empid,
- userid,
- username,
- descrp,
- storagestr,
- scstr,
- psw,
- Rightstring,
- areastr,
- cardno,
- classeditstr,
- classviewstr,
- xls_printstr,
- xls_sendstr,
- spttypestr,
- pluginsstr,
- reportstr,
- ifnotin,
- dlflag,
- accountstr,
- outrepstr,
- ifphone)
- 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);
- 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,
- areastr = :arg_areastr,
- cardno = :ls_cardno,
- classeditstr = :arg_classeditstr,
- classviewstr = :arg_classviewstr,
- xls_printstr = :arg_xls_printstr,
- xls_sendstr = :arg_xls_sendstr,
- spttypestr = :arg_spttypestr,
- pluginsstr = :arg_pluginsstr,
- reportstr = :arg_reportstr,
- ifnotin = :arg_ifnotin,
- dlflag = :arg_dlflag,
- accountstr = :arg_accountstr,
- outrepstr = :arg_outrepstr,
- ifphone = :arg_ifphone
- Where empid = :arg_empid AND scid = :arg_scid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '更新用户基本资料失败,'+sqlca.sqlerrtext
- 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
- on uo_usergroup.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_usergroup.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|