$PBExportHeader$uo_update_cost.sru forward global type uo_update_cost from nonvisualobject end type end forward global type uo_update_cost from nonvisualobject end type global uo_update_cost uo_update_cost type variables public protectedwrite long scid =0 //分部id public protectedwrite long wareid //进仓单表自动增量id public protectedwrite string warecode //单据的唯一编号 public protectedwrite int billtype=0 //业务类型 //业务类型 //1-采购进仓[记帐模式] //2-采购进仓[不记帐模式] //3-成品进仓 //8-其他进仓 //9-盘盈进仓 //12-调拨入仓 public protectedwrite datetime opdate //建立时间,自动 public protectedwrite string opemp //建立人 public protectedwrite datetime modidate //修改时间,自动 public protectedwrite string modiemp //修改操作员 public protectedwrite int flag=0 //仓库审核标志 public protectedwrite int balcflag=0 //仓库结存标志 public protectedwrite datetime auditingdate //审核时间 public protectedwrite string auditingrep //审核操作员 long storageid=0 //进仓仓库 datetime moddate //进仓发生时间 string modrep='' //经手人 string part='' //相关号码 string dscrp='' //备注 int relint_1 int relint_2 boolean if_getid_ture=true transaction commit_transaction //数据commit事务 //uo_unit uo_unit_change s_inwaremx inwaremx[] //明细结构数组 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 p_clearmx () public function integer p_reset () public function integer updatebegin (long arg_scid, long arg_wareid, integer arg_billtype, ref string arg_msg) public function integer p_getinfo (long arg_scid, long arg_wareid, ref string arg_msg) public function integer getinfo (long arg_scid, long arg_wareid, ref string arg_msg) public function integer add_dscrp (long arg_scid, long arg_wareid, string arg_newdescppart, ref string arg_msg) public function integer del (long arg_scid, long arg_wareid, ref string arg_msg, boolean arg_ifcommit) public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg) public function integer uof_create_inware (ref string arg_msg) public function integer acceptmx (long arg_printid, long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_newprice, string arg_mxdscrp, ref string arg_msg, string arg_woodcode, string arg_pcode, decimal arg_cost, decimal arg_newcost, decimal arg_amt, decimal arg_planprice, string arg_unit, decimal arg_cost_notax, decimal arg_newcost_notax) 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 //if not (arg_billtype=1 or arg_billtype=2 or arg_billtype=3 or arg_billtype=4 or arg_billtype=8 or arg_billtype=9 or arg_billtype=12 or arg_billtype=15) then // rslt=0 // arg_msg='此单据类型必须为:' // arg_msg=arg_msg+'1-采购进仓[记帐模式],' // arg_msg=arg_msg+'2-采购进仓[不记帐模式],' // arg_msg=arg_msg+'3-成品进仓,' // arg_msg=arg_msg+'4-外发加工进仓,' // arg_msg=arg_msg+'8-其他进仓,' // arg_msg=arg_msg+'9-盘盈进仓,' // arg_msg=arg_msg+'12-调拨进仓' // arg_msg=arg_msg+'15-拆装进仓' // goto ext //end if p_reset() billtype=arg_billtype 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(modrep) THEN modrep = '' IF IsNull(dscrp) THEN dscrp = '' IF IsNull(part) THEN part = '' 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(moddate)) < 2000 OR IsNull(moddate) THEN rslt = 0 arg_msg = "缺少更新发生时间或不合理" GOTO ext END IF //==================================================================== // Script - save ( boolean arg_ifcommit, ref string arg_msg ) // Reason: //-------------------------------------------------------------------- // Modified By: yyx Date: 2004.01.02 //-------------------------------------------------------------------- IF DaysAfter(Date(String(server_dt,'yyyy-mm-dd')),Date(String(moddate,'yyyy-mm-dd'))) > sys_option_input_days THEN rslt = 0 arg_msg = '更新日期错误,日期不能超前系统日期' GOTO ext END IF IF DaysAfter(Date(String(moddate,'yyyy-mm-dd')),Date(String(server_dt,'yyyy-mm-dd'))) > sys_option_input_days THEN rslt = 0 arg_msg = '更新日期错误,日期不能落后系统日期' GOTO ext END IF ////////////////////////////////////////////////开始区分:新建/更新 处理 IF wareid = 0 THEN //新建 ls_newid = f_sys_scidentity(scid,"u_updatecost","wareid",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 //取得新单据编号 CHOOSE CASE billtype CASE 1,2 warecode = getid(scid,ls_sccode + 'CG',Date(server_dt),if_getid_ture,commit_transaction) CASE 3 warecode = getid(scid,ls_sccode + 'CP',Date(server_dt),if_getid_ture,commit_transaction) CASE 4 warecode = getid(scid,ls_sccode + 'WI',Date(server_dt),if_getid_ture,commit_transaction) CASE 8 warecode = getid(scid,ls_sccode + 'JC',Date(server_dt),if_getid_ture,commit_transaction) CASE 9 warecode = getid(scid,ls_sccode + 'PY',Date(server_dt),if_getid_ture,commit_transaction) CASE 12 warecode = getid(scid,ls_sccode + 'IC',Date(server_dt),if_getid_ture,commit_transaction) CASE 15 warecode = getid(scid,ls_sccode + 'DI',Date(server_dt),if_getid_ture,commit_transaction) CASE 0 warecode = getid(scid,ls_sccode + 'JG',Date(server_dt),if_getid_ture,commit_transaction) END CHOOSE IF warecode = "err" THEN warecode = '' rslt = 0 arg_msg = "无法获取进仓单编号"+"~n"+commit_transaction.SQLErrText GOTO ext END IF INSERT INTO u_updatecost ( scid, wareid, warecode, storageid, part, moddate, modrep, dscrp, opdate, opemp) VALUES ( :scid, :ls_newid, :warecode, :storageid, :part, :moddate, :modrep, :dscrp, :server_dt, :publ_operator) USING commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_updatecost') > 0 THEN arg_msg = '插入单据资料失败,关键字ID重复' ELSEIF Pos(Lower(commit_transaction.SQLErrText),'IX_u_updatecost') > 0 THEN arg_msg = '插入单据资料失败,单据编号重复' ELSE arg_msg = '因网络或其它原因导致插入单据资料失败,'+commit_transaction.SQLErrText END IF GOTO ext END IF //读取新inwareid wareid = ls_newid FOR i = 1 TO it_mxbt INSERT INTO u_updatecostmx (scid, wareid, mtrlwareid, mtrlid, plancode, status, mxdscrp, noallocqty, wareamt, planprice, newprice, woodcode, pcode, cost, newcost, printid, waredscrp, inworkdate, cost_notax, newcost_notax) VALUES ( :scid, :ls_newid, :inwaremx[i].mtrlwareid, :inwaremx[i].mtrlid, :inwaremx[i].plancode, :inwaremx[i].status, :inwaremx[i].mxdscrp, :inwaremx[i].qty, :inwaremx[i].amt, :inwaremx[i].planprice, :inwaremx[i].fprice, :inwaremx[i].woodcode, :inwaremx[i].pcode, :inwaremx[i].cost, :inwaremx[i].newcost, :inwaremx[i].printid, :inwaremx[i].waredscrp, :inwaremx[i].inworkdate, :inwaremx[i].cost_notax, :inwaremx[i].newcost_notax) USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN wareid = 0 //还原inwareid rslt = 0 IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_updatecostmx') > 0 THEN arg_msg = '插入单据明细资料失败,关键字ID,序号重复' ELSE arg_msg = '因网络或其它原因导致插入单据明细资料失败,'+commit_transaction.SQLErrText END IF GOTO ext END IF NEXT ELSE //////////////////////////////////////////////////更新 UPDATE u_updatecost SET storageid = :storageid, moddate = :moddate, modrep = :modrep, part = :part, dscrp = :dscrp, modidate = :server_dt, modiemp = :publ_operator WHERE u_updatecost.wareid = :wareid AND u_updatecost.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_updatecostmx WHERE u_updatecostmx.wareid = :wareid AND u_updatecostmx.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_updatecostmx (scid, wareid, mtrlwareid, mtrlid, plancode, status, mxdscrp, noallocqty, wareamt, planprice, newprice, woodcode, pcode, cost, newcost, printid, waredscrp, inworkdate, cost_notax, newcost_notax) VALUES ( :scid, :wareid, :inwaremx[i].mtrlwareid, :inwaremx[i].mtrlid, :inwaremx[i].plancode, :inwaremx[i].status, :inwaremx[i].mxdscrp, :inwaremx[i].qty, :inwaremx[i].amt, :inwaremx[i].planprice, :inwaremx[i].fprice, :inwaremx[i].woodcode, :inwaremx[i].pcode, :inwaremx[i].cost, :inwaremx[i].newcost, :inwaremx[i].printid, :inwaremx[i].waredscrp, :inwaremx[i].inworkdate, :inwaremx[i].cost_notax, :inwaremx[i].newcost_notax) USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_updatecostmx') > 0 THEN arg_msg = '插入单据明细资料失败,关键字ID,序号重复' ELSE arg_msg = '因网络或其它原因导致插入单据明细资料失败,'+commit_transaction.SQLErrText END IF 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);//==================================================================== // Function: auditing(arg_ifcommit,arg_msg) //-------------------------------------------------------------------- // Description: 审核单据 //-------------------------------------------------------------------- // Arguments: // value boolean arg_ifcommit // reference string arg_msg //-------------------------------------------------------------------- // Returns: integer //-------------------------------------------------------------------- // Author: yyx Date: 2003.11.12 //-------------------------------------------------------------------- // Modify History: // //==================================================================== Long rslt = 1,cnt = 0,i Dec new_noallocqty = 0 Long ls_newid IF wareid = 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 IF uof_create_inware(arg_msg) = 0 THEN rslt = 0 GOTO ext END IF UPDATE u_updatecost SET auditingrep = :publ_operator, auditingdate = getdate(), flag = 1 WHERE u_updatecost.wareid = :wareid 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 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_in_other 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 wareid=0 warecode='' billtype=0 opemp='' modiemp='' auditingrep='' flag=0 storageid=0 modrep='' part='' dscrp='' it_newbegin=false it_updatebegin=false //清除明细 p_clearmx() return 1 end function public function integer updatebegin (long arg_scid, long arg_wareid, integer arg_billtype, 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_wareid<=0 then rslt=0 goto ext end if //if not(arg_billtype=1 or arg_billtype=2 or arg_billtype=3 or arg_billtype=4 or arg_billtype=8 or arg_billtype=9 or arg_billtype=12) then // rslt=0 // arg_msg='此单据类型必须为:' // arg_msg=arg_msg+'1-采购进仓[记帐模式],' // arg_msg=arg_msg+'2-采购进仓[不记帐模式],' // arg_msg=arg_msg+'3-成品进仓,' // arg_msg=arg_msg+'4-外发加工进仓,' // arg_msg=arg_msg+'8-其他进仓,' // arg_msg=arg_msg+'9-盘盈进仓,' // arg_msg=arg_msg+'12-调拨进仓' // goto ext //end if //if arg_billtype=12 then // rslt=0 // arg_msg='单据类型:12-调拨进仓>>不能修改' // goto ext //end if // rslt=p_getinfo(arg_scid,arg_wareid,arg_msg) if rslt=0 then goto ext if flag=1 then rslt=0 arg_msg='单据已经审核,不可以修改' goto ext end if wareid=arg_wareid billtype=arg_billtype 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 p_getinfo (long arg_scid, long arg_wareid, ref string arg_msg);//p_getinfo(arg_scid,arg_inwareid,arg_msg) //0 失败 1成功 INT rslt=1 IF arg_wareid<=0 THEN rslt=0 arG_MSG="非法进仓单唯一码" goto ext end if SELECT u_updatecost.warecode, u_updatecost.storageid, u_updatecost.moddate, u_updatecost.modrep, u_updatecost.part, u_updatecost.dscrp, u_updatecost.modidate, u_updatecost.modiemp, u_updatecost.auditingdate, u_updatecost.auditingrep, u_updatecost.flag, u_updatecost.relint_1 INTO :warecode, :storageid, :moddate, :modrep, :part, :dscrp, :modidate, :modiemp, :auditingdate, :auditingrep, :flag, :relint_1 FROM u_updatecost WHERE u_updatecost.wareid = :arg_wareid and scid=:arg_scid using commit_transaction; if commit_transaction.sqlcode<>0 then rslt=0 arG_MSG="查询操作失败(错误进仓单唯一码),进仓单"+commit_transaction.sqlerrtext goto ext end if wareid = arg_wareid scid = arg_scid ext: IF rslt=0 THEN p_reset() return rslt end function public function integer getinfo (long arg_scid, long arg_wareid, ref string arg_msg);//getinfo(arg_scid,arg_inwareid,arg_msg) //0 失败 1成功 Int rslt = 1,i = 1,no_mxcheck = 0 IF arg_wareid <= 0 THEN rslt = 0 arg_msg = "非法进仓单唯一码" GOTO ext END IF rslt = p_getinfo(arg_scid,arg_wareid,arg_msg) IF rslt = 0 THEN GOTO ext //用游标读取明细 DECLARE cur_waremx CURSOR FOR SELECT u_updatecostmx.printid, u_updatecostmx.mtrlwareid, u_updatecostmx.mtrlid, u_updatecostmx.plancode, u_updatecostmx.status, u_updatecostmx.noallocqty, u_updatecostmx.newprice, u_updatecostmx.planprice, u_updatecostmx.mxdscrp, u_mtrldef.mtrlcode, u_updatecostmx.woodcode, u_updatecostmx.pcode, u_updatecostmx.cost, u_updatecostmx.newcost, u_mtrldef.unit, u_mtrldef.mtrlcode, u_updatecostmx.waredscrp, u_updatecostmx.inworkdate, u_mtrlware.sptid, u_updatecostmx.cost_notax, u_updatecostmx.newcost_notax FROM u_updatecostmx,u_mtrldef,u_updatecost ,u_mtrlware WHERE u_updatecost.wareid = :arg_wareid AND u_updatecostmx.mtrlid = u_mtrldef.mtrlid AND u_updatecost.scid = :arg_scid AND u_updatecost.wareid = u_updatecostmx.wareid AND u_updatecost.scid = u_updatecostmx.scid and u_mtrlware.mtrlwareid = u_updatecostmx.mtrlwareid order by u_updatecostmx.printid USING commit_transaction; OPEN cur_waremx; FETCH cur_waremx INTO :inwaremx[i].printid, :inwaremx[i].mtrlwareid, :inwaremx[i].mtrlid, :inwaremx[i].plancode, :inwaremx[i].status, :inwaremx[i].qty, :inwaremx[i].fprice, :inwaremx[i].planprice, :inwaremx[i].mxdscrp, :inwaremx[i].mtrlcode, :inwaremx[i].woodcode, :inwaremx[i].pcode, :inwaremx[i].cost, :inwaremx[i].newcost, :inwaremx[i].unit, :inwaremx[i].mtrlcode, :inwaremx[i].waredscrp, :inwaremx[i].inworkdate, :inwaremx[i].sptid, :inwaremx[i].cost_notax, :inwaremx[i].newcost_notax; DO WHILE commit_transaction.SQLCode = 0 i++ FETCH cur_waremx INTO :inwaremx[i].printid,:inwaremx[i].mtrlwareid,:inwaremx[i].mtrlid, :inwaremx[i].plancode,:inwaremx[i].status,:inwaremx[i].qty,:inwaremx[i].fprice, :inwaremx[i].planprice,:inwaremx[i].mxdscrp,:inwaremx[i].mtrlcode, :inwaremx[i].woodcode,:inwaremx[i].pcode,:inwaremx[i].cost,:inwaremx[i].newcost, :inwaremx[i].unit,:inwaremx[i].mtrlcode, :inwaremx[i].waredscrp, :inwaremx[i].inworkdate, :inwaremx[i].sptid, :inwaremx[i].cost_notax, :inwaremx[i].newcost_notax; LOOP CLOSE cur_waremx; //检验明细是否读入完整 SELECT count(*) INTO :no_mxcheck FROM u_updatecostmx WHERE u_updatecostmx.wareid = :arg_wareid 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 wareid = arg_wareid 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 add_dscrp (long arg_scid, long arg_wareid, 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_wareid,arg_msg) if rslt=0 then goto ext if flag=0 then rslt=0 arg_msg="非审核状态下不可用" goto ext end if update u_updatecost set dscrp = dscrp+' '+:arg_newdescppart where u_updatecost.wareid = :wareid and scid=:scid using commit_transaction; if commit_transaction.sqlcode<>0 then rollback using commit_transaction; 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 del (long arg_scid, long arg_wareid, ref string arg_msg, boolean arg_ifcommit);//del(arg_scid,arg_inwareid,arg_msg) //如果单据还没有审核删除单据极其明细 //0 fail, 1 success int rslt = 1 if arg_wareid = 0 then rslt = 0 arg_msg = "没有删除对象,操作取消" goto ext end if rslt = p_getinfo(arg_scid,arg_wareid,arg_msg) if rslt = 0 then goto ext if flag = 1 then rslt = 0 arg_msg = "单据已经审核,不可以删除" goto ext end if delete from u_updatecostmx where u_updatecostmx.mtrlwareid = :arg_wareid and 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_updatecost where u_updatecost.wareid = :arg_wareid and 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; elseif rslt=1 and arg_ifcommit then commit using commit_transaction; end if p_reset() return rslt end function public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);//==================================================================== // Function: c_auditing(arg_ifcommit,arg_msg) //-------------------------------------------------------------------- // Description: 撤审 //-------------------------------------------------------------------- // Arguments: // value boolean arg_ifcommit // reference string arg_msg //-------------------------------------------------------------------- // Returns: integer //-------------------------------------------------------------------- // Author: yyx Date: 2003.11.19 //-------------------------------------------------------------------- // Modify History: // //==================================================================== long rslt = 1,cnt = 0,i dec new_noallocqty = 0 long ls_newid datetime null_dt goto ext //setnull(null_dt) // //if wareid = 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 // ////if balcflag=1 then //// rslt = 0 //// arg_msg = "单据已经结存,不能撤审" //// goto ext ////end if // //update u_updatecost // set auditingrep = '', // auditingdate = :null_dt, // flag = 0 // where u_updatecost.wareid = :wareid // 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 // ////uo_outware_other uo_ware_other ////uo_ware_other = create uo_outware_other ////uo_ware_other.commit_transaction = sqlca //// ////IF uo_ware_other.getinfo(scid,relint_1,arg_msg) = 0 THEN //// ROLLBACK USING sqlca; //// rslt = 0 //// goto ext ////END IF //// ////IF uo_ware_other.c_auditing(true,arg_msg) = 0 then //// ROLLBACK USING sqlca; //// rslt = 0 //// goto ext ////end if //// //////for i = 1 to it_mxbt ////// if p_update_mtrlware(inwaremx[i].mtrlid,inwaremx[i].mtrlcode,& ////// storageid,inwaremx[i].plancode,inwaremx[i].status,& ////// 0 - inwaremx[i].qty,inwaremx[i].cost,inwaremx[i].planprice,& ////// 0,inwaremx[i].dxflag,inwaremx[i].woodcode,& ////// inwaremx[i].pcode,arg_msg) = 0 then ////// rslt = 0 ////// goto ext ////// end if //////next //// ////if uo_ware_other.del(scid,relint_1,arg_msg,false) = 0 then //// rslt = 0 //// goto ext ////end if // //update u_updatecost //set relint_1 = 0 //where wareid=:wareid and scid=:scid using commit_transaction; //if commit_transaction.sqlcode <> 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_ware_other return rslt end function public function integer uof_create_inware (ref string arg_msg); Long rslt = 1,ll_printid = 0,i Decimal lde_qty uo_inware uo_in_other uo_in_other = Create uo_inware s_inwaremx s_mx //生成进仓单 负 IF uo_in_other.newbegin(scid,8,arg_msg) = 0 THEN // rslt = 0 GOTO ext END IF uo_in_other.indate = moddate // DateTime(today(),time(0)) // 发生时间 uo_in_other.inrep = modrep // 经手人 IF part = '' THEN uo_in_other.part = warecode //相关部门 ELSE uo_in_other.part = warecode + "["+part+"]" END IF uo_in_other.dscrp = dscrp //备注 uo_in_other.storageid = storageid uo_in_other.sptname = '成本价调整单审核自动生成' uo_in_other.relid = wareid uo_in_other.commit_transaction = commit_transaction uo_in_other.sysautobuild = True FOR i = 1 To it_mxbt IF inwaremx[i].mtrlwareid > 0 THEN ll_printid++ IF inwaremx[i].qty > 0 THEN lde_qty = 0 - inwaremx[i].qty ELSE lde_qty = -1 END IF s_mx.printid = ll_printid s_mx.mtrlid = inwaremx[i].mtrlid s_mx.mtrlcode = inwaremx[i].mtrlcode s_mx.plancode = inwaremx[i].plancode s_mx.status = inwaremx[i].status s_mx.uqty = lde_qty s_mx.addqty = 0 s_mx.uprice = inwaremx[i].cost s_mx.uprice_notax = inwaremx[i].cost_notax s_mx.rebate = 1 s_mx.mxdscrp = inwaremx[i].mxdscrp s_mx.jgprice = 0 s_mx.relid = 0 s_mx.relprintid = 0 s_mx.ifrel = 0 s_mx.woodcode = inwaremx[i].woodcode s_mx.pcode = inwaremx[i].pcode s_mx.mtrlcuscode = '' s_mx.sptid = inwaremx[i].sptid s_mx.unit = inwaremx[i].unit s_mx.rate = 1 s_mx.formula = '' s_mx.waredscrp = inwaremx[i].waredscrp s_mx.inworkdate = inwaremx[i].inworkdate s_mx.cost= inwaremx[i].cost s_mx.cost_notax = inwaremx[i].cost_notax IF uo_in_other.acceptmx(s_mx,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF NEXT FOR i = 1 To it_mxbt IF inwaremx[i].mtrlwareid > 0 THEN ll_printid++ IF inwaremx[i].qty > 0 THEN lde_qty = inwaremx[i].qty ELSE lde_qty = 1 END IF s_mx.printid = ll_printid s_mx.mtrlid = inwaremx[i].mtrlid s_mx.mtrlcode = inwaremx[i].mtrlcode s_mx.plancode = inwaremx[i].plancode s_mx.status = inwaremx[i].status s_mx.uqty = lde_qty s_mx.addqty = 0 s_mx.uprice = inwaremx[i].newcost s_mx.uprice_notax = inwaremx[i].newcost_notax s_mx.rebate = 1 s_mx.mxdscrp = inwaremx[i].mxdscrp s_mx.jgprice = 0 s_mx.relid = 0 s_mx.relprintid = 0 s_mx.ifrel = 0 s_mx.woodcode = inwaremx[i].woodcode s_mx.pcode = inwaremx[i].pcode s_mx.mtrlcuscode = '' s_mx.sptid = inwaremx[i].sptid s_mx.unit = inwaremx[i].unit s_mx.rate = 1 s_mx.formula = '' s_mx.waredscrp = inwaremx[i].waredscrp s_mx.inworkdate = inwaremx[i].inworkdate s_mx.cost = inwaremx[i].newcost s_mx.cost_notax = inwaremx[i].newcost_notax IF uo_in_other.acceptmx(s_mx,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF NEXT IF uo_in_other.it_mxbt > 0 THEN IF uo_in_other.Save(False,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF uo_in_other.getinfo(scid,uo_in_other.inwareid,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF uo_in_other.auditing(False,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF ext: Destroy uo_in_other RETURN rslt end function public function integer acceptmx (long arg_printid, long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_newprice, string arg_mxdscrp, ref string arg_msg, string arg_woodcode, string arg_pcode, decimal arg_cost, decimal arg_newcost, decimal arg_amt, decimal arg_planprice, string arg_unit, decimal arg_cost_notax, decimal arg_newcost_notax);Long rslt = 1,cnt = 0,ls_i Decimal ld_planprice,ld_cost String ls_relcode Decimal ld_rate Int i_dxflag Long i_mtrlid,i_storageid,i_sptid String i_plancode,i_status,i_mtrlcode,i_woodcode,i_pcode Dec i_cost,i_planprice,i_notauditqty,i_allouseqty String i_waredscrp DateTime i_inworkdate IF it_newbegin = False And it_updatebegin = False THEN rslt = 0 arg_msg = "非编辑状态不可以使用,操作取消" GOTO ext END IF IF arg_mtrlwareid < 0 THEN rslt = 0 GOTO ext END IF //清除空值 IF IsNull(arg_printid) THEN arg_printid = 0 IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0 IF IsNull(arg_mtrlcode) THEN arg_mtrlcode = '' IF IsNull(arg_plancode) THEN arg_plancode = '' IF IsNull(arg_status) THEN arg_status = '' IF IsNull(arg_qty) THEN arg_qty = 0 IF IsNull(arg_newprice) THEN arg_newprice = 0 IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = '' IF IsNull(arg_woodcode) THEN arg_woodcode = '' IF IsNull(arg_pcode) THEN arg_pcode = '' IF IsNull(arg_cost) THEN arg_cost = 0 IF IsNull(arg_newcost) THEN arg_newcost = 0 IF IsNull(arg_unit) THEN arg_unit = '' IF IsNull(arg_amt) THEN arg_amt = 0 IF IsNull(arg_planprice) THEN arg_planprice = 0 IF IsNull(arg_cost_notax) THEN arg_cost_notax = 0 IF IsNull(arg_newcost_notax) THEN arg_newcost_notax = 0 // 如果出仓数量为 0,或物料编号为空,则不作任何处理 IF arg_mtrlwareid = 0 Or arg_qty = 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_mtrlware.sptid, u_mtrlware.dxflag, u_mtrlware.woodcode, u_mtrlware.pcode, isnull(uv_mtrlware_noauditingqty.noauditingqty,0), u_mtrlware.noallocqty, u_mtrlware.waredscrp, u_mtrlware.inworkdate INTO :i_mtrlid, :i_storageid, :i_plancode, :i_status, :i_cost, :i_planprice, :i_mtrlcode, :i_sptid, :i_dxflag, :i_woodcode, :i_pcode, :i_notauditqty, :i_allouseqty, :i_waredscrp, :i_inworkdate 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.mtrlid = u_mtrldef.mtrlid ) And ( u_mtrlware.mtrlwareid = :arg_mtrlwareid ) AND ( u_mtrlware.scid = :scid ) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,库存编号错误" GOTO ext END IF it_mxbt++ inwaremx[it_mxbt].mtrlwareid = arg_mtrlwareid inwaremx[it_mxbt].printid = arg_printid inwaremx[it_mxbt].mtrlid = i_mtrlid inwaremx[it_mxbt].mtrlcode = arg_mtrlcode inwaremx[it_mxbt].plancode = i_plancode inwaremx[it_mxbt].status = i_status inwaremx[it_mxbt].qty = i_allouseqty inwaremx[it_mxbt].fprice = arg_newprice inwaremx[it_mxbt].planprice = arg_planprice inwaremx[it_mxbt].mxdscrp = arg_mxdscrp inwaremx[it_mxbt].woodcode = i_woodcode inwaremx[it_mxbt].pcode = i_pcode inwaremx[it_mxbt].aunit = arg_unit inwaremx[it_mxbt].cost = arg_cost inwaremx[it_mxbt].newcost = arg_newcost // //inwaremx[it_mxbt].amt = arg_amt inwaremx[it_mxbt].dxflag = i_dxflag inwaremx[it_mxbt].sptid = i_sptid inwaremx[it_mxbt].waredscrp = i_waredscrp inwaremx[it_mxbt].inworkdate = i_inworkdate inwaremx[it_mxbt].cost_notax = arg_cost_notax inwaremx[it_mxbt].newcost_notax = arg_newcost_notax ext: IF rslt = 0 THEN p_clearmx() arg_msg = "第" + String(arg_printid) + "行," + arg_msg END IF Return(rslt) end function on uo_update_cost.create call super::create TriggerEvent( this, "constructor" ) end on on uo_update_cost.destroy TriggerEvent( this, "destructor" ) call super::destroy end on event constructor;//uo_unit_change = create uo_unit end event event destructor;//destroy uo_unit_change end event