123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- $PBExportHeader$uo_mtrlware_propel_rule.sru
- forward
- global type uo_mtrlware_propel_rule from nonvisualobject
- end type
- end forward
- global type uo_mtrlware_propel_rule from nonvisualobject
- end type
- global uo_mtrlware_propel_rule uo_mtrlware_propel_rule
- type variables
- long uo_ruleid
- end variables
- forward prototypes
- public function integer del (long arg_ruleid, ref string arg_msg, boolean arg_ifcommit)
- public function integer save (s_mtrlware_propel_rule arg_s_rule, ref string arg_msg, boolean arg_ifcommit)
- end prototypes
- public function integer del (long arg_ruleid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- IF arg_ruleid <= 0 THEN
- rslt = 0
- arg_msg = '错误单据唯一码'
- GOTO ext
- END IF
- DELETE FROM u_mtrlware_propel_rule_mx
- Where ruleid = :arg_ruleid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除规则明细操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- DELETE FROM u_mtrlware_propel_rule
- Where ruleid = :arg_ruleid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除策略操作失败"+"~n"+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 save (s_mtrlware_propel_rule arg_s_rule, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Long cnt = 0
- Long ll_newid
- DateTime server_dt
- Long it_mxbt,it_mxbt_mtrl
- Long i,j
- IF IsNull(arg_s_rule.ruleid) THEN arg_s_rule.ruleid = 0
- IF IsNull(arg_s_rule.rulename) THEN arg_s_rule.rulename = ''
- IF IsNull(arg_s_rule.rulestr) THEN arg_s_rule.rulestr = ''
- IF IsNull(arg_s_rule.dscrp) THEN arg_s_rule.dscrp = ''
- IF IsNull(arg_s_rule.storageid) THEN arg_s_rule.storageid = 0
- IF IsNull(arg_s_rule.handtypestr) THEN arg_s_rule.handtypestr = ''
- IF IsNull(arg_s_rule.isrunning) THEN arg_s_rule.isrunning = 0
- IF IsNull(arg_s_rule.timertype) THEN arg_s_rule.timertype = 0
- IF IsNull(arg_s_rule.timerparm) THEN arg_s_rule.timerparm = ''
- SELECT Top 1 getdate() Into :server_dt From u_user;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,日期 "
- GOTO ext
- END IF
- IF arg_s_rule.rulename = '' THEN
- rslt = 0
- arg_msg = '请输入策略名称'
- GOTO ext
- END IF
- //IF arg_s_rule.rulestr = '' THEN
- // rslt = 0
- // arg_msg = '请填写策略规则'
- // GOTO ext
- //END IF
- IF arg_s_rule.storageid = 0 THEN
- rslt = 0
- arg_msg = '请选择仓库'
- GOTO ext
- END IF
- it_mxbt = UpperBound(arg_s_rule.arg_s_mx)
- IF it_mxbt <= 0 THEN
- rslt = 0
- arg_msg = "没有正确规则明细内容"
- GOTO ext
- END IF
- IF arg_s_rule.ruleid = 0 THEN
- ll_newid = f_sys_scidentity(0,"u_mtrlware_propel_rule","ruleid",arg_msg,True,id_sqlca)
-
- IF ll_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- INSERT INTO u_mtrlware_propel_rule
- (ruleid,
- rulename,
- rulestr,
- dscrp,
- opemp,
- opdate,
- storageid,
- handtypestr,
- isrunning,
- nextexectime,
- timertype,
- timerparm)
- VALUES
- (:ll_newid,
- :arg_s_rule.rulename,
- :arg_s_rule.rulestr,
- :arg_s_rule.dscrp,
- :publ_operator,
- getdate(),
- :arg_s_rule.storageid,
- :arg_s_rule.handtypestr,
- :arg_s_rule.isrunning,
- :arg_s_rule.nextexectime,
- :arg_s_rule.timertype,
- :arg_s_rule.timerparm);
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '新增策略失败'+sqlca.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 To it_mxbt
- INSERT INTO u_mtrlware_propel_rule_mx
- (ruleid,
- cusid,
- ifmatch)
- VALUES
- (:ll_newid,
- :arg_s_rule.arg_s_mx[i].cusid,
- :arg_s_rule.arg_s_mx[i].ifmatch);
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '插入明细失败'+sqlca.SQLErrText
- GOTO ext
- END IF
-
- NEXT
-
- uo_ruleid = ll_newid
- ELSE
- UPDATE u_mtrlware_propel_rule
- SET rulename = :arg_s_rule.rulename,
- rulestr = :arg_s_rule.rulestr,
- dscrp = :arg_s_rule.dscrp,
- storageid = :arg_s_rule.storageid,
- moddate = getdate(),
- modemp = :publ_operator,
- handtypestr = :arg_s_rule.handtypestr,
- isrunning = :arg_s_rule.isrunning,
- nextexectime = :arg_s_rule.nextexectime,
- timertype = :arg_s_rule.timertype,
- timerparm = :arg_s_rule.timerparm
- Where ruleid = :arg_s_rule.ruleid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '更新策略失败'+sqlca.SQLErrText
- GOTO ext
- END IF
-
-
- DELETE FROM u_mtrlware_propel_rule_mx
- Where ruleid = :arg_s_rule.ruleid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除旧有规则明细操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
-
-
- FOR i = 1 To it_mxbt
- INSERT INTO u_mtrlware_propel_rule_mx
- (ruleid,
- cusid,
- ifmatch)
- VALUES
- (:arg_s_rule.ruleid,
- :arg_s_rule.arg_s_mx[i].cusid,
- :arg_s_rule.arg_s_mx[i].ifmatch);
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '插入明细规则失败'+sqlca.SQLErrText
- GOTO ext
- END IF
- NEXT
-
-
- uo_ruleid = arg_s_rule.ruleid
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF arg_ifcommit And rslt = 1 THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- on uo_mtrlware_propel_rule.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_mtrlware_propel_rule.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|