$PBExportHeader$uo_cust_exchange.sru forward global type uo_cust_exchange from nonvisualobject end type end forward global type uo_cust_exchange from nonvisualobject end type global uo_cust_exchange uo_cust_exchange type variables PUBLIC PROTECTEDWRITE Long scid = 0 //分部id PUBLIC PROTECTEDWRITE Long billid //进仓单表自动增量id PUBLIC PROTECTEDWRITE String billcode //单据的唯一编号 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 long relid Long storageid = 0 //进仓仓库 DateTime outdate //进仓发生时间 String rep = '' //经手人 String part = '' //相关号码 String dscrp = '' //备注 Long cusid = 0 //客户id Decimal sum_amt = 0 //单据总金额 Boolean if_getid_ture = TRUE Transaction commit_transaction //数据commit事务 s_cust_exchangemx exchangemx[] //明细结构数组 Long it_mxbt = 0 //明细结构数组末指针 Boolean it_newbegin = FALSE //新建标志 Boolean it_updatebegin = FALSE //修改标志 end variables forward prototypes public function integer newbegin (long arg_scid, integer arg_billtype, ref string arg_msg) public function integer save (boolean arg_ifcommit, ref string arg_msg) 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 p_clearmx () public function integer p_reset () public function integer acceptmx (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, decimal arg_qty, decimal arg_addqty, decimal arg_fprice, string arg_mxdscrp, long arg_printid, ref string arg_msg) public function integer updatebegin (long arg_scid, long arg_billid, ref string arg_msg) public function integer getinfo (long arg_scid, long arg_billid, ref string arg_msg) public function integer del (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit) public function integer add_dscrp (long arg_scid, long arg_billid, string arg_newdescppart, ref string arg_msg) public function integer p_getinfo (long arg_scid, long arg_billid, ref string arg_msg) end prototypes public function integer newbegin (long arg_scid, integer arg_billtype, 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 save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1,cnt = 0,i DateTime server_dt Long ls_newid String ls_sccode IF IsNull(storageid) THEN storageid = 0 IF IsNull(rep) THEN rep = '' IF IsNull(dscrp) THEN dscrp = '' IF IsNull(part) THEN part = '' IF IsNull(cusid) THEN cusid = 0 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 it_mxbt = 0 THEN //如果输入物料资料错则已经清空 // rslt = 0 // arg_msg = "没有正确进仓内容" // GOTO ext //END IF cnt = 0 //检查仓库 SELECT count(*) INTO :cnt FROM u_storage Where u_storage.storageid = :storageid 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(storageid) GOTO ext END IF IF Year(Date(outdate)) < 2000 OR IsNull(outdate) THEN rslt = 0 arg_msg = "缺少出仓发生时间或不合理" GOTO ext END IF IF DaysAfter(Date(String(server_dt,'yyyy-mm-dd')),Date(String(outdate,'yyyy-mm-dd'))) > sys_option_input_days THEN rslt = 0 arg_msg = '出仓日期错误,日期不能超前系统日期' GOTO ext END IF IF DaysAfter(Date(String(outdate,'yyyy-mm-dd')),Date(String(server_dt,'yyyy-mm-dd'))) > sys_option_input_days THEN rslt = 0 arg_msg = '出仓日期错误,日期不能落后系统日期' GOTO ext END IF IF f_check_inoutdate(storageid,outdate,true,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF //==================================================================== ////////////////////////////////////////////////开始区分:新建/更新 处理 IF billid = 0 THEN //新建 ls_newid = f_sys_scidentity(scid,"u_cust_exchange","billid",arg_msg,if_getid_ture,commit_transaction) 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 //取得新单据编号 billcode = getid(scid,ls_sccode + 'DH',Date(server_dt),if_getid_ture,commit_transaction) IF billcode = "err" THEN billcode = '' rslt = 0 arg_msg = "无法获取进仓单编号"+"~n"+commit_transaction.SQLErrText GOTO ext END IF INSERT INTO u_cust_exchange ( scid, billid, billcode, cusid, billdate, rep, part, dscrp, opemp, opdate, exchangeamt, storageid ) VALUES ( :scid, :ls_newid, :billcode, :cusid, :outdate, :rep, :part, :dscrp, :publ_operator, :server_dt , :sum_amt, :storageid) USING commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF //读取新outwareid billid = ls_newid FOR i = 1 TO it_mxbt INSERT INTO u_cust_exchangemx ( scid, billid, printid, mtrlwareid, mtrlid, qty, addqty, price, Mxdscrp ) VALUES ( :scid, :billid, :exchangemx[i].printid, :exchangemx[i].mtrlwareid, :exchangemx[i].mtrlid, :exchangemx[i].qty, :exchangemx[i].addqty, :exchangemx[i].price, :exchangemx[i].Mxdscrp) USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN billid = 0 rslt = 0 arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF NEXT ELSE //////////////////////////////////////////////////更新 UPDATE u_cust_exchange SET cusid = :cusid, billdate = :outdate, rep = :rep, part = :part, dscrp = :dscrp, modemp = :publ_operator, moddate = :server_dt, exchangeamt = :sum_amt, storageid = :storageid WHERE u_cust_exchange.billid = :billid AND u_cust_exchange.scid = :scid AND u_cust_exchange.flag = 0 USING commit_transaction; IF commit_transaction.SQLCode <> 0 OR commit_transaction.SQLNRows <= 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致更新单据操作失败(1)"+"~n"+commit_transaction.SQLErrText GOTO ext END IF //删除原有明细 DELETE FROM u_cust_exchangemx WHERE u_cust_exchangemx.billid = :billid AND u_cust_exchangemx.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_cust_exchangemx ( scid, billid, printid, mtrlwareid, mtrlid, qty, addqty, price, Mxdscrp ) VALUES ( :scid, :billid, :exchangemx[i].printid, :exchangemx[i].mtrlwareid, :exchangemx[i].mtrlid, :exchangemx[i].qty, :exchangemx[i].addqty, :exchangemx[i].price, :exchangemx[i].Mxdscrp) 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 auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i Dec new_noallocqty = 0 Long ls_newid IF billid = 0 THEN rslt = 0 arg_msg = "没有审核对象" GOTO ext END IF IF it_newbegin OR it_updatebegin THEN rslt = 0 arg_msg = "编辑状态下不可以执行审核" GOTO ext END IF IF flag = 1 THEN rslt = 0 arg_msg = "单据已经审核" GOTO ext END IF uo_outware uo_out uo_out = CREATE uo_outware uo_out.commit_transaction = commit_transaction uo_out.if_getid_ture = FALSE uo_custdef uo_cust uo_cust = CREATE uo_custdef uo_cust.commit_transaction = commit_transaction uo_cust.if_getid_ture = FALSE IF uo_cust.uof_cust_score(cusid,0 - sum_amt,arg_msg,FALSE) = 0 THEN rslt = 0 GOTO ext END IF IF it_mxbt > 0 THEN //2.原事务生成其他出仓单 IF uo_out.newbegin(scid,8,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF uo_out.relid = billid uo_out.outdate = outdate uo_out.outrep = rep uo_out.part = billcode uo_out.dscrp = dscrp uo_out.cusname = '客户积分换礼品' uo_out.storageid = storageid FOR i = 1 TO it_mxbt IF uo_out.acceptmx(exchangemx[i].mtrlwareid,& exchangemx[i].qty,exchangemx[i].addqty,exchangemx[i].price,1,& exchangemx[i].mxdscrp,exchangemx[i].printid,arg_msg,0,0,0,0,0,0,0,exchangemx[i].unit,1,'','') = 0 THEN rslt = 0 GOTO ext END IF NEXT IF uo_out.Save(FALSE,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF relid = uo_out.outwareid //4.原事务审核出仓单 IF uo_out.getinfo(scid,relid,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF uo_out.auditing(FALSE,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF UPDATE u_cust_exchange SET flag = 1, relid = :relid, auditemp = :publ_operator, auditdate = getdate() 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 flag = 1 ext: IF rslt = 0 THEN ROLLBACK USING commit_transaction; ELSEIF rslt = 1 AND arg_ifcommit THEN COMMIT USING commit_transaction; END IF DESTROY uo_out DESTROY uo_cust RETURN rslt end function public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg); Long rslt = 1,cnt = 0,i Long ls_newid DateTime null_dt SetNull(null_dt) IF billid = 0 THEN rslt = 0 arg_msg = "没有审核对象" GOTO ext END IF IF it_newbegin OR it_updatebegin THEN rslt = 0 arg_msg = "编辑状态下不可以执行审核" GOTO ext END IF IF flag = 0 THEN rslt = 0 arg_msg = "单据还未审核" GOTO ext END IF ////////////////////自动删除出仓单 uo_outware uo_out uo_out = CREATE uo_outware uo_out.commit_transaction = sqlca uo_out.if_getid_ture = FALSE uo_custdef uo_cust uo_cust = CREATE uo_custdef uo_cust.commit_transaction = commit_transaction uo_cust.if_getid_ture = FALSE IF uo_cust.uof_cust_score(cusid,sum_amt,arg_msg,FALSE) = 0 THEN rslt = 0 GOTO ext END IF IF it_mxbt > 0 THEN //撤审出仓单,再删除 IF uo_out.getinfo(scid,relid,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF uo_out.c_auditing(FALSE,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF uo_out.del(scid,relid,arg_msg,FALSE) = 0 THEN rslt = 0 GOTO ext END IF END IF UPDATE u_cust_exchange SET Auditemp = '', Auditdate = :null_dt, flag = 0, relid = 0 WHERE u_cust_exchange.billid = :billid 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 flag = 0 ext: IF rslt = 0 THEN ROLLBACK USING commit_transaction; ELSEIF rslt = 1 AND arg_ifcommit THEN COMMIT USING commit_transaction; END IF DESTROY uo_out DESTROY uo_cust RETURN rslt end function public function integer p_clearmx ();//int p_clearmx() //清除明细 it_mxbt=0 return 1 end function public function integer p_reset ();//int p_reset() //清除对象及其明细 scid = 0 billid = 0 billcode = '' opemp = '' modemp = '' flag = 0 storageid = 0 rep = '' part = '' dscrp = '' cusid = 0 it_newbegin = FALSE it_updatebegin = FALSE //清除明细 p_clearmx() RETURN 1 end function public function integer acceptmx (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, decimal arg_qty, decimal arg_addqty, decimal arg_fprice, string arg_mxdscrp, long arg_printid, ref string arg_msg);Long rslt = 1,cnt = 0,LS_i Long i_mtrlid,i_storageid,i_sptid Int i_dxflag,li_mtrlkind String i_plancode,i_mtrlcode,i_status,i_woodcode,i_pcode,i_mtrlname Decimal i_planprice,ld_dftsaleprice Double i_cost,i_newprice Decimal i_notauditqty,i_allouseqty,i_noallocaddqty String ls_relcode IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN rslt = 0 arg_msg = "非编辑状态不可以使用,操作取消" GOTO ext END IF //清除空值 IF IsNull(arg_mtrlwareid) THEN arg_mtrlwareid = 0 IF IsNull(arg_printid) THEN arg_printid = 0 IF IsNull(arg_qty) THEN arg_qty = 0 IF IsNull(arg_addqty) THEN arg_addqty = 0 IF IsNull(arg_fprice) THEN arg_fprice = 0 IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = '' // 如果出仓数量为 0,或物料编号为空,则不作任何处理 IF arg_mtrlwareid = 0 OR (arg_qty = 0 and arg_addqty=0) THEN rslt = 1 GOTO ext END IF //检查物料库存ID SELECT u_mtrlware.mtrlid, u_mtrlware.storageid, u_mtrlware.plancode, u_mtrlware.status, u_mtrlware.cost, u_mtrldef.planprice, u_mtrldef.mtrlcode, u_mtrldef.mtrlname, u_mtrlware.sptid, u_mtrlware.dxflag, u_mtrlware.woodcode, u_mtrlware.pcode, isnull(uv_mtrlware_noauditingqty.noauditingqty,0), u_mtrlware.noallocqty, u_mtrlware.noallocaddqty INTO :i_mtrlid, :i_storageid, :i_plancode, :i_status, :i_cost, :i_planprice, :i_mtrlcode, :i_mtrlname, :i_sptid, :i_dxflag, :i_woodcode, :i_pcode, :i_notauditqty, :i_allouseqty, :i_noallocaddqty FROM u_mtrlware left OUTER join uv_mtrlware_noauditingqty on ( u_mtrlware.mtrlwareid = uv_mtrlware_noauditingqty.mtrlwareid) AND ( u_mtrlware.scid = uv_mtrlware_noauditingqty.scid),u_mtrldef WHERE ( u_mtrlware.mtrlwareid = :arg_mtrlwareid ) AND ( u_mtrlware.mtrlid = u_mtrldef.mtrlid ) And ( u_mtrlware.scid = :scid ) USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,库存编号错误" GOTO ext END IF IF IsNull(ld_dftsaleprice) THEN ld_dftsaleprice = 0 IF IsNull(i_cost) THEN i_cost = 0 IF IsNull(i_plancode) THEN i_plancode = '' IF IsNull(i_status) THEN i_status = '' IF IsNull(i_mtrlid) THEN i_mtrlid = 0 IF IsNull(i_storageid) THEN i_storageid = 0 IF IsNull(i_planprice) THEN i_planprice = 0 IF IsNull(i_sptid) THEN i_sptid = 0 IF IsNull(i_dxflag) THEN i_dxflag = 0 IF IsNull(i_woodcode) THEN i_woodcode = '' IF IsNull(i_pcode) THEN i_pcode = '' if sys_option_addqty=1 and i_noallocaddqty <> 0 then //辅数限制 if arg_addqty= 0 then rslt=0 arg_msg='['+i_mtrlcode+' '+i_mtrlname+']在库存中使用了辅数,出仓时必须录入辅数。' goto ext end if if (i_noallocaddqty = arg_addqty) and (i_allouseqty <> arg_qty) then rslt = 0 arg_msg = '['+i_mtrlcode+' '+i_mtrlname+']在库存中使用了辅数,当库存辅数全部出仓时,库存数量应全部出仓.' goto ext end if if (i_allouseqty = arg_qty) and (i_noallocaddqty <> arg_addqty) then rslt = 0 arg_msg = '['+i_mtrlcode+' '+i_mtrlname+']在库存中使用了辅数,当库存数量全部出仓时,库存辅数应全部出仓.' goto ext end if end if //写入内容 it_mxbt++ exchangemx[it_mxbt].mtrlwareid = arg_mtrlwareid exchangemx[it_mxbt].mtrlid = arg_mtrlid exchangemx[it_mxbt].qty = arg_qty exchangemx[it_mxbt].price = arg_fprice exchangemx[it_mxbt].mxdscrp = arg_mxdscrp exchangemx[it_mxbt].printid = arg_printid exchangemx[it_mxbt].mtrlcode = arg_mtrlcode exchangemx[it_mxbt].addqty = arg_addqty ext: IF rslt = 0 THEN p_clearmx() RETURN rslt end function public function integer updatebegin (long arg_scid, long arg_billid, 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_billid<=0 then rslt=0 goto ext end if rslt=p_getinfo(arg_scid,arg_billid,arg_msg) if rslt=0 then goto ext if flag=1 then rslt=0 arg_msg='单据已经审核,不可以修改' goto ext end if billid=arg_billid 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 getinfo (long arg_scid, long arg_billid, ref string arg_msg);Int rslt = 1,i = 1,no_mxcheck = 0 sum_amt = 0 IF arg_billid <= 0 THEN rslt = 0 arg_msg = "非法出仓单唯一码" GOTO ext END IF rslt = p_getinfo(arg_scid,arg_billid,arg_msg) IF rslt = 0 THEN GOTO ext DECLARE cur_inwaermx CURSOR FOR SELECT u_cust_exchangemx.scid, u_cust_exchangemx.billid, u_cust_exchangemx.printid, u_cust_exchangemx.mtrlwareid, u_cust_exchangemx.mtrlid, u_cust_exchangemx.qty, u_cust_exchangemx.addqty, u_cust_exchangemx.price, u_cust_exchangemx.Mxdscrp, u_mtrldef.mtrlcode, u_mtrldef.unit FROM u_cust_exchangemx,u_mtrldef WHERE u_cust_exchangemx.billid = :arg_billid AND u_cust_exchangemx.mtrlid = u_mtrldef.mtrlid AND u_cust_exchangemx.scid = :arg_scid USING commit_transaction; OPEN cur_inwaermx; FETCH cur_inwaermx INTO :exchangemx[i].scid, :exchangemx[i].billid, :exchangemx[i].printid, :exchangemx[i].mtrlwareid, :exchangemx[i].mtrlid, :exchangemx[i].qty, :exchangemx[i].addqty, :exchangemx[i].price, :exchangemx[i].Mxdscrp, :exchangemx[i].mtrlcode, :exchangemx[i].unit; DO WHILE commit_transaction.SQLCode = 0 i ++ FETCH cur_inwaermx INTO :exchangemx[i].scid, :exchangemx[i].billid, :exchangemx[i].printid, :exchangemx[i].mtrlwareid, :exchangemx[i].mtrlid, :exchangemx[i].qty, :exchangemx[i].addqty, :exchangemx[i].price, :exchangemx[i].Mxdscrp, :exchangemx[i].mtrlcode, :exchangemx[i].unit; LOOP CLOSE cur_inwaermx; //检验明细是否读入完整 SELECT count(*) INTO :no_mxcheck FROM u_cust_exchangemx WHERE u_cust_exchangemx.billid = :arg_billid AND u_cust_exchangemx.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 billid = arg_billid 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 del (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);//如果单据还没有审核删除单据极其明细 //0 FAIL, 1 SUCCESS Int rslt = 1 IF arg_billid <= 0 THEN rslt = 0 arG_MSG = "没有删除对象,操作取消" GOTO ext END IF IF p_getinfo(arg_scid,arg_billid,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_cust_exchange WHERE u_cust_exchange.billid = :arg_billid AND u_cust_exchange.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_cust_exchangemx WHERE u_cust_exchangemx.billid = :arg_billid AND u_cust_exchangemx.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 add_dscrp (long arg_scid, long arg_billid, 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_billid,arg_msg) if rslt=0 then goto ext if flag=0 then rslt=0 arg_msg="非审核状态下不可用" goto ext end if update u_cust_exchange set dscrp = dscrp+' '+:arg_newdescppart where u_cust_exchange.billid = :arg_billid 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 p_getinfo (long arg_scid, long arg_billid, ref string arg_msg);//p_getinfo(arg_scid,arg_outwareid,arg_msg) //0 失败 1成功 Int rslt = 1 IF arg_billid <= 0 THEN rslt = 0 arG_MSG = "非法出仓单唯一码" GOTO ext END IF SELECT u_cust_exchange.billcode, u_cust_exchange.cusid, u_cust_exchange.billdate, u_cust_exchange.rep, u_cust_exchange.part, u_cust_exchange.dscrp, u_cust_exchange.flag, u_cust_exchange.exchangeamt, u_cust_exchange.storageid , u_cust_exchange.relid INTO :billcode, :cusid, :outdate, :rep, :part, :dscrp, :flag, :sum_amt, :storageid , :relid FROM u_cust_exchange WHERE u_cust_exchange.billid = :arg_billid AND u_cust_exchange.scid = :arg_scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arG_MSG = "查询操作失败(错误出仓单唯一码),出仓单"+commit_transaction.SQLErrText GOTO ext END IF billid = arg_billid scid = arg_scid ext: IF rslt = 0 THEN p_reset() RETURN rslt end function on uo_cust_exchange.create call super::create TriggerEvent( this, "constructor" ) end on on uo_cust_exchange.destroy TriggerEvent( this, "destructor" ) call super::destroy end on