$PBExportHeader$uo_quote.sru forward global type uo_quote from nonvisualobject end type type s_quotemx from structure within uo_quote end type end forward type s_quotemx from structure long mtrlid string mtrlcode string mtrlname string mtrlmode string unit long printid decimal { 10 } maxprice decimal { 10 } planprice string mxdscrp decimal { 10 } wfjgprice decimal { 10 } profit_margin decimal { 10 } sumprice decimal { 10 } sumprice_1 decimal { 10 } outcost decimal { 10 } mancost decimal { 10 } mtrlcost string pfcode string status string woodcode string pcode decimal { 10 } qty decimal { 10 } qty1 decimal { 5 } rebate decimal { 10 } addqty string formula decimal { 10 } lastprice string dscrp_text string mxdscrp2 string mxdscrp3 string mxdscrp4 string newunit end type global type uo_quote from nonvisualobject end type global uo_quote uo_quote type variables PUBLIC PROTECTEDWRITE Long scid = 0 PUBLIC PROTECTEDWRITE Long quoteID = 0 PUBLIC PROTECTEDWRITE String quoteCode = '' PUBLIC PROTECTEDWRITE DateTime opdate PUBLIC PROTECTEDWRITE String operator = '' PUBLIC PROTECTEDWRITE String Permit_emp = ''//审核操作员 public protectedwrite datetime moddate //修改时间,自动 public protectedwrite string modemp //修改操作员 public protectedwrite int flag=0 //审核标志 public protectedwrite datetime auditingdate //审核时间 Long custID = 0 String Assign_emp DateTime quotedate String dscrp String dscrp2 string relcode long moneyid int billtype datetime sendTime string sendUser,fiebrelcode Transaction commit_transaction PRIVATE: s_quotemx quotemx[] //明细结构数组 Long it_MXBT = 0 //明细结构数组末指针 Boolean IT_NEWBEGIN = FALSE //新建标志 Boolean IT_UPDATEBEGIN = FALSE//修改标志 end variables forward prototypes public function integer p_reset () public function integer p_clearmx () public function integer newbegin (long arg_scid, ref string arg_msg) public function integer save (string arg_operator, ref string arg_msg, boolean arg_ifcommit) public function integer add_dscrp (long arg_scid, long arg_quoteid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit) public function integer cancel (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit) public function integer p_getinfo (long arg_scid, long arg_quoteid, ref string arg_msg) public function integer updatebegin (long arg_scid, long arg_quoteid, ref string arg_msg) public function integer audit (long arg_scid, long arg_quoteid, string arg_emp, ref string arg_msg, boolean arg_ifcommit) public function integer cancelaudit (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit) public function integer uof_audit_mx (long arg_scid, long arg_quoteid, long arg_printid, integer arg_flag, string arg_opemp, ref string arg_msg, boolean arg_ifcommit) public function integer uof_update_mx (long arg_scid, long arg_quoteid, long arg_printid, decimal arg_sumprice, decimal arg_sumprice_1, decimal arg_profit_margin, decimal arg_mtrlcost, decimal arg_mancost, decimal arg_outcost, decimal arg_wfjgprice, string arg_pfcode, s_quote_rqmtrl arg_rqmtrl, s_quote_workprice arg_workprice, ref string arg_msg, boolean arg_ifcommit) public function integer acceptmx (long arg_mtrlid, string arg_mtrlcode, string arg_mtrlname, string arg_mtrlmode, string arg_unit, string arg_mxdscrp, ref string arg_msg, long arg_printid, decimal arg_sumprice, decimal arg_sumprice_1, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_maxprice, decimal arg_planprice, decimal arg_profit_margin, decimal arg_wfjgprice, decimal arg_outcost, decimal arg_mancost, decimal arg_mtrlcost, decimal arg_qty, decimal arg_qty1, decimal arg_rebate, decimal arg_addqty, string arg_formula, string arg_dscrp_text) public function integer sec_audit (long arg_scid, long arg_quoteid, string arg_emp, ref string arg_msg, boolean arg_ifcommit) public function integer getinfo (long arg_scid, long arg_quoteid, ref string arg_msg) public function integer cancelsecaudit (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit) public function integer uof_stop_mx (long arg_scid, long arg_quoteid, long arg_printid, integer arg_flag, string arg_opemp, ref string arg_msg, boolean arg_ifcommit) public function integer acceptmx (long arg_mtrlid, string arg_mtrlcode, string arg_mtrlname, string arg_mtrlmode, string arg_unit, string arg_mxdscrp, ref string arg_msg, long arg_printid, decimal arg_sumprice, decimal arg_sumprice_1, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_maxprice, decimal arg_planprice, decimal arg_profit_margin, decimal arg_wfjgprice, decimal arg_outcost, decimal arg_mancost, decimal arg_mtrlcost, decimal arg_qty, decimal arg_qty1, decimal arg_rebate, decimal arg_addqty, string arg_formula, string arg_dscrp_text, string arg_mxdscrp2, string arg_mxdscrp3, readonly string arg_mxdscrp4, string arg_newunit) end prototypes public function integer p_reset ();//INT p_RESET() //清除对象及其明细 //taskid=0 //taskcode='' //operator='' //relcode = '' //status=0 it_newbegin=FALSE it_updatebegin=FALSE //清除明细 P_CLEARMX() RETURN 1 end function public function integer p_clearmx ();//INT p_clearmx() //清除明细 it_mxbt=0 RETURN 1 end function public function integer newbegin (long arg_scid, ref string arg_msg);//重置对象,设定业务类型与关联ID,准备建立新单 //0 fail 1 success long rslt=1,CNT=0 if arg_scid < 0 then arg_msg = '请选择分部' rslt = 0 goto ext end if p_reset() it_newbegin=TRUE it_updatebegin=FALSE scid=arg_scid quoteid = 0 ext: if rslt = 0 then p_reset() return rslt end function public function integer save (string arg_operator, ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1,cnt = 0,i DateTime server_dt Long ll_quoteid String ls_sccode IF IsNull(dscrp) THEN dscrp = '' IF IsNull(dscrp2) THEN dscrp2 = '' IF IsNull(assign_emp) THEN assign_emp = '' IF IsNull(arg_operator) THEN arg_operator = '' IF IsNull(sendUser) THEN sendUser = '' IF IsNull(fiebrelcode) THEN fiebrelcode = '' operator = arg_operator IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN rslt = 0 arG_MSG = "非编辑状态不可以提交" GOTO ext END IF IF Trim(assign_emp) = '' THEN rslt = 0 arG_MSG = "请输入报价单经手人" GOTO ext END IF cnt = 0 SELECT count(*) INTO :cnt FROM u_cust Where cusid = :custID USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arG_MSG = "查询操作失败,客户资料" GOTO ext END IF IF cnt = 0 THEN rslt = 0 arG_MSG = "客户未定义或错误" GOTO ext END IF 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 f_check_inoutdate(0,quotedate,true,arG_MSG) = 0 THEN rslt = 0 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_user Where username = :arg_operator USING commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arG_MSG = "查询操作失败,操作员!" GOTO ext END IF IF cnt = 0 THEN rslt = 0 arG_MSG = "操作员姓名未登记或已取消!" GOTO ext END IF opdate = server_dt //填写单据建立时间(最近修改时间) ////////////////////////////////////////////////// //开始区分:新建/更新 处理 IF quoteID = 0 THEN //新建 ll_quoteid = f_sys_scidentity(scid,"u_quote","quoteID",arG_MSG,TRUE,commit_transaction) //数据commit事务) IF ll_quoteid <= 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 quoteCode = getid(scid,ls_sccode + 'BJ',Date(server_dt),FALSE,commit_transaction) IF quoteCode = "err" THEN quoteCode = '' rslt = 0 arG_MSG = "无法获取报价单编号"+"~n"+commit_transaction.SQLErrText GOTO ext END IF INSERT INTO u_quote ( scid, quoteid, quoteCode, cusID, quotedate, Assign_Emp, relcode, flag, Dscrp, Dscrp2, opemp, opdate, fiebrelcode, billtype, moneyid ) VALUES ( :scid, :ll_quoteid, :quoteCode, :custID, :quotedate, :Assign_Emp, :relcode, 0, :Dscrp, :Dscrp2, :operator, :server_dt, :fiebrelcode, :billtype, :moneyid) USING commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arG_MSG = "插入报价单操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF //读取新quoteid quoteID = ll_quoteid ELSE //////////////////////////////////////////////// //更新 UPDATE u_quote SET cusID = :custID, quotedate = :quotedate, Assign_Emp = :Assign_Emp, Dscrp = :Dscrp, Dscrp2 = :Dscrp2, moddate = getdate(), Modemp = :publ_operator, relcode = :relcode, fiebrelcode = :fiebrelcode, billtype = :billtype, moneyid = :moneyid WHERE u_quote.quoteid = :quoteID AND scid = :scid AND flag = 0 USING commit_transaction; IF commit_transaction.SQLCode <> 0 OR sqlca.SQLNRows <= 0 THEN rslt = 0 arG_MSG = "更新报价单操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF //删除原有明细 DELETE FROM u_quotemx WHERE quoteID = :quoteID AND scid = :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_quoteMx_dscrp WHERE quoteID = :quoteID AND scid = :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_quoterqmtrl WHERE quoteID = :quoteID AND scid = :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_quoteworkprice WHERE quoteID = :quoteID AND scid = :scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arG_MSG = "删除明细成本操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF END IF FOR i = 1 TO it_mxbt INSERT INTO u_quotemx ( scid, quoteid, mtrlid, printid, maxprice, planprice, mxdscrp, sumprice, sumprice_1, pfcode, status, woodcode, pcode, profit_margin, wfjgprice, outcost, mancost, mtrlcost, qty, rebate, addqty, formula, lastprice, mtrlcode, mtrlname, mtrlmode, unit, qty1, mxdscrp2, mxdscrp3, mxdscrp4, newunit) VALUES (:scid, :quoteID, :quotemx[i].mtrlid, :quotemx[i].printid, :quotemx[i].maxprice , :quotemx[i].planprice , :quotemx[i].mxdscrp, :quotemx[i].sumprice, :quotemx[i].sumprice_1, :quotemx[i].pfcode, :quotemx[i].status, :quotemx[i].woodcode, :quotemx[i].pcode, :quotemx[i].profit_margin, :quotemx[i].wfjgprice, :quotemx[i].outcost, :quotemx[i].mancost, :quotemx[i].mtrlcost, :quotemx[i].qty, :quotemx[i].rebate, :quotemx[i].addqty, :quotemx[i].formula, :quotemx[i].lastprice, :quotemx[i].mtrlcode, :quotemx[i].mtrlname, :quotemx[i].mtrlmode, :quotemx[i].unit, :quotemx[i].qty1, :quotemx[i].mxdscrp2, :quotemx[i].mxdscrp3, :quotemx[i].mxdscrp4, :quotemx[i].newunit) USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN if it_newbegin then quoteID = 0 rslt = 0 arG_MSG = "插入明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF IF Len(Trim(quotemx[i].dscrp_text)) > 0 THEN INSERT INTO u_quotemx_dscrp (scid, quoteid, printid, dscrp) VALUES (:scid, :quoteID, :quotemx[i].printid, :quotemx[i].dscrp_text) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN if it_newbegin then quoteID = 0 //还原quoteID rslt = 0 arG_MSG = "插入明细备注操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF END IF NEXT it_newbegin = FALSE it_updatebegin = FALSE ext: IF rslt = 0 THEN p_clearmx() ROLLBACK USING commit_transaction; ELSEIF arg_ifcommit AND rslt = 1 THEN COMMIT USING commit_transaction; END IF Return(rslt) end function public function integer add_dscrp (long arg_scid, long arg_quoteid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit);//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 IF p_getinfo(arg_scid,arg_quoteid,arG_MSG) = 0 THEN rslt = 0 GOTO ext END IF IF flag = 0 THEN rslt = 0 arG_MSG = "待审核状态下不可用" GOTO ext END IF UPDATE u_quote SET DSCRP = DSCRP+' '+:arg_newdescppart Where u_quote.quoteid = :arg_quoteid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arG_MSG = "因网络或其它原因导致添加报价单备注操作失败"+"~n"+commit_transaction.SQLErrText ROLLBACK USING commit_transaction; GOTO ext END IF DSCRP = DSCRP+' '+arg_newdescppart it_newbegin = FALSE it_updatebegin = FALSE ext: IF arg_ifcommit AND rslt = 1 THEN COMMIT USING commit_transaction; END IF p_reset() Return (rslt) end function public function integer cancel (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit);//删除未审核的报价单 //0 FAIL, 1 SUCCESS Int rslt = 1 IF arg_quoteid <= 0 THEN rslt = 0 ARG_MSG = '错误报价单唯一码' GOTO ext END IF IF p_getinfo(arg_scid,arg_quoteid,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_quoterqmtrl Where u_quoterqmtrl.quoteid = :arg_quoteid AND u_quoterqmtrl.scid = :arg_scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 ARG_MSG = "删除报价单用料明细操作失败"+"~n"+SQLCA.SQLErrText ROLLBACK USING commit_transaction; GOTO ext END IF DELETE FROM u_quotemx Where u_quotemx.quoteid = :arg_quoteid AND u_quotemx.scid = :arg_scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 ARG_MSG = "删除报价单明细操作失败"+"~n"+SQLCA.SQLErrText ROLLBACK USING commit_transaction; GOTO ext END IF DELETE FROM u_quote Where u_quote.quoteid = :arg_quoteid AND u_quote.scid = :arg_scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 ARG_MSG = "删除报价单操作失败"+"~n"+commit_transaction.SQLErrText ROLLBACK USING commit_transaction; GOTO ext END IF it_newbegin = FALSE it_updatebegin = FALSE IF arg_ifcommit THEN COMMIT USING commit_transaction; END IF ext: p_reset() Return (rslt) end function public function integer p_getinfo (long arg_scid, long arg_quoteid, ref string arg_msg);Int rslt = 1 SELECT quotecode, cusid, quotedate, assign_emp, relcode, dscrp, opemp, opdate, flag, billtype INTO :quotecode, :custid, :quotedate, :assign_emp, :relcode, :dscrp, :operator, :opdate, :flag, :billtype FROM u_quote Where u_quote.quoteid = :arg_quoteid AND u_quote.scid = :arg_scid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 ARG_MSG = '查询报价单内容失败(错误订单唯一码)'+sqlca.SQLErrText GOTO ext END IF scid = arg_scid quoteid = arg_quoteid ext: RETURN rslt end function public function integer updatebegin (long arg_scid, long arg_quoteid, ref string arg_msg);//UPDATEbegin(long arg_taskid,ref string arg_msg) //从置对象,设定业务类型与关联ID,准备更新单 //0 fail 1 success long rslt=1,CNT=0 if arg_scid < 0 then arg_msg = '请选择分部' rslt = 0 goto ext end if IF arg_quoteid<=0 THEN rslt=0 ARG_MSG='错误报价单唯一码' goto ext end if if p_getinfo(arg_scid,arg_quoteid,arg_msg)=0 then rslt=0 goto ext end if if flag=1 then rslt=0 ARG_MSG='已经处于审核状态,不可以修改,要修改请先撤销审核' goto ext end if it_newbegin=FALSE it_updatebegin=TRUE p_clearmx() //清除明细 scid=arg_scid quoteid=arg_quoteid ext: if rslt=0 then p_reset() return rslt end function public function integer audit (long arg_scid, long arg_quoteid, string arg_emp, ref string arg_msg, boolean arg_ifcommit); Int rslt = 1,cnt = 0 IF arg_quoteid <= 0 THEN rslt = 0 ARG_MSG = '错误报价单唯一码' GOTO ext END IF IF p_getinfo(arg_scid,arg_quoteid,ARG_MSG) = 0 THEN rslt = 0 GOTO ext END IF IF flag = 1 THEN rslt = 0 ARG_MSG = "报价单已经审核,操作取消" GOTO ext END IF cnt = 0 SELECT count(*) INTO :cnt FROM u_user Where username = :arg_emp USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 ARG_MSG = "查询操作失败,操作员!" GOTO ext END IF IF cnt = 0 THEN rslt = 0 ARG_MSG = "操作员姓名未登记或已取消!" GOTO ext END IF //更新审核标记 UPDATE u_quote SET auditingrep = :arg_emp, auditingdate = getdate(), flag = 4 Where u_quote.quoteid = :arg_quoteid AND u_quote.scid = :arg_scid AND u_quote.flag = 0 USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 ARG_MSG = "单据审核操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF flag = 4 it_newbegin = FALSE it_updatebegin = FALSE ext: IF rslt = 0 THEN ROLLBACK USING commit_transaction; ELSEIF arg_ifcommit THEN COMMIT USING commit_transaction; END IF p_reset() Return (rslt) end function public function integer cancelaudit (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1,cnt = 0 DateTime ls_auditingdate SetNull(ls_auditingdate) IF arg_quoteid <= 0 THEN rslt = 0 ARG_MSG = '错误报价单唯一码' GOTO ext END IF IF p_getinfo(arg_scid,arg_quoteid,ARG_MSG) = 0 THEN rslt = 0 GOTO ext END IF IF flag = 0 THEN rslt = 0 ARG_MSG = "报价只有在已审核状态才可以执行撤消审核,请核对" GOTO ext END IF UPDATE u_quote SET flag = 0,auditingrep = '',auditingdate = :ls_auditingdate Where u_quote.quoteid = :arg_quoteid AND u_quote.scid = :arg_scid AND u_quote.flag = 4 USING commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 ARG_MSG = "报价单撤消审核操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF //删除旧有物料需求记录 DELETE FROM u_quoterqmtrl WHERE u_quoterqmtrl.quoteid = :arg_quoteid AND u_quoterqmtrl.scid = :arg_scid; IF sqlca.SQLCode <> 0 THEN ROLLBACK; ARG_MSG = '删除旧有物料需求记录失败 '+sqlca.SQLErrText rslt = 0 GOTO ext END IF it_newbegin = FALSE it_updatebegin = FALSE ext: IF rslt = 0 THEN ROLLBACK USING commit_transaction; ELSEIF arg_ifcommit THEN COMMIT USING commit_transaction; END IF p_reset() Return (rslt) end function public function integer uof_audit_mx (long arg_scid, long arg_quoteid, long arg_printid, integer arg_flag, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Int li_flag DateTime null_dt SetNull(null_dt) SELECT flag INTO :li_flag FROM u_quote WHERE scid = :arg_scid AND quoteid = :arg_quoteid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询报价单审核标记失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF IF li_flag = 0 THEN IF arg_flag = 1 THEN arg_msg = '报价单还未审核,不能明细审核' ELSE arg_msg = '报价单还未审核,不能明细撤审' END IF rslt = 0 GOTO ext END IF SELECT flag INTO :li_flag FROM u_quotemx WHERE scid = :arg_scid AND quoteid = :arg_quoteid AND printid = :arg_printid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询明细审核标记失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF IF arg_flag = 1 THEN IF li_flag = 1 THEN arg_msg = '明细已审核不能再审核' rslt = 0 GOTO ext END IF ELSE IF li_flag = 0 THEN arg_msg = '明细还未审核不能撤审' rslt = 0 GOTO ext END IF END IF IF arg_flag = 1 THEN UPDATE u_quotemx SET flag = 1, auditemp = :arg_opemp, auditdate = getdate() WHERE scid = :arg_scid AND quoteid = :arg_quoteid AND printid = :arg_printid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '审核明细失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF ELSE UPDATE u_quotemx SET flag = 0, auditemp = '', auditdate = :null_dt WHERE scid = :arg_scid AND quoteid = :arg_quoteid AND printid = :arg_printid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '审核明细失败,'+commit_transaction.SQLErrText 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 uof_update_mx (long arg_scid, long arg_quoteid, long arg_printid, decimal arg_sumprice, decimal arg_sumprice_1, decimal arg_profit_margin, decimal arg_mtrlcost, decimal arg_mancost, decimal arg_outcost, decimal arg_wfjgprice, string arg_pfcode, s_quote_rqmtrl arg_rqmtrl, s_quote_workprice arg_workprice, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Int li_flag Long cnt,ll_mtrlid,ll_i SELECT flag,mtrlid INTO :li_flag,:ll_mtrlid FROM u_quotemx WHERE scid = :arg_scid AND quoteid = :arg_quoteid AND printid = :arg_printid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询明细审核标记失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF IF li_flag = 1 THEN arg_msg = '明细已审核不能修改' rslt = 0 GOTO ext END IF //SELECT count(*) INTO :cnt // FROM u_mtrl_pf // WHERE mtrlid = :ll_mtrlid // AND pfcode = :arg_pfcode USING commit_transaction; //IF commit_transaction.SQLCode <> 0 THEN // arg_msg = '查询明细物料清单资料失败,'+commit_transaction.SQLErrText // rslt = 0 // GOTO ext //END IF // //IF cnt = 0 THEN // arg_msg = '明细物料不存在清单:'+arg_pfcode // rslt = 0 // GOTO ext //END IF DELETE FROM u_quoterqmtrl WHERE scid = :arg_scid AND quoteid = :arg_quoteid and printid = :arg_printid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '删除报价明细物料成本明细失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF IF UpperBound(arg_rqmtrl.mtrlid) > 0 THEN FOR ll_i = 1 TO UpperBound(arg_rqmtrl.mtrlid) INSERT INTO u_quoterqmtrl (scid, quoteid, printid, pid, MtrlID, RqQty, newprice, planprice, lp, pmtrlid, costprice) VALUES (:arg_scid, :arg_quoteid, :arg_printid, :arg_rqmtrl.printid[ll_i], :arg_rqmtrl.mtrlid[ll_i], :arg_rqmtrl.RqQty[ll_i], :arg_rqmtrl.newprice[ll_i], :arg_rqmtrl.planprice[ll_i], :arg_rqmtrl.lp[ll_i], :arg_rqmtrl.pmtrlid[ll_i], :arg_rqmtrl.costprice[ll_i]) USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '建立报价明细物料成本明细失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF NEXT END IF DELETE FROM u_quoteworkprice WHERE scid = :arg_scid AND quoteid = :arg_quoteid and printid = :arg_printid USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '删除报价明细工价信息明细失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF IF UpperBound(arg_workprice.mtrlid) > 0 THEN FOR ll_i = 1 TO UpperBound(arg_workprice.mtrlid) INSERT INTO u_quoteworkprice (scid, quoteid, printid, pid, MtrlID, proid, proorder, procode, proname, wrkgrpid, workprice, workqty, dscrp, cost) VALUES (:arg_scid, :arg_quoteid, :arg_printid, :arg_workprice.pid[ll_i], :arg_workprice.mtrlid[ll_i], :arg_workprice.proid[ll_i], :arg_workprice.proorder[ll_i], :arg_workprice.procode[ll_i], :arg_workprice.proname[ll_i], :arg_workprice.wrkgrpid[ll_i], :arg_workprice.workprice[ll_i], :arg_workprice.workqty[ll_i], :arg_workprice.dscrp[ll_i], :arg_workprice.cost[ll_i]) USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '建立报价明细工价信息明细失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF NEXT END IF UPDATE u_quotemx SET sumprice = :arg_sumprice, sumprice_1 = :arg_sumprice_1, profit_margin = :arg_profit_margin, mtrlcost = :arg_mtrlcost, mancost = :arg_mancost, outcost = :arg_outcost, wfjgprice = :arg_wfjgprice, pfcode = :arg_pfcode WHERE scid = :arg_scid AND quoteid = :arg_quoteid AND printid = :arg_printid 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 acceptmx (long arg_mtrlid, string arg_mtrlcode, string arg_mtrlname, string arg_mtrlmode, string arg_unit, string arg_mxdscrp, ref string arg_msg, long arg_printid, decimal arg_sumprice, decimal arg_sumprice_1, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_maxprice, decimal arg_planprice, decimal arg_profit_margin, decimal arg_wfjgprice, decimal arg_outcost, decimal arg_mancost, decimal arg_mtrlcost, decimal arg_qty, decimal arg_qty1, decimal arg_rebate, decimal arg_addqty, string arg_formula, string arg_dscrp_text);Long rslt = 1,cnt = 0,i Decimal ld_newprice,ld_planprice String ls_pfcode Decimal ld_lastprice IF it_newbegin = False And it_updatebegin = False THEN rslt = 0 arg_msg = "非编辑状态不可以使用,操作取消" GOTO ext END IF //清除空值 IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0 IF IsNull(arg_mtrlcode) THEN arg_mtrlcode = '' IF IsNull(arg_mtrlname) THEN arg_mtrlname = '' IF IsNull(arg_mtrlmode) THEN arg_mtrlmode = '' IF IsNull(arg_unit) THEN arg_unit = '' IF IsNull(arg_sumprice) THEN arg_sumprice = 0 IF IsNull(arg_sumprice_1) THEN arg_sumprice_1 = 0 IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = '' IF IsNull(arg_printid) THEN arg_printid = 0 IF IsNull(arg_status) THEN arg_status = '' IF IsNull(arg_woodcode) THEN arg_woodcode = '' IF IsNull(arg_pcode) THEN arg_pcode = '' IF IsNull(arg_qty) THEN arg_qty = 0 IF IsNull(arg_qty1) THEN arg_qty1 = 0 IF IsNull(arg_rebate) THEN arg_rebate = 1 IF IsNull(arg_addqty) THEN arg_addqty = 0 IF IsNull(arg_formula) THEN arg_formula = '' IF IsNull(arg_dscrp_text) THEN arg_dscrp_text = '' IF billtype = 0 THEN IF arg_mtrlid = 0 THEN // 如果物料编号为空,则不作任何处理 rslt = 1 GOTO ext END IF END IF IF arg_printid = 0 THEN // 如果序号为空,则不作任何处理 rslt = 1 GOTO ext END IF IF billtype = 0 or arg_mtrlid > 0 THEN SELECT planprice INTO :ld_planprice FROM u_mtrldef Where u_mtrldef.mtrlid = :arg_mtrlid ; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询物料:"+arg_mtrlcode+'计划价失败' GOTO ext END IF SELECT price INTO :ld_newprice FROM v_maxprice_cusprice Where mtrlid = :arg_mtrlid; IF sqlca.SQLCode <> 0 Or IsNull(ld_newprice) THEN ld_newprice = 0 SELECT top 1 u_quotemx.sumprice_1 INTO :ld_lastprice FROM u_quotemx,u_quote WHERE u_quotemx.quoteid = u_quote.quoteid AND u_quotemx.status = :arg_status AND u_quotemx.woodcode = :arg_woodcode AND u_quotemx.pcode = :arg_pcode AND u_quote.cusid = :custID AND u_quote.flag = 1 Order By u_quote.quotedate Desc; IF sqlca.SQLCode <> 0 Or IsNull(ld_lastprice) THEN ld_lastprice = 0 ls_pfcode = f_get_dft_pf(arg_mtrlid) END IF FOR i = 1 To it_mxbt //合并重复项(产品) IF quotemx[i].mtrlid = arg_mtrlid And & quotemx[i].mtrlcode = arg_mtrlcode And & quotemx[i].status = arg_status And & quotemx[i].woodcode = arg_woodcode And & quotemx[i].pcode = arg_pcode And & quotemx[i].qty = arg_qty And & quotemx[i].qty1 = arg_qty1 THEN rslt = 0 arg_msg = "存在相同的产品,在"+quotemx[i].mtrlcode+",请自行手动合并" GOTO ext END IF NEXT //写入内容 it_mxbt++ quotemx[it_mxbt].mtrlid = arg_mtrlid quotemx[it_mxbt].mtrlcode = arg_mtrlcode quotemx[it_mxbt].mtrlname = arg_mtrlname quotemx[it_mxbt].mtrlmode = arg_mtrlmode quotemx[it_mxbt].unit = arg_unit quotemx[it_mxbt].maxprice = ld_newprice quotemx[it_mxbt].planprice = ld_planprice quotemx[it_mxbt].mxdscrp = arg_mxdscrp quotemx[it_mxbt].printid = arg_printid quotemx[it_mxbt].sumprice = arg_sumprice quotemx[it_mxbt].sumprice_1 = arg_sumprice_1 quotemx[it_mxbt].pfcode = ls_pfcode quotemx[it_mxbt].status = arg_status quotemx[it_mxbt].woodcode = arg_woodcode quotemx[it_mxbt].pcode = arg_pcode quotemx[it_mxbt].maxprice = arg_maxprice quotemx[it_mxbt].planprice = arg_planprice quotemx[it_mxbt].profit_margin = arg_profit_margin quotemx[it_mxbt].wfjgprice = arg_wfjgprice quotemx[it_mxbt].outcost = arg_outcost quotemx[it_mxbt].mancost = arg_mancost quotemx[it_mxbt].mtrlcost = arg_mtrlcost quotemx[it_mxbt].qty = arg_qty quotemx[it_mxbt].qty1 = arg_qty1 quotemx[it_mxbt].rebate = arg_rebate quotemx[it_mxbt].addqty = arg_addqty quotemx[it_mxbt].formula = arg_formula quotemx[it_mxbt].lastprice = ld_lastprice quotemx[it_mxbt].dscrp_text = arg_dscrp_text ext: IF rslt = 0 THEN p_clearmx() Return(rslt) end function public function integer sec_audit (long arg_scid, long arg_quoteid, string arg_emp, ref string arg_msg, boolean arg_ifcommit); Int rslt = 1,cnt = 0 Long i uo_cusprice uo_update_cusprice uo_update_cusprice = CREATE uo_cusprice IF arg_quoteid <= 0 THEN rslt = 0 ARG_MSG = '错误报价单唯一码' GOTO ext END IF //IF uo_option_if_oa_quote = 1 And uo_option_quote_secaudit = 1 and audit_buildtype = 0 THEN // IF f_check_if_oaflow(arg_scid,arg_quoteid,461,ARG_MSG ) = 0 THEN // rslt = 0 // GOTO ext // END IF //END IF IF getinfo(arg_scid,arg_quoteid,ARG_MSG) = 0 THEN rslt = 0 GOTO ext END IF IF flag <> 4 THEN rslt = 0 ARG_MSG = "销售报价单不是在待终审状态,不能执行终审" GOTO ext END IF cnt = 0 SELECT count(*) INTO :cnt FROM u_user Where username = :arg_emp USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 ARG_MSG = "查询操作失败,操作员!" GOTO ext END IF IF cnt = 0 THEN rslt = 0 ARG_MSG = "操作员姓名未登记或已取消!" GOTO ext END IF //if billtype = 0 then // FOR i = 1 TO it_mxbt // IF quotemx[i].sumprice_1 <= 0 THEN // rslt = 0 // ARG_MSG = '第'+String(i)+'行,请输入客户还价' // GOTO ext // END IF // // IF uo_update_cusprice.uof_update_custprice(0,0,custID,& // quotemx[i].mtrlid,quotemx[i].mtrlcode,quotemx[i].status,& // quotemx[i].woodcode,quotemx[i].pcode,& // quoteID,quoteCode,quotedate,quotemx[i].sumprice_1,& // quotemx[i].rebate,quotemx[i].sumprice_1 * quotemx[i].rebate * quotemx[i].qty,2,'',& // quotemx[i].printid,2,moneyid,quotemx[i].qty,quotemx[i].qty1,FALSE,ARG_MSG) = 0 THEN // rslt = 0 // GOTO ext // END IF // NEXT //end if //更新审核标记 UPDATE u_quote SET sec_auditemp = :arg_emp, sec_auditdate = getdate(), flag = 1 Where u_quote.quoteID = :arg_quoteid AND u_quote.scid = :arg_scid AND u_quote.flag = 4 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 arg_ifcommit THEN COMMIT USING commit_transaction; END IF p_reset() Return (rslt) end function public function integer getinfo (long arg_scid, long arg_quoteid, ref string arg_msg);Int rslt = 1 Long i = 1 Long no_mxcheck IF arg_quoteid <= 0 THEN rslt = 0 arg_msg = "非法销售报价单唯一码" GOTO ext END IF rslt = p_getinfo(arg_scid,arg_quoteid,arg_msg) IF rslt = 0 THEN GOTO ext DECLARE cur_quotemx CURSOR FOR SELECT u_quotemx.printid, u_quotemx.mtrlid, u_quotemx.sumprice, u_quotemx.sumprice_1, u_quotemx.qty, u_quotemx.qty1, u_quotemx.mxDscrp, u_quotemx.status, u_quotemx.woodcode, u_quotemx.pcode, u_quotemx.rebate, u_quotemx.mtrlcode, u_quotemx.mtrlname, u_quotemx.mtrlmode, u_quotemx.unit FROM u_quotemx WHERE u_quotemx.scid = :arg_scid AND u_quotemx.quoteid = :arg_quoteid USING commit_transaction; OPEN cur_quotemx; FETCH cur_quotemx INTO :quotemx[i].printid,:quotemx[i].mtrlid, :quotemx[i].sumprice,:quotemx[i].sumprice_1,:quotemx[i].qty,:quotemx[i].qty1,:quotemx[i].mxdscrp, :quotemx[i].status,:quotemx[i].woodcode,:quotemx[i].pcode,:quotemx[i].rebate,:quotemx[i].mtrlcode, :quotemx[i].mtrlname, :quotemx[i].mtrlmode, :quotemx[i].unit; DO WHILE commit_transaction.SQLCode = 0 i++ FETCH cur_quotemx INTO :quotemx[i].printid,:quotemx[i].mtrlid, :quotemx[i].sumprice,:quotemx[i].sumprice_1,:quotemx[i].qty,:quotemx[i].qty1,:quotemx[i].mxdscrp, :quotemx[i].status,:quotemx[i].woodcode,:quotemx[i].pcode,:quotemx[i].rebate,:quotemx[i].mtrlcode, :quotemx[i].mtrlname, :quotemx[i].mtrlmode, :quotemx[i].unit; LOOP close cur_quotemx; SELECT count(*) INTO :no_mxcheck FROM u_quotemx WHERE quoteid = :arg_quoteid 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 it_mxbt = i - 1 it_newbegin = FALSE it_updatebegin = FALSE ext: IF rslt = 0 THEN p_reset() RETURN rslt end function public function integer cancelsecaudit (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1,cnt = 0 Long i DateTime ls_auditingdate SetNull(ls_auditingdate) uo_cusprice uo_update_cusprice uo_update_cusprice = Create uo_cusprice IF arg_quoteid <= 0 THEN rslt = 0 ARG_MSG = '错误报价单唯一码' GOTO ext END IF IF getinfo(arg_scid,arg_quoteid,ARG_MSG) = 0 THEN rslt = 0 GOTO ext END IF IF flag <> 1 THEN rslt = 0 ARG_MSG = "报价只有在已审核状态才可以执行撤销终审,请核对" GOTO ext END IF UPDATE u_quote SET flag = 4, sec_auditemp = '', sec_auditdate = :ls_auditingdate WHERE u_quote.quoteid = :arg_quoteid AND u_quote.scid = :arg_scid AND u_quote.flag = 1 Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 ARG_MSG = "因网络或其它原因导致报价单撤消审核操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF //删除旧有物料需求记录 DELETE FROM u_quoterqmtrl WHERE u_quoterqmtrl.quoteid = :arg_quoteid And u_quoterqmtrl.scid = :arg_scid; IF sqlca.SQLCode <> 0 THEN ROLLBACK; ARG_MSG = '删除旧有物料需求记录失败 '+sqlca.SQLErrText rslt = 0 GOTO ext END IF //IF billtype = 0 THEN // FOR i = 1 To it_mxbt // IF uo_update_cusprice.uof_del_cusprice_auto(custid,quoteid,& // quotemx[i].printid,quotemx[i].mtrlid,quotemx[i].status,& // quotemx[i].woodcode,quotemx[i].pcode,& // 2,moneyid,quotemx[i].qty,quotemx[i].qty1,False,ARG_MSG) = 0 THEN // rslt = 0 // GOTO ext // END IF // NEXT //END IF it_newbegin = False it_updatebegin = False ext: IF rslt = 0 THEN ROLLBACK Using commit_transaction; ELSEIF arg_ifcommit THEN COMMIT Using commit_transaction; END IF Destroy uo_update_cusprice p_reset() Return (rslt) end function public function integer uof_stop_mx (long arg_scid, long arg_quoteid, long arg_printid, integer arg_flag, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Int li_bill_flag,li_mx_flag,li_mx_stopflag DateTime null_dt SetNull(null_dt) SELECT flag INTO :li_bill_flag FROM u_quote WHERE scid = :arg_scid And quoteid = :arg_quoteid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询报价单审核标记失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF IF li_bill_flag = 0 THEN IF arg_flag = 1 THEN arg_msg = '报价单还未审核,不能明细终止' ELSE arg_msg = '报价单还未审核,不能明细终止' END IF rslt = 0 GOTO ext END IF SELECT flag,stopflag INTO :li_mx_flag,:li_mx_stopflag FROM u_quotemx WHERE scid = :arg_scid AND quoteid = :arg_quoteid And printid = :arg_printid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询明细审核标记失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF IF li_mx_flag = 0 THEN arg_msg = '明细未审核,不能终止操作' rslt = 0 GOTO ext END IF IF arg_flag = 1 THEN IF li_mx_stopflag = 1 THEN arg_msg = '明细已终止不能再终止' rslt = 0 GOTO ext END IF UPDATE u_quotemx SET stopflag = 1, stopemp = :arg_opemp, stopdate = getdate() WHERE scid = :arg_scid AND quoteid = :arg_quoteid And printid = :arg_printid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '终止明细失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF ELSE IF li_mx_stopflag = 0 THEN arg_msg = '明细还未终止不能取消终止操作' rslt = 0 GOTO ext END IF UPDATE u_quotemx SET stopflag = 0, stopemp = '', stopdate = :null_dt WHERE scid = :arg_scid AND quoteid = :arg_quoteid And printid = :arg_printid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '取消终止明细失败,'+commit_transaction.SQLErrText 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 acceptmx (long arg_mtrlid, string arg_mtrlcode, string arg_mtrlname, string arg_mtrlmode, string arg_unit, string arg_mxdscrp, ref string arg_msg, long arg_printid, decimal arg_sumprice, decimal arg_sumprice_1, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_maxprice, decimal arg_planprice, decimal arg_profit_margin, decimal arg_wfjgprice, decimal arg_outcost, decimal arg_mancost, decimal arg_mtrlcost, decimal arg_qty, decimal arg_qty1, decimal arg_rebate, decimal arg_addqty, string arg_formula, string arg_dscrp_text, string arg_mxdscrp2, string arg_mxdscrp3, readonly string arg_mxdscrp4, string arg_newunit);Long rslt = 1,cnt = 0,i Decimal ld_newprice,ld_planprice String ls_pfcode Decimal ld_lastprice IF it_newbegin = False And it_updatebegin = False THEN rslt = 0 arg_msg = "非编辑状态不可以使用,操作取消" GOTO ext END IF //清除空值 IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0 IF IsNull(arg_mtrlcode) THEN arg_mtrlcode = '' IF IsNull(arg_mtrlname) THEN arg_mtrlname = '' IF IsNull(arg_mtrlmode) THEN arg_mtrlmode = '' IF IsNull(arg_unit) THEN arg_unit = '' IF IsNull(arg_sumprice) THEN arg_sumprice = 0 IF IsNull(arg_sumprice_1) THEN arg_sumprice_1 = 0 IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = '' IF IsNull(arg_printid) THEN arg_printid = 0 IF IsNull(arg_status) THEN arg_status = '' IF IsNull(arg_woodcode) THEN arg_woodcode = '' IF IsNull(arg_pcode) THEN arg_pcode = '' IF IsNull(arg_qty) THEN arg_qty = 0 IF IsNull(arg_qty1) THEN arg_qty1 = 0 IF IsNull(arg_rebate) THEN arg_rebate = 1 IF IsNull(arg_addqty) THEN arg_addqty = 0 IF IsNull(arg_formula) THEN arg_formula = '' IF IsNull(arg_dscrp_text) THEN arg_dscrp_text = '' IF IsNull(arg_newunit) THEN arg_newunit = '' IF billtype = 0 THEN IF arg_mtrlid = 0 THEN // 如果物料编号为空,则不作任何处理 rslt = 1 GOTO ext END IF END IF IF arg_printid = 0 THEN // 如果序号为空,则不作任何处理 rslt = 1 GOTO ext END IF IF billtype = 0 or arg_mtrlid > 0 THEN SELECT planprice INTO :ld_planprice FROM u_mtrldef Where u_mtrldef.mtrlid = :arg_mtrlid ; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询物料:"+arg_mtrlcode+'计划价失败' GOTO ext END IF SELECT price INTO :ld_newprice FROM v_maxprice_cusprice Where mtrlid = :arg_mtrlid; IF sqlca.SQLCode <> 0 Or IsNull(ld_newprice) THEN ld_newprice = 0 SELECT top 1 u_quotemx.sumprice_1 INTO :ld_lastprice FROM u_quotemx,u_quote WHERE u_quotemx.quoteid = u_quote.quoteid AND u_quotemx.status = :arg_status AND u_quotemx.woodcode = :arg_woodcode AND u_quotemx.pcode = :arg_pcode AND u_quote.cusid = :custID AND u_quote.flag = 1 Order By u_quote.quotedate Desc; IF sqlca.SQLCode <> 0 Or IsNull(ld_lastprice) THEN ld_lastprice = 0 ls_pfcode = f_get_dft_pf(arg_mtrlid) END IF FOR i = 1 To it_mxbt //合并重复项(产品) IF quotemx[i].mtrlid = arg_mtrlid And & quotemx[i].mtrlcode = arg_mtrlcode And & quotemx[i].status = arg_status And & quotemx[i].woodcode = arg_woodcode And & quotemx[i].pcode = arg_pcode And & quotemx[i].qty = arg_qty And & quotemx[i].qty1 = arg_qty1 THEN rslt = 0 arg_msg = "存在相同的产品,在"+quotemx[i].mtrlcode+",请自行手动合并" GOTO ext END IF NEXT //写入内容 it_mxbt++ quotemx[it_mxbt].mtrlid = arg_mtrlid quotemx[it_mxbt].mtrlcode = arg_mtrlcode quotemx[it_mxbt].mtrlname = arg_mtrlname quotemx[it_mxbt].mtrlmode = arg_mtrlmode quotemx[it_mxbt].unit = arg_unit quotemx[it_mxbt].maxprice = ld_newprice quotemx[it_mxbt].planprice = ld_planprice quotemx[it_mxbt].mxdscrp = arg_mxdscrp quotemx[it_mxbt].printid = arg_printid quotemx[it_mxbt].sumprice = arg_sumprice quotemx[it_mxbt].sumprice_1 = arg_sumprice_1 quotemx[it_mxbt].pfcode = ls_pfcode quotemx[it_mxbt].status = arg_status quotemx[it_mxbt].woodcode = arg_woodcode quotemx[it_mxbt].pcode = arg_pcode quotemx[it_mxbt].maxprice = arg_maxprice quotemx[it_mxbt].planprice = arg_planprice quotemx[it_mxbt].profit_margin = arg_profit_margin quotemx[it_mxbt].wfjgprice = arg_wfjgprice quotemx[it_mxbt].outcost = arg_outcost quotemx[it_mxbt].mancost = arg_mancost quotemx[it_mxbt].mtrlcost = arg_mtrlcost quotemx[it_mxbt].qty = arg_qty quotemx[it_mxbt].qty1 = arg_qty1 quotemx[it_mxbt].rebate = arg_rebate quotemx[it_mxbt].addqty = arg_addqty quotemx[it_mxbt].formula = arg_formula quotemx[it_mxbt].lastprice = ld_lastprice quotemx[it_mxbt].dscrp_text = arg_dscrp_text quotemx[it_mxbt].mxdscrp2 = arg_mxdscrp2 quotemx[it_mxbt].mxdscrp3 = arg_mxdscrp3 quotemx[it_mxbt].mxdscrp4 = arg_mxdscrp4 quotemx[it_mxbt].newunit = arg_newunit ext: IF rslt = 0 THEN p_clearmx() Return(rslt) end function on uo_quote.create call super::create TriggerEvent( this, "constructor" ) end on on uo_quote.destroy TriggerEvent( this, "destructor" ) call super::destroy end on global type uo_incase from nonvisualobject end type