12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712 |
- $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
|