$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 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 string dscrp_text string mtrlname string mtrlmode string unit string mxdscrp2 decimal { 10 } paintarea decimal { 10 } commonqty decimal { 10 } customqty decimal { 5 } taxrate decimal { 10 } fprice 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 relcode long moneyid int billtype datetime sendTime string sendUser,fiebrelcode decimal mrate Long audit_buildtype Transaction commit_transaction PRIVATE: s_quotemx quotemx[] //明细结构数组 Long it_MXBT = 0 //明细结构数组末指针 Boolean IT_NEWBEGIN = FALSE //新建标志 Boolean IT_UPDATEBEGIN = FALSE//修改标志 string uo_option_change_status,uo_option_change_woodcode,uo_option_change_pcode int uo_option_if_oa_quote,uo_option_quote_secaudit 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 getinfo (long arg_scid, long arg_quoteid, ref string arg_msg) public function integer uof_update_suliao (long arg_scid, long arg_quoteid, long arg_printid, s_quotesuliao arg_s_sl, ref string arg_msg, boolean arg_ifcommit) public function integer sec_audit (long arg_scid, long arg_quoteid, string arg_emp, ref string arg_msg, boolean arg_ifcommit) 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 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, decimal arg_paintarea, decimal arg_commonqty, decimal arg_customqty, 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, string arg_dscrp_text, string arg_mxdscrp2, decimal arg_paintarea, decimal arg_commonqty, decimal arg_customqty, decimal arg_taxrate) end prototypes public function integer p_reset (); quoteID = 0 quoteCode = '' operator = '' sendUser = '' fiebrelcode = '' mrate = 0 flag = 0 //审核标志 custID = 0 Assign_emp = '' dscrp = '' relcode = '' 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 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(assign_emp) THEN assign_emp = '' IF IsNull(arg_operator) THEN arg_operator = '' IF IsNull(sendUser) THEN sendUser = '' IF IsNull(fiebrelcode) THEN fiebrelcode = '' IF IsNull(billtype) THEN billtype = 0 IF IsNull(mrate) THEN mrate = 1 //==================================================================== // Script - save ( ref string arg_msg, boolean arg_ifcommit ) // Reason: //-------------------------------------------------------------------- // Modified By: yyx Date: 2004.02.20 //-------------------------------------------------------------------- //IF Len(dscrp) > 0 THEN dscrp = ' ' + dscrp //==================================================================== 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 cnt = 0 SELECT count(*) INTO :cnt FROM cw_currency Where moneyid = :moneyid; IF commit_transaction.SQLCode <> 0 THEN arG_MSG = '查询币种失败' rslt = 0 GOTO ext END IF IF cnt = 0 THEN arG_MSG = '币种资料不存在' rslt = 0 GOTO ext END IF IF mrate = 0 THEN arG_MSG = '币种汇率错误' rslt = 0 GOTO ext END IF IF f_moneyid_rate_check(moneyid,mrate,arG_MSG) = 0 THEN rslt = 0 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,False,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,id_sqlca) //数据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 IF billtype = 0 THEN 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 ELSEIF billtype = 1 THEN quoteCode = getid(scid,ls_sccode + 'QR',Date(server_dt),False,commit_transaction) IF quoteCode = "err" THEN quoteCode = '' rslt = 0 arG_MSG = "无法获取报价单编号"+"~n"+commit_transaction.SQLErrText GOTO ext END IF END IF INSERT INTO u_quote ( scid, quoteid, quoteCode, cusID, quotedate, Assign_Emp, relcode, flag, Dscrp, opemp, opdate, moneyid, fiebrelcode, billtype, mrate ) VALUES ( :scid, :ll_quoteid, :quoteCode, :custID, :quotedate, :Assign_Emp, :relcode, 0, :Dscrp, :operator, :server_dt, :moneyid, :fiebrelcode, :billtype, :mrate) 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 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, qty1, rebate, mtrlcode, mtrlname, mtrlmode, unit, paintarea, commonqty, customqty, mxdscrp2, taxrate, fprice) VALUES (:scid, :ll_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].qty1, :quotemx[i].rebate, :quotemx[i].mtrlcode, :quotemx[i].mtrlname, :quotemx[i].mtrlmode, :quotemx[i].unit, :quotemx[i].paintarea, :quotemx[i].commonqty, :quotemx[i].customqty, :quotemx[i].mxdscrp2, :quotemx[i].taxrate, :quotemx[i].fprice) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN quoteID = 0 //还原quoteID 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, :ll_quoteid, :quotemx[i].printid, :quotemx[i].dscrp_text) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN quoteID = 0 //还原quoteID rslt = 0 arG_MSG = "因网络或其它原因导致插入明细备注操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF END IF NEXT ELSE //////////////////////////////////////////////// //更新 UPDATE u_quote SET cusID = :custID, quotedate = :quotedate, Assign_Emp = :Assign_Emp, Dscrp = :Dscrp, moddate = getdate(), Modemp = :publ_operator, relcode = :relcode, moneyid = :moneyid, fiebrelcode = :fiebrelcode, mrate = :mrate 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_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 //删除原有明细 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 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, qty1, rebate, mtrlcode, mtrlname, mtrlmode, unit, paintarea, commonqty, customqty, mxdscrp2, taxrate, fprice) 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].qty1, :quotemx[i].rebate, :quotemx[i].mtrlcode, :quotemx[i].mtrlname, :quotemx[i].mtrlmode, :quotemx[i].unit, :quotemx[i].paintarea, :quotemx[i].commonqty, :quotemx[i].customqty, :quotemx[i].mxdscrp2, :quotemx[i].taxrate, :quotemx[i].fprice) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN 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 quoteID = 0 //还原quoteID rslt = 0 arG_MSG = "因网络或其它原因导致插入明细备注操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF END IF NEXT END IF 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_quotemx_dscrp Where quoteid = :arg_quoteid 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_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, moneyid, billtype, mrate INTO :quotecode, :custid, :quotedate, :assign_emp, :relcode, :dscrp, :operator, :opdate, :flag, :moneyid, :billtype, :mrate 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 Long i uo_cusprice uo_update_cusprice uo_update_cusprice = Create uo_cusprice IF uo_option_if_oa_quote = -1000 THEN rslt = 0 arg_msg = '选项:[235]销售报价单使用OA审批流程,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_quote_secaudit = -1000 THEN rslt = 0 arg_msg = '选项:[236]销售报价单使用二级审核,读取初始默认值失败,操作取消!' GOTO ext END IF 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 <> 0 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 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,FALSE,ARG_MSG) = 0 THEN // rslt = 0 // GOTO ext // END IF NEXT //更新审核标记 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 it_newbegin = False it_updatebegin = False IF uo_option_if_oa_quote = 1 And uo_option_quote_secaudit = 1 THEN IF f_oa(sqlca,False,arg_msg,461,arg_scid,arg_quoteid,quoteCode,relcode,dscrp) = 0 THEN rslt = 0 GOTO ext END IF END IF 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 Long i DateTime ls_auditingdate SetNull(ls_auditingdate) IF uo_option_if_oa_quote = -1000 THEN rslt = 0 arg_msg = '选项:[235]销售报价单使用OA审批流程,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_quote_secaudit = -1000 THEN rslt = 0 arg_msg = '选项:[236]销售报价单使用二级审核,读取初始默认值失败,操作取消!' GOTO ext END IF 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 THEN IF f_check_if_oaflow_caudit(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 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 // //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,FALSE,ARG_MSG) = 0 THEN // rslt = 0 // GOTO ext // END IF //NEXT 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_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 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.fprice 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].fprice; 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].fprice; 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 uof_update_suliao (long arg_scid, long arg_quoteid, long arg_printid, s_quotesuliao arg_s_sl, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 IF arg_quoteid <= 0 THEN rslt = 0 arg_msg = '错误的单据唯一码' GOTO ext END IF IF arg_printid <= 0 THEN rslt = 0 arg_msg = '错误的单据明细唯一码' GOTO ext END IF IF IsNull(arg_s_sl.mtrlid) THEN arg_s_sl.mtrlid = 0 IF IsNull(arg_s_sl.Pigment_price) THEN arg_s_sl.Pigment_price = 0 IF IsNull(arg_s_sl.Pigment_weight ) THEN arg_s_sl.Pigment_weight = 0 IF IsNull(arg_s_sl.Worktime ) THEN arg_s_sl.Worktime = 0 IF IsNull(arg_s_sl.Workprice ) THEN arg_s_sl.Workprice = 0 IF IsNull(arg_s_sl.Trans_price ) THEN arg_s_sl.Trans_price = 0 IF IsNull(arg_s_sl.Trans_qty ) THEN arg_s_sl.Trans_qty = 0 IF IsNull(arg_s_sl.Tax_rate ) THEN arg_s_sl.Tax_rate = 0 IF IsNull(arg_s_sl.Discount_rate ) THEN arg_s_sl.Discount_rate = 0 IF IsNull(arg_s_sl.Exprice ) THEN arg_s_sl.Exprice = 0 IF IsNull(arg_s_sl.Pack_price ) THEN arg_s_sl.Pack_price = 0 IF IsNull(arg_s_sl.Sumprice_cust ) THEN arg_s_sl.Sumprice_cust = 0 IF IsNull(arg_s_sl.profit_margin ) THEN arg_s_sl.profit_margin = 0 IF IsNull(arg_s_sl.sumprice ) THEN arg_s_sl.sumprice = 0 IF IsNull(arg_s_sl.consultqty ) THEN arg_s_sl.consultqty = 0 IF IsNull(arg_s_sl.materialprice ) THEN arg_s_sl.materialprice = 0 IF IsNull(arg_s_sl.Modelqty ) THEN arg_s_sl.Modelqty = 0 IF IsNull(arg_s_sl.Period ) THEN arg_s_sl.Period = 0 IF IsNull(arg_s_sl.EquipmentID ) THEN arg_s_sl.EquipmentID = 0 IF IsNull(arg_s_sl.Weight ) THEN arg_s_sl.Weight = 0 IF IsNull(arg_s_sl.Cost_Elec_Degree ) THEN arg_s_sl.Cost_Elec_Degree = 0 IF IsNull(arg_s_sl.Elec_Price ) THEN arg_s_sl.Elec_Price = 0 IF IsNull(arg_s_sl.Materialwaste ) THEN arg_s_sl.Materialwaste = 0 IF IsNull(arg_s_sl.discount_price ) THEN arg_s_sl.discount_price = 0 IF IsNull(arg_s_sl.EquipmentQty ) THEN arg_s_sl.EquipmentQty = 0 IF IsNull(arg_s_sl.management_cost ) THEN arg_s_sl.management_cost = 0 IF IsNull(arg_s_sl.depreciation_cost ) THEN arg_s_sl.depreciation_cost = 0 IF IsNull(arg_s_sl.suppose_price ) THEN arg_s_sl.suppose_price = 0 IF IsNull(arg_s_sl.suppose_ain ) THEN arg_s_sl.suppose_ain = 0 IF IsNull(arg_s_sl.suppose_tax_tate ) THEN arg_s_sl.suppose_tax_tate = 0 IF IsNull(arg_s_sl.net_profit ) THEN arg_s_sl.net_profit = 0 IF IsNull(arg_s_sl.vmtrlid ) THEN arg_s_sl.vmtrlid = 0 IF IsNull(arg_s_sl.material ) THEN arg_s_sl.material = '' IF IsNull(arg_s_sl.total_cost ) THEN arg_s_sl.total_cost = 0 IF IsNull(arg_s_sl.equiment_totalqty) THEN arg_s_sl.equiment_totalqty = 0 DELETE FROM u_quotesuliao 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 INSERT INTO u_quotesuliao (scid, quoteid, printid, Pigment_price, Pigment_weight, Period, Modelqty, Worktime, Workprice, EquipmentID, Trans_price, Trans_qty, Tax_rate, Discount_rate, Exprice, Pack_price, Sumprice_cust, consultqty, Materialprice, Weight, Cost_Elec_Degree, Elec_Price, Materialwaste, discount_price, EquipmentQty, management_cost, depreciation_cost, suppose_price, suppose_ain, suppose_tax_tate, net_profit, vmtrlid, Material, equiment_totalqty, total_cost, mtrlid, profit_margin, sumprice) VALUES (:arg_scid, :arg_quoteid, :arg_printid, :arg_s_sl.Pigment_price, :arg_s_sl.Pigment_weight, :arg_s_sl.Period, :arg_s_sl.Modelqty, :arg_s_sl.Worktime, :arg_s_sl.Workprice, :arg_s_sl.EquipmentID, :arg_s_sl.Trans_price, :arg_s_sl.Trans_qty, :arg_s_sl.Tax_rate, :arg_s_sl.Discount_rate, :arg_s_sl.Exprice, :arg_s_sl.Pack_price, :arg_s_sl.Sumprice_cust, :arg_s_sl.consultqty, :arg_s_sl.Materialprice, :arg_s_sl.Weight, :arg_s_sl.Cost_Elec_Degree, :arg_s_sl.Elec_Price, :arg_s_sl.Materialwaste, :arg_s_sl.discount_price, :arg_s_sl.EquipmentQty, :arg_s_sl.management_cost, :arg_s_sl.depreciation_cost, :arg_s_sl.suppose_price, :arg_s_sl.suppose_ain, :arg_s_sl.suppose_tax_tate, :arg_s_sl.net_profit, :arg_s_sl.vmtrlid, :arg_s_sl.Material, :arg_s_sl.equiment_totalqty, :arg_s_sl.total_cost, :arg_s_sl.mtrlid, :arg_s_sl.profit_margin, :arg_s_sl.sumprice) USING commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '建立报价明细塑料计算信息明细失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF UPDATE u_quotemx SET sumprice = :arg_s_sl.sumprice, sumprice_1 = :arg_s_sl.Sumprice_cust, profit_margin = :arg_s_sl.profit_margin 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 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 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 ELSE IF li_mx_stopflag = 0 THEN arg_msg = '明细还未终止不能取消终止操作' rslt = 0 GOTO ext END IF END IF IF arg_flag = 1 THEN 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 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 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, decimal arg_paintarea, decimal arg_commonqty, decimal arg_customqty, 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 Int li_billtype 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 billtype INTO :li_billtype 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_billtype = 0 THEN 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 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, status, woodcode, pcode, pfgroup, pfgroupqty, pfgroupmode, sonscale, sonloss, promode, klmode, klarea) 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.status[ll_i], :arg_rqmtrl.woodcode[ll_i], :arg_rqmtrl.pcode[ll_i], :arg_rqmtrl.pfgroup[ll_i], :arg_rqmtrl.pfgroupqty[ll_i], :arg_rqmtrl.pfgroupmode[ll_i], :arg_rqmtrl.sonscale[ll_i], :arg_rqmtrl.sonloss[ll_i], :arg_rqmtrl.promode[ll_i], :arg_rqmtrl.klmode[ll_i], :arg_rqmtrl.klarea[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) 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]) 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, paintarea = :arg_paintarea, commonqty = :arg_commonqty, customqty = :arg_customqty 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, string arg_dscrp_text, string arg_mxdscrp2, decimal arg_paintarea, decimal arg_commonqty, decimal arg_customqty, decimal arg_taxrate);Long rslt = 1,cnt = 0,LS_i Decimal ld_newprice,ld_planprice Int li_statusflag,li_woodcodeflag,li_pcodeflag String ls_pfcode Int li_status_check,li_woodcode_check,li_pcode_check IF uo_option_change_status = '-1000' THEN rslt = 0 arg_msg = '选项:[029]配置标题文本,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_change_woodcode = '-1000' THEN rslt = 0 arg_msg = '选项:[027]配置1标题文本,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_change_pcode = '-1000' THEN rslt = 0 arg_msg = '选项:[028]配置2标题文本,读取初始默认值失败,操作取消!' GOTO ext END IF 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_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_mtrlcode) THEN arg_mtrlcode = '' 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_mxdscrp2) THEN arg_mxdscrp2 = '' IF IsNull(arg_paintarea) THEN arg_paintarea = 0 IF IsNull(arg_commonqty) THEN arg_commonqty = 0 IF IsNull(arg_customqty) THEN arg_customqty = 0 IF IsNull(arg_taxrate) THEN arg_taxrate = 0 arg_status = Trim(arg_status) arg_woodcode = Trim(arg_woodcode) arg_pcode = Trim(arg_pcode) 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 THEN SELECT planprice, statusflag, woodcodeflag, pcodeflag, status_check, woodcode_check, pcode_check INTO :ld_planprice, :li_statusflag, :li_woodcodeflag, :li_pcodeflag, :li_status_check, :li_woodcode_check, :li_pcode_check FROM u_mtrldef Where u_mtrldef.mtrlid = :arg_mtrlid ; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = '行:'+String(arg_printid)+",查询物料:"+arg_mtrlcode+'计划价失败' GOTO ext END IF IF li_statusflag = 2 THEN IF arg_status = '' THEN arg_msg = '行:'+String(arg_printid)+',物料'+uo_option_change_status + '字段使用组合配置,请输入' rslt = 0 GOTO ext END IF ELSEIF li_statusflag = 4 And li_status_check = 1 THEN IF arg_status = '' THEN arg_msg = '行:'+String(arg_printid)+',物料'+uo_option_change_woodcode + '字段使用部件选配,请输入' rslt = 0 GOTO ext END IF END IF IF li_woodcodeflag = 4 And li_woodcode_check = 1 THEN IF arg_woodcode = '' THEN arg_msg = '行:'+String(arg_printid)+',物料'+uo_option_change_woodcode + '字段使用部件选配,请输入' rslt = 0 GOTO ext END IF END IF IF li_pcodeflag = 4 And li_pcode_check = 1 THEN IF arg_pcode = '' THEN arg_msg = '行:'+String(arg_printid)+',物料'+uo_option_change_pcode + '字段使用部件选配,请输入' rslt = 0 GOTO ext END IF 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 ls_pfcode = f_get_dft_pf(arg_mtrlid) END IF FOR LS_i = 1 To it_mxbt //合并重复项(产品) IF quotemx[LS_i].mtrlid = arg_mtrlid And & quotemx[LS_i].mtrlcode = arg_mtrlcode And & quotemx[LS_i].status = arg_status And & quotemx[LS_i].woodcode = arg_woodcode And & quotemx[LS_i].pcode = arg_pcode And & quotemx[LS_i].qty = arg_qty And & quotemx[LS_i].qty1 = arg_qty1 THEN rslt = 0 arg_msg = "存在相同的产品,在"+quotemx[LS_i].mtrlcode+",请自行手动合并" GOTO ext END IF NEXT //写入内容 it_mxbt++ quotemx[it_mxbt].mtrlid = arg_mtrlid quotemx[it_mxbt].mtrlcode = arg_mtrlcode 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].dscrp_text = arg_dscrp_text quotemx[it_mxbt].unit = arg_unit quotemx[it_mxbt].mtrlname = arg_mtrlname quotemx[it_mxbt].mtrlmode = arg_mtrlmode quotemx[it_mxbt].mxdscrp2 = arg_mxdscrp2 quotemx[it_mxbt].paintarea = arg_paintarea quotemx[it_mxbt].commonqty = arg_commonqty quotemx[it_mxbt].customqty = arg_customqty quotemx[it_mxbt].taxrate = arg_taxrate quotemx[it_mxbt].fprice = arg_sumprice * mrate 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 event constructor;String str_optionvalue,arg_msg f_get_sys_option_value('029',str_optionvalue,arg_msg) uo_option_change_status = str_optionvalue f_get_sys_option_value('027',str_optionvalue,arg_msg) uo_option_change_woodcode = str_optionvalue f_get_sys_option_value('028',str_optionvalue,arg_msg) uo_option_change_pcode = str_optionvalue f_get_sys_option_value('235',str_optionvalue,arg_msg) uo_option_if_oa_quote = long(str_optionvalue) f_get_sys_option_value('236',str_optionvalue,arg_msg) uo_option_quote_secaudit = long(str_optionvalue) end event global type uo_incase from nonvisualobject end type