123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- $PBExportHeader$f_set_right.srf
- global type f_set_right from function_object
- end type
- forward prototypes
- global function integer f_set_right ()
- end prototypes
- global function integer f_set_right ();Long i ,cnt,rslt = 1
- Long empid[]
- String ls_powerstring[]
- Long it_mx
- i = 1
- String ls_update,ls_update2,ls_update3
- ls_update = f_ProfileString (0,'right','update_right', "no")
- ls_update2 = f_ProfileString (0,'right','update_right2', "no")
- ls_update3 = f_ProfileString (0,'right','update_right3', "no")
- IF ls_update = 'no' THEN
- DECLARE CUR_INWAERMX CURSOR FOR SELECT u_user.empid,
- u_user.rightstring
- FROM u_user
- Where empid <> 0;
- OPEN CUR_INWAERMX;
- FETCH CUR_INWAERMX INTO :empid[i],:ls_powerstring[i];
- DO WHILE sqlca.SQLCode = 0
- i++
- FETCH CUR_INWAERMX INTO :empid[i],:ls_powerstring[i];
- LOOP
- CLOSE CUR_INWAERMX;
-
- it_mx = i - 1
-
- FOR i = 1 TO it_mx
- IF Mid(ls_powerstring[i],121,1) = '1' THEN
- ls_powerstring[i] = Replace(ls_powerstring[i],1448,1,'1')
- ls_powerstring[i] = Replace(ls_powerstring[i],1449,1,'1')
- UPDATE u_user
- SET u_user.rightstring = :ls_powerstring[i]
- Where u_user.empid = :empid[i];
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- NEXT
-
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSE
- COMMIT;
- f_setProfileString (0,'right','update_right', "yes")
- END IF
- END IF
- IF ls_update2 = 'no' THEN
- DECLARE CUR_INWAERMX2 CURSOR FOR
- SELECT u_user.empid,
- u_user.rightstring
- FROM u_user
- Where empid <> 0;
- OPEN CUR_INWAERMX2;
- FETCH CUR_INWAERMX2 INTO :empid[i],:ls_powerstring[i];
- DO WHILE sqlca.SQLCode = 0
- i++
- FETCH CUR_INWAERMX2 INTO :empid[i],:ls_powerstring[i];
- LOOP
- CLOSE CUR_INWAERMX2;
-
- it_mx = i - 1
-
- FOR i = 1 TO it_mx
- IF Mid(ls_powerstring[i],490,1) = '1' THEN
- ls_powerstring[i] = Replace(ls_powerstring[i],1451,1,'1')
- UPDATE u_user
- SET u_user.rightstring = :ls_powerstring[i]
- Where u_user.empid = :empid[i];
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- GOTO ext2
- END IF
- END IF
- NEXT
-
- ext2:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSE
- COMMIT;
- f_setProfileString (0,'right','update_right2', "yes")
- END IF
- END IF
- IF ls_update3 = 'no' THEN
- DECLARE CUR_INWAERMX3 CURSOR FOR
- SELECT u_user.empid,
- u_user.rightstring
- FROM u_user
- Where empid <> 0;
- OPEN CUR_INWAERMX3;
- FETCH CUR_INWAERMX3 INTO :empid[i],:ls_powerstring[i];
- DO WHILE sqlca.SQLCode = 0
- i++
- FETCH CUR_INWAERMX3 INTO :empid[i],:ls_powerstring[i];
- LOOP
- CLOSE CUR_INWAERMX3;
-
- it_mx = i - 1
-
- FOR i = 1 TO it_mx
- IF Mid(ls_powerstring[i],122,1) = '1' THEN
- ls_powerstring[i] = Replace(ls_powerstring[i],1473,1,'1')
- UPDATE u_user
- SET u_user.rightstring = :ls_powerstring[i]
- Where u_user.empid = :empid[i];
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- GOTO ext3
- END IF
- END IF
- NEXT
-
- ext3:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSE
- COMMIT;
- f_setProfileString (0,'right','update_right3', "yes")
- END IF
- END IF
- RETURN rslt
- end function
|