123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- $PBExportHeader$f_init_billstyle.srf
- global type f_init_billstyle from function_object
- end type
- forward prototypes
- global function integer f_init_billstyle (ref string arg_msg)
- end prototypes
- global function integer f_init_billstyle (ref string arg_msg);Int rslt
- rslt = 1
- datastore ds_billstyle
- ds_billstyle = CREATE datastore
- ds_billstyle.DataObject = 'ds_sys_billstyle'
- ds_billstyle.SetTransObject(sqlca)
- Long ll_row
- ll_row = ds_billstyle.RowCount()
- //DELETE FROM u_billcode
- //where id = 49 ;
- //IF sqlca.SQLCode = -1 THEN
- // arg_msg = '删除单据抬头失败'+sqlca.SQLErrText
- // rslt = 0
- // GOTO ext
- //END IF
- //
- //DELETE FROM u_billcode
- //where id = 60 and firststr = 'FP';
- //IF sqlca.SQLCode = -1 THEN
- // arg_msg = '删除单据抬头失败'+sqlca.SQLErrText
- // rslt = 0
- // GOTO ext
- //END IF
- Long cnt
- SELECT count(*) INTO :cnt
- FROM u_billcode;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询单据抬头失败'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- Long ll_id_arr[]
- String ls_firststr_arr[]
- String ls_datestyle_arr[]
- String ls_dscrp_arr[]
- Long ll_cnt = 1
- IF cnt < ll_row THEN
- DECLARE cur_billcode CURSOR FOR
- SELECT u_billcode.id,
- u_billcode.firststr,
- u_billcode.datestyle,
- u_billcode.dscrp
- FROM u_billcode
- WHERE u_billcode.firststr <> ''
- OR u_billcode.datestyle <> 'yymmdd';
- OPEN cur_billcode;
- FETCH cur_billcode INTO :ll_id_arr[ll_cnt],
- :ls_firststr_arr[ll_cnt],
- :ls_datestyle_arr[ll_cnt],
- :ls_dscrp_arr[ll_cnt];
-
- DO WHILE sqlca.SQLCode = 0
- ll_cnt++
- FETCH cur_billcode INTO :ll_id_arr[ll_cnt],
- :ls_firststr_arr[ll_cnt],
- :ls_datestyle_arr[ll_cnt],
- :ls_dscrp_arr[ll_cnt];
- LOOP
-
- CLOSE cur_billcode;
-
- ll_cnt = ll_cnt - 1
-
- DELETE FROM u_billcode;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '删除原系统单据抬头数据失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- Long ll_i
- Long ll_id
- String ls_firststr
- String ls_datestyle
- String ls_dscrp
- String ls_oldfirststr
- String ls_billstyle
- String ls_win1
- String ls_win2
- String ls_tablename
- String ls_codename
- String ls_module
- FOR ll_i = 1 TO ds_billstyle.RowCount()
- ll_id = ds_billstyle.Object.id[ll_i]
-
- IF IsNull(ds_billstyle.Object.firststr[ll_i]) THEN
- ls_firststr = ''
- ELSE
- ls_firststr = ds_billstyle.Object.firststr[ll_i]
- END IF
-
- IF IsNull(ds_billstyle.Object.datestyle[ll_i]) THEN
- ls_datestyle = ''
- ELSE
- ls_datestyle = ds_billstyle.Object.datestyle[ll_i]
- END IF
-
- IF IsNull(ds_billstyle.Object.dscrp[ll_i]) THEN
- ls_dscrp = ''
- ELSE
- ls_dscrp = ds_billstyle.Object.dscrp[ll_i]
- END IF
-
- IF IsNull(ds_billstyle.Object.oldfirststr[ll_i]) THEN
- ls_oldfirststr = ''
- ELSE
- ls_oldfirststr = ds_billstyle.Object.oldfirststr[ll_i]
- END IF
-
- IF IsNull(ds_billstyle.Object.billstyle[ll_i]) THEN
- ls_billstyle = ''
- ELSE
- ls_billstyle = ds_billstyle.Object.billstyle[ll_i]
- END IF
-
- IF IsNull(ds_billstyle.Object.win1[ll_i]) THEN
- ls_win1 = ''
- ELSE
- ls_win1 = ds_billstyle.Object.win1[ll_i]
- END IF
-
- IF IsNull(ds_billstyle.Object.win2[ll_i]) THEN
- ls_win2 = ''
- ELSE
- ls_win2 = ds_billstyle.Object.win2[ll_i]
- END IF
-
- IF IsNull(ds_billstyle.Object.tablename[ll_i]) THEN
- ls_tablename = ''
- ELSE
- ls_tablename = ds_billstyle.Object.tablename[ll_i]
- END IF
-
- IF IsNull(ds_billstyle.Object.codename[ll_i]) THEN
- ls_codename = ''
- ELSE
- ls_codename = ds_billstyle.Object.codename[ll_i]
- END IF
-
- IF IsNull(ds_billstyle.Object.module[ll_i]) THEN
- ls_module = ''
- ELSE
- ls_module = ds_billstyle.Object.module[ll_i]
- END IF
-
-
- INSERT INTO
- u_billcode(id,
- firststr,
- datestyle,
- dscrp,
- oldfirststr,
- billstyle,
- win1,
- win2,
- tablename,
- codename,
- module)
- VALUES(:ll_id,
- :ls_firststr,
- :ls_datestyle,
- :ls_dscrp,
- :ls_oldfirststr,
- :ls_billstyle,
- :ls_win1,
- :ls_win2,
- :ls_tablename,
- :ls_codename,
- :ls_module);
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '新增系统单据抬头数据失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- NEXT
-
- FOR ll_i = 1 TO ll_cnt
- UPDATE u_billcode
- SET firststr = :ls_firststr_arr[ll_i],
- datestyle = :ls_datestyle_arr[ll_i],
- dscrp = :ls_dscrp_arr[ll_i]
- Where id = :ll_id_arr[ll_i];
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '更新改变系统单据抬头数据失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- NEXT
-
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSE
- COMMIT;
- END IF
- RETURN rslt
- end function
|