uo_spt_price.sru 86 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088
  1. $PBExportHeader$uo_spt_price.sru
  2. forward
  3. global type uo_spt_price from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_spt_price from nonvisualobject
  7. end type
  8. global uo_spt_price uo_spt_price
  9. type variables
  10. Int uo_option_buyprice_ifbj
  11. int uo_option_sptprice_effdate
  12. int uo_option_zero_update_sptprice
  13. end variables
  14. forward prototypes
  15. public function integer uof_getmtrlname (long arg_sptid, long arg_mtrlid, ref string arg_sptmtrlname, ref string arg_msg)
  16. public function integer uof_getmtrlsptprice (long arg_moneyid, long arg_sptid, long arg_mtrlid, ref string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, ref decimal arg_price, ref decimal arg_zqrate, ref decimal arg_rate, datetime arg_billdate, ref string arg_msg)
  17. public function integer uf_getmtrlsptprice_ch (long arg_sptid, long arg_mtrlid, ref string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, ref decimal arg_price, ref decimal arg_rate, ref datetime arg_lastdate, ref string arg_msg)
  18. public function integer uof_check_price (integer arg_thflag, long arg_sptid, long arg_mtrlid, string arg_mtrlcode, string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, long arg_moneyid, decimal arg_price, datetime arg_billdate, ref string arg_msg)
  19. public function integer uof_del_sdsptprice (long arg_mtrlid, long arg_moneyid, long arg_sptid, string arg_unit, datetime arg_opdate, long arg_printid, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, decimal arg_price, decimal arg_zqrate, boolean arg_ifcommit, ref string arg_msg)
  20. public function integer uof_del_sptprice_auto (long arg_sptid, long arg_inwareid, long arg_printid, long arg_mtrlid, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, string arg_unit, long arg_moneyid, boolean arg_ifcommit, ref string arg_msg)
  21. public function integer uof_update_sptmtrlname (long arg_sptid, long arg_mtrlid, string arg_sptmtrlname, boolean arg_ifcommit, ref string arg_msg)
  22. public function integer uof_check_limitprice (integer arg_thflag, long arg_mtrlid, string arg_status, string arg_woodcode, string arg_pcode, string arg_unit, decimal arg_price, ref string arg_msg)
  23. public function integer uof_getnewprice (long arg_sptid, long arg_moneyid, long arg_mtrlid, ref string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, ref decimal arg_price, ref decimal arg_zqrate, ref decimal arg_rate, ref datetime arg_opdate, ref string arg_msg)
  24. public function integer uof_sptmtrlname_set (long arg_sptid, long arg_mtrlid, string arg_sptmtrlname, boolean arg_ifcommit, ref string arg_msg)
  25. public function integer uof_sptmtrlname_get (long arg_sptid, long arg_mtrlid, ref string arg_sptmtrlname, ref string arg_msg)
  26. public function integer uof_sptmtrlprice_get (long arg_sptid, long arg_moneyid, long arg_mtrlid, ref string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, datetime arg_effdate, ref decimal arg_fprice, ref decimal arg_zqrate, ref decimal arg_rate, ref datetime arg_billdate, ref string arg_msg)
  27. public function integer uof_sptmtrlprice_delete (long arg_inwareid, long arg_printid, long arg_sptid, long arg_moneyid, long arg_mtrlid, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, string arg_unit, boolean arg_ifcommit, ref string arg_msg)
  28. public function integer uof_getmtrlsptbuybargainprice (long arg_moneyid, long arg_sptid, long arg_mtrlid, ref string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, ref long arg_buybargainid, ref long arg_buybargainprintid, ref string arg_buybargaincode, ref decimal arg_price, ref decimal arg_rebate, ref string arg_msg)
  29. public function integer uof_getmtrlsptbuybargain (long arg_moneyid, long arg_sptid, long arg_mtrlid, ref string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, ref long arg_buybargainid, ref long arg_buybargainprintid, ref string arg_buybargaincode, ref string arg_msg)
  30. public function integer uof_sptmtrlprice_set (integer arg_ifth, integer arg_ifbj, long arg_sptid, long arg_moneyid, long arg_mtrlid, string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, datetime arg_effdate, datetime arg_effdate_end, decimal arg_fprice, decimal arg_zqrate, decimal arg_rate, decimal arg_wareprice, decimal arg_wareprice_notax, integer arg_billtype, integer arg_buildtype, long arg_inwareid, string arg_inwarecode, long arg_printid, datetime arg_indate, string arg_dscrp, boolean arg_ifcommit, ref string arg_msg)
  31. public function integer uof_update_sptprice (integer arg_ifth, long arg_sptid, long arg_mtrlid, string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, long arg_inwareid, decimal arg_fprice, decimal arg_zqrate, decimal arg_rate, decimal arg_wareprice, decimal arg_wareprice_notax, datetime arg_indate, string arg_inwarecode, long arg_flag, string arg_dscrp, long arg_printid, integer arg_billtype, long arg_moneyid, datetime arg_effdate, datetime arg_effdate_end, boolean arg_ifcommit, ref string arg_msg)
  32. public function integer uof_getmtrlsptbuyareaprice (long arg_moneyid, long arg_sptid, long arg_mtrlid, ref string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, ref long arg_buybargainid, ref long arg_buybargainprintid, ref string arg_buybargaincode, ref decimal arg_price, ref decimal arg_otherprice, ref decimal arg_areaqty, ref string arg_msg)
  33. end prototypes
  34. public function integer uof_getmtrlname (long arg_sptid, long arg_mtrlid, ref string arg_sptmtrlname, ref string arg_msg);
  35. return uof_sptmtrlname_get(arg_sptid, arg_mtrlid, arg_sptmtrlname, arg_msg)
  36. //Long rslt = 1
  37. //String rtn_sptmtrlname
  38. //
  39. //
  40. //SELECT sptmtrlname
  41. // INTO :rtn_sptmtrlname
  42. // FROM u_sptmtrlname
  43. // WHERE u_sptmtrlname.mtrlid = :arg_mtrlid
  44. // AND u_sptmtrlname.sptid = :arg_sptid;
  45. //IF sqlca.SQLCode = -1 THEN
  46. // rslt = 0
  47. // arg_msg = '查询操作失败'+sqlca.SQLErrText
  48. // GOTO ext
  49. //ELSEIF sqlca.SQLCode = 100 OR IsNull(rtn_sptmtrlname) THEN
  50. // rtn_sptmtrlname = ''
  51. //END IF
  52. //
  53. //arg_sptmtrlname = rtn_sptmtrlname
  54. //
  55. //ext:
  56. //
  57. //RETURN rslt
  58. end function
  59. public function integer uof_getmtrlsptprice (long arg_moneyid, long arg_sptid, long arg_mtrlid, ref string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, ref decimal arg_price, ref decimal arg_zqrate, ref decimal arg_rate, datetime arg_billdate, ref string arg_msg);datetime ldt_opdate
  60. return uof_sptmtrlprice_get ( arg_sptid, arg_moneyid, arg_mtrlid, arg_unit, arg_status, arg_woodcode, arg_pcode, arg_jgdscrp, arg_billdate, arg_price, arg_zqrate, arg_rate, ldt_opdate,arg_msg)
  61. //Long rslt = 1
  62. //Decimal rtn_price,rtn_zqrate,rtn_rate
  63. //String rtn_unit
  64. //String rtn_wareunit
  65. //Int li_iflimitprice,li_price_ifpz_buy
  66. //Int li_issuliao
  67. //
  68. //arg_status = Trim(arg_status)
  69. //arg_woodcode = Trim(arg_woodcode)
  70. //arg_pcode = Trim(arg_pcode)
  71. //arg_jgdscrp = Trim(arg_jgdscrp)
  72. //
  73. //
  74. //arg_unit = Trim(arg_unit)
  75. //
  76. //arg_billdate = DateTime(Date(arg_billdate),Time(0))
  77. //
  78. //IF uo_option_buyprice_ifbj = -1000 THEN
  79. // arg_msg = '选项:[053]收货单取单价模式,读取初始默认值失败,操作取消!'
  80. // rslt = 0
  81. // GOTO ext
  82. //END IF
  83. //
  84. //
  85. //IF uo_option_sptprice_effdate = -1000 THEN
  86. // arg_msg = '选项:[244]供应商报价使用生效日期,读取初始默认值失败,操作取消!'
  87. // rslt = 0
  88. // GOTO ext
  89. //END IF
  90. //
  91. //
  92. //SELECT iflimitprice,price_ifpz_buy,issuliao INTO :li_iflimitprice,:li_price_ifpz_buy,:li_issuliao
  93. // FROM u_mtrldef
  94. // Where mtrlid = :arg_mtrlid;
  95. //IF sqlca.SQLCode <> 0 THEN
  96. // arg_msg = '查询物料限价属性失败 '+sqlca.SQLErrText
  97. // rslt = 0
  98. // GOTO ext
  99. //END IF
  100. //
  101. //CHOOSE CASE li_price_ifpz_buy
  102. // CASE 0
  103. // arg_status = ''
  104. // arg_woodcode = ''
  105. // arg_pcode = ''
  106. // CASE 1
  107. // arg_pcode = ''
  108. // arg_woodcode = ''
  109. // CASE 2
  110. // arg_status = ''
  111. // arg_pcode = ''
  112. // CASE 3
  113. // arg_status = ''
  114. // arg_woodcode = ''
  115. // CASE 4
  116. // arg_pcode = ''
  117. // CASE 5
  118. // arg_status = ''
  119. // CASE 6
  120. // arg_woodcode = ''
  121. //END CHOOSE
  122. //
  123. //IF arg_unit = '' THEN
  124. //
  125. // IF uo_option_buyprice_ifbj = 0 Or uo_option_buyprice_ifbj = 2 And li_iflimitprice = 0 THEN
  126. // SELECT top 1 fprice,zqrate,rate,unit
  127. // INTO :rtn_price,:rtn_zqrate ,:rtn_rate ,:rtn_unit
  128. // FROM u_spt_price_mx
  129. // WHERE u_spt_price_mx.mtrlid = :arg_mtrlid
  130. // AND u_spt_price_mx.sptid = :arg_sptid
  131. // AND u_spt_price_mx.status = :arg_status
  132. // AND u_spt_price_mx.woodcode = :arg_woodcode
  133. // AND u_spt_price_mx.pcode = :arg_pcode
  134. // AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  135. // AND u_spt_price_mx.moneyid = :arg_moneyid
  136. // Order By u_spt_price_mx.opdate Desc;
  137. // ELSE
  138. // IF uo_option_sptprice_effdate = 1 THEN
  139. // SELECT top 1 fprice,zqrate,rate,unit
  140. // INTO :rtn_price,:rtn_zqrate ,:rtn_rate ,:rtn_unit
  141. // FROM u_spt_price_mx
  142. // WHERE u_spt_price_mx.mtrlid = :arg_mtrlid
  143. // AND u_spt_price_mx.sptid = :arg_sptid
  144. // AND u_spt_price_mx.status = :arg_status
  145. // AND u_spt_price_mx.woodcode = :arg_woodcode
  146. // AND u_spt_price_mx.pcode = :arg_pcode
  147. // AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  148. // AND u_spt_price_mx.billtype = 2
  149. // AND u_spt_price_mx.moneyid = :arg_moneyid
  150. // AND u_spt_price_mx.effdate <= :arg_billdate
  151. // Order By u_spt_price_mx.effdate Desc,u_spt_price_mx.opdate Desc;
  152. // ELSE
  153. // SELECT top 1 fprice,zqrate,rate,unit
  154. // INTO :rtn_price,:rtn_zqrate ,:rtn_rate ,:rtn_unit
  155. // FROM u_spt_price_mx
  156. // WHERE u_spt_price_mx.mtrlid = :arg_mtrlid
  157. // AND u_spt_price_mx.sptid = :arg_sptid
  158. // AND u_spt_price_mx.status = :arg_status
  159. // AND u_spt_price_mx.woodcode = :arg_woodcode
  160. // AND u_spt_price_mx.pcode = :arg_pcode
  161. // AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  162. // AND u_spt_price_mx.billtype = 2
  163. // AND u_spt_price_mx.moneyid = :arg_moneyid
  164. // Order By u_spt_price_mx.opdate Desc;
  165. // END IF
  166. // END IF
  167. //
  168. // IF sqlca.SQLCode = -1 THEN
  169. // rslt = 0
  170. // arg_msg = '查询价格操作失败'+sqlca.SQLErrText
  171. // GOTO ext
  172. // ELSEIF sqlca.SQLCode = 100 Or IsNull(rtn_price) THEN
  173. // rtn_zqrate = 1
  174. //
  175. // SELECT unit,unit_buy,rate_buy
  176. // INTO :rtn_wareunit,:rtn_unit,:rtn_rate
  177. // FROM u_mtrldef
  178. // Where mtrlid = :arg_mtrlid;
  179. //
  180. // IF sqlca.SQLCode <> 0 THEN
  181. // rslt = 2
  182. // rtn_price = 0.00
  183. // rtn_zqrate = 1
  184. // rtn_rate = 1
  185. // rtn_unit = ''
  186. // arg_msg = '不存在产品资料'+sqlca.SQLErrText
  187. // GOTO ext
  188. // END IF
  189. //
  190. // IF rtn_unit = '' Or rtn_rate = 0 THEN
  191. // rtn_unit = rtn_wareunit
  192. // rtn_price = 0.00
  193. // rtn_rate = 1
  194. // rtn_zqrate = 1
  195. // rslt = 2
  196. // GOTO ext
  197. // END IF
  198. // END IF
  199. //ELSE
  200. // IF uo_option_buyprice_ifbj = 0 Or uo_option_buyprice_ifbj = 2 And li_iflimitprice = 0 THEN
  201. // //取最新价 //053
  202. // SELECT top 1 fprice,zqrate,rate,unit
  203. // INTO :rtn_price,:rtn_zqrate ,:rtn_rate ,:rtn_unit
  204. // FROM u_spt_price
  205. // WHERE u_spt_price.mtrlid = :arg_mtrlid
  206. // AND u_spt_price.sptid = :arg_sptid
  207. // AND u_spt_price.unit = :arg_unit
  208. // AND u_spt_price.status = :arg_status
  209. // AND u_spt_price.woodcode = :arg_woodcode
  210. // AND u_spt_price.pcode = :arg_pcode
  211. // AND u_spt_price.jgdscrp = :arg_jgdscrp
  212. // AND u_spt_price.moneyid = :arg_moneyid
  213. // Order By u_spt_price.sys_changetime Desc;
  214. // ELSE//取最新报价
  215. // //加强为考虑合同
  216. // IF uo_option_sptprice_effdate = 1 THEN //使用生效日期 //244
  217. // SELECT top 1 fprice,zqrate,rate,unit
  218. // INTO :rtn_price,:rtn_zqrate ,:rtn_rate ,:rtn_unit
  219. // FROM u_spt_price_mx
  220. // WHERE u_spt_price_mx.mtrlid = :arg_mtrlid
  221. // AND u_spt_price_mx.sptid = :arg_sptid
  222. // AND u_spt_price_mx.status = :arg_status
  223. // AND u_spt_price_mx.woodcode = :arg_woodcode
  224. // AND u_spt_price_mx.pcode = :arg_pcode
  225. // AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  226. // AND u_spt_price_mx.billtype = 2
  227. // AND u_spt_price_mx.unit = :arg_unit
  228. // AND u_spt_price_mx.moneyid = :arg_moneyid
  229. // AND u_spt_price_mx.effdate <= :arg_billdate
  230. // Order By u_spt_price_mx.effdate Desc,u_spt_price_mx.opdate Desc;
  231. // ELSE
  232. // SELECT top 1 fprice,zqrate,rate,unit
  233. // INTO :rtn_price,:rtn_zqrate ,:rtn_rate ,:rtn_unit
  234. // FROM u_spt_price_mx
  235. // WHERE u_spt_price_mx.mtrlid = :arg_mtrlid
  236. // AND u_spt_price_mx.sptid = :arg_sptid
  237. // AND u_spt_price_mx.status = :arg_status
  238. // AND u_spt_price_mx.woodcode = :arg_woodcode
  239. // AND u_spt_price_mx.pcode = :arg_pcode
  240. // AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  241. // AND u_spt_price_mx.billtype = 2
  242. // AND u_spt_price_mx.unit = :arg_unit
  243. // AND u_spt_price_mx.moneyid = :arg_moneyid
  244. // Order By u_spt_price_mx.opdate Desc;
  245. // END IF
  246. // END IF
  247. //
  248. // IF sqlca.SQLCode = -1 THEN
  249. // rslt = 0
  250. // arg_msg = '查询操作失败'+sqlca.SQLErrText
  251. // GOTO ext
  252. // ELSEIF sqlca.SQLCode = 100 Or IsNull(rtn_price) THEN
  253. // // if li_issuliao = 5 or li_issuliao = 8 then //纸箱 或 泡沫 特殊读价
  254. // // f_getbaseprice_dwuse(arg_mtrlid,arg_material,ls_billcode)
  255. // // end if
  256. //
  257. // rslt = 2
  258. // rtn_price = 0.00
  259. // rtn_zqrate = 1
  260. // GOTO ext
  261. // END IF
  262. //
  263. //END IF
  264. //
  265. //ext:
  266. //IF rslt <> 1 THEN
  267. // rtn_price = 0.00
  268. // rtn_zqrate = 1
  269. // rtn_rate = 1
  270. //END IF
  271. //
  272. //arg_price = rtn_price
  273. //arg_zqrate = rtn_zqrate
  274. //arg_rate = rtn_rate
  275. //arg_unit = rtn_unit
  276. //
  277. //
  278. //RETURN rslt
  279. end function
  280. public function integer uf_getmtrlsptprice_ch (long arg_sptid, long arg_mtrlid, ref string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, ref decimal arg_price, ref decimal arg_rate, ref datetime arg_lastdate, ref string arg_msg);//datetime ldt_effdate
  281. //ldt_effdate = datetime(1900-01-01)
  282. //
  283. //decimal lde_zqrate
  284. //
  285. //decimal lde_moneyid
  286. //
  287. //return uof_sptmtrlprice_get ( arg_sptid, lde_moneyid, arg_mtrlid, arg_unit, arg_status, arg_woodcode, arg_pcode, arg_jgdscrp, ldt_effdate, arg_price, lde_zqrate, arg_rate, arg_lastdate,arg_msg)
  288. //
  289. //供应商调价,查上次价, 无用
  290. Long rslt = 1
  291. //Decimal rtn_price,rtn_rate
  292. //DateTime rtn_lastdate
  293. //
  294. //Int li_iflimitprice,li_price_ifpz_buy
  295. //
  296. //arg_status = Trim(arg_status)
  297. //arg_woodcode = Trim(arg_woodcode)
  298. //arg_pcode = Trim(arg_pcode)
  299. //arg_jgdscrp = Trim(arg_jgdscrp)
  300. //
  301. //
  302. //arg_unit = Trim(arg_unit)
  303. //
  304. //IF uo_option_buyprice_ifbj = -1000 THEN
  305. // arg_msg = '选项:[053]收货单取单价模式,读取初始默认值失败,操作取消!'
  306. // rslt = 0
  307. // GOTO ext
  308. //END IF
  309. //
  310. //SELECT iflimitprice,
  311. // price_ifpz_buy
  312. // INTO :li_iflimitprice,
  313. // :li_price_ifpz_buy
  314. // FROM u_mtrldef
  315. // Where mtrlid = :arg_mtrlid;
  316. //IF sqlca.SQLCode <> 0 THEN
  317. // arg_msg = '查询物料限价属性失败 '+sqlca.SQLErrText
  318. // rslt = 0
  319. // GOTO ext
  320. //END IF
  321. //
  322. //CHOOSE CASE li_price_ifpz_buy
  323. // CASE 0
  324. // arg_status = ''
  325. // arg_woodcode = ''
  326. // arg_pcode = ''
  327. // CASE 1
  328. // arg_pcode = ''
  329. // arg_woodcode = ''
  330. // CASE 2
  331. // arg_status = ''
  332. // arg_pcode = ''
  333. // CASE 3
  334. // arg_status = ''
  335. // arg_woodcode = ''
  336. // CASE 4
  337. // arg_pcode = ''
  338. // CASE 5
  339. // arg_status = ''
  340. // CASE 6
  341. // arg_woodcode = ''
  342. //END CHOOSE
  343. //
  344. //IF arg_unit = '' THEN
  345. // rtn_price = 0.00
  346. // rtn_rate = 1
  347. // SetNull(rtn_lastdate)
  348. // rslt = 2
  349. // GOTO ext
  350. //ELSE
  351. // IF uo_option_buyprice_ifbj = 0 Or uo_option_buyprice_ifbj = 2 And li_iflimitprice = 0 THEN
  352. // SELECT top 1 fprice,rate,outdate
  353. // INTO :rtn_price,:rtn_rate ,:rtn_lastdate
  354. // FROM u_spt_price_mx
  355. // WHERE u_spt_price_mx.mtrlid = :arg_mtrlid
  356. // AND u_spt_price_mx.sptid = :arg_sptid
  357. // AND u_spt_price_mx.unit = :arg_unit
  358. // AND u_spt_price_mx.status = :arg_status
  359. // AND u_spt_price_mx.woodcode = :arg_woodcode
  360. // AND u_spt_price_mx.pcode = :arg_pcode
  361. // AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  362. // Order By Opdate Desc;
  363. // ELSE
  364. // SELECT top 1 fprice,rate,outdate
  365. // INTO :rtn_price,:rtn_rate ,:rtn_lastdate
  366. // FROM u_spt_price_mx
  367. // WHERE u_spt_price_mx.mtrlid = :arg_mtrlid
  368. // AND u_spt_price_mx.sptid = :arg_sptid
  369. // AND u_spt_price_mx.unit = :arg_unit
  370. // AND u_spt_price_mx.status = :arg_status
  371. // AND u_spt_price_mx.woodcode = :arg_woodcode
  372. // AND u_spt_price_mx.pcode = :arg_pcode
  373. // AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  374. // AND u_spt_price_mx.billtype = 2
  375. // Order By Opdate Desc;
  376. // END IF
  377. //
  378. // IF sqlca.SQLCode = -1 THEN
  379. // rslt = 0
  380. // arg_msg = '查询操作失败'+sqlca.SQLErrText
  381. // GOTO ext
  382. // ELSEIF sqlca.SQLCode = 100 Or IsNull(rtn_price) THEN
  383. // rslt = 2
  384. // rtn_price = 0.00
  385. // rtn_rate = 1
  386. // SetNull(rtn_lastdate)
  387. // GOTO ext
  388. // END IF
  389. //
  390. //END IF
  391. //
  392. //ext:
  393. //arg_price = rtn_price
  394. //arg_lastdate = rtn_lastdate
  395. //arg_rate = rtn_rate
  396. //
  397. RETURN rslt
  398. end function
  399. public function integer uof_check_price (integer arg_thflag, long arg_sptid, long arg_mtrlid, string arg_mtrlcode, string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, long arg_moneyid, decimal arg_price, datetime arg_billdate, ref string arg_msg);//采购订单,采购收货,外协订单,外协收货,限价
  400. Int rslt = 1
  401. Long cnt
  402. String ls_sptname
  403. Decimal ld_updownprice, lde_lmbuyprice
  404. Int li_ifnocheck,li_iflimitprice,li_price_ifpz_buy
  405. IF Not f_power_ind(124,sys_msg_pow) Or sys_power_issuper THEN
  406. rslt = 1
  407. GOTO ext
  408. END IF
  409. SELECT count(*) INTO :cnt
  410. FROM u_spt
  411. Where sptid = :arg_sptid;
  412. IF sqlca.SQLCode <> 0 THEN
  413. rslt = 0
  414. arg_msg = "查询操作失败,供应商/加工商资料,"+sqlca.SQLErrText
  415. GOTO ext
  416. END IF
  417. IF cnt = 0 THEN
  418. rslt = 0
  419. arg_msg = "供应商资料错误!"
  420. GOTO ext
  421. END IF
  422. SELECT ifnocheck, name
  423. INTO :li_ifnocheck, :ls_sptname
  424. FROM u_spt
  425. Where sptid = :arg_sptid;
  426. IF sqlca.SQLCode <> 0 THEN
  427. rslt = 0
  428. arg_msg = "查询操作失败,供应商/加工商不限价属性,"+sqlca.SQLErrText
  429. GOTO ext
  430. END IF
  431. IF li_ifnocheck = 1 THEN //供应商不限
  432. rslt = 1
  433. GOTO ext
  434. END IF
  435. SELECT updownprice,iflimitprice,price_ifpz_buy
  436. INTO :ld_updownprice,:li_iflimitprice,:li_price_ifpz_buy
  437. FROM u_mtrldef
  438. Where mtrlid = :arg_mtrlid;
  439. IF sqlca.SQLCode <> 0 THEN
  440. rslt = 0
  441. arg_msg = "查询操作失败,产品限价浮动差额资料,"+sqlca.SQLErrText
  442. GOTO ext
  443. END IF
  444. IF li_iflimitprice = 0 THEN //物料不限
  445. rslt = 1
  446. GOTO ext
  447. end if
  448. DateTime ldt_opdate
  449. Decimal lde_zqrate, lde_rate
  450. IF uo_option_buyprice_ifbj = 0 Or uo_option_buyprice_ifbj = 2 And li_iflimitprice = 0 THEN
  451. cnt = 1
  452. ELSE
  453. IF uo_option_sptprice_effdate = 1 THEN
  454. SELECT count(*) INTO :cnt
  455. FROM u_spt_price_changemx INNER JOIN
  456. u_spt_price_change ON u_spt_price_changemx.billid = u_spt_price_change.billid
  457. WHERE u_spt_price_changemx.mtrlid = :arg_mtrlid
  458. AND u_spt_price_changemx.status = :arg_status
  459. AND u_spt_price_changemx.woodcode = :arg_woodcode
  460. AND u_spt_price_changemx.pcode = :arg_pcode
  461. AND u_spt_price_changemx.jgdscrp = :arg_jgdscrp
  462. AND u_spt_price_changemx.unit = :arg_unit
  463. AND u_spt_price_changemx.effdate <= :arg_billdate
  464. AND u_spt_price_change.sptid = :arg_sptid
  465. AND u_spt_price_change.moneyid = :arg_moneyid
  466. And u_spt_price_change.flag = 0;
  467. IF sqlca.SQLCode <> 0 THEN
  468. rslt = 0
  469. arg_msg = '查询物料:'+arg_mtrlcode+' '+arg_status+'单据日期前未审的供应商询价单失败, ~n'+sqlca.SQLErrText
  470. GOTO ext
  471. END IF
  472. IF cnt > 0 THEN
  473. rslt = 0
  474. arg_msg = '查询物料:'+arg_mtrlcode+' '+arg_status+',共有'+String(cnt)+'张生效日期在本单据日期前的供应商询价单未审,请先审核'
  475. GOTO ext
  476. END IF
  477. SELECT count(*)
  478. INTO :cnt
  479. FROM u_spt_price_MX INNER JOIN
  480. u_spt ON u_spt_price_MX.sptid = u_spt.sptid
  481. WHERE u_spt_price_mx.mtrlid = :arg_mtrlid
  482. AND u_spt_price_mx.sptid = :arg_sptid
  483. AND u_spt_price_mx.status = :arg_status
  484. AND u_spt_price_mx.woodcode = :arg_woodcode
  485. AND u_spt_price_mx.pcode = :arg_pcode
  486. AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  487. AND u_spt_price_mx.billtype = 2
  488. AND u_spt_price_mx.unit = :arg_unit
  489. AND u_spt_price_mx.moneyid = :arg_moneyid
  490. AND u_spt_price_mx.effdate <= :arg_billdate;
  491. ELSE
  492. SELECT count(*)
  493. INTO :cnt
  494. FROM u_spt_price_MX INNER JOIN
  495. u_spt ON u_spt_price_MX.sptid = u_spt.sptid
  496. WHERE u_spt_price_mx.mtrlid = :arg_mtrlid
  497. AND u_spt_price_mx.sptid = :arg_sptid
  498. AND u_spt_price_mx.status = :arg_status
  499. AND u_spt_price_mx.woodcode = :arg_woodcode
  500. AND u_spt_price_mx.pcode = :arg_pcode
  501. AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  502. AND u_spt_price_mx.billtype = 2
  503. AND u_spt_price_mx.unit = :arg_unit
  504. AND u_spt_price_mx.moneyid = :arg_moneyid;
  505. END IF
  506. IF sqlca.SQLCode <> 0 THEN
  507. rslt = 0
  508. arg_msg = '查询物料:'+arg_mtrlcode+' '+arg_status+'是否有供应商询价单失败, ~n'+sqlca.SQLErrText
  509. GOTO ext
  510. END IF
  511. if cnt = 0 then
  512. rslt = 0
  513. arg_msg = '物料:'+arg_mtrlcode+' '+arg_status+'没有供应商询价单'
  514. GOTO ext
  515. end if
  516. END IF
  517. IF uof_sptmtrlprice_get ( arg_sptid, arg_moneyid, arg_mtrlid, arg_unit, arg_status, arg_woodcode, arg_pcode, arg_jgdscrp, arg_billdate, lde_lmbuyprice, lde_zqrate, lde_rate, ldt_opdate,arg_msg) = 0 THEN
  518. rslt = 0
  519. arg_msg = "查询产品最新价失败,"+arg_msg
  520. GOTO ext
  521. END IF
  522. IF arg_thflag = 0 THEN
  523. IF arg_price > lde_lmbuyprice + ld_updownprice THEN
  524. rslt = 0
  525. arg_msg = '供应商:'+ls_sptname+',物料:'+arg_mtrlcode+'收货时,收货单价{'+String(arg_price,'#,##0.00##')+'} 高于收货限价{'+String( lde_lmbuyprice + ld_updownprice ,'#,##0.00##')+'}'
  526. GOTO ext
  527. END IF
  528. ELSE
  529. IF arg_price < lde_lmbuyprice - ld_updownprice THEN
  530. rslt = 0
  531. arg_msg = '供应商:'+ls_sptname+',物料:'+arg_mtrlcode+'退货时,退货单价{'+String(arg_price,'#,##0.00##')+'} 低于收货限价{'+String(lde_lmbuyprice - ld_updownprice,'#,##0.00##')+'}'
  532. GOTO ext
  533. END IF
  534. END IF
  535. ext:
  536. RETURN rslt
  537. end function
  538. public function integer uof_del_sdsptprice (long arg_mtrlid, long arg_moneyid, long arg_sptid, string arg_unit, datetime arg_opdate, long arg_printid, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, decimal arg_price, decimal arg_zqrate, boolean arg_ifcommit, ref string arg_msg);return uof_sptmtrlprice_delete ( 0, 0, arg_sptid, arg_moneyid, arg_mtrlid, arg_status, arg_woodcode, arg_pcode, arg_jgdscrp, arg_unit, arg_ifcommit, ref arg_msg)
  539. //Int rslt = 1
  540. //Long cnt = 0
  541. //
  542. ////检查供应商存在否
  543. //SELECT count(*)
  544. // INTO :cnt
  545. // FROM u_spt
  546. // Where u_spt.sptid = :arg_sptid;
  547. //IF sqlca.SQLCode <> 0 THEN
  548. // rslt = 0
  549. // arg_msg = '因网络和其他原因查询失败'+sqlca.SQLErrText
  550. // GOTO ext
  551. //END IF
  552. //IF cnt = 0 THEN
  553. // rslt = 0
  554. // arg_msg = '供应商不存在'
  555. // GOTO ext
  556. //END IF
  557. //
  558. //
  559. ////检查商品存在否
  560. //SELECT count(*)
  561. // INTO :cnt
  562. // FROM u_mtrldef
  563. // Where u_mtrldef.mtrlid = :arg_mtrlid;
  564. //IF sqlca.SQLCode <> 0 THEN
  565. // rslt = 0
  566. // arg_msg = '因网络和其他原因查询失败'+sqlca.SQLErrText
  567. // GOTO ext
  568. //END IF
  569. //IF cnt = 0 THEN
  570. // rslt = 0
  571. // arg_msg = '物料不存在'
  572. // GOTO ext
  573. //END IF
  574. //
  575. ////删除手动添加价格
  576. //DELETE
  577. //From u_spt_price_mx
  578. //Where u_spt_price_mx.sptid = :arg_sptid
  579. //And u_spt_price_mx.mtrlid = :arg_mtrlid
  580. //And u_spt_price_mx.opdate = :arg_opdate
  581. //And u_spt_price_mx.printid = :arg_printid
  582. //And u_spt_price_mx.moneyid = :arg_moneyid
  583. //And u_spt_price_mx.status = :arg_status
  584. //And u_spt_price_mx.woodcode = :arg_woodcode
  585. //And u_spt_price_mx.pcode = :arg_pcode
  586. //And u_spt_price_mx.jgdscrp = :arg_jgdscrp
  587. //;
  588. //IF sqlca.SQLCode <> 0 THEN
  589. // rslt = 0
  590. // arg_msg = '查询失败'+sqlca.SQLErrText
  591. // GOTO ext
  592. //END IF
  593. //
  594. ////更新最新价格表
  595. //UPDATE u_spt_price
  596. // SET u_spt_price.price = :arg_price * :arg_zqrate,
  597. // u_spt_price.fprice = :arg_price,
  598. // u_spt_price.zqrate = :arg_zqrate
  599. // WHERE u_spt_price.sptid = :arg_sptid
  600. // AND u_spt_price.mtrlid = :arg_mtrlid
  601. // AND u_spt_price.status = :arg_status
  602. // AND u_spt_price.woodcode = :arg_woodcode
  603. // AND u_spt_price.pcode = :arg_pcode
  604. // AND u_spt_price.jgdscrp = :arg_jgdscrp
  605. // And u_spt_price.moneyid = :arg_moneyid;
  606. //IF sqlca.SQLCode <> 0 THEN
  607. // rslt = 0
  608. // arg_msg = '查询失败'+sqlca.SQLErrText
  609. // GOTO ext
  610. //END IF
  611. //ext:
  612. //IF rslt = 0 THEN
  613. // ROLLBACK;
  614. //ELSEIF rslt = 1 And arg_ifcommit THEN
  615. // COMMIT;
  616. //END IF
  617. //RETURN rslt
  618. end function
  619. public function integer uof_del_sptprice_auto (long arg_sptid, long arg_inwareid, long arg_printid, long arg_mtrlid, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, string arg_unit, long arg_moneyid, boolean arg_ifcommit, ref string arg_msg);return uof_sptmtrlprice_delete ( arg_inwareid, arg_printid, arg_sptid, arg_moneyid, arg_mtrlid, arg_status, arg_woodcode, arg_pcode, arg_jgdscrp, arg_unit, arg_ifcommit, ref arg_msg)
  620. //Int rslt = 1
  621. //Long cnt = 0,ll_cnt = 0
  622. //DateTime ld_opdate
  623. //
  624. ////检查供应商存在否
  625. //SELECT count(*)
  626. // INTO :cnt
  627. // FROM u_spt
  628. // Where u_spt.sptid = :arg_sptid;
  629. //IF sqlca.SQLCode <> 0 THEN
  630. // rslt = 0
  631. // arg_msg = '查询供应商失败'+sqlca.SQLErrText
  632. // GOTO ext
  633. //END IF
  634. //IF cnt = 0 THEN
  635. // rslt = 0
  636. // arg_msg = '供应商不存在'
  637. // GOTO ext
  638. //END IF
  639. //
  640. //
  641. ////检查商品存在否
  642. //SELECT count(*)
  643. // INTO :cnt
  644. // FROM u_mtrldef
  645. // Where u_mtrldef.mtrlid = :arg_mtrlid;
  646. //IF sqlca.SQLCode <> 0 THEN
  647. // rslt = 0
  648. // arg_msg = '查询物料失败'+sqlca.SQLErrText
  649. // GOTO ext
  650. //END IF
  651. //IF cnt = 0 THEN
  652. // rslt = 0
  653. // arg_msg = '物料不存在'
  654. // GOTO ext
  655. //END IF
  656. //
  657. //SELECT count(*) INTO :cnt
  658. // FROM u_spt_price_mx
  659. // WHERE u_spt_price_mx.sptid = :arg_sptid
  660. // AND u_spt_price_mx.mtrlid = :arg_mtrlid
  661. // AND u_spt_price_mx.inwareid = :arg_inwareid
  662. // AND u_spt_price_mx.printid = :arg_printid
  663. // AND u_spt_price_mx.status = :arg_status
  664. // AND u_spt_price_mx.woodcode = :arg_woodcode
  665. // AND u_spt_price_mx.pcode = :arg_pcode
  666. // AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  667. // AND u_spt_price_mx.unit = :arg_unit
  668. // And u_spt_price_mx.moneyid = :arg_moneyid;
  669. //IF sqlca.SQLCode <> 0 THEN
  670. // rslt = 0
  671. // arg_msg = '查询供应商最新价条目失败'+sqlca.SQLErrText
  672. // GOTO ext
  673. //END IF
  674. //
  675. //IF cnt = 0 THEN
  676. // rslt = 1
  677. // GOTO ext
  678. //END IF
  679. //
  680. //SELECT top 1 Opdate INTO :ld_opdate
  681. // FROM u_spt_price_mx
  682. // WHERE u_spt_price_mx.sptid = :arg_sptid
  683. // AND u_spt_price_mx.mtrlid = :arg_mtrlid
  684. // AND u_spt_price_mx.inwareid = :arg_inwareid
  685. // AND u_spt_price_mx.printid = :arg_printid
  686. // AND u_spt_price_mx.status = :arg_status
  687. // AND u_spt_price_mx.woodcode = :arg_woodcode
  688. // AND u_spt_price_mx.pcode = :arg_pcode
  689. // AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  690. // AND u_spt_price_mx.unit = :arg_unit
  691. // AND u_spt_price_mx.moneyid = :arg_moneyid
  692. // Order By Opdate Desc;
  693. //IF sqlca.SQLCode <> 0 THEN
  694. // rslt = 0
  695. // arg_msg = '查询供应商最新价时间失败'+sqlca.SQLErrText
  696. // GOTO ext
  697. //END IF
  698. //
  699. //SELECT count(*) INTO :cnt
  700. // FROM u_spt_price_mx
  701. // WHERE u_spt_price_mx.sptid = :arg_sptid
  702. // AND u_spt_price_mx.mtrlid = :arg_mtrlid
  703. // AND u_spt_price_mx.status = :arg_status
  704. // AND u_spt_price_mx.woodcode = :arg_woodcode
  705. // AND u_spt_price_mx.pcode = :arg_pcode
  706. // AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  707. // AND u_spt_price_mx.unit = :arg_unit
  708. // AND u_spt_price_mx.Opdate > :ld_opdate
  709. // And u_spt_price_mx.moneyid = :arg_moneyid;
  710. //IF sqlca.SQLCode <> 0 THEN
  711. // rslt = 0
  712. // arg_msg = '查询供应商最新价内容失败'+sqlca.SQLErrText
  713. // GOTO ext
  714. //END IF
  715. //
  716. //Decimal ld_fprice,ld_zqrate,ld_price
  717. //DateTime ld_sys_changetime,ld_nulldt
  718. //SetNull(ld_nulldt)
  719. //IF cnt = 0 THEN //如果被删明细是最新,用次新明细更新最新价
  720. // SELECT count(*) INTO :ll_cnt
  721. // FROM u_spt_price_mx
  722. // WHERE u_spt_price_mx.sptid = :arg_sptid
  723. // AND u_spt_price_mx.mtrlid = :arg_mtrlid
  724. // AND u_spt_price_mx.status = :arg_status
  725. // AND u_spt_price_mx.woodcode = :arg_woodcode
  726. // AND u_spt_price_mx.pcode = :arg_pcode
  727. // AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  728. // AND u_spt_price_mx.unit = :arg_unit
  729. // And u_spt_price_mx.Opdate < :ld_opdate
  730. // And u_spt_price_mx.moneyid = :arg_moneyid;
  731. // IF sqlca.SQLCode <> 0 THEN
  732. // rslt = 0
  733. // arg_msg = '查询供应商最新价内容失败'+sqlca.SQLErrText
  734. // GOTO ext
  735. // END IF
  736. //
  737. // IF ll_cnt = 0 THEN
  738. // DELETE
  739. // From u_spt_price
  740. // Where u_spt_price.sptid = :arg_sptid
  741. // And u_spt_price.mtrlid = :arg_mtrlid
  742. // And u_spt_price.status = :arg_status
  743. // And u_spt_price.woodcode = :arg_woodcode
  744. // And u_spt_price.pcode = :arg_pcode
  745. // And u_spt_price.jgdscrp = :arg_jgdscrp
  746. // And u_spt_price.unit = :arg_unit
  747. // And u_spt_price.moneyid = :arg_moneyid;
  748. // IF sqlca.SQLCode <> 0 THEN
  749. // rslt = 0
  750. // arg_msg = '删除供应商最新价失败'+sqlca.SQLErrText
  751. // GOTO ext
  752. // END IF
  753. // ELSE
  754. // SELECT top 1 fprice,zqrate,price,sys_changetime
  755. // INTO :ld_fprice,:ld_zqrate,:ld_price,:ld_sys_changetime
  756. // FROM u_spt_price_mx
  757. // WHERE u_spt_price_mx.sptid = :arg_sptid
  758. // AND u_spt_price_mx.mtrlid = :arg_mtrlid
  759. // AND u_spt_price_mx.status = :arg_status
  760. // AND u_spt_price_mx.woodcode = :arg_woodcode
  761. // AND u_spt_price_mx.pcode = :arg_pcode
  762. // AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  763. // AND u_spt_price_mx.unit = :arg_unit
  764. // AND u_spt_price_mx.Opdate < :ld_opdate
  765. // AND u_spt_price_mx.moneyid = :arg_moneyid
  766. // Order By u_spt_price_mx.Opdate Desc;
  767. // IF sqlca.SQLCode <> 0 THEN
  768. // rslt = 0
  769. // arg_msg = '查询供应商最新价失败'+sqlca.SQLErrText
  770. // GOTO ext
  771. // END IF
  772. //
  773. // UPDATE u_spt_price
  774. // SET fprice = :ld_fprice ,
  775. // zqrate = :ld_zqrate,
  776. // price = :ld_price,
  777. // sys_changetime = :ld_sys_changetime
  778. // WHERE u_spt_price.sptid = :arg_sptid
  779. // AND u_spt_price.mtrlid = :arg_mtrlid
  780. // AND u_spt_price.status = :arg_status
  781. // AND u_spt_price.woodcode = :arg_woodcode
  782. // AND u_spt_price.pcode = :arg_pcode
  783. // AND u_spt_price.jgdscrp = :arg_jgdscrp
  784. // AND u_spt_price.unit = :arg_unit
  785. // And u_spt_price.moneyid = :arg_moneyid;
  786. // IF sqlca.SQLCode <> 0 THEN
  787. // rslt = 0
  788. // arg_msg = '更新最新价失败'+sqlca.SQLErrText
  789. // GOTO ext
  790. // END IF
  791. // END IF
  792. //END IF
  793. //
  794. ////删除手动添加价格
  795. //DELETE
  796. //From u_spt_price_mx
  797. //Where u_spt_price_mx.sptid = :arg_sptid
  798. //And u_spt_price_mx.mtrlid = :arg_mtrlid
  799. //And u_spt_price_mx.inwareid = :arg_inwareid
  800. //And u_spt_price_mx.printid = :arg_printid
  801. //And u_spt_price_mx.status = :arg_status
  802. //And u_spt_price_mx.woodcode = :arg_woodcode
  803. //And u_spt_price_mx.pcode = :arg_pcode
  804. //And u_spt_price_mx.jgdscrp = :arg_jgdscrp
  805. //And u_spt_price_mx.unit = :arg_unit
  806. //And u_spt_price_mx.moneyid = :arg_moneyid;
  807. //IF sqlca.SQLCode <> 0 THEN
  808. // rslt = 0
  809. // arg_msg = '删除供应商价格历史失败'+sqlca.SQLErrText
  810. // GOTO ext
  811. //END IF
  812. //
  813. //ext:
  814. //IF rslt = 0 THEN
  815. // ROLLBACK;
  816. //ELSEIF rslt = 1 And arg_ifcommit THEN
  817. // COMMIT;
  818. //END IF
  819. //RETURN rslt
  820. end function
  821. public function integer uof_update_sptmtrlname (long arg_sptid, long arg_mtrlid, string arg_sptmtrlname, boolean arg_ifcommit, ref string arg_msg);//旧函数,取缔
  822. return uof_sptmtrlname_set(arg_sptid, arg_mtrlid, arg_sptmtrlname, arg_ifcommit, arg_msg)
  823. //Long rslt = 1
  824. //Long cnt = 0
  825. //
  826. //IF IsNull(arg_sptmtrlname) THEN arg_sptmtrlname = ''
  827. //
  828. ////检查供应商存在否
  829. //SELECT count(*)
  830. // INTO :cnt
  831. // FROM u_spt
  832. // Where u_spt.sptid = :arg_sptid;
  833. //IF sqlca.SQLCode <> 0 THEN
  834. // rslt = 0
  835. // arg_msg = '因网络和其他原因查询失败'+sqlca.SQLErrText
  836. // GOTO ext
  837. //END IF
  838. //
  839. //IF cnt = 0 THEN
  840. // rslt = 0
  841. // arg_msg = '供应商不存在'
  842. // GOTO ext
  843. //END IF
  844. //
  845. //
  846. ////检查商品存在否
  847. //SELECT count(*)
  848. // INTO :cnt
  849. // FROM u_mtrldef
  850. // Where u_mtrldef.mtrlid = :arg_mtrlid;
  851. //IF sqlca.SQLCode <> 0 THEN
  852. // rslt = 0
  853. // arg_msg = '因网络和其他原因查询失败'+sqlca.SQLErrText
  854. // GOTO ext
  855. //END IF
  856. //IF cnt = 0 THEN
  857. // rslt = 0
  858. // arg_msg = '物料资料不存在'
  859. // GOTO ext
  860. //END IF
  861. //
  862. //SELECT count(*)
  863. // INTO :cnt
  864. // FROM u_sptmtrlname
  865. // WHERE u_sptmtrlname.sptid = :arg_sptid AND
  866. // u_sptmtrlname.mtrlid = :arg_mtrlid;
  867. //IF sqlca.SQLCode <> 0 THEN
  868. // rslt = 0
  869. // arg_msg = '因网络和其他原因查询供应商物料最新价格失败'+sqlca.SQLErrText
  870. // GOTO ext
  871. //END IF
  872. //
  873. //
  874. //IF cnt > 0 THEN
  875. // UPDATE u_sptmtrlname
  876. // SET u_sptmtrlname.sptmtrlname = :arg_sptmtrlname
  877. // WHERE u_sptmtrlname.sptid = :arg_sptid AND
  878. // u_sptmtrlname.mtrlid = :arg_mtrlid;
  879. // IF sqlca.SQLCode <> 0 THEN
  880. // rslt = 0
  881. // arg_msg = '因网络和其它原因,供应商物料别名更新失败'+sqlca.SQLErrText
  882. // GOTO ext
  883. // END IF
  884. //ELSEIF cnt = 0 THEN
  885. // INSERT INTO u_sptmtrlname
  886. // (sptid,
  887. // mtrlid,
  888. // sptmtrlname)
  889. // VALUES
  890. // (:arg_sptid,
  891. // :arg_mtrlid,
  892. // :arg_sptmtrlname);
  893. // IF sqlca.SQLCode <> 0 THEN
  894. // rslt = 0
  895. // arg_msg = '因网络或其他原因,新增供应商物料别名失败'+sqlca.sqlerrtext
  896. // GOTO ext
  897. // END IF
  898. //END IF
  899. //
  900. //ext:
  901. //IF rslt = 0 THEN
  902. // ROLLBACK;
  903. //ELSEIF arg_ifcommit And rslt = 1 THEN
  904. // COMMIT;
  905. //END IF
  906. //
  907. //RETURN rslt
  908. //
  909. end function
  910. public function integer uof_check_limitprice (integer arg_thflag, long arg_mtrlid, string arg_status, string arg_woodcode, string arg_pcode, string arg_unit, decimal arg_price, ref string arg_msg);//采购订单,采购收货,限价
  911. Int rslt = 1
  912. Decimal ld_limitprice
  913. String ls_mtrlcode
  914. Long cnt
  915. Int li_price_ifpz_buy
  916. Decimal ld_updownprice
  917. arg_unit = Trim(arg_unit)
  918. arg_status = Trim(arg_status)
  919. arg_woodcode = Trim(arg_woodcode)
  920. arg_pcode = Trim(arg_pcode)
  921. SELECT mtrlcode,
  922. price_ifpz_buy,
  923. updownprice
  924. INTO :ls_mtrlcode,
  925. :li_price_ifpz_buy,
  926. :ld_updownprice
  927. FROM u_mtrldef
  928. Where mtrlid = :arg_mtrlid;
  929. IF sqlca.SQLCode <> 0 THEN
  930. rslt = 0
  931. arg_msg = '查询物料资料失败'+sqlca.SQLErrText
  932. GOTO ext
  933. END IF
  934. CHOOSE CASE li_price_ifpz_buy
  935. CASE 0
  936. arg_status = ''
  937. arg_woodcode = ''
  938. arg_pcode = ''
  939. CASE 1
  940. arg_pcode = ''
  941. arg_woodcode = ''
  942. CASE 2
  943. arg_status = ''
  944. arg_pcode = ''
  945. CASE 3
  946. arg_status = ''
  947. arg_woodcode = ''
  948. CASE 4
  949. arg_pcode = ''
  950. CASE 5
  951. arg_status = ''
  952. CASE 6
  953. arg_woodcode = ''
  954. END CHOOSE
  955. SELECT count(*) INTO :cnt
  956. FROM u_mtrl_limitprice
  957. WHERE mtrlid = :arg_mtrlid
  958. AND status = :arg_status
  959. AND woodcode = :arg_woodcode
  960. AND pcode = :arg_pcode
  961. And unit = :arg_unit;
  962. IF sqlca.SQLCode <> 0 THEN
  963. rslt = 0
  964. arg_msg = '查询物料['+ls_mtrlcode+']是否设有采购限价失败'+sqlca.SQLErrText
  965. GOTO ext
  966. END IF
  967. IF cnt = 1 THEN
  968. SELECT limitprice INTO :ld_limitprice
  969. FROM u_mtrl_limitprice
  970. WHERE mtrlid = :arg_mtrlid
  971. AND status = :arg_status
  972. AND woodcode = :arg_woodcode
  973. AND pcode = :arg_pcode
  974. And unit = :arg_unit;
  975. IF sqlca.SQLCode <> 0 THEN
  976. rslt = 0
  977. arg_msg = '查询物料['+ls_mtrlcode+']采购限价失败'+sqlca.SQLErrText
  978. GOTO ext
  979. END IF
  980. IF arg_thflag = 0 THEN
  981. IF arg_price > ld_limitprice + ld_updownprice THEN
  982. rslt = 0
  983. arg_msg = '物料:'+ls_mtrlcode+',收货单价{'+String(arg_price,'#,##0.00##')+'} 高于收货限价{'+String( ld_limitprice + ld_updownprice ,'#,##0.00##')+'}'
  984. GOTO ext
  985. END IF
  986. ELSE
  987. IF arg_price < ld_limitprice - ld_updownprice THEN
  988. rslt = 0
  989. arg_msg = '物料:'+ls_mtrlcode+',退货单价{'+String(arg_price,'#,##0.00##')+'} 低于收货限价{'+String( ld_limitprice - ld_updownprice ,'#,##0.00##')+'}'
  990. GOTO ext
  991. END IF
  992. END IF
  993. END IF
  994. ext:
  995. RETURN rslt
  996. end function
  997. public function integer uof_getnewprice (long arg_sptid, long arg_moneyid, long arg_mtrlid, ref string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, ref decimal arg_price, ref decimal arg_zqrate, ref decimal arg_rate, ref datetime arg_opdate, ref string arg_msg);
  998. datetime ldt_effdate
  999. ldt_effdate = datetime(1900-01-01)
  1000. return uof_sptmtrlprice_get ( arg_sptid, arg_moneyid, arg_mtrlid, arg_unit, arg_status, arg_woodcode, arg_pcode, arg_jgdscrp, ldt_effdate, arg_price, arg_zqrate, arg_rate, arg_opdate,arg_msg)
  1001. //Long rslt = 1
  1002. //Decimal rtn_price,rtn_zqrate,rtn_rate, rtn_rate_buy
  1003. //String rtn_unit, rtn_unit_buy
  1004. //String rtn_wareunit
  1005. //Int li_iflimitprice,li_price_ifpz_buy
  1006. //DateTime rtn_opdate
  1007. //
  1008. //arg_status = Trim(arg_status)
  1009. //arg_woodcode = Trim(arg_woodcode)
  1010. //arg_pcode = Trim(arg_pcode)
  1011. //arg_jgdscrp = Trim(arg_jgdscrp)
  1012. //arg_unit = Trim(arg_unit)
  1013. //
  1014. //
  1015. //SELECT price_ifpz_buy, unit,unit_buy,rate_buy , iflimitprice
  1016. // INTO :li_price_ifpz_buy, :rtn_wareunit,:rtn_unit_buy,:rtn_rate_buy,:li_iflimitprice
  1017. // FROM u_mtrldef
  1018. // Where mtrlid = :arg_mtrlid;
  1019. //IF sqlca.SQLCode <> 0 THEN
  1020. // rslt = 0
  1021. // arg_msg = '查询物料采购限价策略失败,'+sqlca.SQLErrText
  1022. // GOTO ext
  1023. //END IF
  1024. //
  1025. //CHOOSE CASE li_price_ifpz_buy
  1026. // CASE 0
  1027. // arg_status = ''
  1028. // arg_woodcode = ''
  1029. // arg_pcode = ''
  1030. // CASE 1
  1031. // arg_pcode = ''
  1032. // arg_woodcode = ''
  1033. // CASE 2
  1034. // arg_status = ''
  1035. // arg_pcode = ''
  1036. // CASE 3
  1037. // arg_status = ''
  1038. // arg_woodcode = ''
  1039. // CASE 4
  1040. // arg_pcode = ''
  1041. // CASE 5
  1042. // arg_status = ''
  1043. // CASE 6
  1044. // arg_woodcode = ''
  1045. //END CHOOSE
  1046. //
  1047. //IF arg_unit = '' THEN
  1048. // IF uo_option_buyprice_ifbj = 0 Or uo_option_buyprice_ifbj = 2 And li_iflimitprice = 0 THEN //取最新价
  1049. // SELECT top 1 fprice,zqrate,rate,unit,sys_changetime
  1050. // INTO :rtn_price,:rtn_zqrate ,:rtn_rate ,:rtn_unit, :rtn_opdate
  1051. // FROM u_spt_price
  1052. // WHERE u_spt_price.mtrlid = :arg_mtrlid
  1053. // AND u_spt_price.sptid = :arg_sptid
  1054. // AND u_spt_price.status = :arg_status
  1055. // AND u_spt_price.woodcode = :arg_woodcode
  1056. // AND u_spt_price.pcode = :arg_pcode
  1057. // AND u_spt_price.jgdscrp = :arg_jgdscrp
  1058. // AND u_spt_price.moneyid = :arg_moneyid
  1059. // Order By u_spt_price.sys_changetime Desc;
  1060. // ELSE
  1061. // SELECT top 1 fprice_bj,zqrate_bj,rate_bj,unit,sys_changetime
  1062. // INTO :rtn_price,:rtn_zqrate ,:rtn_rate ,:rtn_unit, :rtn_opdate
  1063. // FROM u_spt_price
  1064. // WHERE u_spt_price.mtrlid = :arg_mtrlid
  1065. // AND u_spt_price.sptid = :arg_sptid
  1066. // AND u_spt_price.status = :arg_status
  1067. // AND u_spt_price.woodcode = :arg_woodcode
  1068. // AND u_spt_price.pcode = :arg_pcode
  1069. // AND u_spt_price.jgdscrp = :arg_jgdscrp
  1070. // AND u_spt_price.moneyid = :arg_moneyid
  1071. // Order By u_spt_price.sys_changetime Desc;
  1072. // END IF
  1073. //
  1074. // IF sqlca.SQLCode = -1 THEN
  1075. // rslt = 0
  1076. // arg_msg = '查询价格操作失败'+sqlca.SQLErrText
  1077. // GOTO ext
  1078. // ELSEIF sqlca.SQLCode = 100 Or IsNull(rtn_price) THEN
  1079. //
  1080. // IF rtn_unit_buy = '' Or rtn_rate_buy = 0 THEN
  1081. // rtn_unit = rtn_wareunit
  1082. // rtn_rate = 1
  1083. // ELSE
  1084. // rtn_unit = rtn_unit_buy
  1085. // rtn_rate = rtn_rate_buy
  1086. // END IF
  1087. //
  1088. // rslt = 2
  1089. // GOTO ext
  1090. // END IF
  1091. //ELSE
  1092. // SELECT top 1 fprice,zqrate,rate,unit,sys_changetime
  1093. // INTO :rtn_price,:rtn_zqrate ,:rtn_rate ,:rtn_unit, :rtn_opdate
  1094. // FROM u_spt_price
  1095. // WHERE u_spt_price.mtrlid = :arg_mtrlid
  1096. // AND u_spt_price.sptid = :arg_sptid
  1097. // AND u_spt_price.unit = :arg_unit
  1098. // AND u_spt_price.status = :arg_status
  1099. // AND u_spt_price.woodcode = :arg_woodcode
  1100. // AND u_spt_price.pcode = :arg_pcode
  1101. // AND u_spt_price.jgdscrp = :arg_jgdscrp
  1102. // AND u_spt_price.moneyid = :arg_moneyid
  1103. // Order By u_spt_price.sys_changetime Desc;
  1104. //
  1105. //
  1106. // IF sqlca.SQLCode = -1 THEN
  1107. // rslt = 0
  1108. // arg_msg = '查询操作失败'+sqlca.SQLErrText
  1109. // GOTO ext
  1110. // ELSEIF sqlca.SQLCode = 100 Or IsNull(rtn_price) THEN
  1111. // rslt = 2
  1112. // GOTO ext
  1113. // END IF
  1114. //
  1115. //END IF
  1116. //
  1117. //ext:
  1118. //IF rslt <> 1 THEN
  1119. // rtn_price = 0.00
  1120. // rtn_zqrate = 1
  1121. // // rtn_rate = 1
  1122. // SetNull(rtn_opdate)
  1123. //END IF
  1124. //
  1125. //arg_price = rtn_price
  1126. //arg_zqrate = rtn_zqrate
  1127. //arg_rate = rtn_rate
  1128. //arg_unit = rtn_unit
  1129. //arg_opdate = rtn_opdate
  1130. //
  1131. //
  1132. //RETURN rslt
  1133. end function
  1134. public function integer uof_sptmtrlname_set (long arg_sptid, long arg_mtrlid, string arg_sptmtrlname, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1
  1135. Long cnt = 0
  1136. IF IsNull(arg_sptmtrlname) THEN arg_sptmtrlname = ''
  1137. //检查供应商存在否
  1138. SELECT count(*)
  1139. INTO :cnt
  1140. FROM u_spt
  1141. Where u_spt.sptid = :arg_sptid;
  1142. IF sqlca.SQLCode <> 0 THEN
  1143. rslt = 0
  1144. arg_msg = '因网络和其他原因查询失败'+sqlca.SQLErrText
  1145. GOTO ext
  1146. END IF
  1147. IF cnt = 0 THEN
  1148. rslt = 0
  1149. arg_msg = '供应商不存在'
  1150. GOTO ext
  1151. END IF
  1152. //检查商品存在否
  1153. SELECT count(*)
  1154. INTO :cnt
  1155. FROM u_mtrldef
  1156. Where u_mtrldef.mtrlid = :arg_mtrlid;
  1157. IF sqlca.SQLCode <> 0 THEN
  1158. rslt = 0
  1159. arg_msg = '因网络和其他原因查询失败'+sqlca.SQLErrText
  1160. GOTO ext
  1161. END IF
  1162. IF cnt = 0 THEN
  1163. rslt = 0
  1164. arg_msg = '物料资料不存在'
  1165. GOTO ext
  1166. END IF
  1167. UPDATE u_sptmtrlname
  1168. SET sptmtrlname = :arg_sptmtrlname
  1169. WHERE sptid = :arg_sptid
  1170. AND mtrlid = :arg_mtrlid;
  1171. IF sqlca.SQLCode = 0 THEN
  1172. IF sqlca.SQLNRows = 0 THEN
  1173. INSERT INTO u_sptmtrlname
  1174. (sptid,
  1175. mtrlid,
  1176. sptmtrlname)
  1177. VALUES
  1178. (:arg_sptid,
  1179. :arg_mtrlid,
  1180. :arg_sptmtrlname);
  1181. IF sqlca.SQLCode <> 0 THEN
  1182. rslt = 0
  1183. arg_msg = '新增供应商物料别名失败,'+sqlca.SQLErrText
  1184. GOTO ext
  1185. END IF
  1186. END IF
  1187. ELSE
  1188. rslt = 0
  1189. arg_msg = '更新供应商物料别名失败,'+sqlca.SQLErrText
  1190. GOTO ext
  1191. END IF
  1192. /////////////////////////////////////////////////////////////////// //
  1193. //SELECT count(*)
  1194. // INTO :cnt
  1195. // FROM u_sptmtrlname
  1196. // WHERE u_sptmtrlname.sptid = :arg_sptid AND
  1197. // u_sptmtrlname.mtrlid = :arg_mtrlid;
  1198. //IF sqlca.SQLCode <> 0 THEN
  1199. // rslt = 0
  1200. // arg_msg = '因网络和其他原因查询供应商物料最新价格失败'+sqlca.SQLErrText
  1201. // GOTO ext
  1202. //END IF
  1203. //
  1204. //
  1205. //IF cnt > 0 THEN
  1206. // UPDATE u_sptmtrlname
  1207. // SET u_sptmtrlname.sptmtrlname = :arg_sptmtrlname
  1208. // WHERE u_sptmtrlname.sptid = :arg_sptid AND
  1209. // u_sptmtrlname.mtrlid = :arg_mtrlid;
  1210. // IF sqlca.SQLCode <> 0 THEN
  1211. // rslt = 0
  1212. // arg_msg = '因网络和其它原因,供应商物料别名更新失败'+sqlca.SQLErrText
  1213. // GOTO ext
  1214. // END IF
  1215. //ELSEIF cnt = 0 THEN
  1216. // INSERT INTO u_sptmtrlname
  1217. // (sptid,
  1218. // mtrlid,
  1219. // sptmtrlname)
  1220. // VALUES
  1221. // (:arg_sptid,
  1222. // :arg_mtrlid,
  1223. // :arg_sptmtrlname);
  1224. // IF sqlca.SQLCode <> 0 THEN
  1225. // rslt = 0
  1226. // arg_msg = '因网络或其他原因,新增供应商物料别名失败'+sqlca.SQLErrText
  1227. // GOTO ext
  1228. // END IF
  1229. //END IF
  1230. ext:
  1231. IF rslt = 0 THEN
  1232. ROLLBACK;
  1233. ELSEIF arg_ifcommit And rslt = 1 THEN
  1234. COMMIT;
  1235. END IF
  1236. RETURN rslt
  1237. end function
  1238. public function integer uof_sptmtrlname_get (long arg_sptid, long arg_mtrlid, ref string arg_sptmtrlname, ref string arg_msg);Long rslt = 1
  1239. String ls_sptmtrlname
  1240. SELECT sptmtrlname
  1241. INTO :ls_sptmtrlname
  1242. FROM u_sptmtrlname
  1243. WHERE u_sptmtrlname.mtrlid = :arg_mtrlid
  1244. AND u_sptmtrlname.sptid = :arg_sptid;
  1245. IF sqlca.SQLCode = -1 THEN
  1246. rslt = 0
  1247. arg_msg = '查询供应商物料别名操作失败,'+sqlca.SQLErrText
  1248. GOTO ext
  1249. ELSEIF sqlca.SQLCode = 100 OR IsNull(ls_sptmtrlname) THEN
  1250. ls_sptmtrlname = ''
  1251. END IF
  1252. arg_sptmtrlname = ls_sptmtrlname
  1253. ext:
  1254. RETURN rslt
  1255. end function
  1256. public function integer uof_sptmtrlprice_get (long arg_sptid, long arg_moneyid, long arg_mtrlid, ref string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, datetime arg_effdate, ref decimal arg_fprice, ref decimal arg_zqrate, ref decimal arg_rate, ref datetime arg_billdate, ref string arg_msg);//====================================================================
  1257. // 事件: uo_spt_price.Script - uof_sptmtrlprice_get ( long arg_sptid, long arg_moneyid, long arg_mtrlid, ref string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, datetime arg_effdate, ref decimal arg_fprice, ref decimal arg_zqrate, ref()
  1258. //--------------------------------------------------------------------
  1259. // 描述:
  1260. //--------------------------------------------------------------------
  1261. // 参数:
  1262. // value long arg_sptid
  1263. // value long arg_moneyid
  1264. // value long arg_mtrlid
  1265. // reference string arg_unit
  1266. // value string arg_status
  1267. // value string arg_woodcode
  1268. // value string arg_pcode
  1269. // value string arg_jgdscrp
  1270. // value datetime arg_effdate
  1271. // reference decimal arg_fprice
  1272. // reference decimal arg_zqrate
  1273. // reference decimal arg_rate
  1274. // reference datetime arg_billdate
  1275. // reference string arg_msg
  1276. //--------------------------------------------------------------------
  1277. // 返回: (none)
  1278. //--------------------------------------------------------------------
  1279. // 作者: LHD 日期: 2013年05月28日
  1280. //--------------------------------------------------------------------
  1281. // Copyright (c) 2002-2018 RICHTA(TM), All rights reserved.
  1282. //--------------------------------------------------------------------
  1283. // 修改历史:
  1284. //
  1285. //====================================================================
  1286. Long rslt = 1
  1287. Decimal lde_fprice,lde_zqrate,lde_rate, lde_price, lde_wareprice, lde_rate_buy
  1288. String ls_unit, ls_unit_buy
  1289. String ls_wareunit
  1290. Int li_iflimitprice,li_price_ifpz_buy
  1291. DateTime lde_billdate
  1292. arg_status = Trim(arg_status)
  1293. arg_woodcode = Trim(arg_woodcode)
  1294. arg_pcode = Trim(arg_pcode)
  1295. arg_jgdscrp = Trim(arg_jgdscrp)
  1296. arg_unit = Trim(arg_unit)
  1297. arg_effdate = DateTime(Date(arg_effdate),Time(0))
  1298. IF uo_option_buyprice_ifbj = -1000 THEN
  1299. arg_msg = '选项:[053]收货单取单价模式,读取初始默认值失败,操作取消!'
  1300. rslt = 0
  1301. GOTO ext
  1302. END IF
  1303. IF uo_option_sptprice_effdate = -1000 THEN
  1304. arg_msg = '选项:[244]供应商报价使用生效日期,读取初始默认值失败,操作取消!'
  1305. rslt = 0
  1306. GOTO ext
  1307. END IF
  1308. SELECT iflimitprice,price_ifpz_buy, unit,unit_buy,rate_buy
  1309. INTO :li_iflimitprice,:li_price_ifpz_buy,:ls_wareunit,:ls_unit_buy,:lde_rate_buy
  1310. FROM u_mtrldef
  1311. Where mtrlid = :arg_mtrlid;
  1312. IF sqlca.SQLCode <> 0 THEN
  1313. arg_msg = '查询物料限价属性失败 '+sqlca.SQLErrText
  1314. rslt = 0
  1315. GOTO ext
  1316. END IF
  1317. CHOOSE CASE li_price_ifpz_buy
  1318. CASE 0
  1319. arg_status = ''
  1320. arg_woodcode = ''
  1321. arg_pcode = ''
  1322. CASE 1
  1323. arg_pcode = ''
  1324. arg_woodcode = ''
  1325. CASE 2
  1326. arg_status = ''
  1327. arg_pcode = ''
  1328. CASE 3
  1329. arg_status = ''
  1330. arg_woodcode = ''
  1331. CASE 4
  1332. arg_pcode = ''
  1333. CASE 5
  1334. arg_status = ''
  1335. CASE 6
  1336. arg_woodcode = ''
  1337. END CHOOSE
  1338. IF uo_option_buyprice_ifbj = 0 Or uo_option_buyprice_ifbj = 2 And li_iflimitprice = 0 THEN //取最新价
  1339. SELECT top 1 fprice,zqrate,rate,price, wareprice,unit,sys_changetime
  1340. INTO :lde_fprice,:lde_zqrate ,:lde_rate ,:lde_price, :lde_wareprice,:ls_unit, :lde_billdate
  1341. FROM u_spt_price
  1342. WHERE sptid = :arg_sptid
  1343. AND moneyid = :arg_moneyid
  1344. AND mtrlid = :arg_mtrlid
  1345. AND (unit = :arg_unit OR :arg_unit = '')
  1346. AND status = :arg_status
  1347. AND woodcode = :arg_woodcode
  1348. AND pcode = :arg_pcode
  1349. AND jgdscrp = :arg_jgdscrp
  1350. Order By sys_changetime Desc;
  1351. ELSE //取报价
  1352. IF uo_option_sptprice_effdate = 1 THEN
  1353. SELECT top 1 fprice,zqrate,rate,price, wareprice,unit, opdate
  1354. INTO :lde_fprice,:lde_zqrate ,:lde_rate ,:lde_price, :lde_wareprice,:ls_unit, :lde_billdate
  1355. FROM u_spt_price_mx
  1356. WHERE sptid = :arg_sptid
  1357. AND moneyid = :arg_moneyid
  1358. AND mtrlid = :arg_mtrlid
  1359. AND (unit = :arg_unit OR :arg_unit = '')
  1360. AND status = :arg_status
  1361. AND woodcode = :arg_woodcode
  1362. AND pcode = :arg_pcode
  1363. AND jgdscrp = :arg_jgdscrp
  1364. AND effdate <= :arg_effdate
  1365. AND effdate_end >= :arg_effdate
  1366. AND billtype = 2
  1367. Order By opdate Desc;
  1368. ELSE
  1369. SELECT top 1 fprice_bj,zqrate_bj,rate_bj,price_bj, wareprice_bj,unit,sys_changetime
  1370. INTO :lde_fprice,:lde_zqrate ,:lde_rate ,:lde_price, :lde_wareprice,:ls_unit, :lde_billdate
  1371. FROM u_spt_price
  1372. WHERE sptid = :arg_sptid
  1373. AND moneyid = :arg_moneyid
  1374. AND mtrlid = :arg_mtrlid
  1375. AND (unit = :arg_unit OR :arg_unit = '')
  1376. AND status = :arg_status
  1377. AND woodcode = :arg_woodcode
  1378. AND pcode = :arg_pcode
  1379. AND jgdscrp = :arg_jgdscrp
  1380. Order By sys_changetime Desc;
  1381. END IF
  1382. END IF
  1383. IF sqlca.SQLCode = -1 THEN
  1384. rslt = 0
  1385. arg_msg = '查询供应商物料最新价格失败'+sqlca.SQLErrText
  1386. GOTO ext
  1387. ELSEIF sqlca.SQLCode = 100 Or IsNull(lde_fprice) THEN
  1388. // lde_zqrate = 1
  1389. // lde_fprice = 0.00
  1390. IF arg_unit = '' THEN
  1391. IF ls_unit_buy = '' Or lde_rate_buy = 0 THEN
  1392. ls_unit = ls_wareunit
  1393. lde_rate = 1
  1394. ELSE
  1395. ls_unit = ls_unit_buy
  1396. lde_rate = lde_rate_buy
  1397. END IF
  1398. END IF
  1399. rslt = 2
  1400. GOTO ext
  1401. END IF
  1402. ext:
  1403. IF rslt <> 1 THEN
  1404. lde_fprice = 0.00
  1405. lde_zqrate = 1
  1406. //lde_rate = 1
  1407. IF ls_unit = '' THEN
  1408. ls_unit = arg_unit
  1409. END IF
  1410. END IF
  1411. if lde_zqrate = 0 then lde_zqrate = 1
  1412. arg_fprice = lde_fprice
  1413. arg_zqrate = lde_zqrate
  1414. arg_rate = lde_rate
  1415. IF ls_unit <> '' THEN
  1416. arg_unit = ls_unit
  1417. END IF
  1418. arg_billdate = lde_billdate
  1419. RETURN rslt
  1420. end function
  1421. public function integer uof_sptmtrlprice_delete (long arg_inwareid, long arg_printid, long arg_sptid, long arg_moneyid, long arg_mtrlid, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, string arg_unit, boolean arg_ifcommit, ref string arg_msg);//====================================================================
  1422. // 事件: uo_spt_price.Script - uof_sptmtrlprice_delete ( long arg_inwareid, long arg_printid, long arg_sptid, long arg_moneyid, long arg_mtrlid, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, string arg_unit, boolean arg_ifcommit, ref string arg_()
  1423. //--------------------------------------------------------------------
  1424. // 描述:
  1425. //--------------------------------------------------------------------
  1426. // 参数:
  1427. // value long arg_inwareid
  1428. // value long arg_printid
  1429. // value long arg_sptid
  1430. // value long arg_moneyid
  1431. // value long arg_mtrlid
  1432. // value string arg_status
  1433. // value string arg_woodcode
  1434. // value string arg_pcode
  1435. // value string arg_jgdscrp
  1436. // value string arg_unit
  1437. // value boolean arg_ifcommit
  1438. // reference string arg_msg
  1439. //--------------------------------------------------------------------
  1440. // 返回: (none)
  1441. //--------------------------------------------------------------------
  1442. // 作者: LHD 日期: 2013年05月29日
  1443. //--------------------------------------------------------------------
  1444. // Copyright (c) 2002-2018 RICHTA(TM), All rights reserved.
  1445. //--------------------------------------------------------------------
  1446. // 修改历史:
  1447. //
  1448. //====================================================================
  1449. Int rslt = 1
  1450. Long cnt = 0,ll_cnt = 0
  1451. Int li_ifbj
  1452. DateTime ld_opdate
  1453. Decimal ld_fprice,ld_zqrate,ld_price, lde_wareprice, lde_rate
  1454. DateTime ld_sys_changetime,ldt_opdate
  1455. String ls_mtrlcode
  1456. Int li_price_ifpz_buy
  1457. Boolean lb_del = False
  1458. //检查商品存在否
  1459. SELECT mtrlcode,
  1460. price_ifpz_buy
  1461. INTO :ls_mtrlcode,
  1462. :li_price_ifpz_buy
  1463. FROM u_mtrldef
  1464. Where u_mtrldef.mtrlid = :arg_mtrlid;
  1465. IF sqlca.SQLCode <> 0 THEN
  1466. rslt = 0
  1467. arg_msg = '查询物料编码失败,'+sqlca.SQLErrText
  1468. GOTO ext
  1469. END IF
  1470. CHOOSE CASE li_price_ifpz_buy
  1471. CASE 0
  1472. arg_status = ''
  1473. arg_woodcode = ''
  1474. arg_pcode = ''
  1475. CASE 1
  1476. arg_pcode = ''
  1477. arg_woodcode = ''
  1478. CASE 2
  1479. arg_status = ''
  1480. arg_pcode = ''
  1481. CASE 3
  1482. arg_status = ''
  1483. arg_woodcode = ''
  1484. CASE 4
  1485. arg_pcode = ''
  1486. CASE 5
  1487. arg_status = ''
  1488. CASE 6
  1489. arg_woodcode = ''
  1490. END CHOOSE
  1491. SELECT Top 1 Opdate,ifbj
  1492. INTO :ldt_opdate, :li_ifbj
  1493. FROM u_spt_price_mx
  1494. WHERE u_spt_price_mx.sptid = :arg_sptid
  1495. AND u_spt_price_mx.moneyid = :arg_moneyid
  1496. AND u_spt_price_mx.mtrlid = :arg_mtrlid
  1497. AND u_spt_price_mx.status = :arg_status
  1498. AND u_spt_price_mx.woodcode = :arg_woodcode
  1499. AND u_spt_price_mx.pcode = :arg_pcode
  1500. AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  1501. AND u_spt_price_mx.unit = :arg_unit
  1502. AND u_spt_price_mx.inwareid = :arg_inwareid
  1503. AND u_spt_price_mx.printid = :arg_printid
  1504. Order By u_spt_price_mx.Opdate Desc;
  1505. IF sqlca.SQLCode <> 0 THEN
  1506. IF sqlca.SQLCode = 100 THEN
  1507. rslt = 1 //明细单价为0 , 有可能不插入供应商历史
  1508. GOTO ext
  1509. ELSE
  1510. rslt = 0
  1511. arg_msg = '查询供应商价格历史明细信息失败'+sqlca.SQLErrText
  1512. GOTO ext
  1513. END IF
  1514. END IF
  1515. //删除添加价格
  1516. DELETE FROM u_spt_price_mx
  1517. WHERE u_spt_price_mx.sptid = :arg_sptid
  1518. AND u_spt_price_mx.moneyid = :arg_moneyid
  1519. AND u_spt_price_mx.mtrlid = :arg_mtrlid
  1520. AND u_spt_price_mx.status = :arg_status
  1521. AND u_spt_price_mx.woodcode = :arg_woodcode
  1522. AND u_spt_price_mx.pcode = :arg_pcode
  1523. AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  1524. AND u_spt_price_mx.unit = :arg_unit
  1525. AND u_spt_price_mx.inwareid = :arg_inwareid
  1526. AND u_spt_price_mx.printid = :arg_printid
  1527. And u_spt_price_mx.Opdate = :ldt_opdate;
  1528. IF sqlca.SQLCode <> 0 THEN
  1529. rslt = 0
  1530. arg_msg = '删除供应商价格历史失败'+sqlca.SQLErrText
  1531. GOTO ext
  1532. END IF
  1533. //查询最新价格,更新u_spt_price
  1534. SELECT Top 1 fprice,zqrate,price,wareprice,rate,Opdate,ifbj
  1535. INTO :ld_fprice,:ld_zqrate,:ld_price,:lde_wareprice,:lde_rate,:ld_sys_changetime, :li_ifbj
  1536. FROM u_spt_price_mx
  1537. WHERE u_spt_price_mx.sptid = :arg_sptid
  1538. AND u_spt_price_mx.moneyid = :arg_moneyid
  1539. AND u_spt_price_mx.mtrlid = :arg_mtrlid
  1540. AND u_spt_price_mx.status = :arg_status
  1541. AND u_spt_price_mx.woodcode = :arg_woodcode
  1542. AND u_spt_price_mx.pcode = :arg_pcode
  1543. AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  1544. AND u_spt_price_mx.unit = :arg_unit
  1545. AND u_spt_price_mx.ifbj = :li_ifbj
  1546. Order By u_spt_price_mx.Opdate Desc;
  1547. IF sqlca.SQLCode <> 0 THEN
  1548. IF sqlca.SQLNRows = 0 THEN
  1549. //如果没有,找另一种,有则update, 没有则删除
  1550. SELECT count(*)
  1551. INTO :ll_cnt
  1552. FROM u_spt_price_mx
  1553. WHERE u_spt_price_mx.sptid = :arg_sptid
  1554. AND u_spt_price_mx.moneyid = :arg_moneyid
  1555. AND u_spt_price_mx.mtrlid = :arg_mtrlid
  1556. AND u_spt_price_mx.status = :arg_status
  1557. AND u_spt_price_mx.woodcode = :arg_woodcode
  1558. AND u_spt_price_mx.pcode = :arg_pcode
  1559. AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  1560. AND u_spt_price_mx.unit = :arg_unit
  1561. And u_spt_price_mx.ifbj = 1 - :li_ifbj;
  1562. IF ll_cnt = 0 THEN
  1563. lb_del = True
  1564. ELSE
  1565. ld_fprice = 0
  1566. ld_zqrate = 1
  1567. ld_price = 0
  1568. lde_wareprice = 0
  1569. lde_rate = 1
  1570. setnull(ld_sys_changetime)
  1571. END IF
  1572. ELSE
  1573. rslt = 0
  1574. arg_msg = '查询供应商价格历史失败'+sqlca.SQLErrText
  1575. GOTO ext
  1576. END IF
  1577. END IF
  1578. IF lb_del THEN
  1579. DELETE FROM u_spt_price
  1580. WHERE sptid = :arg_sptid
  1581. AND moneyid = :arg_moneyid
  1582. AND mtrlid = :arg_mtrlid
  1583. AND status = :arg_status
  1584. AND woodcode = :arg_woodcode
  1585. AND pcode = :arg_pcode
  1586. AND jgdscrp = :arg_jgdscrp
  1587. And unit = :arg_unit;
  1588. IF sqlca.SQLCode <> 0 THEN
  1589. rslt = 0
  1590. arg_msg = '删除供应商价格历史失败'+sqlca.SQLErrText
  1591. GOTO ext
  1592. END IF
  1593. ELSE
  1594. //如果前面删除,可能没有更新
  1595. IF li_ifbj = 0 THEN
  1596. UPDATE u_spt_price
  1597. SET fprice = :ld_fprice ,
  1598. zqrate = :ld_zqrate,
  1599. price = :ld_price,
  1600. wareprice = :lde_wareprice,
  1601. rate = :lde_rate,
  1602. sys_changetime = :ld_sys_changetime
  1603. WHERE u_spt_price.sptid = :arg_sptid
  1604. AND u_spt_price.mtrlid = :arg_mtrlid
  1605. AND u_spt_price.status = :arg_status
  1606. AND u_spt_price.woodcode = :arg_woodcode
  1607. AND u_spt_price.pcode = :arg_pcode
  1608. AND u_spt_price.jgdscrp = :arg_jgdscrp
  1609. AND u_spt_price.unit = :arg_unit
  1610. And u_spt_price.moneyid = :arg_moneyid;
  1611. ELSE
  1612. UPDATE u_spt_price
  1613. SET fprice_bj = :ld_fprice ,
  1614. zqrate_bj = :ld_zqrate,
  1615. price_bj = :ld_price,
  1616. wareprice_bj = :lde_wareprice,
  1617. rate_bj = :lde_rate,
  1618. sys_changetime = :ld_sys_changetime
  1619. WHERE u_spt_price.sptid = :arg_sptid
  1620. AND u_spt_price.mtrlid = :arg_mtrlid
  1621. AND u_spt_price.status = :arg_status
  1622. AND u_spt_price.woodcode = :arg_woodcode
  1623. AND u_spt_price.pcode = :arg_pcode
  1624. AND u_spt_price.jgdscrp = :arg_jgdscrp
  1625. AND u_spt_price.unit = :arg_unit
  1626. And u_spt_price.moneyid = :arg_moneyid;
  1627. END IF
  1628. IF sqlca.SQLCode <> 0 THEN
  1629. rslt = 0
  1630. arg_msg = '更新供应商价格历史失败'+sqlca.SQLErrText
  1631. GOTO ext
  1632. END IF
  1633. END IF
  1634. /*
  1635. SELECT count(*) INTO :cnt
  1636. FROM u_spt_price_mx
  1637. WHERE u_spt_price_mx.sptid = :arg_sptid
  1638. And u_spt_price_mx.moneyid = :arg_moneyid
  1639. AND u_spt_price_mx.mtrlid = :arg_mtrlid
  1640. AND u_spt_price_mx.status = :arg_status
  1641. AND u_spt_price_mx.woodcode = :arg_woodcode
  1642. AND u_spt_price_mx.pcode = :arg_pcode
  1643. AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  1644. AND u_spt_price_mx.unit = :arg_unit
  1645. AND u_spt_price_mx.inwareid = :arg_inwareid
  1646. AND u_spt_price_mx.printid = :arg_printid;
  1647. IF sqlca.SQLCode <> 0 THEN
  1648. rslt = 0
  1649. arg_msg = '查询供应商最新价条目失败'+sqlca.SQLErrText
  1650. GOTO ext
  1651. END IF
  1652. IF cnt = 0 THEN
  1653. rslt = 1
  1654. GOTO ext
  1655. END IF
  1656. SELECT top 1 Opdate INTO :ld_opdate
  1657. FROM u_spt_price_mx
  1658. WHERE u_spt_price_mx.sptid = :arg_sptid
  1659. And u_spt_price_mx.moneyid = :arg_moneyid
  1660. AND u_spt_price_mx.mtrlid = :arg_mtrlid
  1661. AND u_spt_price_mx.status = :arg_status
  1662. AND u_spt_price_mx.woodcode = :arg_woodcode
  1663. AND u_spt_price_mx.pcode = :arg_pcode
  1664. AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  1665. AND u_spt_price_mx.unit = :arg_unit
  1666. AND u_spt_price_mx.inwareid = :arg_inwareid
  1667. AND u_spt_price_mx.printid = :arg_printid
  1668. Order By Opdate Desc;
  1669. IF sqlca.SQLCode <> 0 THEN
  1670. rslt = 0
  1671. arg_msg = '查询供应商最新价时间失败'+sqlca.SQLErrText
  1672. GOTO ext
  1673. END IF
  1674. SELECT count(*) INTO :cnt
  1675. FROM u_spt_price_mx
  1676. WHERE u_spt_price_mx.sptid = :arg_sptid
  1677. And u_spt_price_mx.moneyid = :arg_moneyid
  1678. AND u_spt_price_mx.mtrlid = :arg_mtrlid
  1679. AND u_spt_price_mx.status = :arg_status
  1680. AND u_spt_price_mx.woodcode = :arg_woodcode
  1681. AND u_spt_price_mx.pcode = :arg_pcode
  1682. AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  1683. AND u_spt_price_mx.unit = :arg_unit
  1684. AND u_spt_price_mx.Opdate > :ld_opdate;
  1685. IF sqlca.SQLCode <> 0 THEN
  1686. rslt = 0
  1687. arg_msg = '查询供应商最新价内容失败'+sqlca.SQLErrText
  1688. GOTO ext
  1689. END IF
  1690. IF cnt = 0 THEN //如果被删明细是最新,用次新明细更新最新价
  1691. SELECT count(*) INTO :ll_cnt
  1692. FROM u_spt_price_mx
  1693. WHERE u_spt_price_mx.sptid = :arg_sptid
  1694. AND u_spt_price_mx.mtrlid = :arg_mtrlid
  1695. AND u_spt_price_mx.status = :arg_status
  1696. AND u_spt_price_mx.woodcode = :arg_woodcode
  1697. AND u_spt_price_mx.pcode = :arg_pcode
  1698. AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  1699. AND u_spt_price_mx.unit = :arg_unit
  1700. And u_spt_price_mx.Opdate < :ld_opdate
  1701. And u_spt_price_mx.moneyid = :arg_moneyid;
  1702. IF sqlca.SQLCode <> 0 THEN
  1703. rslt = 0
  1704. arg_msg = '查询供应商最新价内容失败'+sqlca.SQLErrText
  1705. GOTO ext
  1706. END IF
  1707. IF ll_cnt = 0 THEN
  1708. DELETE
  1709. From u_spt_price
  1710. Where u_spt_price.sptid = :arg_sptid
  1711. And u_spt_price.mtrlid = :arg_mtrlid
  1712. And u_spt_price.status = :arg_status
  1713. And u_spt_price.woodcode = :arg_woodcode
  1714. And u_spt_price.pcode = :arg_pcode
  1715. And u_spt_price.jgdscrp = :arg_jgdscrp
  1716. And u_spt_price.unit = :arg_unit
  1717. And u_spt_price.moneyid = :arg_moneyid;
  1718. IF sqlca.SQLCode <> 0 THEN
  1719. rslt = 0
  1720. arg_msg = '删除供应商最新价失败'+sqlca.SQLErrText
  1721. GOTO ext
  1722. END IF
  1723. ELSE
  1724. SELECT top 1 fprice,zqrate,price,sys_changetime
  1725. INTO :ld_fprice,:ld_zqrate,:ld_price,:ld_sys_changetime
  1726. FROM u_spt_price_mx
  1727. WHERE u_spt_price_mx.sptid = :arg_sptid
  1728. AND u_spt_price_mx.mtrlid = :arg_mtrlid
  1729. AND u_spt_price_mx.status = :arg_status
  1730. AND u_spt_price_mx.woodcode = :arg_woodcode
  1731. AND u_spt_price_mx.pcode = :arg_pcode
  1732. AND u_spt_price_mx.jgdscrp = :arg_jgdscrp
  1733. AND u_spt_price_mx.unit = :arg_unit
  1734. AND u_spt_price_mx.Opdate < :ld_opdate
  1735. AND u_spt_price_mx.moneyid = :arg_moneyid
  1736. Order By u_spt_price_mx.Opdate Desc;
  1737. IF sqlca.SQLCode <> 0 THEN
  1738. rslt = 0
  1739. arg_msg = '查询供应商最新价失败'+sqlca.SQLErrText
  1740. GOTO ext
  1741. END IF
  1742. UPDATE u_spt_price
  1743. SET fprice = :ld_fprice ,
  1744. zqrate = :ld_zqrate,
  1745. price = :ld_price,
  1746. sys_changetime = :ld_sys_changetime
  1747. WHERE u_spt_price.sptid = :arg_sptid
  1748. AND u_spt_price.mtrlid = :arg_mtrlid
  1749. AND u_spt_price.status = :arg_status
  1750. AND u_spt_price.woodcode = :arg_woodcode
  1751. AND u_spt_price.pcode = :arg_pcode
  1752. AND u_spt_price.jgdscrp = :arg_jgdscrp
  1753. AND u_spt_price.unit = :arg_unit
  1754. And u_spt_price.moneyid = :arg_moneyid;
  1755. IF sqlca.SQLCode <> 0 THEN
  1756. rslt = 0
  1757. arg_msg = '更新最新价失败'+sqlca.SQLErrText
  1758. GOTO ext
  1759. END IF
  1760. END IF
  1761. END IF
  1762. */
  1763. ext:
  1764. IF rslt = 0 THEN
  1765. ROLLBACK;
  1766. ELSEIF rslt = 1 And arg_ifcommit THEN
  1767. COMMIT;
  1768. END IF
  1769. RETURN rslt
  1770. end function
  1771. public function integer uof_getmtrlsptbuybargainprice (long arg_moneyid, long arg_sptid, long arg_mtrlid, ref string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, ref long arg_buybargainid, ref long arg_buybargainprintid, ref string arg_buybargaincode, ref decimal arg_price, ref decimal arg_rebate, ref string arg_msg);Long rslt = 1
  1772. Decimal rtn_price,rtn_zqrate,rtn_rate
  1773. String ls_unit
  1774. String rtn_wareunit
  1775. Int li_iflimitprice,li_price_ifpz_buy
  1776. Long ll_buybargainid, ll_buybargainprintid
  1777. String ls_buybargaincode
  1778. decimal lde_price, lde_rebate
  1779. lde_rebate = 1
  1780. IF sys_option_buy_getbuybargain = 0 THEN
  1781. ll_buybargainid = 0
  1782. ll_buybargainprintid = 0
  1783. ls_buybargaincode = ''
  1784. lde_price = 0
  1785. // lde_rebate = 1
  1786. GOTO ext
  1787. END IF
  1788. arg_status = Trim(arg_status)
  1789. arg_woodcode = Trim(arg_woodcode)
  1790. arg_pcode = Trim(arg_pcode)
  1791. arg_jgdscrp = Trim(arg_jgdscrp)
  1792. arg_unit = Trim(arg_unit)
  1793. SELECT iflimitprice,price_ifpz_buy , unit
  1794. INTO :li_iflimitprice,:li_price_ifpz_buy, :ls_unit
  1795. FROM u_mtrldef
  1796. Where mtrlid = :arg_mtrlid;
  1797. IF sqlca.SQLCode <> 0 THEN
  1798. arg_msg = '查询物料限价属性失败 '+sqlca.SQLErrText
  1799. rslt = 0
  1800. GOTO ext
  1801. END IF
  1802. CHOOSE CASE li_price_ifpz_buy
  1803. CASE 0
  1804. arg_status = ''
  1805. arg_woodcode = ''
  1806. arg_pcode = ''
  1807. CASE 1
  1808. arg_pcode = ''
  1809. arg_woodcode = ''
  1810. CASE 2
  1811. arg_status = ''
  1812. arg_pcode = ''
  1813. CASE 3
  1814. arg_status = ''
  1815. arg_woodcode = ''
  1816. CASE 4
  1817. arg_pcode = ''
  1818. CASE 5
  1819. arg_status = ''
  1820. CASE 6
  1821. arg_woodcode = ''
  1822. END CHOOSE
  1823. IF arg_unit = '' THEN
  1824. arg_unit = ls_unit
  1825. END IF
  1826. SELECT top 1 billid,printid,billcode, price
  1827. INTO :ll_buybargainid,:ll_buybargainprintid,:ls_buybargaincode, :lde_price
  1828. FROM (
  1829. SELECT top 1 case argaintype when 3 then (case u_buybargainmx.areaqty when 0 then u_buybargainmx.price else round(u_buybargainmx.price*u_buybargainmx.areaqty+u_buybargainmx.otherprice,2) END )
  1830. else u_buybargainmx.price END AS price,
  1831. u_buybargainmx.rate as rate,
  1832. u_buybargainmx.unit as unit,
  1833. u_buybargainmx.billid as billid,
  1834. u_buybargainmx.printid as printid,
  1835. ltrim(rtrim(u_buybargain.Billcode))+'[合同]' as billcode,
  1836. u_buybargain.auditdate as auditdate
  1837. FROM u_buybargain INNER JOIN
  1838. u_buybargainmx ON u_buybargain.billid = u_buybargainmx.billid
  1839. WHERE u_buybargain.flag = 1
  1840. AND u_buybargain.sptid_b = :arg_sptid
  1841. AND u_buybargainmx.mtrlid = :arg_mtrlid
  1842. AND u_buybargainmx.unit = :arg_unit
  1843. AND u_buybargain.moneyid = :arg_moneyid
  1844. and u_buybargainmx.material = :arg_jgdscrp
  1845. ORDER BY u_buybargain.auditdate DESC
  1846. UNION
  1847. SELECT top 1 u_spt_price_changemx.price,
  1848. u_spt_price_changemx.rate,
  1849. u_spt_price_changemx.unit,
  1850. u_spt_price_changemx.billid,
  1851. u_spt_price_changemx.printid,
  1852. ltrim(rtrim(u_spt_price_change.Billcode))+'[调价]',
  1853. u_spt_price_change.auditdate as auditdate
  1854. FROM u_spt_price_change INNER JOIN
  1855. u_spt_price_changemx ON
  1856. u_spt_price_change.billid = u_spt_price_changemx.billid
  1857. WHERE (u_spt_price_change.flag = 1)
  1858. AND u_spt_price_change.sptid = :arg_sptid
  1859. AND u_spt_price_changemx.mtrlid = :arg_mtrlid
  1860. AND u_spt_price_change.moneyid = :arg_moneyid
  1861. AND u_spt_price_changemx.unit = :arg_unit
  1862. AND u_spt_price_changemx.status = :arg_status
  1863. AND u_spt_price_changemx.woodcode = :arg_woodcode
  1864. AND u_spt_price_changemx.pcode = :arg_pcode
  1865. and u_spt_price_changemx.jgdscrp = :arg_jgdscrp
  1866. ORDER BY u_spt_price_change.auditdate DESC) A
  1867. Order By A.auditdate Desc;
  1868. IF sqlca.SQLCode <> 0 THEN
  1869. ll_buybargainid = 0
  1870. ll_buybargainprintid = 0
  1871. ls_buybargaincode = ''
  1872. lde_price = 0
  1873. END IF
  1874. ext:
  1875. arg_buybargainid = ll_buybargainid
  1876. arg_buybargainprintid = ll_buybargainprintid
  1877. arg_buybargaincode = ls_buybargaincode
  1878. arg_price = lde_price
  1879. arg_rebate = lde_rebate
  1880. RETURN rslt
  1881. end function
  1882. public function integer uof_getmtrlsptbuybargain (long arg_moneyid, long arg_sptid, long arg_mtrlid, ref string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, ref long arg_buybargainid, ref long arg_buybargainprintid, ref string arg_buybargaincode, ref string arg_msg);
  1883. decimal lde_price, lde_rebate
  1884. return uof_getmtrlsptbuybargainprice(arg_moneyid, arg_sptid, arg_mtrlid, arg_unit, arg_status, arg_woodcode, arg_pcode, arg_jgdscrp, arg_buybargainid, arg_buybargainprintid, arg_buybargaincode, lde_price, lde_rebate,arg_msg)
  1885. //Long rslt = 1
  1886. //Decimal rtn_price,rtn_zqrate,rtn_rate
  1887. //String ls_unit
  1888. //String rtn_wareunit
  1889. //Int li_iflimitprice,li_price_ifpz_buy
  1890. //
  1891. //Long ll_buybargainid, ll_buybargainprintid
  1892. //String ls_buybargaincode
  1893. //
  1894. //IF sys_option_buy_getbuybargain = 0 THEN
  1895. // ll_buybargainid = 0
  1896. // ll_buybargainprintid = 0
  1897. // ls_buybargaincode = ''
  1898. // GOTO ext
  1899. //END IF
  1900. //
  1901. //
  1902. //arg_status = Trim(arg_status)
  1903. //arg_woodcode = Trim(arg_woodcode)
  1904. //arg_pcode = Trim(arg_pcode)
  1905. ////arg_jgdscrp = Trim(arg_jgdscrp)
  1906. //
  1907. //
  1908. //arg_unit = Trim(arg_unit)
  1909. //
  1910. ////arg_billdate = DateTime(Date(arg_billdate),Time(0))
  1911. //
  1912. //
  1913. //
  1914. //SELECT iflimitprice,price_ifpz_buy , unit
  1915. // INTO :li_iflimitprice,:li_price_ifpz_buy, :ls_unit
  1916. // FROM u_mtrldef
  1917. // Where mtrlid = :arg_mtrlid;
  1918. //IF sqlca.SQLCode <> 0 THEN
  1919. // arg_msg = '查询物料限价属性失败 '+sqlca.SQLErrText
  1920. // rslt = 0
  1921. // GOTO ext
  1922. //END IF
  1923. //
  1924. //CHOOSE CASE li_price_ifpz_buy
  1925. // CASE 0
  1926. // arg_status = ''
  1927. // arg_woodcode = ''
  1928. // arg_pcode = ''
  1929. // CASE 1
  1930. // arg_pcode = ''
  1931. // arg_woodcode = ''
  1932. // CASE 2
  1933. // arg_status = ''
  1934. // arg_pcode = ''
  1935. // CASE 3
  1936. // arg_status = ''
  1937. // arg_woodcode = ''
  1938. // CASE 4
  1939. // arg_pcode = ''
  1940. // CASE 5
  1941. // arg_status = ''
  1942. // CASE 6
  1943. // arg_woodcode = ''
  1944. //END CHOOSE
  1945. //
  1946. //IF arg_unit = '' THEN
  1947. // arg_unit = ls_unit
  1948. //END IF
  1949. //
  1950. //
  1951. //SELECT top 1 billid,printid,billcode
  1952. // INTO :ll_buybargainid,:ll_buybargainprintid,:ls_buybargaincode
  1953. // FROM (
  1954. // SELECT top 1 case argaintype when 3 then (case u_buybargainmx.areaqty when 0 then u_buybargainmx.price else round(u_buybargainmx.price*u_buybargainmx.areaqty+u_buybargainmx.otherprice,2) END )
  1955. // else u_buybargainmx.price END AS price,
  1956. // u_buybargainmx.rate as rate,
  1957. // u_buybargainmx.unit as unit,
  1958. // u_buybargainmx.billid as billid,
  1959. // u_buybargainmx.printid as printid,
  1960. // ltrim(rtrim(u_buybargain.Billcode))+'[合同]' as billcode,
  1961. // u_buybargain.auditdate as auditdate
  1962. // FROM u_buybargain INNER JOIN
  1963. // u_buybargainmx ON u_buybargain.billid = u_buybargainmx.billid
  1964. // WHERE u_buybargain.flag = 1
  1965. // AND u_buybargain.sptid_b = :arg_sptid
  1966. // AND u_buybargainmx.mtrlid = :arg_mtrlid
  1967. // AND u_buybargainmx.unit = :arg_unit
  1968. // AND u_buybargain.moneyid = :arg_moneyid
  1969. // ORDER BY u_buybargain.auditdate DESC
  1970. // UNION
  1971. // SELECT top 1 u_spt_price_changemx.price,
  1972. // u_spt_price_changemx.rate,
  1973. // u_spt_price_changemx.unit,
  1974. // u_spt_price_changemx.billid,
  1975. // u_spt_price_changemx.printid,
  1976. // ltrim(rtrim(u_spt_price_change.Billcode))+'[调价]',
  1977. // u_spt_price_change.auditdate as auditdate
  1978. // FROM u_spt_price_change INNER JOIN
  1979. // u_spt_price_changemx ON
  1980. // u_spt_price_change.billid = u_spt_price_changemx.billid
  1981. // WHERE (u_spt_price_change.flag = 1)
  1982. // AND u_spt_price_change.sptid = :arg_sptid
  1983. // AND u_spt_price_changemx.mtrlid = :arg_mtrlid
  1984. // AND u_spt_price_change.moneyid = :arg_moneyid
  1985. // AND u_spt_price_changemx.unit = :arg_unit
  1986. // AND u_spt_price_changemx.status = :arg_status
  1987. // AND u_spt_price_changemx.woodcode = :arg_woodcode
  1988. // AND u_spt_price_changemx.pcode = :arg_pcode
  1989. // ORDER BY u_spt_price_change.auditdate DESC) A
  1990. // Order By A.auditdate Desc;
  1991. //
  1992. //IF sqlca.SQLCode <> 0 THEN
  1993. // ll_buybargainid = 0
  1994. // ll_buybargainprintid = 0
  1995. // ls_buybargaincode = ''
  1996. //END IF
  1997. //
  1998. //
  1999. //
  2000. //ext:
  2001. //arg_buybargainid = ll_buybargainid
  2002. //arg_buybargainprintid = ll_buybargainprintid
  2003. //arg_buybargaincode = ls_buybargaincode
  2004. //
  2005. //RETURN rslt
  2006. //
  2007. end function
  2008. public function integer uof_sptmtrlprice_set (integer arg_ifth, integer arg_ifbj, long arg_sptid, long arg_moneyid, long arg_mtrlid, string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, datetime arg_effdate, datetime arg_effdate_end, decimal arg_fprice, decimal arg_zqrate, decimal arg_rate, decimal arg_wareprice, decimal arg_wareprice_notax, integer arg_billtype, integer arg_buildtype, long arg_inwareid, string arg_inwarecode, long arg_printid, datetime arg_indate, string arg_dscrp, boolean arg_ifcommit, ref string arg_msg);//====================================================================
  2009. // 事件: uo_spt_price.Script - uof_sptmtrlprice_set ( integer arg_ifth, integer arg_ifbj, long arg_sptid, long arg_moneyid, long arg_mtrlid, string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, datetime arg_effdate, decimal arg_fprice,()
  2010. //--------------------------------------------------------------------
  2011. // 描述:
  2012. //--------------------------------------------------------------------
  2013. // 参数:
  2014. // value integer arg_ifth 是否退货传入
  2015. // value integer arg_ifbj 是否更新报价
  2016. // value long arg_sptid
  2017. // value long arg_moneyid
  2018. // value long arg_mtrlid
  2019. // value string arg_unit
  2020. // value string arg_status
  2021. // value string arg_woodcode
  2022. // value string arg_pcode
  2023. // value string arg_jgdscrp
  2024. // value datetime arg_effdate //有效期
  2025. // value decimal arg_fprice
  2026. // value decimal arg_zqrate
  2027. // value decimal arg_rate
  2028. // value decimal arg_wareprice //库存单位,本位币,单价
  2029. // value integer arg_billtype //数据来源方式;采购单,外协单,报价单,手动
  2030. // value long arg_buildtype //建立方式,来源; 0-自动,来自单据审核; 1-手动; 原flag
  2031. // value long arg_inwareid
  2032. // value string arg_inwarecode
  2033. // value long arg_printid
  2034. // value datetime arg_indate
  2035. // value string arg_dscrp
  2036. // value boolean arg_ifcommit
  2037. // reference string arg_msg
  2038. //--------------------------------------------------------------------
  2039. // 返回: (none)
  2040. //--------------------------------------------------------------------
  2041. // 作者: LHD 日期: 2013年05月28日
  2042. //--------------------------------------------------------------------
  2043. // Copyright (c) 2002-2018 RICHTA(TM), All rights reserved.
  2044. //--------------------------------------------------------------------
  2045. // 修改历史:
  2046. //
  2047. //====================================================================
  2048. Long rslt = 1
  2049. Long cnt = 0
  2050. String ls_mtrlcode
  2051. Int li_price_ifpz_buy
  2052. IF uo_option_zero_update_sptprice = -1000 THEN
  2053. rslt = 0
  2054. arg_msg = '选项:[366]采购收货单0单价更新价格历史,读取初始默认值失败,操作取消!'
  2055. GOTO ext
  2056. END IF
  2057. //检查退货
  2058. IF arg_ifth = 1 THEN
  2059. rslt = 1
  2060. GOTO ext
  2061. END IF
  2062. //yyx2013-4-12
  2063. IF uo_option_zero_update_sptprice = 0 THEN
  2064. IF arg_fprice = 0 THEN
  2065. rslt = 1
  2066. GOTO ext
  2067. END IF
  2068. END IF
  2069. //end yyx2013-4-12
  2070. //检查参数
  2071. IF IsNull(arg_sptid) THEN arg_sptid = 0
  2072. IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
  2073. IF IsNull(arg_status) THEN arg_status = ''
  2074. IF IsNull(arg_fprice) THEN arg_fprice = 0.0
  2075. IF IsNull(arg_moneyid) THEN arg_moneyid = 0
  2076. IF IsNull(arg_woodcode) THEN arg_woodcode = ''
  2077. IF IsNull(arg_pcode) THEN arg_pcode = ''
  2078. IF IsNull(arg_jgdscrp) THEN arg_jgdscrp = ''
  2079. arg_inwarecode = Trim(arg_inwarecode)
  2080. arg_status = Trim(arg_status)
  2081. arg_woodcode = Trim(arg_woodcode)
  2082. arg_pcode = Trim(arg_pcode)
  2083. arg_jgdscrp = Trim(arg_jgdscrp)
  2084. arg_unit = Trim(arg_unit)
  2085. IF arg_indate <= DateTime(Date('1900-01-01'),Time(0)) THEN
  2086. rslt = 0
  2087. arg_msg = '不合理的发生时间'
  2088. GOTO ext
  2089. END IF
  2090. IF arg_unit = '' THEN
  2091. rslt = 0
  2092. arg_msg = '没有单位'
  2093. GOTO ext
  2094. END IF
  2095. //检查供应商存在否
  2096. SELECT count(*)
  2097. INTO :cnt
  2098. FROM u_spt
  2099. Where u_spt.sptid = :arg_sptid;
  2100. IF sqlca.SQLCode <> 0 THEN
  2101. rslt = 0
  2102. arg_msg = '查询失败'+sqlca.SQLErrText
  2103. GOTO ext
  2104. END IF
  2105. IF cnt = 0 THEN
  2106. rslt = 0
  2107. arg_msg = '供应商不存在'
  2108. GOTO ext
  2109. END IF
  2110. cnt = 0
  2111. SELECT count(*) INTO :cnt
  2112. FROM cw_currency
  2113. Where moneyid = :arg_moneyid;
  2114. IF sqlca.SQLCode <> 0 THEN
  2115. arg_msg = '查询币种失败'
  2116. rslt = 0
  2117. GOTO ext
  2118. END IF
  2119. IF cnt = 0 THEN
  2120. arg_msg = '币种资料不存在'
  2121. rslt = 0
  2122. GOTO ext
  2123. END IF
  2124. //检查商品存在否
  2125. SELECT mtrlcode,
  2126. price_ifpz_buy
  2127. INTO :ls_mtrlcode,
  2128. :li_price_ifpz_buy
  2129. FROM u_mtrldef
  2130. Where u_mtrldef.mtrlid = :arg_mtrlid;
  2131. IF sqlca.SQLCode <> 0 THEN
  2132. rslt = 0
  2133. arg_msg = '查询物料编码失败,'+sqlca.SQLErrText
  2134. GOTO ext
  2135. END IF
  2136. CHOOSE CASE li_price_ifpz_buy
  2137. CASE 0
  2138. arg_status = ''
  2139. arg_woodcode = ''
  2140. arg_pcode = ''
  2141. CASE 1
  2142. arg_pcode = ''
  2143. arg_woodcode = ''
  2144. CASE 2
  2145. arg_status = ''
  2146. arg_pcode = ''
  2147. CASE 3
  2148. arg_status = ''
  2149. arg_woodcode = ''
  2150. CASE 4
  2151. arg_pcode = ''
  2152. CASE 5
  2153. arg_status = ''
  2154. CASE 6
  2155. arg_woodcode = ''
  2156. END CHOOSE
  2157. //1.更新供应商价格历史-更新最新收货价
  2158. IF arg_ifbj = 0 THEN
  2159. UPDATE u_spt_price
  2160. SET u_spt_price.price = :arg_fprice * :arg_zqrate,
  2161. u_spt_price.fprice = :arg_fprice,
  2162. u_spt_price.zqrate = :arg_zqrate,
  2163. u_spt_price.wareprice = :arg_wareprice,
  2164. u_spt_price.wareprice_notax = :arg_wareprice_notax,
  2165. u_spt_price.rate = :arg_rate,
  2166. u_spt_price.sys_changetime = getdate()
  2167. WHERE u_spt_price.sptid = :arg_sptid AND
  2168. u_spt_price.mtrlid = :arg_mtrlid AND
  2169. u_spt_price.unit = :arg_unit AND
  2170. u_spt_price.status = :arg_status AND
  2171. u_spt_price.woodcode = :arg_woodcode AND
  2172. u_spt_price.pcode = :arg_pcode AND
  2173. u_spt_price.jgdscrp = :arg_jgdscrp AND
  2174. u_spt_price.moneyid = :arg_moneyid;
  2175. IF sqlca.SQLCode = 0 THEN
  2176. IF sqlca.SQLNRows = 0 THEN
  2177. INSERT INTO u_spt_price
  2178. (sptid,
  2179. mtrlid,
  2180. unit,
  2181. price,
  2182. fprice,
  2183. zqrate,
  2184. wareprice,
  2185. wareprice_notax,
  2186. rate,
  2187. status,
  2188. woodcode,
  2189. pcode,
  2190. jgdscrp,
  2191. dscrp,
  2192. moneyid,
  2193. sys_changetime)
  2194. VALUES
  2195. (:arg_sptid,
  2196. :arg_mtrlid,
  2197. :arg_unit,
  2198. :arg_fprice * :arg_zqrate,
  2199. :arg_fprice,
  2200. :arg_zqrate,
  2201. :arg_wareprice,
  2202. :arg_wareprice_notax,
  2203. :arg_rate,
  2204. :arg_status,
  2205. :arg_woodcode,
  2206. :arg_pcode,
  2207. :arg_jgdscrp,
  2208. :arg_dscrp,
  2209. :arg_moneyid,
  2210. getdate());
  2211. IF sqlca.SQLCode <> 0 THEN
  2212. rslt = 0
  2213. arg_msg = '新增物料:'+ls_mtrlcode+'供应商价格历史失败,'+sqlca.SQLErrText
  2214. GOTO ext
  2215. END IF
  2216. END IF
  2217. ELSE
  2218. rslt = 0
  2219. arg_msg = '更新物料:'+ls_mtrlcode+'供应商价格历史失败,'+sqlca.SQLErrText
  2220. GOTO ext
  2221. END IF
  2222. ELSE //更新最新报价
  2223. UPDATE u_spt_price
  2224. SET u_spt_price.price_bj = :arg_fprice * :arg_zqrate,
  2225. u_spt_price.fprice_bj = :arg_fprice,
  2226. u_spt_price.zqrate_bj = :arg_zqrate,
  2227. u_spt_price.wareprice_bj = :arg_wareprice,
  2228. u_spt_price.rate_bj = :arg_rate,
  2229. u_spt_price.sys_changetime_bj = getdate()
  2230. WHERE u_spt_price.sptid = :arg_sptid AND
  2231. u_spt_price.mtrlid = :arg_mtrlid AND
  2232. u_spt_price.unit = :arg_unit AND
  2233. u_spt_price.status = :arg_status AND
  2234. u_spt_price.woodcode = :arg_woodcode AND
  2235. u_spt_price.pcode = :arg_pcode AND
  2236. u_spt_price.jgdscrp = :arg_jgdscrp AND
  2237. u_spt_price.moneyid = :arg_moneyid;
  2238. IF sqlca.SQLCode = 0 THEN
  2239. IF sqlca.SQLNRows = 0 THEN
  2240. INSERT INTO u_spt_price
  2241. (sptid,
  2242. mtrlid,
  2243. unit,
  2244. price_bj,
  2245. fprice_bj,
  2246. zqrate_bj,
  2247. wareprice_bj,
  2248. rate_bj,
  2249. status,
  2250. woodcode,
  2251. pcode,
  2252. jgdscrp,
  2253. moneyid,
  2254. dscrp,
  2255. sys_changetime_bj)
  2256. VALUES
  2257. (:arg_sptid,
  2258. :arg_mtrlid,
  2259. :arg_unit,
  2260. :arg_fprice * :arg_zqrate,
  2261. :arg_fprice,
  2262. :arg_zqrate,
  2263. :arg_wareprice,
  2264. :arg_rate,
  2265. :arg_status,
  2266. :arg_woodcode,
  2267. :arg_pcode,
  2268. :arg_jgdscrp,
  2269. :arg_moneyid,
  2270. :arg_dscrp,
  2271. getdate());
  2272. IF sqlca.SQLCode <> 0 THEN
  2273. rslt = 0
  2274. arg_msg = '新增物料:'+ls_mtrlcode+'供应商价格历史失败,'+sqlca.SQLErrText
  2275. GOTO ext
  2276. END IF
  2277. END IF
  2278. ELSE
  2279. rslt = 0
  2280. arg_msg = '更新物料:'+ls_mtrlcode+'供应商价格历史失败,'+sqlca.SQLErrText
  2281. GOTO ext
  2282. END IF
  2283. END IF
  2284. //2.插入供应商售价变动明细表
  2285. INSERT INTO u_spt_price_mx
  2286. (u_spt_price_mx.sptid,
  2287. u_spt_price_mx.mtrlid,
  2288. u_spt_price_mx.opdate,
  2289. u_spt_price_mx.opemp,
  2290. u_spt_price_mx.inwareid,
  2291. u_spt_price_mx.inwarecode,
  2292. u_spt_price_mx.outdate,
  2293. u_spt_price_mx.price,
  2294. u_spt_price_mx.fprice,
  2295. u_spt_price_mx.zqrate,
  2296. u_spt_price_mx.dscrp,
  2297. u_spt_price_mx.status,
  2298. u_spt_price_mx.woodcode,
  2299. u_spt_price_mx.pcode,
  2300. u_spt_price_mx.jgdscrp,
  2301. u_spt_price_mx.buildtype,
  2302. u_spt_price_mx.unit,
  2303. u_spt_price_mx.printid,
  2304. u_spt_price_mx.wareprice,
  2305. u_spt_price_mx.wareprice_notax,
  2306. u_spt_price_mx.rate,
  2307. u_spt_price_mx.billtype,
  2308. u_spt_price_mx.moneyid,
  2309. u_spt_price_mx.effdate,
  2310. u_spt_price_mx.effdate_end,
  2311. ifbj
  2312. )
  2313. VALUES
  2314. ( :arg_sptid,
  2315. :arg_mtrlid,
  2316. getdate(),
  2317. :publ_operator,
  2318. :arg_inwareid,
  2319. :arg_inwarecode,
  2320. :arg_indate,
  2321. :arg_fprice * :arg_zqrate,
  2322. :arg_fprice,
  2323. :arg_zqrate,
  2324. :arg_dscrp,
  2325. :arg_status,
  2326. :arg_woodcode,
  2327. :arg_pcode,
  2328. :arg_jgdscrp,
  2329. :arg_buildtype,
  2330. :arg_unit,
  2331. :arg_printid,
  2332. :arg_wareprice,
  2333. :arg_wareprice_notax,
  2334. :arg_rate,
  2335. :arg_billtype,
  2336. :arg_moneyid,
  2337. :arg_effdate,
  2338. :arg_effdate_end,
  2339. :arg_ifbj);
  2340. IF sqlca.SQLCode <> 0 THEN
  2341. rslt = 0
  2342. arg_msg = '建立物料:'+ls_mtrlcode+'供应商价格历史明细失败,'+sqlca.SQLErrText
  2343. GOTO ext
  2344. END IF
  2345. ext:
  2346. IF rslt = 0 THEN
  2347. ROLLBACK;
  2348. ELSEIF arg_ifcommit And rslt = 1 THEN
  2349. COMMIT;
  2350. END IF
  2351. RETURN rslt
  2352. end function
  2353. public function integer uof_update_sptprice (integer arg_ifth, long arg_sptid, long arg_mtrlid, string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, long arg_inwareid, decimal arg_fprice, decimal arg_zqrate, decimal arg_rate, decimal arg_wareprice, decimal arg_wareprice_notax, datetime arg_indate, string arg_inwarecode, long arg_flag, string arg_dscrp, long arg_printid, integer arg_billtype, long arg_moneyid, datetime arg_effdate, datetime arg_effdate_end, boolean arg_ifcommit, ref string arg_msg);Int li_ifbj
  2354. IF arg_billtype = 0 Or arg_billtype = 1 THEN //采购,外协收货单
  2355. li_ifbj = 0
  2356. ELSE //报价, 手动添加
  2357. li_ifbj = 1
  2358. END IF
  2359. RETURN uof_sptmtrlprice_set ( arg_ifth, li_ifbj, arg_sptid, arg_moneyid, arg_mtrlid, arg_unit, arg_status, arg_woodcode, arg_pcode, arg_jgdscrp, &
  2360. arg_effdate, arg_effdate_end, arg_fprice, arg_zqrate, arg_rate, arg_wareprice,arg_wareprice_notax,&
  2361. arg_billtype, arg_flag, arg_inwareid, arg_inwarecode, arg_printid, arg_indate, arg_dscrp, arg_ifcommit, arg_msg)
  2362. //Long rslt = 1
  2363. //Long cnt = 0
  2364. //DateTime server_time
  2365. //String ls_mtrlcode
  2366. //Int li_price_ifpz_buy
  2367. //
  2368. ////检查退货
  2369. //IF arg_ifth = 1 THEN
  2370. // rslt = 1
  2371. // GOTO ext
  2372. //END IF
  2373. //
  2374. ////yyx2013-4-12
  2375. //IF arg_fprice = 0 THEN
  2376. // rslt = 1
  2377. // GOTO ext
  2378. //END IF
  2379. ////end yyx2013-4-12
  2380. //
  2381. ////检查参数
  2382. //IF IsNull(arg_sptid) THEN arg_sptid = 0
  2383. //IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
  2384. //IF IsNull(arg_status) THEN arg_status = ''
  2385. //IF IsNull(arg_fprice) THEN arg_fprice = 0.0
  2386. //IF IsNull(arg_moneyid) THEN arg_moneyid = 0
  2387. //
  2388. //IF IsNull(arg_woodcode) THEN arg_woodcode = ''
  2389. //IF IsNull(arg_pcode) THEN arg_pcode = ''
  2390. //IF IsNull(arg_jgdscrp) THEN arg_jgdscrp = ''
  2391. //
  2392. //
  2393. //arg_inwarecode = Trim(arg_inwarecode)
  2394. //arg_status = Trim(arg_status)
  2395. //arg_woodcode = Trim(arg_woodcode)
  2396. //arg_pcode = Trim(arg_pcode)
  2397. //arg_jgdscrp = Trim(arg_jgdscrp)
  2398. //
  2399. //
  2400. //arg_unit = Trim(arg_unit)
  2401. //
  2402. //IF arg_indate <= DateTime(Date('1900-01-01'),Time(0)) THEN
  2403. // rslt = 0
  2404. // arg_msg = '不合理的发生时间'
  2405. // GOTO ext
  2406. //END IF
  2407. //
  2408. //
  2409. ////获得服务器时间
  2410. //SELECT Top 1 getdate() Into :server_time From u_user;
  2411. //
  2412. ////检查供应商存在否
  2413. //SELECT count(*)
  2414. // INTO :cnt
  2415. // FROM u_spt
  2416. // Where u_spt.sptid = :arg_sptid;
  2417. //IF sqlca.SQLCode <> 0 THEN
  2418. // rslt = 0
  2419. // arg_msg = '因网络和其他原因查询失败'+sqlca.SQLErrText
  2420. // GOTO ext
  2421. //END IF
  2422. //
  2423. //IF cnt = 0 THEN
  2424. // rslt = 0
  2425. // arg_msg = '供应商不存在'
  2426. // GOTO ext
  2427. //END IF
  2428. //
  2429. //cnt = 0
  2430. //SELECT count(*) INTO :cnt
  2431. // FROM cw_currency
  2432. // Where moneyid = :arg_moneyid;
  2433. //IF sqlca.SQLCode <> 0 THEN
  2434. // arg_msg = '查询币种失败'
  2435. // rslt = 0
  2436. // GOTO ext
  2437. //END IF
  2438. //
  2439. //IF cnt = 0 THEN
  2440. // arg_msg = '币种资料不存在'
  2441. // rslt = 0
  2442. // GOTO ext
  2443. //END IF
  2444. //
  2445. //
  2446. ////检查商品存在否
  2447. //SELECT mtrlcode,
  2448. // price_ifpz_buy
  2449. // INTO :ls_mtrlcode,
  2450. // :li_price_ifpz_buy
  2451. // FROM u_mtrldef
  2452. // Where u_mtrldef.mtrlid = :arg_mtrlid;
  2453. //IF sqlca.SQLCode <> 0 THEN
  2454. // rslt = 0
  2455. // arg_msg = '因网络和其他原因查询物料编码失败,'+sqlca.SQLErrText
  2456. // GOTO ext
  2457. //END IF
  2458. //
  2459. //CHOOSE CASE li_price_ifpz_buy
  2460. // CASE 0
  2461. // arg_status = ''
  2462. // arg_woodcode = ''
  2463. // arg_pcode = ''
  2464. // CASE 1
  2465. // arg_pcode = ''
  2466. // arg_woodcode = ''
  2467. // CASE 2
  2468. // arg_status = ''
  2469. // arg_pcode = ''
  2470. // CASE 3
  2471. // arg_status = ''
  2472. // arg_woodcode = ''
  2473. // CASE 4
  2474. // arg_pcode = ''
  2475. // CASE 5
  2476. // arg_status = ''
  2477. // CASE 6
  2478. // arg_woodcode = ''
  2479. //END CHOOSE
  2480. //
  2481. ////1.更新供应商售价表
  2482. //SELECT count(*)
  2483. // INTO :cnt
  2484. // FROM u_spt_price
  2485. // WHERE u_spt_price.sptid = :arg_sptid AND
  2486. // u_spt_price.mtrlid = :arg_mtrlid AND
  2487. // u_spt_price.unit = :arg_unit AND
  2488. // u_spt_price.status = :arg_status AND
  2489. // u_spt_price.woodcode = :arg_woodcode AND
  2490. // u_spt_price.pcode = :arg_pcode AND
  2491. // u_spt_price.jgdscrp = :arg_jgdscrp AND
  2492. // u_spt_price.moneyid = :arg_moneyid;
  2493. //IF sqlca.SQLCode <> 0 THEN
  2494. // rslt = 0
  2495. // arg_msg = '因网络和其他原因查询供应商物料:'+ls_mtrlcode+'最新价格失败'+sqlca.SQLErrText
  2496. // GOTO ext
  2497. //END IF
  2498. //
  2499. //
  2500. //IF cnt > 0 THEN
  2501. // UPDATE u_spt_price
  2502. // SET u_spt_price.sptid = :arg_sptid,
  2503. // u_spt_price.mtrlid = :arg_mtrlid,
  2504. // u_spt_price.price = :arg_fprice * :arg_zqrate,
  2505. // u_spt_price.fprice = :arg_fprice,
  2506. // u_spt_price.zqrate = :arg_zqrate,
  2507. // u_spt_price.wareprice = :arg_wareprice,
  2508. // u_spt_price.rate = :arg_rate,
  2509. // u_spt_price.unit = :arg_unit,
  2510. // u_spt_price.sys_changetime = getdate()
  2511. // WHERE u_spt_price.sptid = :arg_sptid AND
  2512. // u_spt_price.mtrlid = :arg_mtrlid AND
  2513. // u_spt_price.unit = :arg_unit AND
  2514. // u_spt_price.status = :arg_status AND
  2515. // u_spt_price.woodcode = :arg_woodcode AND
  2516. // u_spt_price.pcode = :arg_pcode AND
  2517. // u_spt_price.jgdscrp = :arg_jgdscrp AND
  2518. // u_spt_price.moneyid = :arg_moneyid;
  2519. // IF sqlca.SQLCode <> 0 THEN
  2520. // rslt = 0
  2521. // arg_msg = '因网络和其它原因,供应商物料:'+ls_mtrlcode+'报价表更新失败'+sqlca.SQLErrText
  2522. // GOTO ext
  2523. // END IF
  2524. //ELSEIF cnt = 0 THEN
  2525. // INSERT INTO u_spt_price
  2526. // (sptid,
  2527. // mtrlid,
  2528. // price,
  2529. // fprice,
  2530. // zqrate,
  2531. // dscrp,
  2532. // unit,
  2533. // wareprice,
  2534. // rate,
  2535. // status,
  2536. // woodcode,
  2537. // pcode,
  2538. // jgdscrp,
  2539. // moneyid,
  2540. // sys_changetime)
  2541. // VALUES
  2542. // (:arg_sptid,
  2543. // :arg_mtrlid,
  2544. // :arg_fprice * :arg_zqrate,
  2545. // :arg_fprice,
  2546. // :arg_zqrate,
  2547. // :arg_dscrp,
  2548. // :arg_unit,
  2549. // :arg_wareprice,
  2550. // :arg_rate,
  2551. // :arg_status,
  2552. // :arg_woodcode,
  2553. // :arg_pcode,
  2554. // :arg_jgdscrp,
  2555. // :arg_moneyid,
  2556. // getdate());
  2557. // IF sqlca.SQLCode <> 0 THEN
  2558. // rslt = 0
  2559. // arg_msg = '因网络或其他原因,新增供应商物料:'+ls_mtrlcode+'报价失败,'+sqlca.SQLErrText
  2560. // GOTO ext
  2561. // END IF
  2562. //END IF
  2563. //
  2564. ////2.插入供应商售价变动明细表
  2565. //INSERT INTO u_spt_price_mx
  2566. // (u_spt_price_mx.sptid,
  2567. // u_spt_price_mx.mtrlid,
  2568. // u_spt_price_mx.opdate,
  2569. // u_spt_price_mx.opemp,
  2570. // u_spt_price_mx.inwareid,
  2571. // u_spt_price_mx.inwarecode,
  2572. // u_spt_price_mx.outdate,
  2573. // u_spt_price_mx.price,
  2574. // u_spt_price_mx.fprice,
  2575. // u_spt_price_mx.zqrate,
  2576. // u_spt_price_mx.dscrp,
  2577. // u_spt_price_mx.status,
  2578. // u_spt_price_mx.woodcode,
  2579. // u_spt_price_mx.pcode,
  2580. // u_spt_price_mx.jgdscrp,
  2581. // u_spt_price_mx.buildtype,
  2582. // u_spt_price_mx.unit,
  2583. // u_spt_price_mx.printid,
  2584. // u_spt_price_mx.wareprice,
  2585. // u_spt_price_mx.rate,
  2586. // u_spt_price_mx.billtype,
  2587. // u_spt_price_mx.moneyid,
  2588. // u_spt_price_mx.effdate
  2589. // )
  2590. // VALUES
  2591. // (
  2592. // :arg_sptid,
  2593. // :arg_mtrlid,
  2594. // :server_time,
  2595. // :publ_operator,
  2596. // :arg_inwareid,
  2597. // :arg_inwarecode,
  2598. // :arg_indate,
  2599. // :arg_fprice * :arg_zqrate,
  2600. // :arg_fprice,
  2601. // :arg_zqrate,
  2602. // :arg_dscrp,
  2603. // :arg_status,
  2604. // :arg_woodcode,
  2605. // :arg_pcode,
  2606. // :arg_jgdscrp,
  2607. // :arg_flag,
  2608. // :arg_unit,
  2609. // :arg_printid,
  2610. // :arg_wareprice,
  2611. // :arg_rate,
  2612. // :arg_billtype,
  2613. // :arg_moneyid,
  2614. // :arg_effdate);
  2615. //IF sqlca.SQLCode <> 0 THEN
  2616. // rslt = 0
  2617. // arg_msg = '因网络或其他原因,建立供应商物料:'+ls_mtrlcode+'报价历史失败'
  2618. // GOTO ext
  2619. //END IF
  2620. //
  2621. //ext:
  2622. //IF rslt = 0 THEN
  2623. // ROLLBACK;
  2624. //ELSEIF arg_ifcommit And rslt = 1 THEN
  2625. // COMMIT;
  2626. //END IF
  2627. //
  2628. //RETURN rslt
  2629. end function
  2630. public function integer uof_getmtrlsptbuyareaprice (long arg_moneyid, long arg_sptid, long arg_mtrlid, ref string arg_unit, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, ref long arg_buybargainid, ref long arg_buybargainprintid, ref string arg_buybargaincode, ref decimal arg_price, ref decimal arg_otherprice, ref decimal arg_areaqty, ref string arg_msg);Long rslt = 1
  2631. Decimal rtn_price,rtn_zqrate,rtn_rate
  2632. String ls_unit
  2633. String rtn_wareunit
  2634. Int li_iflimitprice,li_price_ifpz_buy
  2635. Long ll_buybargainid, ll_buybargainprintid
  2636. String ls_buybargaincode
  2637. decimal lde_price, lde_rebate, lde_otherprice, lde_areaqty
  2638. //lde_rebate = 1
  2639. //IF sys_option_buy_getbuybargain = 0 THEN
  2640. ll_buybargainid = 0
  2641. ll_buybargainprintid = 0
  2642. ls_buybargaincode = ''
  2643. lde_price = 0
  2644. lde_otherprice = 0
  2645. lde_rebate = 1
  2646. lde_areaqty = 0
  2647. // GOTO ext
  2648. //END IF
  2649. arg_status = Trim(arg_status)
  2650. arg_woodcode = Trim(arg_woodcode)
  2651. arg_pcode = Trim(arg_pcode)
  2652. arg_jgdscrp = Trim(arg_jgdscrp)
  2653. arg_unit = Trim(arg_unit)
  2654. SELECT iflimitprice,price_ifpz_buy , unit
  2655. INTO :li_iflimitprice,:li_price_ifpz_buy, :ls_unit
  2656. FROM u_mtrldef
  2657. Where mtrlid = :arg_mtrlid;
  2658. IF sqlca.SQLCode <> 0 THEN
  2659. arg_msg = '查询物料限价属性失败 '+sqlca.SQLErrText
  2660. rslt = 0
  2661. GOTO ext
  2662. END IF
  2663. CHOOSE CASE li_price_ifpz_buy
  2664. CASE 0
  2665. arg_status = ''
  2666. arg_woodcode = ''
  2667. arg_pcode = ''
  2668. CASE 1
  2669. arg_pcode = ''
  2670. arg_woodcode = ''
  2671. CASE 2
  2672. arg_status = ''
  2673. arg_pcode = ''
  2674. CASE 3
  2675. arg_status = ''
  2676. arg_woodcode = ''
  2677. CASE 4
  2678. arg_pcode = ''
  2679. CASE 5
  2680. arg_status = ''
  2681. CASE 6
  2682. arg_woodcode = ''
  2683. END CHOOSE
  2684. IF arg_unit = '' THEN
  2685. arg_unit = ls_unit
  2686. END IF
  2687. SELECT top 1 billid,printid,billcode, price,otherprice, areaqty
  2688. INTO :ll_buybargainid,:ll_buybargainprintid,:ls_buybargaincode, :lde_price, :lde_otherprice, :lde_areaqty
  2689. FROM (
  2690. SELECT top 1
  2691. u_buybargainmx.price,
  2692. u_buybargainmx.otherprice,
  2693. u_buybargainmx.areaqty,
  2694. u_buybargainmx.rate as rate,
  2695. u_buybargainmx.unit as unit,
  2696. u_buybargainmx.billid as billid,
  2697. u_buybargainmx.printid as printid,
  2698. ltrim(rtrim(u_buybargain.Billcode))+'[合同]' as billcode,
  2699. u_buybargain.auditdate as auditdate
  2700. FROM u_buybargain INNER JOIN
  2701. u_buybargainmx ON u_buybargain.billid = u_buybargainmx.billid
  2702. WHERE u_buybargain.flag = 1
  2703. AND u_buybargain.sptid_b = :arg_sptid
  2704. AND u_buybargainmx.mtrlid = :arg_mtrlid
  2705. AND u_buybargainmx.unit = :arg_unit
  2706. AND u_buybargain.moneyid = :arg_moneyid
  2707. and u_buybargainmx.material = :arg_jgdscrp
  2708. ORDER BY u_buybargain.auditdate DESC
  2709. UNION
  2710. SELECT top 1 u_spt_price_changemx.price,
  2711. 0 as otherprice,
  2712. 0 as areaqty,
  2713. u_spt_price_changemx.rate,
  2714. u_spt_price_changemx.unit,
  2715. u_spt_price_changemx.billid,
  2716. u_spt_price_changemx.printid,
  2717. ltrim(rtrim(u_spt_price_change.Billcode))+'[调价]',
  2718. u_spt_price_change.auditdate as auditdate
  2719. FROM u_spt_price_change INNER JOIN
  2720. u_spt_price_changemx ON
  2721. u_spt_price_change.billid = u_spt_price_changemx.billid
  2722. WHERE (u_spt_price_change.flag = 1)
  2723. AND u_spt_price_change.sptid = :arg_sptid
  2724. AND u_spt_price_changemx.mtrlid = :arg_mtrlid
  2725. AND u_spt_price_change.moneyid = :arg_moneyid
  2726. AND u_spt_price_changemx.unit = :arg_unit
  2727. AND u_spt_price_changemx.status = :arg_status
  2728. AND u_spt_price_changemx.woodcode = :arg_woodcode
  2729. AND u_spt_price_changemx.pcode = :arg_pcode
  2730. and u_spt_price_changemx.jgdscrp = :arg_jgdscrp
  2731. ORDER BY u_spt_price_change.auditdate DESC) A
  2732. Order By A.auditdate Desc;
  2733. IF sqlca.SQLCode <> 0 THEN
  2734. ll_buybargainid = 0
  2735. ll_buybargainprintid = 0
  2736. ls_buybargaincode = ''
  2737. lde_price = 0
  2738. lde_otherprice = 0
  2739. lde_areaqty = 0
  2740. END IF
  2741. ext:
  2742. arg_buybargainid = ll_buybargainid
  2743. arg_buybargainprintid = ll_buybargainprintid
  2744. arg_buybargaincode = ls_buybargaincode
  2745. arg_price = lde_price
  2746. arg_areaqty = lde_areaqty
  2747. arg_otherprice = lde_otherprice
  2748. RETURN rslt
  2749. end function
  2750. on uo_spt_price.create
  2751. call super::create
  2752. TriggerEvent( this, "constructor" )
  2753. end on
  2754. on uo_spt_price.destroy
  2755. TriggerEvent( this, "destructor" )
  2756. call super::destroy
  2757. end on
  2758. event constructor;String arg_msg
  2759. String str_optionvalue
  2760. str_optionvalue = ''
  2761. f_get_sys_option_value('053',str_optionvalue,arg_msg)
  2762. uo_option_buyprice_ifbj = Long(str_optionvalue)
  2763. str_optionvalue = ''
  2764. f_get_sys_option_value('244',str_optionvalue,arg_msg)
  2765. uo_option_sptprice_effdate = Long(str_optionvalue)
  2766. str_optionvalue = ''
  2767. f_get_sys_option_value('366',str_optionvalue,arg_msg)
  2768. uo_option_zero_update_sptprice = Long(str_optionvalue)
  2769. end event