$PBExportHeader$uo_giveback.sru forward global type uo_giveback from nonvisualobject end type end forward global type uo_giveback from nonvisualobject end type global uo_giveback uo_giveback type variables PUBLIC PROTECTEDWRITE Long scid = 0 //分部id PUBLIC PROTECTEDWRITE Long givebackid //进仓单表自动增量id PUBLIC PROTECTEDWRITE String givebackcode //单据的唯一编号 PUBLIC PROTECTEDWRITE DateTime opdate //建立时间,自动 PUBLIC PROTECTEDWRITE String opemp //建立操作员 PUBLIC PROTECTEDWRITE DateTime moddate //修改时间,自动 PUBLIC PROTECTEDWRITE String modemp //修改操作员 PUBLIC PROTECTEDWRITE Int flag = 0 //仓库审核标志 PUBLIC PROTECTEDWRITE DateTime auditingdate //审核时间 PUBLIC PROTECTEDWRITE String auditingrep //审核操作员 String relcode = '' DateTime givebackdate String dscrp = '' //备注 String assign_emp = '' //经手人 Long cusid = 0 //客户id DateTime startdate //开始日 DateTime enddate //结束日 Decimal {5} givebackrate = 0 //返利率 Decimal {5} sumamt = 0 //单据总金额 Long banktypeid = 0 //结算方式 Long relint_3 = 0 long moneyid = 0 decimal givebackamt = 0 int uo_option_if_givebackrate Transaction commit_transaction //数据commit事务 Boolean if_getid_ture = TRUE s_givebackmx givebackmx[] //明细结构数组 Long it_mxbt = 0 //明细结构数组末指针 Boolean it_newbegin = FALSE //新建标志 Boolean it_updatebegin = FALSE //修改标志 end variables forward prototypes public function integer p_clearmx () public function integer p_reset () public function integer p_getinfo (long arg_scid, long arg_givebackid, ref string arg_msg) public function integer getinfo (long arg_scid, long arg_givebackid, ref string arg_msg) public function integer newbegin (long arg_scid, ref string arg_msg) public function integer updatebegin (long arg_scid, long arg_givebackid, ref string arg_msg) public function integer add_dscrp (long arg_scid, long arg_givebackid, string arg_newdescppart, ref string arg_msg) public function integer save (boolean arg_ifcommit, ref string arg_msg) public function integer del (long arg_scid, long arg_givebackid, ref string arg_msg, boolean arg_ifcommit) public function integer auditing (boolean arg_ifcommit, ref string arg_msg) public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg) public function integer acceptmx (decimal arg_norebateamt, decimal arg_childsumamt, string arg_mxdscrp, long arg_printid, ref string arg_msg, long arg_outwareid, string arg_relcode, datetime arg_givebackdate) public function integer acceptmx (decimal arg_norebateamt, decimal arg_childsumamt, string arg_mxdscrp, long arg_printid, ref string arg_msg, long arg_outwareid, string arg_relcode, datetime arg_givebackdate, string arg_rulsqlstr, string arg_gbratestr) end prototypes public function integer p_clearmx ();//int p_clearmx() //清除明细 it_mxbt=0 sumamt = 0 return 1 end function public function integer p_reset ();//int p_reset() //清除对象及其明细 scid = 0 givebackid = 0 givebackcode = '' opemp = '' modemp = '' auditingrep = '' flag = 0 assign_emp = '' relcode = '' dscrp = '' cusid = 0 givebackrate = 0 sumamt = 0 moneyid = 0 it_newbegin = FALSE it_updatebegin = FALSE //清除明细 p_clearmx() RETURN 1 end function public function integer p_getinfo (long arg_scid, long arg_givebackid, ref string arg_msg);//p_getinfo(arg_scid,arg_outwareid,arg_msg) //0 失败 1成功 Int rslt = 1 IF arg_givebackid <= 0 THEN rslt = 0 arG_MSG = "非法返利单唯一码" GOTO ext END IF SELECT givebackcode, cusid, givebackdate, startdate, enddate, givebackrate, sumamt, assign_emp, relcode, dscrp, flag, banktypeid, relint_3, moneyid, givebackamt INTO :givebackcode, :cusid, :givebackdate, :startdate, :enddate, :givebackrate, :sumamt, :assign_emp, :relcode, :dscrp, :flag, :banktypeid, :relint_3, :moneyid, :givebackamt FROM u_giveback WHERE u_giveback.givebackid = :arg_givebackid AND scid = :arg_scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arG_MSG = "查询操作失败(错误返利单唯一码),返利单"+commit_transaction.SQLErrText GOTO ext END IF givebackid = arg_givebackid scid = arg_scid ext: IF rslt = 0 THEN p_reset() RETURN rslt end function public function integer getinfo (long arg_scid, long arg_givebackid, ref string arg_msg);//getinfo(arg_scid,arg_givebackid,arg_msg) //0 失败 1成功 Int rslt = 1,i = 1,no_mxcheck = 0 IF arg_givebackid <= 0 THEN rslt = 0 arg_msg = "非法返利单唯一码" GOTO ext END IF rslt = p_getinfo(arg_scid,arg_givebackid,arg_msg) IF rslt = 0 THEN GOTO ext //用游标读取明细 DECLARE cur_inwaermx CURSOR FOR SELECT givebackdate, relcode, printid, norebateamt, childsumamt, mxDscrp, outwareid, rulSqlStr, gbRateStr FROM u_givebackmx WHERE u_givebackmx.givebackid = :arg_givebackid AND u_givebackmx.scid = :arg_scid USING commit_transaction; OPEN cur_inwaermx; FETCH cur_inwaermx INTO :givebackmx[i].givebackdate, :givebackmx[i].relcode,:givebackmx[i].printid, :givebackmx[i].norebateamt,:givebackmx[i].childsumamt, :givebackmx[i].mxdscrp, :givebackmx[i].outwareid, :givebackmx[i].rulSqlStr, :givebackmx[i].gbRateStr; DO WHILE commit_transaction.SQLCode = 0 i++ FETCH cur_inwaermx INTO :givebackmx[i].givebackdate, :givebackmx[i].relcode,:givebackmx[i].printid, :givebackmx[i].norebateamt,:givebackmx[i].childsumamt, :givebackmx[i].mxdscrp, :givebackmx[i].outwareid, :givebackmx[i].rulSqlStr, :givebackmx[i].gbRateStr; LOOP CLOSE cur_inwaermx; //检验明细是否读入完整 SELECT count(*) INTO :no_mxcheck FROM u_givebackmx WHERE u_givebackmx.givebackid = :arg_givebackid AND scid = :arg_scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,返利单明细数量" GOTO ext END IF IF i <> (no_mxcheck+1) THEN rslt = 0 arg_msg = "查询操作失败,返利单明细" GOTO ext END IF givebackid = arg_givebackid scid = arg_scid it_mxbt = i - 1 it_newbegin = FALSE it_updatebegin = FALSE ext: IF rslt = 0 THEN p_reset() RETURN rslt end function public function integer newbegin (long arg_scid, ref string arg_msg);//==================================================================== // Function: newbegin(long arg_scid,int arg_billtype,ref string arg_msg) //-------------------------------------------------------------------- // Description: 从置对象,设定业务类型,准备建立新进仓单 //-------------------------------------------------------------------- // Arguments: // value long arg_scid // value integer arg_billtype // reference string arg_msg //-------------------------------------------------------------------- // Returns: integer //-------------------------------------------------------------------- // Author: yyx Date: 2003.11.12 //-------------------------------------------------------------------- // Modify History: // //==================================================================== int rslt=1 if arg_scid < 0 then arg_msg = '请选择分部' rslt = 0 goto ext end if p_reset() scid=arg_scid it_newbegin=true it_updatebegin=false ext: if rslt=0 then p_reset() return rslt end function public function integer updatebegin (long arg_scid, long arg_givebackid, ref string arg_msg);//==================================================================== // Function: updatebegin(arg_scid,arg_inwareid,arg_billtype,arg_msg) //-------------------------------------------------------------------- // Description: 从置对象,设定业务类型与关联ID,准备更新进仓单 //-------------------------------------------------------------------- // Arguments: // value long arg_scid // value long arg_inwareid // value integer arg_billtype // reference string arg_msg //-------------------------------------------------------------------- // Returns: integer //-------------------------------------------------------------------- // Author: yyx Date: 2003.11.12 //-------------------------------------------------------------------- // Modify History: // //==================================================================== long rslt=1 if arg_scid < 0 then arg_msg = '请选择分部' rslt = 0 goto ext end if if arg_givebackid<=0 then rslt=0 goto ext end if rslt=p_getinfo(arg_scid,arg_givebackid,arg_msg) if rslt=0 then goto ext if flag=1 then rslt=0 arg_msg='单据已经审核,不可以修改' goto ext end if givebackid=arg_givebackid scid=arg_scid it_newbegin=false it_updatebegin=true p_clearmx() //清除明细 ext: if rslt=0 then p_reset() return rslt end function public function integer add_dscrp (long arg_scid, long arg_givebackid, string arg_newdescppart, ref string arg_msg);//add_dscrp(string arg_newdescppart) //0 fail 1 success int rslt=1 arg_newdescppart=trim(arg_newdescppart) if it_updatebegin or it_newbegin then rslt=0 arg_msg="编辑状态下不可用" goto ext end if if arg_newdescppart='' then rslt=0 arg_msg="要添加内容为空,操作取消" goto ext end if rslt=p_getinfo(arg_scid,arg_givebackid,arg_msg) if rslt=0 then goto ext if flag=0 then rslt=0 arg_msg="非审核状态下不可用" goto ext end if update u_giveback set dscrp = dscrp+' '+:arg_newdescppart where u_giveback.givebackid = :givebackid and scid=:scid using commit_transaction; if commit_transaction.sqlcode<>0 then rollback ; rslt=0 arg_msg="因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.sqlerrtext goto ext end if commit using commit_transaction; dscrp = dscrp+' '+arg_newdescppart ext: return (rslt) end function public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1,cnt = 0,i DateTime server_dt Long ls_newid String ls_sccode IF uo_option_if_givebackrate = -1000 THEN rslt = 0 arg_msg = '选项:[097]返利单按返利率返利,读取初始默认值失败,操作取消!' GOTO ext END IF IF IsNull(givebackrate) THEN givebackrate = 0 IF IsNull(cusid) THEN cusid = 0 IF IsNull(assign_emp) THEN assign_emp = '' IF IsNull(sumamt) THEN sumamt = 0 IF IsNull(relcode) THEN relcode = '' IF IsNull(dscrp) THEN dscrp = '' IF uo_option_if_givebackrate = 1 THEN givebackamt = givebackrate * sumamt ELSE givebackrate = 0 sumamt = 0 it_mxbt = 0 END IF IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN rslt = 0 arg_msg = "非编辑状态不可以提交" GOTO ext END IF SELECT Top 1 getdate() INTO :server_dt FROM u_user USING commit_transaction ; //取得系统时间,借用操作员表 IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,日期 " GOTO ext END IF IF uo_option_if_givebackrate = 1 THEN IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空 rslt = 0 arg_msg = "没有正确明细内容" GOTO ext END IF END IF IF f_check_inoutdate(0,givebackdate,FALSE,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF banktypeid = 0 THEN arg_msg = '请选择结算方式' rslt = 0 GOTO ext END IF IF moneyid = 0 THEN arg_msg = '请选择结算方式' rslt = 0 GOTO ext END IF cnt = 0 SELECT count(*) INTO :cnt FROM cw_currency Where moneyid = :moneyid; 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 ////////////////////////////////////////////// //开始区分:新建/更新 处理 IF givebackid = 0 THEN //新建 ls_newid = f_sys_scidentity(scid,"u_giveback","givebackid",arg_msg,TRUE,id_sqlca) IF ls_newid <= 0 THEN rslt = 0 GOTO ext END IF //取分部代号 IF f_get_sccode(scid,commit_transaction,ls_sccode,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF //取得新单据编号 givebackcode = getid(scid,ls_sccode + 'FL',Date(server_dt),if_getid_ture,commit_transaction) IF givebackcode = "err" THEN givebackcode = '' rslt = 0 arg_msg = "无法获取返利单编号"+"~n"+commit_transaction.SQLErrText GOTO ext END IF INSERT INTO u_giveback ( scid, givebackid, givebackcode, cusid, givebackdate, startdate, enddate, givebackrate, sumamt, assign_emp, relcode, dscrp, opdate, opemp, flag, banktypeid, moneyid, givebackamt) VALUES ( :scid, :ls_newid, :givebackcode, :cusid, :givebackdate, :startdate, :enddate, :givebackrate, :sumamt, :assign_emp, :relcode, :dscrp, :server_dt, :publ_operator, :flag, :banktypeid, :moneyid, :givebackamt) USING commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF //读取新givebackid givebackid = ls_newid FOR i = 1 TO it_mxbt INSERT INTO u_givebackmx (scid, givebackid, givebackdate, outwareid, relcode, printid, norebateamt, childsumamt, mxDscrp, rulSqlStr, gbRateStr) VALUES ( :scid, :ls_newid, :givebackmx[i].givebackdate, :givebackmx[i].outwareid, :givebackmx[i].relcode, :givebackmx[i].printid, :givebackmx[i].norebateamt, :givebackmx[i].childsumamt, :givebackmx[i].mxDscrp, :givebackmx[i].rulSqlStr, :givebackmx[i].gbRateStr) USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN givebackid = 0 //还原givebackid rslt = 0 arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF NEXT ELSE //////////////////////////////////////////////// //更新 UPDATE u_giveback SET cusid = :cusid, givebackdate = :givebackdate, startdate = :startdate, enddate = :enddate, givebackrate = :givebackrate, sumamt = :sumamt, assign_emp = :assign_emp, relcode = :relcode, dscrp = :dscrp, moddate = : server_dt, modemp = :publ_operator, banktypeid = :banktypeid, moneyid = :moneyid, givebackamt = :givebackamt WHERE u_giveback.givebackid = :givebackid AND u_giveback.scid = :scid AND flag = 0 USING commit_transaction; IF commit_transaction.SQLCode <> 0 OR commit_transaction.SQLNRows <= 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF //删除原有明细 DELETE FROM u_givebackmx WHERE u_givebackmx.givebackid = :givebackid AND u_givebackmx.scid = :scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF FOR i = 1 TO it_mxbt INSERT INTO u_givebackmx (scid, givebackid, givebackdate, outwareid, relcode, printid, norebateamt, childsumamt, mxDscrp, rulSqlStr, gbRateStr) VALUES ( :scid, :givebackid, :givebackmx[i].givebackdate, :givebackmx[i].outwareid, :givebackmx[i].relcode, :givebackmx[i].printid, :givebackmx[i].norebateamt, :givebackmx[i].childsumamt, :givebackmx[i].mxDscrp, :givebackmx[i].rulSqlStr, :givebackmx[i].gbRateStr) USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF NEXT END IF it_newbegin = FALSE it_updatebegin = FALSE ext: IF rslt = 0 THEN ROLLBACK USING commit_transaction; p_clearmx() ELSEIF rslt = 1 AND arg_ifcommit THEN COMMIT USING commit_transaction; END IF RETURN rslt end function public function integer del (long arg_scid, long arg_givebackid, ref string arg_msg, boolean arg_ifcommit);//如果单据还没有审核删除单据极其明细 //0 FAIL, 1 SUCCESS Int rslt = 1 IF arg_givebackid <= 0 THEN rslt = 0 arG_MSG = "没有删除对象,操作取消" GOTO ext END IF IF p_getinfo(arg_scid,arg_givebackid,arG_MSG) = 0 THEN rslt = 0 GOTO ext END IF IF flag = 1 THEN rslt = 0 arG_MSG = "单据已经审核,不可以删除" GOTO ext END IF DELETE FROM u_giveback WHERE u_giveback.givebackid = :arg_givebackid AND u_giveback.scid = :arg_scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arG_MSG = "删除返利单操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF DELETE FROM u_givebackmx WHERE u_givebackmx.givebackid = :arg_givebackid AND u_givebackmx.scid = :arg_scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arG_MSG = "删除返利单明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF it_newbegin = FALSE it_updatebegin = FALSE ext: IF rslt = 0 THEN ROLLBACK USING commit_transaction; p_reset() ELSEIF rslt = 1 AND arg_ifcommit THEN COMMIT USING commit_transaction; END IF RETURN (rslt) end function public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0 uo_musttake uo_take uo_take = CREATE uo_musttake Decimal ld_takeamt = 0,ld_msttakeamt = 0,ld_mrate IF givebackid = 0 THEN rslt = 0 arg_msg = "没有审核对象" GOTO ext END IF IF flag = 1 THEN rslt = 0 arg_msg = "单据已经审核" GOTO ext END IF SELECT count(*) INTO :cnt FROM u_user Where username = :publ_operator USING commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,操作员" GOTO ext END IF IF cnt = 0 THEN rslt = 0 arg_msg = "操作员姓名未登记或已取消" GOTO ext END IF ld_mrate = f_get_mrate(moneyid) if ld_mrate = 0 then rslt = 0 arg_msg = '错误的币种汇率' goto ext end if Int li_btype Long ll_accountsid SELECT btype,accountsid INTO :li_btype,:ll_accountsid FROM cw_banktype Where banktypeid = :banktypeid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询结算方式类型失败,'+ commit_transaction.SQLErrText GOTO ext END IF UPDATE u_giveback SET auditingrep = :publ_operator, auditingdate = getdate(), flag = 1 WHERE u_giveback.givebackid = :givebackid AND flag = 0 AND scid = :scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext ELSEIF commit_transaction.SQLNRows = 0 THEN rslt = 0 arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText GOTO ext END IF String ls_about = '',ls_dscrp = '' Decimal sum_amt sum_amt = 0 - Round(givebackamt,2) IF sum_amt <> 0 THEN ls_about = givebackcode + "返利款" ls_dscrp = ls_about ld_msttakeamt = sum_amt IF li_btype = 1 THEN ld_takeamt = ld_msttakeamt ELSE ld_takeamt = 0 END IF Long ll_dft_itemid SELECT itemid INTO :ll_dft_itemid FROM u_itemdef Where dfttype = 6; IF sqlca.SQLCode <> 0 THEN arg_msg = '查询默认销售返利资料失败,'+sqlca.sqlerrtext rslt = 0 GOTO ext END IF s_bmsttake s_take s_take.scid = scid s_take.cusid = cusid s_take.takedate = givebackdate s_take.inrep = assign_emp s_take.oriamt = ld_msttakeamt s_take.msttakeamt = ld_msttakeamt s_take.takeamt = ld_takeamt s_take.dscrp = ls_about s_take.billcode = givebackcode s_take.relcode = relcode s_take.banktypeid = banktypeid s_take.opemp = publ_operator s_take.buildtype = 1 s_take.outwareid = givebackid s_take.accountsid = ll_accountsid s_take.itemid = ll_dft_itemid s_take.moneyid = moneyid s_take.takeamt_cn = ld_takeamt s_take.moneyid_cn = moneyid s_take.mrate = ld_mrate IF uo_take.add_takerec (s_take,arg_msg,FALSE) = 0 THEN rslt = 0 GOTO ext END IF UPDATE u_giveback SET relint_3 = :uo_take.ref_takeid WHERE u_giveback.givebackid = :givebackid AND scid = :scid AND flag = 1 USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '更新返利单相关应收帐ID失败' rslt = 0 GOTO ext END IF END IF flag = 1 ext: IF rslt = 0 THEN ROLLBACK USING commit_transaction; ELSEIF rslt = 1 AND arg_ifcommit THEN COMMIT USING commit_transaction; END IF RETURN rslt end function public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0 DateTime null_dt SetNull(null_dt) uo_musttake uo_take uo_take = CREATE uo_musttake IF givebackid = 0 THEN rslt = 0 arg_msg = "没有审核对象" GOTO ext END IF IF flag = 0 THEN rslt = 0 arg_msg = "单据还未审核" GOTO ext END IF SELECT count(*) INTO :cnt FROM u_user Where username = :publ_operator USING commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,操作员" GOTO ext END IF IF cnt = 0 THEN rslt = 0 arg_msg = "操作员姓名未登记或已取消" GOTO ext END IF UPDATE u_giveback SET Auditingrep = '', Auditingdate = :null_dt, flag = 0, relint_3 = 0 WHERE u_giveback.givebackid = :givebackid AND flag = 1 AND scid = :scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext ELSEIF commit_transaction.SQLNRows = 0 THEN rslt = 0 arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText GOTO ext END IF Decimal sum_amt sum_amt = 0 - Round(givebackamt,2) IF sum_amt <> 0 THEN IF uo_take.del_takerec(scid,1,relint_3,cusid,arg_msg,FALSE) = 0 THEN rslt = 0 GOTO ext END IF END IF flag = 0 ext: IF rslt = 0 THEN ROLLBACK USING commit_transaction; ELSEIF rslt = 1 AND arg_ifcommit THEN COMMIT USING commit_transaction; END IF RETURN rslt end function public function integer acceptmx (decimal arg_norebateamt, decimal arg_childsumamt, string arg_mxdscrp, long arg_printid, ref string arg_msg, long arg_outwareid, string arg_relcode, datetime arg_givebackdate);Long rslt = 1,cnt = 0 IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN rslt = 0 arg_msg = "非编辑状态不可以使用,操作取消" GOTO ext END IF //清除空值 IF IsNull(arg_norebateamt) THEN arg_norebateamt = 0 IF IsNull(arg_childsumamt) THEN arg_childsumamt = 0 IF IsNull(arg_printid) THEN arg_printid = 0 IF IsNull(arg_outwareid) THEN arg_outwareid = 0 IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = '' IF IsNull(arg_relcode) THEN arg_relcode = '' if arg_norebateamt<0 then rslt = 0 arg_msg = "有明细单据金额小于零,操作取消" GOTO ext END IF ////检查相关销售单 //select count(*) //into :cnt //FROM u_outware INNER JOIN // u_outwaremx ON u_outware.scid = u_outwaremx.scid AND // u_outware.outwareid = u_outwaremx.outwareid //where u_outware.outwareid=:arg_outwareid and u_outware.scid=:scid // and u_outwaremx.rebate=1 using commit_transaction; //IF commit_transaction.SQLCode <> 0 THEN // rslt = 0 // arG_MSG = "查询操作失败,相关销售单" // GOTO ext //END IF //IF cnt = 0 THEN // rslt = 0 // arG_MSG = "错误的销售单: "+String(arg_relcode) // GOTO ext //END IF //写入内容 it_mxbt++ sumamt=sumamt+arg_norebateamt givebackmx[it_mxbt].outwareid = arg_outwareid givebackmx[it_mxbt].norebateamt = arg_norebateamt givebackmx[it_mxbt].childsumamt = arg_childsumamt givebackmx[it_mxbt].relcode = arg_relcode givebackmx[it_mxbt].givebackdate = arg_givebackdate givebackmx[it_mxbt].mxdscrp = arg_mxdscrp givebackmx[it_mxbt].printid = arg_printid givebackmx[it_mxbt].rulSqlStr = "" givebackmx[it_mxbt].gbRateStr = "" ext: IF rslt = 0 THEN p_clearmx() RETURN rslt end function public function integer acceptmx (decimal arg_norebateamt, decimal arg_childsumamt, string arg_mxdscrp, long arg_printid, ref string arg_msg, long arg_outwareid, string arg_relcode, datetime arg_givebackdate, string arg_rulsqlstr, string arg_gbratestr); Long rslt = 1,cnt = 0 IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN rslt = 0 arg_msg = "非编辑状态不可以使用,操作取消" GOTO ext END IF //清除空值 IF IsNull(arg_norebateamt) THEN arg_norebateamt = 0 IF IsNull(arg_childsumamt) THEN arg_childsumamt = 0 IF IsNull(arg_printid) THEN arg_printid = 0 IF IsNull(arg_outwareid) THEN arg_outwareid = 0 IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = '' IF IsNull(arg_relcode) THEN arg_relcode = '' IF IsNull(arg_rulSqlStr) THEN arg_rulSqlStr = '' IF IsNull(arg_gbRateStr) THEN arg_gbRateStr = '' if arg_norebateamt<0 then rslt = 0 arg_msg = "有明细单据金额小于零,操作取消" GOTO ext END IF ////检查相关销售单 //select count(*) //into :cnt //FROM u_outware INNER JOIN // u_outwaremx ON u_outware.scid = u_outwaremx.scid AND // u_outware.outwareid = u_outwaremx.outwareid //where u_outware.outwareid=:arg_outwareid and u_outware.scid=:scid // and u_outwaremx.rebate=1 using commit_transaction; //IF commit_transaction.SQLCode <> 0 THEN // rslt = 0 // arG_MSG = "查询操作失败,相关销售单" // GOTO ext //END IF //IF cnt = 0 THEN // rslt = 0 // arG_MSG = "错误的销售单: "+String(arg_relcode) // GOTO ext //END IF //写入内容 it_mxbt++ sumamt=sumamt+arg_norebateamt givebackmx[it_mxbt].outwareid = arg_outwareid givebackmx[it_mxbt].norebateamt = arg_norebateamt givebackmx[it_mxbt].childsumamt = arg_childsumamt givebackmx[it_mxbt].relcode = arg_relcode givebackmx[it_mxbt].givebackdate = arg_givebackdate givebackmx[it_mxbt].mxdscrp = arg_mxdscrp givebackmx[it_mxbt].printid = arg_printid givebackmx[it_mxbt].rulSqlStr = arg_rulSqlStr givebackmx[it_mxbt].gbRateStr = arg_gbRateStr ext: IF rslt = 0 THEN p_clearmx() RETURN rslt end function on uo_giveback.create call super::create TriggerEvent( this, "constructor" ) end on on uo_giveback.destroy TriggerEvent( this, "destructor" ) call super::destroy end on event constructor;String str_optionvalue,arg_msg f_get_sys_option_value('097',str_optionvalue,arg_msg) uo_option_if_givebackrate = Long(str_optionvalue) end event