123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603 |
- $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_knwldg (long arg_empid, string arg_userid, integer arg_knwldgencrypttype, integer arg_knwldgtchnlogytype, string arg_knwldgrgtstr, 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_storagestr_new, string arg_storagestr_audit, string arg_scstr, string arg_classeditstr, string arg_classviewstr, string arg_classdelstr, string arg_areastr, integer arg_iftimelimit, string arg_timelimitdscrp, integer arg_ifcheckcard, string arg_xls_printstr, string arg_xls_sendstr, string arg_spttypestr, string arg_gzitemstr, integer arg_ifcheckcomp, string arg_compname, string arg_pluginsstr, integer arg_ifnotin, string arg_modulestring, string arg_priceliststr, string arg_reportstr, string arg_wkpstr, string arg_workgroupstr, string arg_pricetypestr, string arg_outrepstr, integer arg_dlflag, integer arg_grade, string arg_deptstr, string arg_saletypestr, long arg_pempid, string arg_demotypestr, 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
- Long cnt
- If if_delall Then
- Delete From u_user Where empid <> 0 And scid = :arg_scid;
- Else
- Select count(*)
- Into :cnt
- From u_user
- Where pempid = :arg_empid ;
- If sqlca.SQLCode <> 0 Then
- arg_msg = '查询用户是否有下级用户失败,'+sqlca.sqlerrtext
- rslt = 0
- Goto ext
- End If
-
- if cnt > 0 then
- rslt = 0
- arg_msg = '该用户有下级用户,请先删除下级用户'
- goto ext
- end if
-
- 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 = ''
- String ls_p1,ls_p2
- Int ll_len
- ls_pwd = f_psw_bczh(Lower(arg_userid),0,sys_power_key_new)
- ll_len = Int(Len(ls_pwd) / 2)
- ls_p1 = Mid(ls_pwd,1,ll_len)
- ls_p2 = Mid(ls_pwd,ll_len + 1)
- UPDATE u_user
- SET psw = '',
- pone = :ls_p1,
- ptwo = :ls_p2
- 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,TRUE,id_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_knwldg (long arg_empid, string arg_userid, integer arg_knwldgencrypttype, integer arg_knwldgtchnlogytype, string arg_knwldgrgtstr, ref string arg_msg);Int rslt = 1
- String ls_pass,ls_cardno
- IF arg_userid = "" THEN
- arg_msg = "必须填写用户代码!"
- rslt = 0
- GOTO ext
- END IF
- UPDATE u_user
- SET knwldgencrypttype = :arg_knwldgencrypttype,
- knwldgtchnlogytype = :arg_knwldgtchnlogytype,
- knwldgrgtstr = :arg_knwldgrgtstr
- Where empid = :arg_empid
- and UserID = :arg_userid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '更新用户基本资料失败'
- rslt = 0
- GOTO ext
- END IF
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 THEN
- COMMIT;
- 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_storagestr_new, string arg_storagestr_audit, string arg_scstr, string arg_classeditstr, string arg_classviewstr, string arg_classdelstr, string arg_areastr, integer arg_iftimelimit, string arg_timelimitdscrp, integer arg_ifcheckcard, string arg_xls_printstr, string arg_xls_sendstr, string arg_spttypestr, string arg_gzitemstr, integer arg_ifcheckcomp, string arg_compname, string arg_pluginsstr, integer arg_ifnotin, string arg_modulestring, string arg_priceliststr, string arg_reportstr, string arg_wkpstr, string arg_workgroupstr, string arg_pricetypestr, string arg_outrepstr, integer arg_dlflag, integer arg_grade, string arg_deptstr, string arg_saletypestr, long arg_pempid, string arg_demotypestr, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- String ls_pass,ls_cardno
- String ls_psw,ls_psw_r,ls_psw_new,ls_p1,ls_p2
- Int ll_len
- String ls_ljemail
- 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_iftimelimit = 1 THEN
- IF Len(Trim(arg_timelimitdscrp)) = 0 THEN
- arg_msg = "请输入时间段备注!"
- rslt = 0
- GOTO ext
- END IF
- END IF
- IF arg_ifcheckcomp = 1 THEN
- IF Len(Trim(arg_compname)) = 0 THEN
- arg_msg = '请输入计算机名称'
- rslt = 0
- GOTO ext
- END IF
- END IF
- ls_cardno = arg_cardno
- //定义内部邮件账号
- //ls_ljemail
- String ls_CusCode
- SELECT top 1 CusCode
- INTO :ls_CusCode
- FROM LJFIEB_CusComm
- WHERE CusType = 0
- Using sys_email_sqlca;
- IF sys_email_sqlca.SQLCode <> 0 THEN
- ls_CusCode = "" //假定未设置电子商务
- END IF
- IF ls_CusCode <> '' THEN
- ls_ljemail = Trim(arg_userid) +"@@"+Trim(ls_CusCode)
- END IF
- 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) //加密
-
- ls_psw_new = f_psw_bczh(arg_userid,0,sys_power_key_new)
- ll_len = Int(Len(ls_psw_new) / 2)
-
- ls_p1 = Mid(ls_psw_new,1,ll_len)
- ls_p2 = Mid(ls_psw_new,ll_len + 1)
-
-
- INSERT INTO u_user(scid,
- empid,
- userid,
- username,
- descrp,
- storagestr,
- storagestr_new,
- storagestr_audit,
- scstr,
- psw,
- Rightstring,
- areastr,
- cardno,
- iftimelimit,
- timelimitdscrp,
- ifcheckcard,
- classeditstr,
- classviewstr,
- classdelstr,
- xls_printstr,
- xls_sendstr,
- spttypestr,
- gzitemstr,
- ifcheckcomp,
- compname,
- pluginsstr,
- ifnotin,
- modulestring,
- priceliststr,
- reportstr,
- wkpstr,
- workgroupstr,
- pricetypestr,
- outrepstr,
- dlflag,
- grade,
- pone,
- ptwo,
- deptstr,
- saletypestr,
- pempid,
- ljemail,
- demotypestr)
- VALUES (:arg_scid,
- :arg_empid,
- :arg_userid,
- :arg_username,
- :arg_dscrp,
- :arg_storagestr,
- :arg_storagestr_new,
- :arg_storagestr_audit,
- :arg_scstr,
- :ls_pass,
- :arg_powerstring,
- :arg_areastr,
- :ls_cardno,
- :arg_iftimelimit,
- :arg_timelimitdscrp,
- :arg_ifcheckcard,
- :arg_classeditstr,
- :arg_classviewstr,
- :arg_classdelstr,
- :arg_xls_printstr,
- :arg_xls_sendstr,
- :arg_spttypestr,
- :arg_gzitemstr,
- :arg_ifcheckcomp,
- :arg_compname,
- :arg_pluginsstr,
- :arg_ifnotin,
- :arg_modulestring,
- :arg_priceliststr,
- :arg_reportstr,
- :arg_wkpstr,
- :arg_workgroupstr,
- :arg_pricetypestr,
- :arg_outrepstr,
- :arg_dlflag,
- :arg_grade,
- :ls_p1,
- :ls_p2,
- :arg_deptstr,
- :arg_saletypestr,
- :arg_pempid,
- :ls_ljemail,
- :arg_demotypestr);
- 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,
- storagestr_new = :arg_storagestr_new,
- storagestr_audit = :arg_storagestr_audit,
- Rightstring = :arg_powerstring,
- scstr = :arg_scstr,
- areastr = :arg_areastr,
- cardno = :ls_cardno,
- iftimelimit = :arg_iftimelimit,
- timelimitdscrp = :arg_timelimitdscrp,
- ifcheckcard = :arg_ifcheckcard,
- classeditstr = :arg_classeditstr,
- classviewstr = :arg_classviewstr,
- classdelstr = :arg_classdelstr,
- xls_printstr = :arg_xls_printstr,
- xls_sendstr = :arg_xls_sendstr,
- spttypestr = :arg_spttypestr,
- gzitemstr = :arg_gzitemstr,
- ifcheckcomp = :arg_ifcheckcomp,
- compname = :arg_compname,
- pluginsstr = :arg_pluginsstr,
- ifnotin = :arg_ifnotin,
- modulestring = :arg_modulestring,
- priceliststr = :arg_priceliststr,
- reportstr = :arg_reportstr,
- wkpstr = :arg_wkpstr,
- workgroupstr = :arg_workgroupstr,
- pricetypestr = :arg_pricetypestr,
- outrepstr = :arg_outrepstr,
- dlflag = :arg_dlflag,
- grade = :arg_grade,
- deptstr = :arg_deptstr,
- saletypestr = :arg_saletypestr,
- pempid = :arg_pempid,
- ljemail = :ls_ljemail,
- demotypestr = :arg_demotypestr
- 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
- on uo_usergroup.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_usergroup.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|