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