$PBExportHeader$uo_spt_price_change.sru forward global type uo_spt_price_change from nonvisualobject end type type s_spt_price_changemx2 from structure within uo_spt_price_change end type end forward type s_spt_price_changemx2 from structure long mtrlid string status decimal { 10 } rate decimal { 10 } price decimal { 10 } wareprice decimal { 5 } lastprice decimal { 5 } qty decimal { 5 } qty1 string dscrp long sptid long printid long printid1 string mtrlcode string unit string sptmtrlname datetime lastdate datetime effdate string woodcode string pcode string jgdscrp integer hisflag integer taskflag integer wareflag datetime sdate datetime edate end type global type uo_spt_price_change from nonvisualobject end type global uo_spt_price_change uo_spt_price_change type variables public protectedwrite long billid 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 string auditingrep long mtrlid datetime billdate long sptid string dscrp string inrep int billtype long moneyid Transaction commit_transaction //数据commit事务 long relbillid int ifauto int autobuild = 0 //是否自动操作 private: boolean it_newbegin=false //新建标志 boolean it_updatebegin=false//修改标志 Boolean if_getid_ture = TRUE s_spt_price_changemx changemx[] //明细结构数组 s_spt_price_changemx2 changemx2[] //明细结构数组 Long it_mxbt = 0 //明细结构数组末指针 Long it_mxbt2 = 0 //明细结构数组末指针 s_mtrl_price_changemx changemx3[] //明细结构数组 s_mtrl_price_changemx2 changemx4[] //明细结构数组 Long it_mxbt3 = 0 //明细结构数组末指针 Long it_mxbt4 = 0 //明细结构数组末指针 uo_spt_price uo_price end variables forward prototypes public function integer p_reset () public function integer updatebegin (long arg_billid, ref string arg_msg) public function integer save (ref string arg_msg, boolean arg_ifcommit) public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg) public function integer newbegin () public function integer p_clearmx () public function integer getinfo (long arg_billid, ref string arg_msg) public function integer p_getinfo (long arg_billid, ref string arg_msg) public function integer del (long arg_billid, boolean arg_ifcommit, ref string arg_msg) public function integer auditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg) public function integer c_auditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg) public function integer first_audit (long arg_billid, boolean arg_ifcommit, ref string arg_msg) public function integer first_caudit (long arg_billid, boolean arg_ifcommit, ref string arg_msg) public function integer acceptmx2 (long arg_printid, long arg_printid1, long arg_mtrlid, string arg_mtrlcode, string arg_unit, decimal arg_price, decimal arg_rate, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, string arg_sptmtrlname, string arg_dscrp, datetime arg_effdate, decimal arg_qty, decimal arg_qty1, ref string arg_msg) public function integer uof_create_change (long arg_billid, ref string arg_msg) public function integer uof_destroy_change (long arg_billid, ref string arg_msg) public function integer acceptmx3 (s_mtrl_price_changemx arg_s_mx, ref string arg_msg) public function integer acceptmx4 (s_mtrl_price_changemx2 arg_s_mx, ref string arg_msg) public function integer uof_update_ware (ref string arg_msg, boolean arg_ifcommit) public function integer uof_update_task (ref string arg_msg, boolean arg_ifcommit) public function integer acceptmx (long arg_printid, long arg_mtrlid, string arg_mtrlcode, string arg_unit, decimal arg_enprice, decimal arg_rebate, decimal arg_rate, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, string arg_sptmtrlname, string arg_dscrp, datetime arg_effdate, datetime arg_effdate_end, decimal arg_qty, decimal arg_qty1, integer arg_hisflag, integer arg_taskflag, integer arg_wareflag, datetime arg_sdate, datetime arg_edate, ref string arg_msg) public function integer acceptmx (s_spt_price_changemx s_mx, ref string arg_msg) end prototypes public function integer p_reset ();//INT p_RESET() //清除对象及其明细 billid = 0 billcode = '' flag = 0 inrep = '' sptid = 0 billtype = 0 dscrp = '' moneyid = 0 it_newbegin = FALSE it_updatebegin = FALSE p_clearmx( ) RETURN 1 end function public function integer updatebegin (long arg_billid, ref string arg_msg);Int rslt = 1 IF arg_billid <= 0 THEN billid = 0 arg_msg = '错误的单据ID' GOTO ext END IF rslt = p_getinfo(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 it_newbegin = FALSE it_updatebegin = TRUE p_clearmx() //清除明细 ext: IF rslt = 0 THEN p_reset() RETURN rslt end function public function integer save (ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1,cnt = 0,i DateTime server_dt Long ls_newid IF IsNull(sptid) THEN sptid = 0 IF IsNull(dscrp) THEN dscrp = '' IF IsNull(inrep) THEN inrep = '' IF IsNull(moneyid) THEN moneyid = 0 IF IsNull(relbillid) THEN relbillid = 0 IF it_newbegin = False And it_updatebegin = False THEN rslt = 0 arg_msg = "非编辑状态不可以提交" GOTO ext END IF IF billtype <> 1 And billtype <> 2 And billtype <> 3 THEN arg_msg = '错误的单据类型,1-调价单,2-报价单,3-纸板询价单' 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 cnt = 0 SELECT count(*) INTO :cnt FROM u_spt Where sptid = :sptid; IF sqlca.SQLCode <> 0 THEN arg_msg = '查询供应商资料失败' rslt = 0 GOTO ext END IF IF cnt > 1 THEN arg_msg = '供应商资料重复' rslt = 0 GOTO ext END IF IF inrep = '' THEN arg_msg = '请选择经手人' rslt = 0 GOTO ext END IF IF it_mxbt = 0 THEN arg_msg = '没有正确的明细内容' rslt = 0 GOTO ext END IF SELECT Top 1 getdate() Into :server_dt From u_user; //取得系统时间,借用操作员表 IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,日期 " GOTO ext END IF IF Year(Date(billdate)) < 2000 Or IsNull(billdate) THEN rslt = 0 arg_msg = "时间不合理" GOTO ext END IF IF billid = 0 THEN //新建 ls_newid = f_sys_scidentity(0,"u_spt_price_change","billid",arg_msg,True,id_sqlca) IF ls_newid <= 0 THEN rslt = 0 GOTO ext END IF billcode = getid(0,"SP",Date(server_dt),False,sqlca) //取得新单据编号 IF billcode = "err" THEN billcode = '' rslt = 0 arg_msg = "无法获取单据编号" GOTO ext END IF INSERT INTO u_spt_price_change (billid, billcode, billdate, sptid, dscrp, opemp, opdate, inrep, billtype, moneyid, ifauto, relbillid) VALUES ( :ls_newid, :billcode, :billdate, :sptid, :dscrp, :publ_operator, :server_dt, :inrep, :billtype, :moneyid, :ifauto, :relbillid) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致插入操作失败>>"+"~n"+sqlca.SQLErrText GOTO ext END IF billid = ls_newid ELSE //////////////////////////////////////////////// //更新 UPDATE u_spt_price_change SET billdate = :billdate, sptid = :sptid, moddate = :server_dt, modemp = :publ_operator, dscrp = :dscrp, inrep = :inrep, billtype = :billtype, moneyid = :moneyid, relbillid = :relbillid WHERE billid = :billid And flag = 0 Using commit_transaction; IF sqlca.SQLCode <> 0 Or sqlca.SQLNRows <= 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF //删除原有明细 DELETE FROM u_spt_price_changemx WHERE u_spt_price_changemx.billid = :billid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF //删除原有明细2 DELETE FROM u_spt_price_changemx2 WHERE u_spt_price_changemx2.billid = :billid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "删除旧有明细2操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF //删除原有明细3 DELETE FROM u_mtrl_price_changemx WHERE billid = :billid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "删除旧有明细3操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF //删除原有明细4 DELETE FROM u_mtrl_price_changemx2 WHERE billid = :billid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "删除旧有明细4操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF END IF FOR i = 1 To it_mxbt INSERT INTO u_spt_price_changemx ( billid, mtrlid, unit, enprice, price, rebate, status, woodcode, pcode, jgdscrp, lastprice, wareprice, rate, sptmtrlname, Dscrp, printid, lastdate, effdate, effdate_end, qty, qty1, hisflag, taskflag, wareflag, sdate, edate, buybargainid, buybargainprintid, buybargaincode) VALUES ( :billid, :changemx[i].mtrlid, :changemx[i].unit, :changemx[i].enprice, :changemx[i].price, :changemx[i].rebate, :changemx[i].status, :changemx[i].woodcode, :changemx[i].pcode, :changemx[i].jgdscrp, :changemx[i].lastprice, :changemx[i].wareprice, :changemx[i].rate, :changemx[i].sptmtrlname, :changemx[i].Dscrp, :changemx[i].printid, :changemx[i].lastdate, :changemx[i].effdate, :changemx[i].effdate_end, :changemx[i].qty, :changemx[i].qty1, :changemx[i].hisflag, :changemx[i].taskflag, :changemx[i].wareflag, :changemx[i].sdate, :changemx[i].edate, :changemx[i].buybargainid, :changemx[i].buybargainprintid , :changemx[i].buybargaincode ) Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN IF it_newbegin THEN billid = 0 END IF rslt = 0 arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF NEXT FOR i = 1 To it_mxbt2 INSERT INTO u_spt_price_changemx2 ( billid, mtrlid, unit, price, status, woodcode, pcode, jgdscrp, lastprice, wareprice, rate, sptmtrlname, Dscrp, printid, printid1, lastdate, effdate, qty, qty1) VALUES ( :billid, :changemx2[i].mtrlid, :changemx2[i].unit, :changemx2[i].price, :changemx2[i].status, :changemx2[i].woodcode, :changemx2[i].pcode, :changemx2[i].jgdscrp, :changemx2[i].lastprice, :changemx2[i].wareprice, :changemx2[i].rate, :changemx2[i].sptmtrlname, :changemx2[i].Dscrp, :changemx2[i].printid, :changemx2[i].printid1, :changemx2[i].lastdate, :changemx2[i].effdate, :changemx2[i].qty, :changemx2[i].qty1 ) Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN IF it_newbegin THEN billid = 0 END IF rslt = 0 arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF NEXT FOR i = 1 To it_mxbt3 INSERT INTO u_mtrl_price_changemx (billid, printid, relid, relprintid, relcode, price, rate, unit, mxtype, dscrp, scid, printid2) VALUES ( :billid, :changemx3[i].printid, :changemx3[i].relid, :changemx3[i].relprintid, :changemx3[i].relcode, :changemx3[i].price, :changemx3[i].rate, :changemx3[i].unit, :changemx3[i].mxtype, :changemx3[i].dscrp, :changemx3[i].scid, :changemx3[i].printid2); IF sqlca.SQLCode <> 0 THEN if it_newbegin then billid = 0 rslt = 0 arg_msg = "因网络或其它原因导致插入明细3操作失败"+"~n"+sqlca.SQLErrText GOTO ext END IF NEXT FOR i = 1 To it_mxbt4 INSERT INTO u_mtrl_price_changemx2 (billid, printid, relid, relprintid, relcode, price, rate, unit, mxtype, dscrp, scid, printid2) VALUES ( :billid, :changemx4[i].printid, :changemx4[i].relid, :changemx4[i].relprintid, :changemx4[i].relcode, :changemx4[i].price, :changemx4[i].rate, :changemx4[i].unit, :changemx4[i].mxtype, :changemx4[i].dscrp, :changemx4[i].scid, :changemx4[i].printid2); IF sqlca.SQLCode <> 0 THEN if it_newbegin then billid = 0 rslt = 0 arg_msg = "因网络或其它原因导致插入明细4操作失败"+"~n"+sqlca.SQLErrText GOTO ext END IF NEXT 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 add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg);Int rslt = 1 arg_newdescppart = Trim(arg_newdescppart) IF arg_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 rslt=p_getinfo(arg_billid,arg_msg) if rslt=0 then goto ext if flag=0 then rslt=0 arg_msg="非审核状态下不可用" goto ext end if UPDATE u_spt_price_change SET dscrp = dscrp+' '+:arg_newdescppart Where u_spt_price_change.billid = :billid using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN ROLLBACK ; rslt = 0 arg_msg = "因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF dscrp = dscrp+' '+arg_newdescppart ext: IF rslt = 0 THEN ROLLBACK USING commit_transaction ; ELSE COMMIT USING commit_transaction ; END IF Return(rslt) end function public function integer newbegin ();p_reset() it_newbegin=TRUE it_updatebegin=FALSE return 1 end function public function integer p_clearmx ();//int p_clearmx() //清除明细 it_mxbt=0 it_mxbt2=0 it_mxbt3 = 0 it_mxbt4=0 return 1 end function public function integer getinfo (long arg_billid, ref string arg_msg);//getinfo(arg_scid,arg_billid,arg_msg) //0 失败 1成功 Int rslt = 1,i = 1,no_mxcheck = 0 IF arg_billid <= 0 THEN rslt = 0 arg_msg = "非法调价单唯一码" GOTO ext END IF rslt = p_getinfo(arg_billid,arg_msg) IF rslt = 0 THEN GOTO ext //用游标读取明细 DECLARE cur_changemx CURSOR FOR SELECT u_spt_price_changemx.printid, u_spt_price_changemx.mtrlid, u_mtrldef.mtrlcode, u_spt_price_changemx.unit, u_spt_price_changemx.enprice, u_spt_price_changemx.price, u_spt_price_changemx.rebate, u_spt_price_changemx.status, u_spt_price_changemx.woodcode, u_spt_price_changemx.pcode, u_spt_price_changemx.jgdscrp, u_spt_price_changemx.sptmtrlname, u_spt_price_changemx.Dscrp, u_spt_price_changemx.lastprice, u_spt_price_changemx.wareprice, u_spt_price_changemx.rate, u_spt_price_changemx.lastdate, u_spt_price_changemx.effdate, u_spt_price_changemx.effdate_end, u_spt_price_changemx.qty, u_spt_price_changemx.qty1, u_spt_price_changemx.hisflag, u_spt_price_changemx.taskflag, u_spt_price_changemx.wareflag, u_spt_price_changemx.sdate, u_spt_price_changemx.edate FROM u_spt_price_change INNER JOIN u_spt_price_changemx ON u_spt_price_change.billid = u_spt_price_changemx.billid INNER JOIN u_mtrldef ON u_spt_price_changemx.mtrlid = u_mtrldef.mtrlid WHERE u_spt_price_change.billid = :arg_billid Using commit_transaction; OPEN cur_changemx; FETCH cur_changemx INTO :changemx[i].printid, :changemx[i].mtrlid, :changemx[i].mtrlcode, :changemx[i].unit, :changemx[i].enprice, :changemx[i].price, :changemx[i].rebate, :changemx[i].status, :changemx[i].woodcode, :changemx[i].pcode, :changemx[i].jgdscrp, :changemx[i].sptmtrlname, :changemx[i].Dscrp, :changemx[i].lastprice, :changemx[i].wareprice, :changemx[i].rate, :changemx[i].lastdate, :changemx[i].effdate, :changemx[i].effdate_end, :changemx[i].qty, :changemx[i].qty1, :changemx[i].hisflag, :changemx[i].taskflag, :changemx[i].wareflag, :changemx[i].sdate, :changemx[i].edate; DO WHILE commit_transaction.SQLCode = 0 i++ FETCH cur_changemx INTO :changemx[i].printid, :changemx[i].mtrlid, :changemx[i].mtrlcode, :changemx[i].unit, :changemx[i].enprice, :changemx[i].price, :changemx[i].rebate, :changemx[i].status, :changemx[i].woodcode, :changemx[i].pcode, :changemx[i].jgdscrp, :changemx[i].sptmtrlname, :changemx[i].Dscrp, :changemx[i].lastprice, :changemx[i].wareprice, :changemx[i].rate, :changemx[i].lastdate, :changemx[i].effdate, :changemx[i].effdate_end, :changemx[i].qty, :changemx[i].qty1, :changemx[i].hisflag, :changemx[i].taskflag, :changemx[i].wareflag, :changemx[i].sdate, :changemx[i].edate; LOOP CLOSE cur_changemx; //检验明细是否读入完整 SELECT count(*) INTO :no_mxcheck FROM u_spt_price_changemx WHERE u_spt_price_changemx.billid = :arg_billid 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 it_mxbt = i - 1 //用游标读取明细2 i = 1 DECLARE cur_changemx2 CURSOR FOR SELECT u_spt_price_changemx2.printid, u_spt_price_changemx2.printid1, u_spt_price_changemx2.mtrlid, u_mtrldef.mtrlcode, u_spt_price_changemx2.unit, u_spt_price_changemx2.price, u_spt_price_changemx2.status, u_spt_price_changemx2.woodcode, u_spt_price_changemx2.pcode, u_spt_price_changemx2.jgdscrp, u_spt_price_changemx2.sptmtrlname, u_spt_price_changemx2.Dscrp, u_spt_price_changemx2.lastprice, u_spt_price_changemx2.wareprice, u_spt_price_changemx2.rate, u_spt_price_changemx2.lastdate, u_spt_price_changemx2.effdate, u_spt_price_changemx2.qty, u_spt_price_changemx2.qty1 FROM u_spt_price_change INNER JOIN u_spt_price_changemx2 ON u_spt_price_change.billid = u_spt_price_changemx2.billid INNER JOIN u_mtrldef ON u_spt_price_changemx2.mtrlid = u_mtrldef.mtrlid WHERE u_spt_price_change.billid = :arg_billid Using commit_transaction; OPEN cur_changemx2; FETCH cur_changemx2 INTO :changemx2[i].printid, :changemx2[i].printid1, :changemx2[i].mtrlid, :changemx2[i].mtrlcode, :changemx2[i].unit, :changemx2[i].price, :changemx2[i].status, :changemx2[i].woodcode, :changemx2[i].pcode, :changemx2[i].jgdscrp, :changemx2[i].sptmtrlname, :changemx2[i].Dscrp, :changemx2[i].lastprice, :changemx2[i].wareprice, :changemx2[i].rate, :changemx2[i].lastdate, :changemx2[i].effdate, :changemx2[i].qty, :changemx2[i].qty1; DO WHILE commit_transaction.SQLCode = 0 i++ FETCH cur_changemx2 INTO :changemx2[i].printid, :changemx2[i].printid1, :changemx2[i].mtrlid, :changemx2[i].mtrlcode, :changemx2[i].unit, :changemx2[i].price, :changemx2[i].status, :changemx2[i].woodcode, :changemx2[i].pcode, :changemx2[i].jgdscrp, :changemx2[i].sptmtrlname, :changemx2[i].Dscrp, :changemx2[i].lastprice, :changemx2[i].wareprice, :changemx2[i].rate, :changemx2[i].lastdate, :changemx2[i].effdate, :changemx2[i].qty, :changemx2[i].qty1; LOOP CLOSE cur_changemx2; //检验明细是否读入完整 SELECT count(*) INTO :no_mxcheck FROM u_spt_price_changemx2 WHERE u_spt_price_changemx2.billid = :arg_billid 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 it_mxbt2 = i - 1 //用游标读取明细3 i = 1 DECLARE cur_changemx3 CURSOR FOR SELECT u_mtrl_price_changemx.billid, u_mtrl_price_changemx.printid, u_mtrl_price_changemx.printid2, u_mtrl_price_changemx.relid, u_mtrl_price_changemx.price, u_mtrl_price_changemx.rate, u_mtrl_price_changemx.scid, u_mtrl_price_changemx.relprintid, u_mtrl_price_changemx.mxtype, u_mtrl_price_changemx.unit FROM u_mtrl_price_changemx WHERE u_mtrl_price_changemx.billid = :arg_billid Order By u_mtrl_price_changemx.printid; OPEN cur_changemx3; FETCH cur_changemx3 INTO :changemx3[i].billid, :changemx3[i].printid,:changemx3[i].printid2,:changemx3[i].relid, :changemx3[i].price,:changemx3[i].rate, :changemx3[i].scid,:changemx3[i].relprintid, :changemx3[i].mxtype,:changemx3[i].unit; DO WHILE sqlca.SQLCode = 0 i++ FETCH cur_changemx3 INTO :changemx3[i].billid, :changemx3[i].printid,:changemx3[i].printid2,:changemx3[i].relid, :changemx3[i].price,:changemx3[i].rate, :changemx3[i].scid,:changemx3[i].relprintid, :changemx3[i].mxtype,:changemx3[i].unit; LOOP CLOSE cur_changemx3; //检验明细是否读入完整 SELECT count(*) INTO :no_mxcheck FROM u_mtrl_price_changemx Where billid = :arg_billid; IF sqlca.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 it_mxbt3 = i - 1 //用游标读取明细4 i = 1 DECLARE cur_changemx4 CURSOR FOR SELECT u_mtrl_price_changemx2.billid, u_mtrl_price_changemx2.printid, u_mtrl_price_changemx2.printid2, u_mtrl_price_changemx2.relid, u_mtrl_price_changemx2.price, u_mtrl_price_changemx2.rate, u_mtrl_price_changemx2.scid, u_mtrl_price_changemx2.relprintid, u_mtrl_price_changemx2.mxtype, u_mtrl_price_changemx2.unit FROM u_mtrl_price_changemx2 where u_mtrl_price_changemx2.billid = :arg_billid Order By u_mtrl_price_changemx2.printid; OPEN cur_changemx4; FETCH cur_changemx4 INTO :changemx4[i].billid, :changemx4[i].printid,:changemx4[i].printid2,:changemx4[i].relid, :changemx4[i].price,:changemx4[i].rate, :changemx4[i].scid,:changemx4[i].relprintid, :changemx4[i].mxtype,:changemx4[i].unit; DO WHILE sqlca.SQLCode = 0 i++ FETCH cur_changemx4 INTO :changemx4[i].billid, :changemx4[i].printid,:changemx4[i].printid2,:changemx4[i].relid, :changemx4[i].price,:changemx4[i].rate, :changemx4[i].scid,:changemx4[i].relprintid, :changemx4[i].mxtype,:changemx4[i].unit; LOOP CLOSE cur_changemx4; //检验明细是否读入完整 SELECT count(*) INTO :no_mxcheck FROM u_mtrl_price_changemx2 Where billid = :arg_billid; IF sqlca.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 it_mxbt4 = i - 1 ////////////////// billid = arg_billid it_newbegin = False it_updatebegin = False ext: IF rslt = 0 THEN p_reset() RETURN rslt end function public function integer p_getinfo (long arg_billid, ref string arg_msg);Int rslt = 1 IF arg_billid <= 0 THEN rslt = 0 arG_MSG = "非法调价单唯一码" GOTO ext END IF SELECT Billcode, billdate, sptid, flag, dscrp, inrep, billtype, moneyid, ifauto, relbillid INTO :Billcode, :billdate, :sptid, :flag, :dscrp, :Inrep, :billtype, :moneyid, :ifauto, :relbillid FROM u_spt_price_change Where billid = :arg_billid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arG_MSG = "查询操作失败(错误调价单唯一码),调价单"+commit_transaction.SQLErrText GOTO ext END IF billid = arg_billid ext: IF rslt = 0 THEN p_reset() RETURN rslt end function public function integer del (long arg_billid, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1 IF arg_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 rslt = p_getinfo(arg_billid,arg_msg) IF rslt = 0 THEN GOTO ext IF flag = 1 THEN rslt = 0 arg_msg = "单据已经审核,不可以删除" GOTO ext END IF DELETE FROM u_spt_price_change WHERE u_spt_price_change.billid = :arg_billid 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 Return (rslt) end function public function integer auditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg); Long cnt = 0,i Int rslt rslt = 1 IF arg_billid = 0 THEN rslt = 0 arg_msg = "没有审核对象" GOTO ext END IF IF getinfo(arg_billid,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF flag <> 4 THEN rslt = 0 arg_msg = '单据不是在待终审状态,不能执行终审,请检查!' GOTO ext END IF UPDATE u_spt_price_change SET flag = 1, auditemp = :publ_operator, Auditdate = getdate() WHERE billid = :billid And flag = 4 Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '更新单价调整失败,原因>>'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF FOR i = 1 To it_mxbt //更新价格历史 IF changemx[i].hisflag = 1 THEN IF uo_price.uof_update_sptprice(0,sptid,changemx[i].mtrlid,changemx[i].unit,changemx[i].status,changemx[i].woodcode,changemx[i].pcode,changemx[i].jgdscrp,billid,changemx[i].enprice,changemx[i].rebate,& changemx[i].rate,changemx[i].wareprice,changemx[i].wareprice,billdate,billcode,1,changemx[i].Dscrp,i,2,moneyid,changemx[i].effdate,changemx[i].effdate_end,False,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF uo_price.uof_update_sptmtrlname(sptid,changemx[i].mtrlid,changemx[i].sptmtrlname,False,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF NEXT IF it_mxbt2 > 0 THEN IF uof_create_change(arg_billid, arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF //更新采购订单 IF it_mxbt3 > 0 THEN IF uof_update_task( arg_msg, false) = 0 THEN rslt = 0 GOTO ext END IF END IF //更新采购收货单 IF it_mxbt4 > 0 THEN IF uof_update_ware( arg_msg, false) = 0 THEN rslt = 0 GOTO ext END IF END IF 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 (long arg_billid, boolean arg_ifcommit, ref string arg_msg); Long cnt = 0,i Int rslt = 1 DateTime null_server_dt SetNull(null_server_dt) IF arg_billid = 0 THEN rslt = 0 arg_msg = "没有审核对象" GOTO ext END IF IF getinfo(arg_billid,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF flag <> 1 THEN rslt = 0 arg_msg = '该单价调整未审核,不用撤审!' GOTO ext END IF IF autobuild = 0 THEN IF ifauto = 1 THEN rslt = 0 arg_msg = '单据自动生成,不用手动撤审!' GOTO ext END IF END IF UPDATE u_spt_price_change SET flag = 4, Auditemp = '', Auditdate = :null_server_dt Where flag = 1 And billid = :billid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '更新单价调整失败,原因:'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF 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 first_audit (long arg_billid, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1 IF p_getinfo(arg_billid,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF flag <> 0 THEN rslt = 0 arg_msg = '单据不是在待审核状态,不能执行初审' GOTO ext END IF UPDATE u_spt_price_change SET first_auditemp = :publ_operator, first_auditdate = getdate(), flag = 4 WHERE billid = :arg_billid And flag = 0; 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 first_caudit (long arg_billid, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1 DateTime null_dt SetNull(null_dt) IF p_getinfo(arg_billid,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF flag <> 4 THEN rslt = 0 arg_msg = '单据不是审核状态,不能执行初撤' GOTO ext END IF IF autobuild = 0 THEN IF ifauto = 1 THEN rslt = 0 arg_msg = '单据自动生成,不用手动撤审!' GOTO ext END IF END IF UPDATE u_spt_price_change SET first_auditemp = '', first_auditdate = :null_dt, flag = 0 WHERE billid = :arg_billid And flag = 4; 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 acceptmx2 (long arg_printid, long arg_printid1, long arg_mtrlid, string arg_mtrlcode, string arg_unit, decimal arg_price, decimal arg_rate, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, string arg_sptmtrlname, string arg_dscrp, datetime arg_effdate, decimal arg_qty, decimal arg_qty1, ref string arg_msg);//已无用 Int rslt = 1 Decimal i_lastprice,i_lastrate,i_rate DateTime ld_lastdate String ls_unit Long cnt //IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN // rslt = 0 // arg_msg = "非编辑状态不可以使用,操作取消" // GOTO ext //END IF // // ////清除空值 //IF IsNull(arg_printid) THEN arg_printid = 0 //IF IsNull(arg_printid1) THEN arg_printid1 = 0 //IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0 //IF IsNull(arg_mtrlcode) THEN arg_mtrlcode = '' //IF IsNull(arg_status) THEN arg_status = '' //IF IsNull(arg_dscrp) THEN arg_dscrp = '' //IF IsNull(arg_price) THEN arg_price = 0 //IF IsNull(arg_unit) THEN arg_unit = '' //IF IsNull(arg_rate) THEN arg_rate = 1 //IF arg_rate = 0 THEN arg_rate = 1 //IF IsNull(arg_qty) THEN arg_qty = 0 //IF IsNull(arg_qty1) THEN arg_qty1 = 0 // //arg_effdate = datetime(date(arg_effdate),time(0)) // //ls_unit = arg_unit // //IF arg_mtrlid = 0 and arg_price = 0 THEN // rslt = 1 // GOTO ext //END IF // //IF uo_price.uf_getmtrlsptprice_ch(sptid,arg_mtrlid,ls_unit,arg_status,arg_woodcode,arg_pcode,arg_jgdscrp,i_lastprice,i_rate,ld_lastdate,arg_msg) = 0 THEN // rslt = 0 // GOTO ext //END IF // // //it_mxbt2++ //changemx2[it_mxbt2].mtrlid = arg_mtrlid //changemx2[it_mxbt2].unit = arg_unit //changemx2[it_mxbt2].price = arg_price //changemx2[it_mxbt2].status = arg_status //changemx2[it_mxbt2].lastprice = i_lastprice //changemx2[it_mxbt2].wareprice = Round(arg_price/arg_rate,5) //changemx2[it_mxbt2].rate = arg_rate //changemx2[it_mxbt2].sptmtrlname = arg_sptmtrlname //changemx2[it_mxbt2].Dscrp = arg_dscrp //changemx2[it_mxbt2].lastdate = ld_lastdate //changemx2[it_mxbt2].printid = it_mxbt2 //changemx2[it_mxbt2].printid1 = arg_printid1 //changemx2[it_mxbt2].effdate = arg_effdate //changemx2[it_mxbt2].qty = arg_qty //changemx2[it_mxbt2].qty1 = arg_qty1 // //changemx2[it_mxbt2].woodcode = arg_woodcode //changemx2[it_mxbt2].pcode = arg_pcode //changemx2[it_mxbt2].jgdscrp = arg_jgdscrp // // //ext: //IF rslt = 0 THEN p_clearmx() RETURN rslt end function public function integer uof_create_change (long arg_billid, ref string arg_msg);Int rslt = 1 Long i, mxcnt datetime ldt_sdate, ldt_edate uo_spt_price_change uo_price_chg uo_price_chg = Create uo_spt_price_change uo_price_chg.commit_transaction = commit_transaction IF uo_price_chg.newbegin() = 0 THEN rslt = 0 GOTO ext END IF uo_price_chg.billdate = DateTime(Today()) // 发生时间 uo_price_chg.sptid = sptid // 经手人 uo_price_chg.dscrp = dscrp //备注 uo_price_chg.billtype = 1 //询价单 uo_price_chg.inrep = inrep //备注 uo_price_chg.moneyid = moneyid //备注 uo_price_chg.relbillid = arg_billid // uo_price_chg.ifauto = 1 FOR i = 1 To it_mxbt2 IF uo_price_chg.acceptmx(i,& changemx2[i].mtrlid,& changemx2[i].mtrlcode,& changemx2[i].unit,& changemx2[i].price,& 1,& changemx2[i].rate,& changemx2[i].status,& changemx2[i].woodcode,& changemx2[i].pcode,& changemx2[i].jgdscrp,& changemx2[i].sptmtrlname,& changemx2[i].dscrp,& changemx2[i].effdate,& datetime(9999-01-01, 23:59:59),& changemx2[i].qty,& changemx2[i].qty1,& 1,0,0,ldt_sdate, ldt_edate,& arg_msg) = 0 THEN rslt = 0 GOTO ext END IF NEXT IF uo_price_chg.Save(arg_msg,False) = 0 THEN rslt = 0 GOTO ext END IF long ll_billid ll_billid = uo_price_chg.billid IF uo_price_chg.first_audit(ll_billid,False,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF uo_price_chg.auditing(ll_billid,False,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF ext: //if rslt = 0 then // rollback; //else // //end if Destroy uo_price_chg RETURN rslt end function public function integer uof_destroy_change (long arg_billid, ref string arg_msg);Int rslt = 1 Long i, mxcnt Long ll_billid uo_spt_price_change uo_price_chg uo_price_chg = Create uo_spt_price_change uo_price_chg.commit_transaction = commit_transaction IF uo_price_chg.newbegin() = 0 THEN rslt = 0 GOTO ext END IF SELECT billid INTO :ll_billid FROM u_spt_price_change WHERE relbillid = :arg_billid And billtype = 1; IF sqlca.sqlcode <> 0 THEN arg_msg = "查询相关纸箱询价单失败,"+sqlca.SQLErrText rslt = 0 GOTO ext END IF //uo_price_chg.ifauto = 1 uo_price_chg.autobuild = 1 IF uo_price_chg.first_caudit(ll_billid,False,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF uo_price_chg.del(ll_billid,False,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF ext: //if rslt = 0 then // rollback; //else // //end if Destroy uo_price_chg RETURN rslt end function public function integer acceptmx3 (s_mtrl_price_changemx arg_s_mx, ref string arg_msg); Int rslt = 1 IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN rslt = 0 arg_msg = "非编辑状态不可以使用,操作取消" GOTO ext END IF //清除空值 // // IF arg_s_mx.relid = 0 and arg_s_mx.relprintid = 0 THEN rslt = 1 GOTO ext END IF //插入明细 it_mxbt3++ changemx3[it_mxbt3] = arg_s_mx ext: IF rslt = 0 THEN p_clearmx() RETURN rslt end function public function integer acceptmx4 (s_mtrl_price_changemx2 arg_s_mx, ref string arg_msg); Int rslt = 1 IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN rslt = 0 arg_msg = "非编辑状态不可以使用,操作取消" GOTO ext END IF //清除空值 // // IF arg_s_mx.relid = 0 and arg_s_mx.relprintid = 0 THEN rslt = 1 GOTO ext END IF //插入明细 it_mxbt4++ changemx4[it_mxbt4] = arg_s_mx ext: IF rslt = 0 THEN p_clearmx() RETURN rslt end function public function integer uof_update_ware (ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Decimal lde_newprice //lde_newprice = arg_newprice //s_mtrl_price_changemx2 changemx4[] Long i, ll_printid2 long j uo_inware uo_in_buy uo_in_buy = Create uo_inware uo_in_buy.commit_transaction = sqlca uo_inware_wfjg uo_in_wfjg uo_in_wfjg = Create uo_inware_wfjg uo_in_wfjg.commit_transaction = sqlca //IF getinfo2(arg_billid,changemx4,ll_arr_cnt2,arg_msg) = 0 THEN // rslt = 0 // GOTO ext //END IF IF it_mxbt4 = 0 THEN RETURN 1 //没有的, 不提交事物, 成功返回 Int li_flag, li_secflag, li_balcflag Decimal lde_fprice, lde_price, lde_uprice, lde_enprice, lde_jgprice, lde_enprice_tax, lde_enprice_notax, lde_cost Decimal lde_uqty, lde_rate, lde_rebate, lde_mrate, lde_qty Int li_thflag FOR i = 1 To it_mxbt4 //收货明细 ll_printid2 = changemx4[i].printid2 IF ll_printid2 = 0 THEN rslt = 0 arg_msg = "收货单明细行:["+String(i)+"],询价单明细对应行ID为0" GOTO ext END IF IF ll_printid2 > it_mxbt THEN rslt = 0 arg_msg = "收货单明细行:["+String(i)+"],询价单明细对应行ID错误,"+String(ll_printid2) GOTO ext END IF //为防止对错printid,采用新写法 dyy 20141104 For j = 1 To it_mxbt If changemx[j].printid = ll_printid2 Then lde_newprice = changemx[j].price Exit End If Next // lde_newprice = changemx[ll_printid2].price IF changemx4[i].mxtype = 2 THEN //采购 SELECT flag, secflag, balcflag INTO :li_flag, :li_secflag, :li_balcflag FROM u_inware WHERE scid = :changemx4[i].scid And inwareid = :changemx4[i].relid; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "收货单明细行:["+String(i)+"],查询采购收货单信息失败"+"~n"+sqlca.SQLErrText GOTO ext END IF IF li_secflag = 1 THEN rslt = 0 arg_msg = "收货单明细行:["+String(i)+"],对应采购收货单已经财审,不能更改单价" GOTO ext END IF IF li_balcflag = 1 THEN rslt = 0 arg_msg = "收货单明细行:["+String(i)+"],对应采购收货单已经结存,不能更改单价" GOTO ext END IF IF li_flag = 1 THEN IF uo_in_buy.mod_price(changemx4[i].scid,changemx4[i].relid,changemx4[i].relprintid,lde_newprice,0,-1,-1,arg_msg,False) = 0 THEN rslt = 0 arg_msg = "收货单明细行:["+String(i)+"],"+arg_msg GOTO ext END IF ELSE SELECT u_inwaremx.uqty, u_inwaremx.rate, u_inwaremx.rebate, u_inware.mrate, u_inware.thflag INTO :lde_uqty, :lde_rate, :lde_rebate, :lde_mrate, :li_thflag FROM u_inwaremx INNER JOIN u_inware ON u_inwaremx.scid = u_inware.scid AND u_inwaremx.inwareid = u_inware.inwareid WHERE u_inwaremx.scid = :changemx4[i].scid AND u_inwaremx.inwareid = :changemx4[i].relid And u_inwaremx.printid = :changemx4[i].relprintid Using sqlca; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询进仓单明细内容失败'+sqlca.SQLErrText GOTO ext END IF lde_enprice = lde_newprice lde_uprice = Round(lde_enprice * lde_mrate,10) lde_fprice = Round((lde_uprice * lde_uqty)/(Round(lde_uqty * lde_rate,sys_option_unit_dec)),10) lde_price = lde_fprice * lde_rebate IF li_thflag = 0 THEN lde_cost = lde_price * lde_rebate END IF UPDATE u_inwaremx SET enprice = :lde_enprice, uprice = :lde_uprice, fprice = :lde_fprice, price = :lde_price, cost = :lde_cost, deliprice_notax = :lde_enprice / (1 + tax) WHERE scid = :changemx4[i].scid AND inwareid = :changemx4[i].relid And printid = :changemx4[i].relprintid Using sqlca; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "收货单明细行:["+String(i)+"],更新外协收货单价失败"+"~n"+sqlca.SQLErrText GOTO ext ELSEIF sqlca.SQLNRows = 0 THEN rslt = 0 arg_msg = "收货单明细行:["+String(i)+"],外协收货单对应明细不存在或已财审/结存"+"~n"+sqlca.SQLErrText GOTO ext END IF END IF ELSEIF changemx4[i].mxtype = 3 THEN SELECT flag, secflag, balcflag INTO :li_flag, :li_secflag, :li_balcflag FROM ow_wfjg_in WHERE scid = :changemx4[i].scid And inwareid = :changemx4[i].relid; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "收货单明细行:["+String(i)+"],查询外协收货单信息失败"+"~n"+sqlca.SQLErrText GOTO ext END IF IF li_secflag = 1 THEN rslt = 0 arg_msg = "收货单明细行:["+String(i)+"],对应外协收货单已经财审,不能更改单价" GOTO ext END IF IF li_balcflag = 1 THEN rslt = 0 arg_msg = "收货单明细行:["+String(i)+"],对应外协收货单已经结存,不能更改单价" GOTO ext END IF IF li_flag = 1 THEN IF uo_in_wfjg.mod_price(changemx4[i].scid,changemx4[i].relid,changemx4[i].relprintid,lde_fprice,lde_newprice,-1,-1,arg_msg,False) = 0 THEN rslt = 0 arg_msg = "收货单明细行:["+String(i)+"],"+arg_msg GOTO ext END IF ELSE SELECT fprice, uqty, qty, rebate INTO :lde_fprice, :lde_uqty, :lde_qty, :lde_rebate FROM ow_wfjgmx_in_aft WHERE scid = :changemx4[i].scid AND inwareid = :changemx4[i].relid AND printid = :changemx4[i].relprintid Using sqlca; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询单据明细内容失败'+sqlca.SQLErrText GOTO ext END IF lde_jgprice = lde_newprice IF lde_qty <> 0 THEN lde_uprice = Round(lde_newprice * lde_uqty/lde_qty,5) ELSE lde_uprice = 0 END IF lde_cost = lde_uprice * lde_rebate + lde_fprice lde_price = lde_uprice * lde_rebate + lde_fprice UPDATE ow_wfjgmx_in_aft SET jgprice = :lde_jgprice, fprice = :lde_fprice, uprice = :lde_uprice, price = :lde_price, cost = :lde_cost WHERE scid = :changemx4[i].scid AND inwareid = :changemx4[i].relid And printid = :changemx4[i].relprintid Using sqlca; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "收货单明细行:["+String(i)+"],更新外协收货单价失败"+"~n"+sqlca.SQLErrText GOTO ext ELSEIF sqlca.SQLNRows = 0 THEN rslt = 0 arg_msg = "收货单明细行:["+String(i)+"],外协收货单对应明细不存在或已财审/结存"+"~n"+sqlca.SQLErrText GOTO ext END IF END IF END IF NEXT ext: destroy uo_in_buy destroy uo_in_wfjg IF rslt = 0 THEN ROLLBACK; ELSEIF arg_ifcommit THEN COMMIT; END IF RETURN rslt end function public function integer uof_update_task (ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 //s_mtrl_price_changemx changemx3[] Decimal lde_newprice //lde_newprice = arg_newprice Long i, ll_printid2 Long j If it_mxbt3 = 0 Then Return 1 //没有的, 不提交事物, 成功返回 Int li_status, li_secflag, li_balcflag Decimal lde_fprice, lde_price, lde_uprice, lde_enprice, lde_jgprice, lde_enprice_tax, lde_enprice_notax, lde_cost Decimal lde_uqty, lde_rate, lde_rebate, lde_mrate For i = 1 To it_mxbt3 //订单明细 ll_printid2 = changemx3[i].printid2 If ll_printid2 = 0 Then rslt = 0 arg_msg = "订单明细行:["+String(i)+"],询价单明细对应行ID为0" Goto ext End If If ll_printid2 > it_mxbt Then rslt = 0 arg_msg = "订单明细行:["+String(i)+"],询价单明细对应行ID错误,"+String(ll_printid2) Goto ext End If //为防止对错printid,采用新写法 dyy 20141104 For j = 1 To it_mxbt If changemx[j].printid = ll_printid2 Then lde_newprice = changemx[j].price Exit End If Next // lde_newprice = changemx[ll_printid2].price If changemx3[i].mxtype = 2 Then //采购 Select u_buytaskmx.uqty, u_buytaskmx.rate, u_buytaskmx.rebate, u_buytask.mrate Into :lde_uqty, :lde_rate, :lde_rebate, :lde_mrate From u_buytaskmx Inner join u_buytask On u_buytask.scid = u_buytaskmx.scid And u_buytask.taskid = u_buytaskmx.taskid Where u_buytaskmx.scid = :changemx3[i].scid And u_buytaskmx.taskid = :changemx3[i].relid And u_buytaskmx.printid = :changemx3[i].relprintid Using sqlca; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "订单明细行:["+String(i)+"],查询采购订单明细内容失败"+sqlca.SQLErrText Goto ext End If lde_enprice = lde_newprice lde_uprice = Round(lde_enprice * lde_mrate,10) lde_fprice = Round((lde_uprice * lde_uqty)/(Round(lde_uqty * lde_rate,sys_option_unit_dec)),10) lde_price = lde_fprice * lde_rebate Update u_buyTaskMx Set fprice = :lde_fprice, Price = :lde_price, uprice = :lde_uprice, enprice = :lde_enprice Where scid = :changemx3[i].scid And taskid = :changemx3[i].relid And printid = :changemx3[i].relprintid; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "订单明细行:["+String(i)+"],更新采购订单单价失败"+"~n"+sqlca.SQLErrText Goto ext ElseIf sqlca.SQLNRows = 0 Then rslt = 0 arg_msg = "订单明细行:["+String(i)+"],采购订单对应明细不存在"+"~n"+sqlca.SQLErrText Goto ext End If ElseIf changemx3[i].mxtype = 3 Then lde_price = lde_newprice Update u_order_wfjgMx Set price = :lde_price Where scid = :changemx3[i].scid And wfjgid = :changemx3[i].relid And printid = :changemx3[i].relprintid; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "订单明细行:["+String(i)+"],更新外协订单单价失败"+"~n"+sqlca.SQLErrText Goto ext ElseIf sqlca.SQLNRows = 0 Then rslt = 0 arg_msg = "订单明细行:["+String(i)+"],外协订单对应明细不存在"+"~n"+sqlca.SQLErrText Goto ext End If End If Next ext: If rslt = 0 Then Rollback; ElseIf arg_ifcommit Then Commit; End If Return rslt end function public function integer acceptmx (long arg_printid, long arg_mtrlid, string arg_mtrlcode, string arg_unit, decimal arg_enprice, decimal arg_rebate, decimal arg_rate, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, string arg_sptmtrlname, string arg_dscrp, datetime arg_effdate, datetime arg_effdate_end, decimal arg_qty, decimal arg_qty1, integer arg_hisflag, integer arg_taskflag, integer arg_wareflag, datetime arg_sdate, datetime arg_edate, ref string arg_msg);s_spt_price_changemx s_mx s_mx.printid = arg_printid s_mx.mtrlid = arg_mtrlid s_mx.mtrlcode = arg_mtrlcode s_mx.unit = arg_unit s_mx.enprice = arg_enprice s_mx.rebate = arg_rebate s_mx.rate = arg_rate s_mx.status = arg_status s_mx.woodcode = arg_woodcode s_mx.pcode = arg_pcode s_mx.jgdscrp = arg_jgdscrp s_mx.sptmtrlname = arg_sptmtrlname s_mx.dscrp = arg_dscrp s_mx.effdate = arg_effdate s_mx.effdate_end = arg_effdate_end s_mx.qty = arg_qty s_mx.qty1 = arg_qty1 s_mx.hisflag = arg_hisflag s_mx.taskflag = arg_taskflag s_mx.wareflag = arg_wareflag s_mx.sdate = arg_sdate s_mx.edate = arg_edate s_mx.buybargainid = 0 s_mx.buybargainprintid = 0 s_mx.buybargaincode = '' return acceptmx(s_mx, arg_msg) /* Int rslt = 1 Decimal i_lastprice,i_lastrate, i_lastzqrate DateTime ld_lastdate Long cnt datetime ldt_effdate ldt_effdate = datetime(today(),time(0)) IF it_newbegin = False And it_updatebegin = False THEN rslt = 0 arg_msg = "非编辑状态不可以使用,操作取消" 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_status) THEN arg_status = '' IF IsNull(arg_dscrp) THEN arg_dscrp = '' IF IsNull(arg_enprice) THEN arg_enprice = 0 IF IsNull(arg_rebate) THEN arg_rebate = 1 IF IsNull(arg_unit) THEN arg_unit = '' IF IsNull(arg_rate) THEN arg_rate = 1 IF arg_rate = 0 THEN arg_rate = 1 IF IsNull(arg_qty) THEN arg_qty = 0 IF IsNull(arg_qty1) THEN arg_qty1 = 0 IF IsNull(arg_hisflag) THEN arg_hisflag = 1 IF IsNull(arg_taskflag) THEN arg_taskflag = 0 IF IsNull(arg_wareflag) THEN arg_wareflag = 0 IF arg_mtrlid = 0 And arg_enprice = 0 THEN rslt = 1 GOTO ext END IF IF arg_unit = '' THEN arg_msg = "请选择单位" rslt = 0 GOTO ext END IF arg_effdate = DateTime(Date(arg_effdate),Time(0)) arg_effdate_end = DateTime(Date(arg_effdate_end),Time(23:59:59)) IF arg_taskflag = 0 And arg_wareflag = 0 THEN SetNull(arg_sdate) SetNull(arg_edate) ELSE arg_sdate = DateTime(Date(arg_sdate),Time(0)) arg_edate = DateTime(Date(arg_edate),23:59:59) IF Date(arg_sdate) < 2000-01-01 THEN arg_msg = "请填写开始时间" rslt = 0 GOTO ext END IF IF Date(arg_edate) < 2000-01-01 THEN arg_msg = "请填写结束时间" rslt = 0 GOTO ext END IF END IF //IF uo_price.uf_getmtrlsptprice_ch(sptid,arg_mtrlid,arg_unit,arg_status,arg_woodcode,arg_pcode,arg_jgdscrp,i_lastprice,i_lastrate,ld_lastdate,arg_msg) = 0 THEN //IF uo_price.uof_getnewprice(sptid,moneyid,arg_mtrlid,arg_unit,arg_status,arg_woodcode,arg_pcode,arg_jgdscrp,i_lastprice,i_lastzqrate,i_lastrate,ld_lastdate,arg_msg) = 0 THEN IF uo_price.uof_sptmtrlprice_get(sptid,moneyid,arg_mtrlid,arg_unit,arg_status,arg_woodcode,arg_pcode,arg_jgdscrp,ldt_effdate,i_lastprice,i_lastzqrate,i_lastrate,ld_lastdate,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF //查询合同号 Long ll_buybargainid, ll_buybargainprintid String ls_buybargaincode IF uo_price.uof_getmtrlsptbuybargain(moneyid, sptid, arg_mtrlid,arg_unit,arg_status,arg_woodcode,arg_pcode,arg_jgdscrp,& ll_buybargainid, ll_buybargainprintid, ls_buybargaincode,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF it_mxbt++ changemx[it_mxbt].printid = it_mxbt changemx[it_mxbt].mtrlid = arg_mtrlid changemx[it_mxbt].unit = arg_unit changemx[it_mxbt].enprice = arg_enprice //原单价 - 采购单位 changemx[it_mxbt].rebate = arg_rebate //折扣 changemx[it_mxbt].price = Round(arg_enprice * arg_rebate,5) //折后单价 - 采购单位 changemx[it_mxbt].wareprice = Round(changemx[it_mxbt].price/arg_rate,5) //折后单价 - 库存单位 changemx[it_mxbt].rate = arg_rate changemx[it_mxbt].status = arg_status changemx[it_mxbt].woodcode = arg_woodcode changemx[it_mxbt].pcode = arg_pcode changemx[it_mxbt].jgdscrp = arg_jgdscrp changemx[it_mxbt].lastprice = i_lastprice changemx[it_mxbt].lastdate = ld_lastdate changemx[it_mxbt].effdate = arg_effdate changemx[it_mxbt].effdate_end = arg_effdate_end changemx[it_mxbt].sptmtrlname = arg_sptmtrlname changemx[it_mxbt].Dscrp = arg_dscrp changemx[it_mxbt].qty = arg_qty changemx[it_mxbt].qty1 = arg_qty1 changemx[it_mxbt].hisflag = arg_hisflag changemx[it_mxbt].taskflag = arg_taskflag changemx[it_mxbt].wareflag = arg_wareflag changemx[it_mxbt].sdate = arg_sdate changemx[it_mxbt].edate = arg_edate changemx[it_mxbt].buybargainid = ll_buybargainid changemx[it_mxbt].buybargainprintid = ll_buybargainprintid changemx[it_mxbt].buybargaincode = ls_buybargaincode ext: IF rslt = 0 THEN p_clearmx() RETURN rslt */ end function public function integer acceptmx (s_spt_price_changemx s_mx, ref string arg_msg);Int rslt = 1 Decimal i_lastprice,i_lastrate, i_lastzqrate DateTime ld_lastdate Long cnt datetime ldt_effdate ldt_effdate = datetime(today(),time(0)) IF it_newbegin = False And it_updatebegin = False THEN rslt = 0 arg_msg = "非编辑状态不可以使用,操作取消" GOTO ext END IF //清除空值 IF IsNull(s_mx.printid) THEN s_mx.printid = 0 IF IsNull(s_mx.mtrlid) THEN s_mx.mtrlid = 0 IF IsNull(s_mx.mtrlcode) THEN s_mx.mtrlcode = '' IF IsNull(s_mx.status) THEN s_mx.status = '' IF IsNull(s_mx.dscrp) THEN s_mx.dscrp = '' IF IsNull(s_mx.enprice) THEN s_mx.enprice = 0 IF IsNull(s_mx.rebate) THEN s_mx.rebate = 1 IF IsNull(s_mx.unit) THEN s_mx.unit = '' IF IsNull(s_mx.rate) THEN s_mx.rate = 1 IF s_mx.rate = 0 THEN s_mx.rate = 1 IF IsNull(s_mx.qty) THEN s_mx.qty = 0 IF IsNull(s_mx.qty1) THEN s_mx.qty1 = 0 IF IsNull(s_mx.hisflag) THEN s_mx.hisflag = 1 IF IsNull(s_mx.taskflag) THEN s_mx.taskflag = 0 IF IsNull(s_mx.wareflag) THEN s_mx.wareflag = 0 IF s_mx.mtrlid = 0 And s_mx.enprice = 0 THEN rslt = 1 GOTO ext END IF IF s_mx.unit = '' THEN arg_msg = "请选择单位" rslt = 0 GOTO ext END IF s_mx.effdate = DateTime(Date(s_mx.effdate),Time(0)) s_mx.effdate_end = DateTime(Date(s_mx.effdate_end),Time(23:59:59)) IF s_mx.taskflag = 0 And s_mx.wareflag = 0 THEN SetNull(s_mx.sdate) SetNull(s_mx.edate) ELSE s_mx.sdate = DateTime(Date(s_mx.sdate),Time(0)) s_mx.edate = DateTime(Date(s_mx.edate),23:59:59) IF Date(s_mx.sdate) < 2000-01-01 THEN arg_msg = "请填写开始时间" rslt = 0 GOTO ext END IF IF Date(s_mx.edate) < 2000-01-01 THEN arg_msg = "请填写结束时间" rslt = 0 GOTO ext END IF END IF IF uo_price.uof_sptmtrlprice_get(sptid,moneyid,s_mx.mtrlid,s_mx.unit,s_mx.status,s_mx.woodcode,s_mx.pcode,s_mx.jgdscrp,ldt_effdate,i_lastprice,i_lastzqrate,i_lastrate,ld_lastdate,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF //改成传入 20131014 ////查询合同号 //Long ll_buybargainid, ll_buybargainprintid //String ls_buybargaincode //IF uo_price.uof_getmtrlsptbuybargain(moneyid, sptid, s_mx.mtrlid,s_mx.unit,s_mx.status,s_mx.woodcode,s_mx.pcode,s_mx.jgdscrp,& // ll_buybargainid, ll_buybargainprintid, ls_buybargaincode,arg_msg) = 0 THEN // rslt = 0 // GOTO ext //END IF it_mxbt++ changemx[it_mxbt].printid = it_mxbt changemx[it_mxbt].mtrlid = s_mx.mtrlid changemx[it_mxbt].unit = s_mx.unit changemx[it_mxbt].enprice = s_mx.enprice //原单价 - 采购单位 changemx[it_mxbt].rebate = s_mx.rebate //折扣 changemx[it_mxbt].price = Round(s_mx.enprice * s_mx.rebate,5) //折后单价 - 采购单位 changemx[it_mxbt].wareprice = Round(changemx[it_mxbt].price/s_mx.rate,5) //折后单价 - 库存单位 changemx[it_mxbt].rate = s_mx.rate changemx[it_mxbt].status = s_mx.status changemx[it_mxbt].woodcode = s_mx.woodcode changemx[it_mxbt].pcode = s_mx.pcode changemx[it_mxbt].jgdscrp = s_mx.jgdscrp changemx[it_mxbt].lastprice = i_lastprice changemx[it_mxbt].lastdate = ld_lastdate changemx[it_mxbt].effdate = s_mx.effdate changemx[it_mxbt].effdate_end = s_mx.effdate_end changemx[it_mxbt].sptmtrlname = s_mx.sptmtrlname changemx[it_mxbt].Dscrp = s_mx.dscrp changemx[it_mxbt].qty = s_mx.qty changemx[it_mxbt].qty1 = s_mx.qty1 changemx[it_mxbt].hisflag = s_mx.hisflag changemx[it_mxbt].taskflag = s_mx.taskflag changemx[it_mxbt].wareflag = s_mx.wareflag changemx[it_mxbt].sdate = s_mx.sdate changemx[it_mxbt].edate = s_mx.edate changemx[it_mxbt].buybargainid = s_mx.buybargainid changemx[it_mxbt].buybargainprintid = s_mx.buybargainprintid changemx[it_mxbt].buybargaincode = s_mx.buybargaincode ext: IF rslt = 0 THEN p_clearmx() RETURN rslt end function on uo_spt_price_change.create call super::create TriggerEvent( this, "constructor" ) end on on uo_spt_price_change.destroy TriggerEvent( this, "destructor" ) call super::destroy end on event constructor;uo_price = CREATE uo_spt_price end event event destructor;destroy uo_price end event