uo_mtrlware_trans.sru 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725
  1. $PBExportHeader$uo_mtrlware_trans.sru
  2. forward
  3. global type uo_mtrlware_trans from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_mtrlware_trans from nonvisualobject
  7. end type
  8. global uo_mtrlware_trans uo_mtrlware_trans
  9. type variables
  10. PUBLIC PROTECTEDWRITE Long scid
  11. PUBLIC PROTECTEDWRITE Long billid
  12. PUBLIC PROTECTEDWRITE String billcode
  13. PUBLIC PROTECTEDWRITE DateTime opdate
  14. PUBLIC PROTECTEDWRITE String opemp
  15. PUBLIC PROTECTEDWRITE DateTime moddate
  16. PUBLIC PROTECTEDWRITE String modemp
  17. PUBLIC PROTECTEDWRITE Int fflag = 0
  18. PUBLIC PROTECTEDWRITE Int flag = 0
  19. PUBLIC PROTECTEDWRITE DateTime auditingdate
  20. PUBLIC PROTECTEDWRITE String auditingrep
  21. PUBLIC PROTECTEDWRITE Decimal sum_transqty = 0
  22. PUBLIC PROTECTEDWRITE Decimal sum_transamt = 0
  23. PUBLIC PROTECTEDWRITE Int priceflag = 0 //确认标志
  24. PUBLIC PROTECTEDWRITE DateTime pricedate //确认时间
  25. PUBLIC PROTECTEDWRITE String priceemp //确认操作员
  26. Long mtrlwareid
  27. Long storageid
  28. Long mtrlid
  29. Long relid
  30. String plancode
  31. String status
  32. DateTime billdate
  33. String inrep
  34. String part
  35. String dscrp
  36. Decimal transqty
  37. Decimal cost
  38. String woodcode
  39. String pcode
  40. string mtrlcuscode
  41. string location
  42. Int ifunit
  43. String uunit,unit
  44. Decimal rate
  45. string waredscrp
  46. Int billtype
  47. // 0 - 正常
  48. // 1 - 异常
  49. String transreason
  50. int kind
  51. // 0 - 一调多
  52. // 1 - 多调一
  53. // 2 - 借货
  54. // 3 - 还货
  55. // 4 - 多产品调一客户
  56. // 5 - 一产品调一客户
  57. Boolean if_getid_ture = TRUE
  58. Transaction commit_transaction //数据commit事务
  59. PRIVATE:
  60. s_transmx billmx[] //明细结构数组
  61. s_outwaremx_barcode s_mx_barcode[]
  62. Long it_mxbt = 0 //明细结构数组末指针
  63. Long it_mxbt_barcode = 0
  64. Boolean it_newbegin = FALSE //新建标志
  65. Boolean it_updatebegin = FALSE //修改标志
  66. end variables
  67. forward prototypes
  68. public function integer p_reset ()
  69. public function integer p_clearmx ()
  70. public function integer newbegin (long arg_scid, ref string arg_msg)
  71. public function integer updatebegin (long arg_scid, long arg_billid, ref string arg_msg)
  72. public function integer p_getinfo (long arg_scid, long arg_billid, ref string arg_msg)
  73. public function integer del (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  74. public function integer add_dscrp (long arg_scid, long arg_billid, string arg_newdescppart, ref string arg_msg)
  75. public function integer getinfo (long arg_scid, long arg_billid, ref string arg_msg)
  76. public function integer save (boolean arg_ifcommit, ref string arg_msg)
  77. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
  78. public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
  79. public function integer uof_add_returnqty (long arg_scid, long arg_relid, long arg_relprintid, decimal arg_qty, ref string arg_msg, boolean arg_ifcommit)
  80. public function integer uof_finish (integer arg_finishtype, integer arg_fflag, long arg_scid, long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
  81. public function integer uof_trycmpl (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  82. public function integer uof_update_waredate (boolean arg_ifcommit, ref string arg_msg)
  83. public function integer acceptmx (long arg_printid, long arg_mtrlwareid, long arg_mtrlid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_fprice, decimal arg_rebate, string arg_mxdscrp, long arg_rel_cusid_sptid, ref string arg_msg, string arg_woodcode, string arg_pcode, long arg_relid, long arg_relprintid, string arg_mtrlcuscode, string arg_location, string arg_waredscrp, string arg_plancode2, string arg_location2, string arg_mtrlcuscode2)
  84. public function integer priceaudit (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  85. public function integer c_priceaudit (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  86. end prototypes
  87. public function integer p_reset ();//int p_reset()
  88. //清除对象及其明细
  89. scid = 0
  90. billid = 0
  91. billcode = ''
  92. opemp = ''
  93. modemp = ''
  94. auditingrep = ''
  95. flag = 0
  96. inrep = ''
  97. part = ''
  98. dscrp = ''
  99. relid = 0
  100. storageid = 0
  101. mtrlwareid = 0
  102. mtrlid = 0
  103. plancode = ''
  104. status = ''
  105. transqty = 0
  106. cost = 0
  107. Kind = 0
  108. mtrlcuscode = ''
  109. location = ''
  110. waredscrp = ''
  111. sum_transqty = 0
  112. sum_transamt = 0
  113. it_newbegin = FALSE
  114. it_updatebegin = FALSE
  115. //清除明细
  116. p_clearmx()
  117. RETURN 1
  118. end function
  119. public function integer p_clearmx ();//int p_clearmx()
  120. //清除明细
  121. it_mxbt = 0
  122. sum_transqty = 0
  123. sum_transamt = 0
  124. RETURN 1
  125. end function
  126. public function integer newbegin (long arg_scid, ref string arg_msg);Int rslt = 1
  127. IF arg_scid < 0 THEN
  128. arg_msg = '请选择分部'
  129. rslt = 0
  130. GOTO ext
  131. END IF
  132. p_reset()
  133. scid = arg_scid
  134. it_newbegin = TRUE
  135. it_updatebegin = FALSE
  136. ext:
  137. IF rslt = 0 THEN p_reset()
  138. RETURN rslt
  139. end function
  140. public function integer updatebegin (long arg_scid, long arg_billid, ref string arg_msg);Int rslt = 1
  141. IF arg_scid < 0 THEN
  142. arg_msg = '请选择分部'
  143. rslt = 0
  144. GOTO ext
  145. END IF
  146. IF arg_billid <= 0 THEN
  147. rslt = 0
  148. GOTO ext
  149. END IF
  150. IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
  151. rslt = 0
  152. GOTO ext
  153. END IF
  154. IF Kind = 5 AND priceflag = 1 THEN
  155. rslt = 0
  156. arg_msg = '单据已经确认,不可以修改'
  157. GOTO ext
  158. END IF
  159. IF flag = 1 THEN
  160. rslt = 0
  161. arg_msg = '单据已经审核,不可以修改'
  162. GOTO ext
  163. END IF
  164. billid = arg_billid
  165. scid = arg_scid
  166. it_newbegin = FALSE
  167. it_updatebegin = TRUE
  168. p_clearmx() //清除明细
  169. ext:
  170. IF rslt = 0 THEN p_reset()
  171. RETURN rslt
  172. end function
  173. public function integer p_getinfo (long arg_scid, long arg_billid, ref string arg_msg);Int rslt = 1
  174. IF arg_billid <= 0 THEN
  175. rslt = 0
  176. arG_MSG = "非法单据唯一码"
  177. GOTO ext
  178. END IF
  179. SELECT u_mtrlware_trans.billcode,
  180. u_mtrlware_trans.mtrlwareid,
  181. u_mtrlware_trans.storageid,
  182. u_mtrlware_trans.mtrlid,
  183. u_mtrlware_trans.relid,
  184. u_mtrlware_trans.plancode,
  185. u_mtrlware_trans.status,
  186. u_mtrlware_trans.transqty,
  187. u_mtrlware_trans.billdate,
  188. u_mtrlware_trans.inrep,
  189. u_mtrlware_trans.flag,
  190. u_mtrlware_trans.fflag,
  191. u_mtrlware_trans.dscrp,
  192. u_mtrlware_trans.part,
  193. u_mtrlware_trans.cost,
  194. u_mtrlware_trans.woodcode,
  195. u_mtrlware_trans.pcode,
  196. u_mtrlware_trans.billtype,
  197. u_mtrlware_trans.transreason,
  198. u_mtrlware_trans.kind,
  199. u_mtrldef.ifunit,
  200. u_mtrldef.rate_buy,
  201. u_mtrldef.unit_buy,
  202. u_mtrldef.unit,
  203. u_mtrlware_trans.mtrlcuscode,
  204. u_mtrlware_trans.location,
  205. u_mtrlware_trans.waredscrp,
  206. u_mtrlware_trans.priceflag,
  207. u_mtrlware_trans.pricedate,
  208. u_mtrlware_trans.priceemp
  209. INTO :billcode,
  210. :mtrlwareid,
  211. :storageid,
  212. :mtrlid,
  213. :relid,
  214. :plancode,
  215. :status,
  216. :transqty,
  217. :billdate,
  218. :inrep,
  219. :flag,
  220. :fflag,
  221. :dscrp,
  222. :part,
  223. :cost,
  224. :woodcode,
  225. :pcode,
  226. :billtype,
  227. :transreason,
  228. :Kind,
  229. :ifunit,
  230. :rate,
  231. :uunit,
  232. :unit,
  233. :mtrlcuscode,
  234. :location,
  235. :waredscrp,
  236. :priceflag,
  237. :pricedate,
  238. :priceemp
  239. FROM u_mtrlware_trans,u_mtrldef
  240. WHERE u_mtrlware_trans.billid = :arg_billid
  241. AND u_mtrlware_trans.scid = :arg_scid
  242. and u_mtrlware_trans.mtrlid *= u_mtrldef.mtrlid
  243. USING commit_transaction;
  244. IF commit_transaction.SQLCode <> 0 THEN
  245. rslt = 0
  246. arG_MSG = "查询操作失败(错误调货单唯一码),调货单"+commit_transaction.SQLErrText
  247. GOTO ext
  248. END IF
  249. billid = arg_billid
  250. scid = arg_scid
  251. ext:
  252. IF rslt = 0 THEN p_reset()
  253. RETURN rslt
  254. end function
  255. public function integer del (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  256. IF arg_scid < 0 THEN
  257. arg_msg = '请选择分部'
  258. rslt = 0
  259. GOTO ext
  260. END IF
  261. IF arg_billid = 0 THEN
  262. rslt = 0
  263. arg_msg = "没有删除对象,操作取消"
  264. GOTO ext
  265. END IF
  266. rslt = p_getinfo(arg_scid,arg_billid,arg_msg)
  267. IF rslt = 0 THEN GOTO ext
  268. IF Kind = 5 AND priceflag = 1 THEN
  269. rslt = 0
  270. arg_msg = '单据已经确认,不可以删除'
  271. GOTO ext
  272. END IF
  273. IF flag = 1 THEN
  274. rslt = 0
  275. arg_msg = "单据已经审核,不可以删除"
  276. GOTO ext
  277. END IF
  278. DELETE FROM u_mtrlware_transmx
  279. WHERE u_mtrlware_transmx.billid = :arg_billid
  280. AND scid = :arg_scid USING commit_transaction;
  281. IF commit_transaction.SQLCode <> 0 THEN
  282. rslt = 0
  283. arg_msg = "删除单据明细操作失败"+"~n"+commit_transaction.SQLErrText
  284. GOTO ext
  285. END IF
  286. DELETE FROM u_mtrlware_trans
  287. WHERE u_mtrlware_trans.billid = :arg_billid
  288. AND scid = :arg_scid USING commit_transaction;
  289. IF commit_transaction.SQLCode <> 0 THEN
  290. rslt = 0
  291. arg_msg = "删除单据操作失败"+"~n"+commit_transaction.SQLErrText
  292. GOTO ext
  293. END IF
  294. it_newbegin = FALSE
  295. it_updatebegin = FALSE
  296. ext:
  297. IF rslt = 0 THEN
  298. ROLLBACK USING commit_transaction;
  299. ELSEIF rslt = 1 AND arg_ifcommit THEN
  300. COMMIT USING commit_transaction;
  301. END IF
  302. p_reset()
  303. RETURN rslt
  304. end function
  305. public function integer add_dscrp (long arg_scid, long arg_billid, string arg_newdescppart, ref string arg_msg);int rslt=1
  306. arg_newdescppart=trim(arg_newdescppart)
  307. if it_updatebegin or it_newbegin then
  308. rslt=0
  309. arg_msg="编辑状态下不可用"
  310. goto ext
  311. end if
  312. if arg_newdescppart='' then
  313. rslt=0
  314. arg_msg="要添加内容为空,操作取消"
  315. goto ext
  316. end if
  317. rslt=p_getinfo(arg_scid,arg_billid,arg_msg)
  318. if rslt=0 then goto ext
  319. if flag=0 then
  320. rslt=0
  321. arg_msg="非审核状态下不可用"
  322. goto ext
  323. end if
  324. update u_mtrlware_trans
  325. set dscrp = dscrp+' '+:arg_newdescppart
  326. where u_mtrlware_trans.billid = :billid
  327. and scid=:scid using commit_transaction;
  328. if commit_transaction.sqlcode<>0 then
  329. rollback using commit_transaction;
  330. rslt=0
  331. arg_msg="因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.sqlerrtext
  332. goto ext
  333. end if
  334. commit using commit_transaction;
  335. dscrp = dscrp+' '+arg_newdescppart
  336. ext: return (rslt)
  337. end function
  338. public function integer getinfo (long arg_scid, long arg_billid, ref string arg_msg);Int rslt = 1
  339. long i = 1,no_mxcheck = 0,no_mxcheck_barcode = 0,k = 1
  340. Int li_outtype
  341. sum_transqty = 0
  342. IF arg_billid <= 0 THEN
  343. rslt = 0
  344. arg_msg = "非法单据唯一码"
  345. GOTO ext
  346. END IF
  347. rslt = p_getinfo(arg_scid,arg_billid,arg_msg)
  348. IF rslt = 0 THEN GOTO ext
  349. SELECT outtype
  350. INTO :li_outtype
  351. FROM u_storage
  352. Where storageid = :storageid;
  353. IF sqlca.SQLCode <> 0 THEN
  354. rslt = 0
  355. arg_msg = "查询操作失败,仓库出仓类型,"+sqlca.SQLErrText
  356. GOTO ext
  357. END IF
  358. //用游标读取明细
  359. DECLARE cur_transmx CURSOR FOR
  360. SELECT u_mtrlware_transmx.printid,
  361. u_mtrlware_transmx.mtrlid,
  362. u_mtrlware_transmx.plancode,
  363. u_mtrlware_transmx.status,
  364. u_mtrlware_transmx.qty,
  365. u_mtrlware_transmx.fprice,
  366. u_mtrlware_transmx.rebate,
  367. u_mtrlware_transmx.price,
  368. u_mtrlware_transmx.mxdscrp,
  369. u_mtrldef.mtrlcode,
  370. u_mtrlware_transmx.rel_cusid_sptid,
  371. u_mtrlware_transmx.woodcode,
  372. u_mtrlware_transmx.pcode,
  373. u_mtrlware_transmx.relid,
  374. u_mtrlware_transmx.relprintid,
  375. u_mtrldef.ifunit,
  376. u_mtrldef.rate_buy,
  377. u_mtrldef.unit_buy,
  378. u_mtrldef.unit,
  379. u_mtrlware_transmx.mtrlcuscode,
  380. u_mtrlware_transmx.location,
  381. u_mtrlware_transmx.waredscrp,
  382. u_mtrlware_transmx.mtrlcuscode2,
  383. u_mtrlware_transmx.location2,
  384. u_mtrlware_transmx.plancode2,
  385. u_mtrlware_transmx.mtrlwareid
  386. FROM u_mtrlware_transmx,u_mtrldef
  387. WHERE u_mtrlware_transmx.billid = :arg_billid AND
  388. u_mtrlware_transmx.mtrlid = u_mtrldef.mtrlid AND
  389. u_mtrlware_transmx.scid = :arg_scid USING commit_transaction;
  390. OPEN cur_transmx;
  391. FETCH cur_transmx INTO :billmx[i].printid,:billmx[i].mtrlid,:billmx[i].plancode,
  392. :billmx[i].status,:billmx[i].qty,:billmx[i].fprice,
  393. :billmx[i].rebate,:billmx[i].price,
  394. :billmx[i].mxdscrp,:billmx[i].mtrlcode,
  395. :billmx[i].rel_cusid_sptid,
  396. :billmx[i].woodcode,
  397. :billmx[i].pcode,
  398. :billmx[i].relid,
  399. :billmx[i].relprintid,
  400. :billmx[i].ifunit,
  401. :billmx[i].rate,
  402. :billmx[i].uunit,
  403. :billmx[i].unit,
  404. :billmx[i].mtrlcuscode,
  405. :billmx[i].location,
  406. :billmx[i].waredscrp,
  407. :billmx[i].mtrlcuscode2,
  408. :billmx[i].location2,
  409. :billmx[i].plancode2,
  410. :billmx[i].mtrlwareid;
  411. DO WHILE commit_transaction.SQLCode = 0
  412. sum_transqty = sum_transqty + billmx[i].qty
  413. i++
  414. FETCH cur_transmx INTO :billmx[i].printid,:billmx[i].mtrlid,:billmx[i].plancode,
  415. :billmx[i].status,:billmx[i].qty,:billmx[i].fprice,
  416. :billmx[i].rebate,:billmx[i].price,
  417. :billmx[i].mxdscrp,:billmx[i].mtrlcode,
  418. :billmx[i].rel_cusid_sptid,
  419. :billmx[i].woodcode,
  420. :billmx[i].pcode,
  421. :billmx[i].relid,
  422. :billmx[i].relprintid,
  423. :billmx[i].ifunit,
  424. :billmx[i].rate,
  425. :billmx[i].uunit,
  426. :billmx[i].unit,
  427. :billmx[i].mtrlcuscode,
  428. :billmx[i].location,
  429. :billmx[i].waredscrp,
  430. :billmx[i].mtrlcuscode2,
  431. :billmx[i].location2,
  432. :billmx[i].plancode2,
  433. :billmx[i].mtrlwareid;
  434. LOOP
  435. CLOSE cur_transmx;
  436. //检验明细是否读入完整
  437. SELECT count(*) INTO :no_mxcheck
  438. FROM u_mtrlware_transmx
  439. WHERE u_mtrlware_transmx.billid = :arg_billid
  440. AND scid = :arg_scid USING commit_transaction;
  441. IF commit_transaction.SQLCode <> 0 THEN
  442. rslt = 0
  443. arg_msg = "查询操作失败,调货单明细数量"
  444. GOTO ext
  445. END IF
  446. IF i <> (no_mxcheck+1) THEN
  447. rslt = 0
  448. arg_msg = "查询操作失败,调货单明细"
  449. GOTO ext
  450. END IF
  451. //用游标读取条码明细
  452. IF li_outtype = 2 or li_outtype = 3 THEN
  453. DECLARE cur_outwaremx_barcode CURSOR FOR
  454. SELECT u_outwaremx_mx_barcode.barcode,
  455. u_outwaremx_mx_barcode.qty,
  456. u_mtrlware_mx.packqty
  457. FROM u_outwaremx_mx_barcode,u_mtrlware_mx
  458. WHERE u_outwaremx_mx_barcode.barcode = u_mtrlware_mx.barcode and
  459. u_outwaremx_mx_barcode.outwareid = :arg_billid AND
  460. u_outwaremx_mx_barcode.scid = :arg_scid and
  461. u_outwaremx_mx_barcode.billtype = 51
  462. Order By u_outwaremx_mx_barcode.barcode;
  463. OPEN cur_outwaremx_barcode;
  464. FETCH cur_outwaremx_barcode INTO :s_mx_barcode[k].barcode,:s_mx_barcode[k].qty,:s_mx_barcode[k].packqty;
  465. DO WHILE sqlca.SQLCode = 0
  466. k++
  467. FETCH cur_outwaremx_barcode INTO :s_mx_barcode[k].barcode,:s_mx_barcode[k].qty,:s_mx_barcode[k].packqty;
  468. LOOP
  469. CLOSE cur_outwaremx_barcode;
  470. //检验明细是否读入完整
  471. SELECT count(*) INTO :no_mxcheck_barcode
  472. FROM u_outwaremx_mx_barcode
  473. WHERE u_outwaremx_mx_barcode.outwareid = :arg_billid
  474. AND u_outwaremx_mx_barcode.scid = :arg_scid
  475. and u_outwaremx_mx_barcode.billtype = 51;
  476. IF sqlca.SQLCode <> 0 THEN
  477. rslt = 0
  478. arg_msg = "查询操作失败,出仓单明细数量"
  479. GOTO ext
  480. END IF
  481. IF k <> (no_mxcheck_barcode+1) THEN
  482. rslt = 0
  483. arg_msg = "查询操作失败,出仓单条码明细"
  484. GOTO ext
  485. END IF
  486. it_mxbt_barcode = k - 1
  487. END IF
  488. billid = arg_billid
  489. scid = arg_scid
  490. it_mxbt = i - 1
  491. it_newbegin = FALSE
  492. it_updatebegin = FALSE
  493. ext:
  494. IF rslt = 0 THEN p_reset()
  495. RETURN rslt
  496. end function
  497. public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1
  498. Long cnt = 0,i
  499. DateTime server_dt
  500. Long ls_newid
  501. String ls_sccode
  502. Long i_mtrlid
  503. Long i_relid
  504. String i_plancode
  505. String i_status
  506. Long i_storageid
  507. String i_woodcode
  508. String i_pcode
  509. String i_mtrlcuscode
  510. String i_location
  511. String i_waredscrp
  512. Int li_outtype,li_storagetype
  513. Int li_noallocflag
  514. Decimal ld_noallocqty,ld_notauditqty,ld_allocqty
  515. IF IsNull(mtrlwareid) THEN mtrlwareid = 0
  516. IF IsNull(storageid) THEN storageid = 0
  517. IF IsNull(cost) THEN cost = 0
  518. IF IsNull(inrep) THEN inrep = ''
  519. IF IsNull(part) THEN part = ''
  520. IF IsNull(dscrp) THEN dscrp = ''
  521. IF IsNull(transqty) THEN transqty = 0
  522. IF IsNull(billtype) THEN billtype = 0
  523. IF IsNull(transreason) THEN transreason = ''
  524. IF IsNull(waredscrp) THEN waredscrp = ''
  525. IF it_newbegin = False And it_updatebegin = False THEN
  526. rslt = 0
  527. arg_msg = "非编辑状态不可以提交"
  528. GOTO ext
  529. END IF
  530. IF Kind <> 0 And Kind <> 1 And Kind <> 2 And Kind <> 3 And Kind <> 4 And Kind <> 5 THEN
  531. arg_msg = '错误的单据类型'
  532. rslt = 0
  533. GOTO ext
  534. END IF
  535. SELECT outtype,noallocflag,storagetype
  536. INTO :li_outtype,:li_noallocflag,:li_storagetype
  537. FROM u_storage
  538. Where storageid = :storageid Using commit_transaction;
  539. IF commit_transaction.SQLCode <> 0 THEN
  540. arg_msg = '查询调出仓库所属分部资料,出仓类型失败,'+commit_transaction.SQLErrText
  541. rslt = 0
  542. GOTO ext
  543. END IF
  544. IF Kind = 5 THEN
  545. IF li_outtype <> 2 And li_outtype <> 3 THEN
  546. arg_msg = '仓库出仓类型不是条码出仓,请使用其它调货单进行操作'
  547. rslt = 0
  548. GOTO ext
  549. END IF
  550. ELSE
  551. IF li_outtype = 2 Or li_outtype = 3 THEN
  552. arg_msg = '仓库出仓类型为条码出仓,请使用条码调货单进行操作'
  553. rslt = 0
  554. GOTO ext
  555. END IF
  556. END IF
  557. IF li_storagetype = 1 And Kind <> 5 THEN
  558. arg_msg = '仓库使用库存分配策略,请使用库存分配调货单进行操作'
  559. rslt = 0
  560. GOTO ext
  561. END IF
  562. SELECT Top 1 getdate() Into :server_dt From u_user Using commit_transaction ;
  563. //取得系统时间,借用操作员表
  564. IF commit_transaction.SQLCode <> 0 THEN
  565. rslt = 0
  566. arg_msg = "查询操作失败,日期 "
  567. GOTO ext
  568. END IF
  569. IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
  570. rslt = 0
  571. arg_msg = "没有正确进仓内容"
  572. GOTO ext
  573. END IF
  574. IF f_check_inoutdate(storageid,billdate,True,arg_msg) = 0 THEN
  575. rslt = 0
  576. GOTO ext
  577. END IF
  578. IF billtype = 1 THEN
  579. IF transreason = '' THEN
  580. arg_msg = '请输入调货原因'
  581. rslt = 0
  582. GOTO ext
  583. END IF
  584. END IF
  585. IF Kind <> 4 THEN
  586. IF transqty <= 0 THEN
  587. arg_msg = '请输入正确的转换数量'
  588. rslt = 0
  589. GOTO ext
  590. END IF
  591. IF transqty <> sum_transqty THEN
  592. arg_msg = '转换与被转换数量不相等'
  593. rslt = 0
  594. GOTO ext
  595. END IF
  596. END IF
  597. IF Kind = 0 Or Kind = 3 Or Kind = 5 THEN //1调n
  598. SELECT u_mtrlware.mtrlid,
  599. u_mtrlware.sptid,
  600. u_mtrlware.storageid,
  601. u_mtrlware.plancode,
  602. u_mtrlware.status,
  603. u_mtrlware.woodcode,
  604. u_mtrlware.pcode,
  605. u_mtrlware.mtrlcuscode,
  606. u_mtrlware.location,
  607. u_mtrlware.dscrp,
  608. u_mtrlware.noallocqty,
  609. u_mtrlware.noauditingqty,
  610. u_mtrlware.allocqty
  611. INTO :i_mtrlid,
  612. :i_relid,
  613. :i_storageid,
  614. :i_plancode,
  615. :i_status,
  616. :i_woodcode,
  617. :i_pcode,
  618. :i_mtrlcuscode,
  619. :i_location,
  620. :i_waredscrp,
  621. :ld_noallocqty,
  622. :ld_notauditqty,
  623. :ld_allocqty
  624. FROM u_mtrlware
  625. WHERE u_mtrlware.scid = :scid
  626. AND u_mtrlware.mtrlwareid = :mtrlwareid
  627. Using commit_transaction;
  628. IF commit_transaction.SQLCode <> 0 THEN
  629. arg_msg = '查询相关转换库存失败>>' + commit_transaction.SQLErrText
  630. rslt = 0
  631. GOTO ext
  632. END IF
  633. IF IsNull(i_mtrlid) THEN i_mtrlid = 0
  634. IF IsNull(i_relid) THEN i_relid = 0
  635. IF IsNull(i_storageid) THEN i_storageid = 0
  636. IF IsNull(i_plancode) THEN i_plancode = ''
  637. IF IsNull(i_status) THEN i_status = ''
  638. IF IsNull(i_woodcode) THEN i_woodcode = ''
  639. IF IsNull(i_pcode) THEN i_pcode = ''
  640. IF IsNull(i_mtrlcuscode) THEN i_mtrlcuscode = ''
  641. IF IsNull(i_location) THEN i_location = ''
  642. IF IsNull(i_waredscrp) THEN i_waredscrp = ''
  643. IF IsNull(ld_notauditqty) THEN ld_notauditqty = 0
  644. IF IsNull(ld_noallocqty) THEN ld_noallocqty = 0
  645. IF i_storageid <> storageid THEN
  646. arg_msg = '仓库与库存不符'
  647. rslt = 0
  648. GOTO ext
  649. END IF
  650. IF li_noallocflag = 1 THEN
  651. IF ld_noallocqty - ld_notauditqty < transqty THEN
  652. arg_msg = '库存未开单数不足,不能调货,请检查'
  653. rslt = 0
  654. GOTO ext
  655. END IF
  656. END IF
  657. IF Kind = 5 THEN
  658. IF ld_noallocqty - ld_allocqty < transqty THEN
  659. arg_msg = '库存未分配数量不足,不能调货,请检查'
  660. rslt = 0
  661. GOTO ext
  662. END IF
  663. END IF
  664. mtrlid = i_mtrlid
  665. relid = i_relid
  666. storageid = i_storageid
  667. plancode = i_plancode
  668. status = i_status
  669. woodcode = i_woodcode
  670. pcode = i_pcode
  671. mtrlcuscode = i_mtrlcuscode
  672. Location = i_location
  673. waredscrp = i_waredscrp
  674. ELSEIF Kind = 4 THEN //多产品调一客户
  675. IF relid = 0 THEN
  676. arg_msg = '请选择客户'
  677. rslt = 0
  678. GOTO ext
  679. END IF
  680. cnt = 0
  681. SELECT count(*) INTO :cnt
  682. FROM u_cust
  683. Where cusid = :relid Using commit_transaction;
  684. IF commit_transaction.SQLCode <> 0 THEN
  685. arg_msg = '查询客户资料失败,请检查,'+commit_transaction.SQLErrText
  686. rslt = 0
  687. GOTO ext
  688. END IF
  689. IF cnt = 0 THEN
  690. arg_msg = '客户资料不存在,请检查'
  691. rslt = 0
  692. GOTO ext
  693. END IF
  694. IF cnt > 1 THEN
  695. arg_msg = '客户资料重复,请检查'
  696. rslt = 0
  697. GOTO ext
  698. END IF
  699. ELSE // n调1
  700. cost = sum_transamt / sum_transqty
  701. END IF
  702. ////////////////////////////////////////////// //开始区分:新建/更新 处理
  703. IF billid = 0 THEN //新建
  704. ls_newid = f_sys_scidentity(scid,"u_mtrlware_trans","billid",arg_msg,True,id_sqlca)
  705. IF ls_newid <= 0 THEN
  706. rslt = 0
  707. GOTO ext
  708. END IF
  709. //取分部代号
  710. IF f_get_sccode(scid,commit_transaction,ls_sccode,arg_msg) = 0 THEN
  711. rslt = 0
  712. GOTO ext
  713. END IF
  714. CHOOSE CASE Kind
  715. CASE 0,1
  716. billcode = getid(scid,ls_sccode + 'MT',Date(server_dt),if_getid_ture,commit_transaction)
  717. CASE 2
  718. billcode = getid(scid,ls_sccode + 'ML',Date(server_dt),if_getid_ture,commit_transaction)
  719. CASE 3
  720. billcode = getid(scid,ls_sccode + 'MR',Date(server_dt),if_getid_ture,commit_transaction)
  721. CASE 4
  722. billcode = getid(scid,ls_sccode + 'MH',Date(server_dt),if_getid_ture,commit_transaction)
  723. CASE 5
  724. billcode = getid(scid,ls_sccode + 'MB',Date(server_dt),if_getid_ture,commit_transaction)
  725. END CHOOSE
  726. IF billcode = "err" THEN
  727. billcode = ''
  728. rslt = 0
  729. arg_msg = "无法获取单据编号"+"~n"+commit_transaction.SQLErrText
  730. GOTO ext
  731. END IF
  732. INSERT INTO u_mtrlware_trans
  733. ( scid,
  734. billid,
  735. billcode,
  736. mtrlwareid,
  737. storageid,
  738. mtrlid,
  739. relid,
  740. plancode,
  741. status,
  742. transqty,
  743. billdate,
  744. inrep,
  745. part,
  746. dscrp,
  747. cost,
  748. opdate,
  749. opemp,
  750. woodcode,
  751. pcode,
  752. billtype,
  753. transreason,
  754. kind,
  755. mtrlcuscode,
  756. location,
  757. waredscrp)
  758. VALUES (:scid,
  759. :ls_newid,
  760. :billcode,
  761. :mtrlwareid,
  762. :storageid,
  763. :mtrlid,
  764. :relid,
  765. :plancode,
  766. :status,
  767. :transqty,
  768. :billdate,
  769. :inrep,
  770. :part,
  771. :dscrp,
  772. :cost,
  773. :server_dt,
  774. :publ_operator,
  775. :woodcode,
  776. :pcode,
  777. :billtype,
  778. :transreason,
  779. :Kind,
  780. :mtrlcuscode,
  781. :Location,
  782. :waredscrp) Using commit_transaction ;
  783. IF commit_transaction.SQLCode <> 0 THEN
  784. rslt = 0
  785. arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
  786. GOTO ext
  787. END IF
  788. //读取新inwareid
  789. billid = ls_newid
  790. FOR i = 1 To it_mxbt
  791. INSERT INTO u_mtrlware_transmx
  792. (scid,
  793. billid,
  794. printid,
  795. mtrlid,
  796. plancode,
  797. plancode2,
  798. status,
  799. qty,
  800. fprice,
  801. rebate,
  802. price,
  803. mxdscrp,
  804. rel_cusid_sptid,
  805. woodcode,
  806. pcode,
  807. mtrlwareid,
  808. relid,
  809. relprintid,
  810. mtrlcuscode,
  811. location,
  812. mtrlcuscode2,
  813. location2,
  814. waredscrp)
  815. VALUES (
  816. :scid,
  817. :ls_newid,
  818. :billmx[i].printid,
  819. :billmx[i].mtrlid,
  820. :billmx[i].plancode,
  821. :billmx[i].plancode2,
  822. :billmx[i].status,
  823. :billmx[i].qty,
  824. :billmx[i].fprice,
  825. :billmx[i].rebate,
  826. :billmx[i].price,
  827. :billmx[i].mxdscrp,
  828. :billmx[i].rel_cusid_sptid,
  829. :billmx[i].woodcode,
  830. :billmx[i].pcode,
  831. :billmx[i].mtrlwareid,
  832. :billmx[i].relid,
  833. :billmx[i].relprintid,
  834. :billmx[i].mtrlcuscode,
  835. :billmx[i].Location,
  836. :billmx[i].mtrlcuscode2,
  837. :billmx[i].Location2,
  838. :billmx[i].waredscrp) Using commit_transaction;
  839. IF commit_transaction.SQLCode <> 0 THEN
  840. billid = 0 //还原billid
  841. rslt = 0
  842. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  843. GOTO ext
  844. END IF
  845. NEXT
  846. ELSE //////////////////////////////////////////////// //更新
  847. UPDATE u_mtrlware_trans
  848. SET mtrlwareid = :mtrlwareid,
  849. storageid = :storageid,
  850. mtrlid = :mtrlid,
  851. relid = :relid,
  852. plancode = :plancode,
  853. status = :status,
  854. transqty = :transqty,
  855. billdate = :billdate,
  856. inrep = :inrep,
  857. part = :part,
  858. dscrp = :dscrp,
  859. cost = :cost,
  860. moddate = :server_dt,
  861. modemp = :publ_operator,
  862. woodcode = :woodcode,
  863. pcode = :pcode,
  864. mtrlcuscode = :mtrlcuscode,
  865. location = :Location,
  866. billtype = :billtype,
  867. transreason = :transreason,
  868. waredscrp = :waredscrp
  869. WHERE u_mtrlware_trans.billid = :billid
  870. AND u_mtrlware_trans.scid = :scid
  871. And flag = 0 Using commit_transaction;
  872. IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN
  873. rslt = 0
  874. arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+commit_transaction.SQLErrText
  875. GOTO ext
  876. END IF
  877. //删除原有明细
  878. DELETE FROM u_mtrlware_transmx
  879. WHERE u_mtrlware_transmx.billid = :billid
  880. And u_mtrlware_transmx.scid = :scid Using commit_transaction;
  881. IF commit_transaction.SQLCode <> 0 THEN
  882. rslt = 0
  883. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  884. GOTO ext
  885. END IF
  886. FOR i = 1 To it_mxbt
  887. INSERT INTO u_mtrlware_transmx
  888. (scid,
  889. billid,
  890. printid,
  891. mtrlid,
  892. plancode,
  893. plancode2,
  894. status,
  895. qty,
  896. fprice,
  897. rebate,
  898. price,
  899. mxdscrp,
  900. rel_cusid_sptid,
  901. woodcode,
  902. pcode,
  903. mtrlwareid,
  904. relid,
  905. relprintid,
  906. mtrlcuscode,
  907. location,
  908. mtrlcuscode2,
  909. location2,
  910. waredscrp)
  911. VALUES (
  912. :scid,
  913. :billid,
  914. :billmx[i].printid,
  915. :billmx[i].mtrlid,
  916. :billmx[i].plancode,
  917. :billmx[i].plancode2,
  918. :billmx[i].status,
  919. :billmx[i].qty,
  920. :billmx[i].fprice,
  921. :billmx[i].rebate,
  922. :billmx[i].price,
  923. :billmx[i].mxdscrp,
  924. :billmx[i].rel_cusid_sptid,
  925. :billmx[i].woodcode,
  926. :billmx[i].pcode,
  927. :billmx[i].mtrlwareid,
  928. :billmx[i].relid,
  929. :billmx[i].relprintid,
  930. :billmx[i].mtrlcuscode,
  931. :billmx[i].Location,
  932. :billmx[i].mtrlcuscode2,
  933. :billmx[i].Location2,
  934. :billmx[i].waredscrp) Using commit_transaction;
  935. IF commit_transaction.SQLCode <> 0 THEN
  936. rslt = 0
  937. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  938. GOTO ext
  939. END IF
  940. NEXT
  941. END IF
  942. it_newbegin = False
  943. it_updatebegin = False
  944. ext:
  945. IF rslt = 0 THEN
  946. ROLLBACK Using commit_transaction;
  947. p_clearmx()
  948. ELSEIF rslt = 1 And arg_ifcommit THEN
  949. COMMIT Using commit_transaction;
  950. END IF
  951. RETURN rslt
  952. end function
  953. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  954. Long cnt = 0,i,j
  955. DateTime null_dt
  956. String ls_mtrlcode
  957. Decimal ls_planprice
  958. Long ll_inware_out,ll_inware_in
  959. int li_inoutflag
  960. SetNull(null_dt)
  961. uo_mtrlware_trans uo_trans
  962. uo_trans = Create uo_mtrlware_trans
  963. uo_trans.commit_transaction = commit_transaction
  964. uo_inware uo_in
  965. uo_in = Create uo_inware
  966. uo_in.commit_transaction = sqlca
  967. uo_in.if_getid_ture = False
  968. uo_getbar uo_gb
  969. uo_gb = Create uo_getbar
  970. IF billid = 0 THEN
  971. rslt = 0
  972. arg_msg = "没有审核对象"
  973. GOTO ext
  974. END IF
  975. IF flag = 0 THEN
  976. rslt = 0
  977. arg_msg = "单据还未审核"
  978. GOTO ext
  979. END IF
  980. UPDATE u_mtrlware_trans
  981. SET auditingrep = '',
  982. auditingdate = :null_dt,
  983. flag = 0
  984. WHERE u_mtrlware_trans.billid = :billid
  985. And flag = 1 And scid = :scid Using commit_transaction;
  986. IF commit_transaction.SQLCode <> 0 THEN
  987. rslt = 0
  988. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  989. GOTO ext
  990. ELSEIF commit_transaction.SQLNRows = 0 THEN
  991. rslt = 0
  992. arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  993. GOTO ext
  994. END IF
  995. //还货
  996. IF Kind = 3 THEN
  997. FOR j = 1 To it_mxbt
  998. IF uof_add_returnqty(scid,&
  999. billmx[j].relid,&
  1000. billmx[j].relprintid,&
  1001. 0 - billmx[j].qty,&
  1002. arg_msg,&
  1003. False) = 0 THEN
  1004. arg_msg = '行:'+String(billmx[j].printid)+arg_msg
  1005. rslt = 0
  1006. GOTO ext
  1007. END IF
  1008. IF uo_trans.uof_trycmpl(scid,billmx[j].relid,arg_msg,False) = 0 THEN
  1009. arg_msg = '行:'+String(billmx[j].printid)+arg_msg
  1010. rslt = 0
  1011. GOTO ext
  1012. END IF
  1013. NEXT
  1014. END IF
  1015. //撤审删除相关进仓单(正)
  1016. SELECT inwareid INTO :ll_inware_in
  1017. FROM u_inware
  1018. WHERE scid = :scid
  1019. AND relid = :billid
  1020. AND billtype = 17
  1021. And relint_2 = 1;
  1022. IF sqlca.SQLCode <> 0 THEN
  1023. arg_msg = '查询相关进仓单(正)失败'+sqlca.SQLErrText
  1024. rslt = 0
  1025. GOTO ext
  1026. END IF
  1027. IF uo_in.getinfo(scid,ll_inware_in,arg_msg) = 0 THEN
  1028. rslt = 0
  1029. GOTO ext
  1030. END IF
  1031. IF uo_in.c_auditing(False,arg_msg) = 0 THEN
  1032. rslt = 0
  1033. GOTO ext
  1034. END IF
  1035. IF uo_in.del(scid,ll_inware_in,arg_msg,False) = 0 THEN
  1036. rslt = 0
  1037. GOTO ext
  1038. END IF
  1039. //
  1040. //撤审删除相关进仓单(负)
  1041. SELECT inwareid INTO :ll_inware_out
  1042. FROM u_inware
  1043. WHERE scid = :scid
  1044. AND relid = :billid
  1045. AND billtype = 17
  1046. And relint_2 = 0;
  1047. IF sqlca.SQLCode <> 0 THEN
  1048. arg_msg = '查询相关进仓单(负)失败'+sqlca.SQLErrText
  1049. rslt = 0
  1050. GOTO ext
  1051. END IF
  1052. IF uo_in.getinfo(scid,ll_inware_out,arg_msg) = 0 THEN
  1053. rslt = 0
  1054. GOTO ext
  1055. END IF
  1056. IF uo_in.c_auditing(False,arg_msg) = 0 THEN
  1057. rslt = 0
  1058. GOTO ext
  1059. END IF
  1060. IF uo_in.del(scid,ll_inware_out,arg_msg,False) = 0 THEN
  1061. rslt = 0
  1062. GOTO ext
  1063. END IF
  1064. //
  1065. IF Kind = 5 THEN
  1066. FOR i = 1 To it_mxbt_barcode
  1067. select inflag - outflag into :li_inoutflag
  1068. from u_mtrlware_mx
  1069. where barcode = :s_mx_barcode[i].barcode;
  1070. if sqlca.sqlcode <> 0 then
  1071. arg_msg = '查询条码:'+s_mx_barcode[i].barcode+'进出仓标记失败,'+sqlca.sqlerrtext
  1072. rslt = 0
  1073. GOTO ext
  1074. END IF
  1075. if li_inoutflag <> 1 then
  1076. arg_msg = '条码:'+s_mx_barcode[i].barcode+'不是在未出仓状态,操作取消'
  1077. rslt = 0
  1078. GOTO ext
  1079. END IF
  1080. IF uo_gb.uof_barcode_mtrlwareid(s_mx_barcode[i].barcode,&
  1081. scid,mtrlwareid,False,arg_msg) = 0 THEN
  1082. rslt = 0
  1083. GOTO ext
  1084. END IF
  1085. NEXT
  1086. END IF
  1087. flag = 0
  1088. ext:
  1089. IF rslt = 0 THEN
  1090. ROLLBACK Using commit_transaction;
  1091. ELSEIF rslt = 1 And arg_ifcommit THEN
  1092. COMMIT Using commit_transaction;
  1093. END IF
  1094. Destroy uo_in
  1095. Destroy uo_trans
  1096. Destroy uo_gb
  1097. RETURN rslt
  1098. end function
  1099. public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  1100. Long cnt = 0,i,j
  1101. String ls_mtrlcode
  1102. Decimal ls_planprice,ld_qty_barcode
  1103. Long ll_inwareid_out,ll_inwareid_in,ll_mx_mtrlwareid
  1104. Int li_outtype,li_inoutflag,li_outtype_mtrl
  1105. uo_mtrlware_trans uo_trans
  1106. uo_trans = CREATE uo_mtrlware_trans
  1107. uo_trans.commit_transaction = commit_transaction
  1108. uo_getbar uo_gb
  1109. uo_gb = CREATE uo_getbar
  1110. IF billid = 0 THEN
  1111. rslt = 0
  1112. arg_msg = "没有审核对象"
  1113. GOTO ext
  1114. END IF
  1115. IF flag = 1 THEN
  1116. rslt = 0
  1117. arg_msg = "单据已经审核"
  1118. GOTO ext
  1119. END IF
  1120. SELECT outtype INTO :li_outtype
  1121. FROM u_storage
  1122. Where storageid = :storageid;
  1123. IF sqlca.SQLCode <> 0 THEN
  1124. arg_msg = '查询调出仓库所属分部资料,出仓类型失败,'+sqlca.SQLErrText
  1125. rslt = 0
  1126. GOTO ext
  1127. END IF
  1128. IF Kind = 5 THEN
  1129. IF priceflag = 0 THEN
  1130. arg_msg = '单据未确认,不能审核'
  1131. rslt = 0
  1132. GOTO ext
  1133. END IF
  1134. IF li_outtype <> 2 and li_outtype <> 3 THEN
  1135. arg_msg = '仓库出仓类型不是条码出仓,请使用其它调货单进行操作'
  1136. rslt = 0
  1137. GOTO ext
  1138. END IF
  1139. select outtype
  1140. into :li_outtype_mtrl
  1141. from u_mtrldef
  1142. where mtrlid = :mtrlid;
  1143. IF sqlca.SQLCode <> 0 THEN
  1144. arg_msg = '查询物料出仓类型失败,'+sqlca.SQLErrText
  1145. rslt = 0
  1146. GOTO ext
  1147. END IF
  1148. if li_outtype_mtrl = 2 then
  1149. IF it_mxbt_barcode = 0 THEN
  1150. arg_msg = '未扫描条码,请检查'
  1151. rslt = 0
  1152. GOTO ext
  1153. END IF
  1154. FOR i = 1 TO it_mxbt_barcode
  1155. ld_qty_barcode += s_mx_barcode[i].qty * s_mx_barcode[i].packqty
  1156. NEXT
  1157. IF transqty <> ld_qty_barcode THEN
  1158. arg_msg = '调拨数量与条码对应总数量不相符,请检查'
  1159. rslt = 0
  1160. GOTO ext
  1161. END IF
  1162. end if
  1163. ELSE
  1164. IF li_outtype = 2 or li_outtype = 3 THEN
  1165. arg_msg = '仓库出仓类型为条码出仓,请使用条码调货单进行操作'
  1166. rslt = 0
  1167. GOTO ext
  1168. END IF
  1169. END IF
  1170. UPDATE u_mtrlware_trans
  1171. SET auditingrep = :publ_operator,
  1172. auditingdate = getdate(),
  1173. flag = 1
  1174. WHERE u_mtrlware_trans.billid = :billid
  1175. AND flag = 0 AND scid = :scid USING commit_transaction;
  1176. IF commit_transaction.SQLCode <> 0 THEN
  1177. rslt = 0
  1178. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  1179. GOTO ext
  1180. ELSEIF commit_transaction.SQLNRows = 0 THEN
  1181. rslt = 0
  1182. arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  1183. GOTO ext
  1184. END IF
  1185. //还货
  1186. IF Kind = 3 THEN
  1187. FOR j = 1 TO it_mxbt
  1188. IF uof_add_returnqty(scid,&
  1189. billmx[j].relid,&
  1190. billmx[j].relprintid,&
  1191. billmx[j].qty,&
  1192. arg_msg,&
  1193. FALSE) = 0 THEN
  1194. arg_msg = '行:'+String(billmx[j].printid)+arg_msg
  1195. rslt = 0
  1196. GOTO ext
  1197. END IF
  1198. IF uo_trans.uof_trycmpl(scid,billmx[j].relid,arg_msg,FALSE) = 0 THEN
  1199. arg_msg = '行:'+String(billmx[j].printid)+arg_msg
  1200. rslt = 0
  1201. GOTO ext
  1202. END IF
  1203. NEXT
  1204. END IF
  1205. String ls_uunit
  1206. Decimal ld_rate,ld_uqty,ld_uprice
  1207. uo_inware uo_in
  1208. uo_in = CREATE uo_inware
  1209. uo_in.commit_transaction = sqlca
  1210. uo_in.if_getid_ture = FALSE
  1211. IF Kind = 0 OR Kind = 3 OR Kind = 5 THEN
  1212. //生成进仓单- 负
  1213. IF uo_in.newbegin(scid,17,arg_msg) = 0 THEN
  1214. rslt = 0
  1215. GOTO ext
  1216. END IF
  1217. uo_in.relid = billid
  1218. uo_in.indate = billdate
  1219. uo_in.inrep = inrep
  1220. uo_in.part = billcode
  1221. uo_in.dscrp = dscrp
  1222. uo_in.relint_2 = 0 // 0 - 负 1 - 正
  1223. uo_in.storageid = storageid
  1224. uo_in.sptname = '客户调货进仓(负)'
  1225. //转换
  1226. ls_uunit = ''
  1227. ld_rate = 0
  1228. ld_uqty = 0
  1229. ld_uprice = 0
  1230. IF ifunit = 0 THEN
  1231. ls_uunit = unit
  1232. ld_rate = 1
  1233. ld_uqty = transqty
  1234. ld_uprice = cost
  1235. ELSE
  1236. IF rate = 0 THEN
  1237. arg_msg = '调货产品资料设为双数量核算,但没有设置默认转换率,请检查'
  1238. rslt = 0
  1239. GOTO ext
  1240. END IF
  1241. ls_uunit = uunit
  1242. ld_rate = rate
  1243. ld_uqty = transqty /rate
  1244. ld_uprice = cost * rate
  1245. END IF
  1246. IF uo_in.acceptmx(1,&
  1247. mtrlid,&
  1248. ls_mtrlcode,&
  1249. plancode,&
  1250. status,&
  1251. 0 - ld_uqty,&
  1252. ld_uprice,&
  1253. 1,&
  1254. '',&
  1255. arg_msg,&
  1256. 0,0,0,woodcode,&
  1257. pcode,&
  1258. relid,&
  1259. ls_uunit,ld_rate,0 - transqty,0,0,'',waredscrp,0,0,&
  1260. mtrlcuscode,Location,&
  1261. 0 - ld_uqty,&
  1262. 0) = 0 THEN
  1263. rslt = 0
  1264. GOTO ext
  1265. END IF
  1266. IF uo_in.Save(FALSE,arg_msg) = 0 THEN
  1267. rslt = 0
  1268. GOTO ext
  1269. END IF
  1270. ll_inwareid_out = uo_in.inwareid
  1271. IF uo_in.getinfo(scid,ll_inwareid_out,arg_msg) = 0 THEN
  1272. rslt = 0
  1273. GOTO ext
  1274. END IF
  1275. IF uo_in.auditing(FALSE,arg_msg) = 0 THEN
  1276. rslt = 0
  1277. GOTO ext
  1278. END IF
  1279. //生成进仓单-正
  1280. IF uo_in.newbegin(scid,17,arg_msg) = 0 THEN
  1281. rslt = 0
  1282. GOTO ext
  1283. END IF
  1284. uo_in.relid = billid
  1285. uo_in.indate = billdate
  1286. uo_in.inrep = inrep
  1287. uo_in.part = billcode
  1288. uo_in.dscrp = dscrp
  1289. uo_in.relint_2 = 1 // 0 - 负 1 - 正
  1290. uo_in.storageid = storageid
  1291. uo_in.sptname = '客户调货进仓(正)'
  1292. FOR i = 1 TO it_mxbt
  1293. //转换
  1294. ls_uunit = ''
  1295. ld_rate = 0
  1296. ld_uqty = 0
  1297. ld_uprice = 0
  1298. IF billmx[i].ifunit = 0 THEN
  1299. ls_uunit = billmx[i].unit
  1300. ld_rate = 1
  1301. ld_uqty = billmx[i].qty
  1302. ld_uprice = billmx[i].price
  1303. ELSE
  1304. IF billmx[i].rate = 0 THEN
  1305. arg_msg = '明细行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查'
  1306. rslt = 0
  1307. GOTO ext
  1308. END IF
  1309. ls_uunit = billmx[i].uunit
  1310. ld_rate = billmx[i].rate
  1311. ld_uqty = billmx[i].qty/billmx[i].rate
  1312. ld_uprice = billmx[i].price * billmx[i].rate
  1313. END IF
  1314. IF uo_in.acceptmx(i,&
  1315. billmx[i].mtrlid,&
  1316. billmx[i].mtrlcode,&
  1317. billmx[i].plancode,&
  1318. billmx[i].status,&
  1319. ld_uqty,&
  1320. ld_uprice,&
  1321. 1,&
  1322. '',&
  1323. arg_msg,&
  1324. 0,0,0,billmx[i].woodcode,&
  1325. billmx[i].pcode,&
  1326. billmx[i].rel_cusid_sptid,&
  1327. ls_uunit,ld_rate,billmx[i].qty,0,0,'',billmx[i].waredscrp,0,0,&
  1328. billmx[i].mtrlcuscode,billmx[i].Location,&
  1329. ld_uqty,&
  1330. 0) = 0 THEN
  1331. rslt = 0
  1332. GOTO ext
  1333. END IF
  1334. NEXT
  1335. IF uo_in.Save(FALSE,arg_msg) = 0 THEN
  1336. rslt = 0
  1337. GOTO ext
  1338. END IF
  1339. ll_inwareid_in = uo_in.inwareid
  1340. IF uo_in.getinfo(scid,ll_inwareid_in,arg_msg) = 0 THEN
  1341. rslt = 0
  1342. GOTO ext
  1343. END IF
  1344. IF uo_in.auditing(FALSE,arg_msg) = 0 THEN
  1345. rslt = 0
  1346. GOTO ext
  1347. END IF
  1348. ELSEIF Kind = 1 OR Kind = 2 THEN
  1349. //生成进仓单- 负
  1350. IF uo_in.newbegin(scid,17,arg_msg) = 0 THEN
  1351. rslt = 0
  1352. GOTO ext
  1353. END IF
  1354. uo_in.relid = billid
  1355. uo_in.indate = billdate
  1356. uo_in.inrep = inrep
  1357. uo_in.part = billcode
  1358. uo_in.dscrp = dscrp
  1359. uo_in.relint_2 = 0 // 0 - 负 1 - 正
  1360. uo_in.storageid = storageid
  1361. uo_in.sptname = '客户调货进仓(负)'
  1362. FOR i = 1 TO it_mxbt
  1363. //转换
  1364. ls_uunit = ''
  1365. ld_rate = 0
  1366. ld_uqty = 0
  1367. ld_uprice = 0
  1368. IF billmx[i].ifunit = 0 THEN
  1369. ls_uunit = billmx[i].unit
  1370. ld_rate = 1
  1371. ld_uqty = billmx[i].qty
  1372. ld_uprice = billmx[i].price
  1373. ELSE
  1374. IF billmx[i].rate = 0 THEN
  1375. arg_msg = '明细行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查'
  1376. rslt = 0
  1377. GOTO ext
  1378. END IF
  1379. ls_uunit = billmx[i].uunit
  1380. ld_rate = billmx[i].rate
  1381. ld_uqty = billmx[i].qty/billmx[i].rate
  1382. ld_uprice = billmx[i].price * billmx[i].rate
  1383. END IF
  1384. IF uo_in.acceptmx(i,&
  1385. billmx[i].mtrlid,&
  1386. billmx[i].mtrlcode,&
  1387. billmx[i].plancode,&
  1388. billmx[i].status,&
  1389. 0 - ld_uqty,&
  1390. ld_uprice,&
  1391. 1,&
  1392. '',&
  1393. arg_msg,&
  1394. 0,0,0,billmx[i].woodcode,&
  1395. billmx[i].pcode,&
  1396. billmx[i].rel_cusid_sptid,&
  1397. ls_uunit,ld_rate,0 - billmx[i].qty,0,0,'',billmx[i].waredscrp,0,0,&
  1398. billmx[i].mtrlcuscode,billmx[i].Location,&
  1399. 0 - ld_uqty,&
  1400. 0) = 0 THEN
  1401. rslt = 0
  1402. GOTO ext
  1403. END IF
  1404. NEXT
  1405. IF uo_in.Save(FALSE,arg_msg) = 0 THEN
  1406. rslt = 0
  1407. GOTO ext
  1408. END IF
  1409. ll_inwareid_out = uo_in.inwareid
  1410. IF uo_in.getinfo(scid,ll_inwareid_out,arg_msg) = 0 THEN
  1411. rslt = 0
  1412. GOTO ext
  1413. END IF
  1414. IF uo_in.auditing(FALSE,arg_msg) = 0 THEN
  1415. rslt = 0
  1416. GOTO ext
  1417. END IF
  1418. //生成进仓单-正
  1419. IF uo_in.newbegin(scid,17,arg_msg) = 0 THEN
  1420. rslt = 0
  1421. GOTO ext
  1422. END IF
  1423. uo_in.relid = billid
  1424. uo_in.indate = billdate
  1425. uo_in.inrep = inrep
  1426. uo_in.part = billcode
  1427. uo_in.dscrp = dscrp
  1428. uo_in.relint_2 = 1 // 0 - 负 1 - 正
  1429. uo_in.storageid = storageid
  1430. uo_in.sptname = '客户调货进仓(正)'
  1431. //转换
  1432. ls_uunit = ''
  1433. ld_rate = 0
  1434. ld_uqty = 0
  1435. ld_uprice = 0
  1436. IF ifunit = 0 THEN
  1437. ls_uunit = unit
  1438. ld_rate = 1
  1439. ld_uqty = transqty
  1440. ld_uprice = cost
  1441. ELSE
  1442. IF rate = 0 THEN
  1443. arg_msg = '调货产品资料设为双数量核算,但没有设置默认转换率,请检查'
  1444. rslt = 0
  1445. GOTO ext
  1446. END IF
  1447. ls_uunit = uunit
  1448. ld_rate = rate
  1449. ld_uqty = transqty /rate
  1450. ld_uprice = cost * rate
  1451. END IF
  1452. IF uo_in.acceptmx(1,&
  1453. mtrlid,&
  1454. ls_mtrlcode,&
  1455. plancode,&
  1456. status,&
  1457. ld_uqty,&
  1458. ld_uprice,&
  1459. 1,&
  1460. '',&
  1461. arg_msg,&
  1462. 0,0,0,woodcode,&
  1463. pcode,&
  1464. relid,&
  1465. ls_uunit,ld_rate,transqty,0,0,'',waredscrp,0,0,&
  1466. mtrlcuscode,Location,&
  1467. ld_uqty,&
  1468. 0) = 0 THEN
  1469. rslt = 0
  1470. GOTO ext
  1471. END IF
  1472. IF uo_in.Save(FALSE,arg_msg) = 0 THEN
  1473. rslt = 0
  1474. GOTO ext
  1475. END IF
  1476. ll_inwareid_in = uo_in.inwareid
  1477. IF uo_in.getinfo(scid,ll_inwareid_in,arg_msg) = 0 THEN
  1478. rslt = 0
  1479. GOTO ext
  1480. END IF
  1481. IF uo_in.auditing(FALSE,arg_msg) = 0 THEN
  1482. rslt = 0
  1483. GOTO ext
  1484. END IF
  1485. ELSEIF Kind = 4 THEN
  1486. //生成进仓单- 负
  1487. IF uo_in.newbegin(scid,17,arg_msg) = 0 THEN
  1488. rslt = 0
  1489. GOTO ext
  1490. END IF
  1491. uo_in.relid = billid
  1492. uo_in.indate = billdate
  1493. uo_in.inrep = inrep
  1494. uo_in.part = billcode
  1495. uo_in.dscrp = dscrp
  1496. uo_in.relint_2 = 0 // 0 - 负 1 - 正
  1497. uo_in.storageid = storageid
  1498. uo_in.sptname = '客户调货进仓(负)'
  1499. FOR i = 1 TO it_mxbt
  1500. //转换
  1501. ls_uunit = ''
  1502. ld_rate = 0
  1503. ld_uqty = 0
  1504. ld_uprice = 0
  1505. IF billmx[i].ifunit = 0 THEN
  1506. ls_uunit = billmx[i].unit
  1507. ld_rate = 1
  1508. ld_uqty = billmx[i].qty
  1509. ld_uprice = billmx[i].price
  1510. ELSE
  1511. IF billmx[i].rate = 0 THEN
  1512. arg_msg = '明细行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查'
  1513. rslt = 0
  1514. GOTO ext
  1515. END IF
  1516. ls_uunit = billmx[i].uunit
  1517. ld_rate = billmx[i].rate
  1518. ld_uqty = billmx[i].qty/billmx[i].rate
  1519. ld_uprice = billmx[i].price * billmx[i].rate
  1520. END IF
  1521. IF uo_in.acceptmx(i,&
  1522. billmx[i].mtrlid,&
  1523. billmx[i].mtrlcode,&
  1524. billmx[i].plancode,&
  1525. billmx[i].status,&
  1526. 0 - ld_uqty,&
  1527. ld_uprice,&
  1528. 1,&
  1529. '',&
  1530. arg_msg,&
  1531. 0,0,0,billmx[i].woodcode,&
  1532. billmx[i].pcode,&
  1533. billmx[i].rel_cusid_sptid,&
  1534. ls_uunit,ld_rate,0 - billmx[i].qty,0,0,'',billmx[i].waredscrp,0,0,&
  1535. billmx[i].mtrlcuscode,billmx[i].Location,&
  1536. 0 - ld_uqty,&
  1537. 0) = 0 THEN
  1538. arg_msg = '进仓负单,明细行:'+String(i)+','+arg_msg
  1539. rslt = 0
  1540. GOTO ext
  1541. END IF
  1542. NEXT
  1543. IF uo_in.Save(FALSE,arg_msg) = 0 THEN
  1544. rslt = 0
  1545. GOTO ext
  1546. END IF
  1547. ll_inwareid_out = uo_in.inwareid
  1548. IF uo_in.getinfo(scid,ll_inwareid_out,arg_msg) = 0 THEN
  1549. rslt = 0
  1550. GOTO ext
  1551. END IF
  1552. IF uo_in.auditing(FALSE,arg_msg) = 0 THEN
  1553. rslt = 0
  1554. GOTO ext
  1555. END IF
  1556. //生成进仓单-正
  1557. IF uo_in.newbegin(scid,17,arg_msg) = 0 THEN
  1558. rslt = 0
  1559. GOTO ext
  1560. END IF
  1561. uo_in.relid = billid
  1562. uo_in.indate = billdate
  1563. uo_in.inrep = inrep
  1564. uo_in.part = billcode
  1565. uo_in.dscrp = dscrp
  1566. uo_in.relint_2 = 1 // 0 - 负 1 - 正
  1567. uo_in.storageid = storageid
  1568. uo_in.sptname = '客户调货进仓(正)'
  1569. FOR i = 1 TO it_mxbt
  1570. //转换
  1571. ls_uunit = ''
  1572. ld_rate = 0
  1573. ld_uqty = 0
  1574. ld_uprice = 0
  1575. IF billmx[i].ifunit = 0 THEN
  1576. ls_uunit = billmx[i].unit
  1577. ld_rate = 1
  1578. ld_uqty = billmx[i].qty
  1579. ld_uprice = billmx[i].price
  1580. ELSE
  1581. IF billmx[i].rate = 0 THEN
  1582. arg_msg = '明细行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查'
  1583. rslt = 0
  1584. GOTO ext
  1585. END IF
  1586. ls_uunit = billmx[i].uunit
  1587. ld_rate = billmx[i].rate
  1588. ld_uqty = billmx[i].qty/billmx[i].rate
  1589. ld_uprice = billmx[i].price * billmx[i].rate
  1590. END IF
  1591. IF uo_in.acceptmx(i,&
  1592. billmx[i].mtrlid,&
  1593. billmx[i].mtrlcode,&
  1594. billmx[i].plancode2,&
  1595. billmx[i].status,&
  1596. ld_uqty,&
  1597. ld_uprice,&
  1598. 1,&
  1599. '',&
  1600. arg_msg,&
  1601. 0,0,0,billmx[i].woodcode,&
  1602. billmx[i].pcode,&
  1603. relid,&
  1604. ls_uunit,ld_rate,billmx[i].qty,0,0,'',billmx[i].waredscrp,0,0,&
  1605. billmx[i].mtrlcuscode2,billmx[i].Location2,&
  1606. ld_uqty,&
  1607. 0) = 0 THEN
  1608. arg_msg = '进仓正单,明细行:'+String(i)+','+arg_msg
  1609. rslt = 0
  1610. GOTO ext
  1611. END IF
  1612. NEXT
  1613. IF uo_in.Save(FALSE,arg_msg) = 0 THEN
  1614. rslt = 0
  1615. GOTO ext
  1616. END IF
  1617. ll_inwareid_in = uo_in.inwareid
  1618. IF uo_in.getinfo(scid,ll_inwareid_in,arg_msg) = 0 THEN
  1619. rslt = 0
  1620. GOTO ext
  1621. END IF
  1622. IF uo_in.auditing(FALSE,arg_msg) = 0 THEN
  1623. rslt = 0
  1624. GOTO ext
  1625. END IF
  1626. END IF
  1627. IF uof_update_waredate(FALSE,arg_msg) = 0 THEN
  1628. rslt = 0
  1629. GOTO ext
  1630. END IF
  1631. IF Kind = 5 and li_outtype_mtrl = 2 THEN
  1632. SELECT mtrlwareid INTO :ll_mx_mtrlwareid
  1633. FROM u_mtrlware
  1634. WHERE scid = :scid
  1635. AND storageid = :storageid
  1636. AND mtrlid = :billmx[1].mtrlid
  1637. AND status = :billmx[1].status
  1638. AND woodcode = :billmx[1].woodcode
  1639. AND pcode = :billmx[1].pcode
  1640. AND plancode = :billmx[1].plancode
  1641. AND mtrlcuscode = :billmx[1].mtrlcuscode
  1642. AND location = :billmx[1].location
  1643. AND sptid = :billmx[1].rel_cusid_sptid;
  1644. IF sqlca.SQLCode <> 0 THEN
  1645. arg_msg = '查询明细对应库存id失败,请检查,'+sqlca.sqlerrtext
  1646. rslt = 0
  1647. GOTO ext
  1648. END IF
  1649. FOR i = 1 TO it_mxbt_barcode
  1650. select inflag - outflag into :li_inoutflag
  1651. from u_mtrlware_mx
  1652. where barcode = :s_mx_barcode[i].barcode;
  1653. if sqlca.sqlcode <> 0 then
  1654. arg_msg = '查询条码:'+s_mx_barcode[i].barcode+'进出仓标记失败,'+sqlca.sqlerrtext
  1655. rslt = 0
  1656. GOTO ext
  1657. END IF
  1658. if li_inoutflag <> 1 then
  1659. arg_msg = '条码:'+s_mx_barcode[i].barcode+'不是在未出仓状态,操作取消'
  1660. rslt = 0
  1661. GOTO ext
  1662. END IF
  1663. IF uo_gb.uof_barcode_mtrlwareid(s_mx_barcode[i].barcode,&
  1664. scid,ll_mx_mtrlwareid,FALSE,arg_msg) = 0 THEN
  1665. rslt = 0
  1666. GOTO ext
  1667. END IF
  1668. NEXT
  1669. END IF
  1670. flag = 1
  1671. ext:
  1672. IF rslt = 0 THEN
  1673. ROLLBACK USING commit_transaction;
  1674. ELSEIF rslt = 1 AND arg_ifcommit THEN
  1675. COMMIT USING commit_transaction;
  1676. END IF
  1677. DESTROY uo_in
  1678. DESTROY uo_trans
  1679. DESTROY uo_getbar
  1680. RETURN rslt
  1681. end function
  1682. public function integer uof_add_returnqty (long arg_scid, long arg_relid, long arg_relprintid, decimal arg_qty, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  1683. Decimal ld_qty,ld_returnqty
  1684. SELECT qty,returnqty INTO :ld_qty,:ld_returnqty
  1685. FROM u_mtrlware_transmx
  1686. WHERE scid = :arg_scid
  1687. AND billid = :arg_relid
  1688. AND printid = :arg_relprintid
  1689. USING commit_transaction;
  1690. IF commit_transaction.SQLCode <> 0 THEN
  1691. arg_msg = ',查询已还货数失败,'+commit_transaction.SQLErrText
  1692. rslt = 0
  1693. GOTO ext
  1694. END IF
  1695. IF ld_qty - ld_returnqty < arg_qty THEN
  1696. arg_msg = ',超还货,借货数:'+String(ld_qty,'#0.0#')+',已还货数:'+String(ld_returnqty,'#0.0#')
  1697. rslt = 0
  1698. GOTO ext
  1699. END IF
  1700. UPDATE u_mtrlware_transmx
  1701. SET returnqty = returnqty + :arg_qty
  1702. WHERE scid = :arg_scid
  1703. AND billid = :arg_relid
  1704. AND printid = :arg_relprintid
  1705. USING commit_transaction;
  1706. IF commit_transaction.SQLCode <> 0 THEN
  1707. arg_msg = ',更新还货数失败,'+commit_transaction.SQLErrText
  1708. rslt = 0
  1709. GOTO ext
  1710. END IF
  1711. ext:
  1712. IF rslt = 0 THEN
  1713. ROLLBACK USING commit_transaction;
  1714. ELSEIF rslt = 1 AND arg_ifcommit THEN
  1715. COMMIT USING commit_transaction;
  1716. END IF
  1717. RETURN rslt
  1718. end function
  1719. public function integer uof_finish (integer arg_finishtype, integer arg_fflag, long arg_scid, long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);//arg_finishtype 1-自动,2-手动
  1720. Int rslt = 1
  1721. Long cnt = 0
  1722. Int ll_fflag
  1723. DateTime null_dt
  1724. SetNull(null_dt)
  1725. IF arg_billid <= 0 THEN
  1726. rslt = 0
  1727. ARG_MSG = '错误单据唯一码'
  1728. GOTO ext
  1729. END IF
  1730. IF p_getinfo(arg_scid,arg_billid,ARG_MSG) = 0 THEN
  1731. rslt = 0
  1732. GOTO ext
  1733. END IF
  1734. IF flag = 0 THEN
  1735. ARG_MSG = '单据未审核,不能操作'
  1736. rslt = 0
  1737. GOTO ext
  1738. END IF
  1739. IF arg_finishtype = 1 THEN
  1740. IF arg_fflag = 1 THEN
  1741. IF fflag = 1 OR fflag = 2 THEN
  1742. ARG_MSG = '单据已完成还货,不能操作'
  1743. rslt = 0
  1744. GOTO ext
  1745. END IF
  1746. ll_fflag = 1
  1747. ELSE
  1748. IF fflag <> 1 THEN
  1749. ARG_MSG = '单据不是自动完成还货,不能操作'
  1750. rslt = 0
  1751. GOTO ext
  1752. END IF
  1753. ll_fflag = 0
  1754. END IF
  1755. ELSE
  1756. IF arg_fflag = 1 THEN
  1757. IF fflag = 1 OR fflag = 2 THEN
  1758. ARG_MSG = '单据已完成还货,不能操作'
  1759. rslt = 0
  1760. GOTO ext
  1761. END IF
  1762. ll_fflag = 2
  1763. ELSE
  1764. IF fflag <> 2 THEN
  1765. ARG_MSG = '单据不是手动完成还货,不能操作'
  1766. rslt = 0
  1767. GOTO ext
  1768. END IF
  1769. ll_fflag = 0
  1770. END IF
  1771. END IF
  1772. IF arg_fflag = 1 THEN
  1773. UPDATE u_mtrlware_trans
  1774. SET fflag = :ll_fflag,
  1775. fdate = getdate(),
  1776. femp = :arg_opemp
  1777. WHERE ( u_mtrlware_trans.billid = :arg_billid ) AND
  1778. ( u_mtrlware_trans.scid = :arg_scid) AND
  1779. ( u_mtrlware_trans.fflag = 0 )
  1780. USING commit_transaction;
  1781. IF commit_transaction.SQLCode <> 0 THEN
  1782. rslt = 0
  1783. ARG_MSG = "因网络或其它原因导致完成还货操作失败"+"~n"+commit_transaction.SQLErrText
  1784. GOTO ext
  1785. ELSEIF commit_transaction.SQLNRows = 0 THEN
  1786. ARG_MSG = '单据正在操作,请稍后重试'
  1787. rslt = 0
  1788. GOTO ext
  1789. END IF
  1790. ELSE
  1791. UPDATE u_mtrlware_trans
  1792. SET fflag = :ll_fflag,
  1793. fdate = :null_dt,
  1794. femp = ''
  1795. WHERE ( u_mtrlware_trans.billid = :arg_billid ) AND
  1796. ( u_mtrlware_trans.scid = :arg_scid)
  1797. USING commit_transaction;
  1798. IF commit_transaction.SQLCode <> 0 THEN
  1799. rslt = 0
  1800. ARG_MSG = "因网络或其它原因导致取消手动完成操作失败"+"~n"+commit_transaction.SQLErrText
  1801. GOTO ext
  1802. ELSEIF commit_transaction.SQLNRows = 0 THEN
  1803. ARG_MSG = '单据正在操作,请稍后重试'
  1804. rslt = 0
  1805. GOTO ext
  1806. END IF
  1807. END IF
  1808. ext:
  1809. IF rslt = 0 THEN
  1810. ROLLBACK USING commit_transaction;
  1811. ELSEIF arg_ifcommit AND rslt = 1 THEN
  1812. COMMIT USING commit_transaction;
  1813. END IF
  1814. p_reset()
  1815. RETURN (rslt)
  1816. end function
  1817. public function integer uof_trycmpl (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  1818. Long cnt = 0
  1819. DateTime null_dt
  1820. SetNull(null_dt)
  1821. IF arg_billid <= 0 THEN
  1822. rslt = 0
  1823. arg_msg = '错误单据唯一码'
  1824. GOTO ext
  1825. END IF
  1826. IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
  1827. rslt = 0
  1828. GOTO ext
  1829. END IF
  1830. Decimal ls_zerook
  1831. Boolean if_finish
  1832. if_finish = TRUE
  1833. DECLARE zero_cur CURSOR FOR
  1834. SELECT u_mtrlware_transmx.qty - u_mtrlware_transmx.returnqty
  1835. FROM u_mtrlware_transmx
  1836. WHERE ( u_mtrlware_transmx.billid = :arg_billid )
  1837. AND ( u_mtrlware_transmx.scid = :arg_scid )
  1838. USING commit_transaction;
  1839. OPEN zero_cur;
  1840. FETCH zero_cur INTO :ls_zerook;
  1841. DO WHILE commit_transaction.SQLCode = 0
  1842. IF if_finish THEN
  1843. IF ls_zerook > 0 THEN if_finish = FALSE
  1844. END IF
  1845. FETCH zero_cur INTO :ls_zerook;
  1846. LOOP
  1847. CLOSE zero_cur;
  1848. IF fflag = 0 AND if_finish THEN
  1849. IF uof_finish(1,1,arg_scid,arg_billid,publ_operator,arg_msg,FALSE) = 0 THEN
  1850. rslt = 0
  1851. GOTO ext
  1852. END IF
  1853. END IF
  1854. IF fflag = 1 AND NOT if_finish THEN
  1855. IF uof_finish(1,0,arg_scid,arg_billid,publ_operator,arg_msg,FALSE) = 0 THEN
  1856. rslt = 0
  1857. GOTO ext
  1858. END IF
  1859. END IF
  1860. it_newbegin = FALSE
  1861. it_updatebegin = FALSE
  1862. ext:
  1863. IF rslt = 0 THEN
  1864. ROLLBACK USING commit_transaction;
  1865. ELSEIF rslt = 1 AND arg_ifcommit THEN
  1866. COMMIT USING commit_transaction;
  1867. END IF
  1868. p_reset()
  1869. RETURN (rslt)
  1870. end function
  1871. public function integer uof_update_waredate (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  1872. DateTime ld_waredate,ld_auditingdate,ld_waradate_mx
  1873. String ls_auditdate,ls_waredate
  1874. Long i
  1875. Long ll_mtrlid,ll_sptid,ll_mtrlwareid
  1876. String ls_status,ls_woodcode ,ls_pcode,ls_plancode
  1877. String ls_mtrlcuscode,ls_location
  1878. DateTime ld_waredate_max
  1879. Decimal ld_qty,ld_wareqty
  1880. SELECT auditingdate INTO :ld_auditingdate
  1881. FROM u_mtrlware_trans
  1882. WHERE billid = :billid
  1883. AND scid = :scid
  1884. USING commit_transaction;
  1885. IF commit_transaction.SQLCode <> 0 THEN
  1886. rslt = 0
  1887. arg_msg = '查询单据审核时间失败,'+commit_transaction.SQLErrText
  1888. GOTO ext
  1889. END IF
  1890. ls_auditdate = String(ld_auditingdate,'yyyy-mm-dd hh:mm')
  1891. IF Kind = 0 OR Kind = 3 THEN
  1892. SELECT waredate INTO :ld_waredate
  1893. FROM u_mtrlware
  1894. WHERE mtrlwareid = :mtrlwareid
  1895. AND scid = :scid
  1896. USING commit_transaction;
  1897. IF commit_transaction.SQLCode <> 0 THEN
  1898. rslt = 0
  1899. arg_msg = '查询库存最近进仓日期失败,'+commit_transaction.SQLErrText
  1900. GOTO ext
  1901. END IF
  1902. FOR i = 1 TO it_mxbt
  1903. ll_mtrlid = billmx[i].mtrlid
  1904. ll_sptid = billmx[i].rel_cusid_sptid
  1905. ls_status = billmx[i].status
  1906. ls_woodcode = billmx[i].woodcode
  1907. ls_pcode = billmx[i].pcode
  1908. ls_plancode = billmx[i].plancode
  1909. ls_mtrlcuscode = billmx[i].mtrlcuscode
  1910. ls_location = billmx[i].Location
  1911. ld_qty = billmx[i].qty
  1912. SELECT waredate,noallocqty
  1913. INTO :ld_waradate_mx,:ld_wareqty
  1914. FROM u_mtrlware
  1915. WHERE scid = :scid
  1916. AND storageid = :storageid
  1917. AND mtrlid = :ll_mtrlid
  1918. AND sptid = :ll_sptid
  1919. AND status = :ls_status
  1920. AND woodcode = :ls_woodcode
  1921. AND pcode = :ls_pcode
  1922. AND plancode = :ls_plancode
  1923. AND mtrlcuscode = :ls_mtrlcuscode
  1924. AND Location = :ls_location
  1925. USING commit_transaction;
  1926. IF commit_transaction.SQLCode <> 0 THEN
  1927. rslt = 0
  1928. arg_msg = '查询明细库存最近进仓日期失败,'+commit_transaction.SQLErrText
  1929. GOTO ext
  1930. END IF
  1931. ls_waredate = String(ld_waradate_mx,'yyyy-mm-dd hh:mm')
  1932. IF ls_auditdate = ls_waredate OR ld_qty = ld_wareqty OR ld_waradate_mx < ld_waredate THEN
  1933. UPDATE u_mtrlware
  1934. SET waredate = :ld_waredate
  1935. WHERE scid = :scid
  1936. AND storageid = :storageid
  1937. AND mtrlid = :ll_mtrlid
  1938. AND sptid = :ll_sptid
  1939. AND status = :ls_status
  1940. AND woodcode = :ls_woodcode
  1941. AND pcode = :ls_pcode
  1942. AND plancode = :ls_plancode
  1943. AND mtrlcuscode = :ls_mtrlcuscode
  1944. AND Location = :ls_location
  1945. USING commit_transaction;
  1946. IF commit_transaction.SQLCode <> 0 THEN
  1947. rslt = 0
  1948. arg_msg = '更新明细库存最近进仓日期失败,'+commit_transaction.SQLErrText
  1949. GOTO ext
  1950. END IF
  1951. END IF
  1952. NEXT
  1953. ELSEIF Kind = 1 OR Kind = 2 THEN
  1954. SELECT waredate,noallocqty
  1955. INTO :ld_waredate,:ld_wareqty
  1956. FROM u_mtrlware
  1957. WHERE storageid = :storageid
  1958. AND mtrlid = :mtrlid
  1959. AND sptid = :relid
  1960. AND scid = :scid
  1961. AND status = :status
  1962. AND woodcode = :woodcode
  1963. AND pcode = :pcode
  1964. AND plancode = :plancode
  1965. AND mtrlcuscode = :mtrlcuscode
  1966. AND location = :Location
  1967. USING commit_transaction;
  1968. IF commit_transaction.SQLCode <> 0 THEN
  1969. rslt = 0
  1970. arg_msg = '查询库存最近进仓日期失败,'+commit_transaction.SQLErrText
  1971. GOTO ext
  1972. END IF
  1973. ls_waredate = String(ld_waredate,'yyyy-mm-dd hh:mm')
  1974. FOR i = 1 TO it_mxbt
  1975. ll_mtrlwareid = billmx[i].mtrlwareid
  1976. SELECT waredate INTO :ld_waradate_mx
  1977. FROM u_mtrlware
  1978. WHERE scid = :scid
  1979. AND mtrlwareid = :ll_mtrlwareid
  1980. USING commit_transaction;
  1981. IF commit_transaction.SQLCode <> 0 THEN
  1982. rslt = 0
  1983. arg_msg = '查询明细库存最近进仓日期失败,'+commit_transaction.SQLErrText
  1984. GOTO ext
  1985. END IF
  1986. IF i = 1 THEN
  1987. ld_waredate_max = ld_waradate_mx
  1988. ELSE
  1989. IF ld_waradate_mx > ld_waredate_max THEN
  1990. ld_waredate_max = ld_waradate_mx
  1991. END IF
  1992. END IF
  1993. ld_qty = ld_qty+billmx[i].qty
  1994. NEXT
  1995. IF ls_auditdate = ls_waredate OR ld_waredate < ld_waredate_max OR ld_qty = ld_wareqty THEN
  1996. UPDATE u_mtrlware
  1997. SET waredate = :ld_waredate_max
  1998. WHERE storageid = :storageid
  1999. AND mtrlid = :mtrlid
  2000. AND sptid = :relid
  2001. AND scid = :scid
  2002. AND status = :status
  2003. AND woodcode = :woodcode
  2004. AND pcode = :pcode
  2005. AND plancode = :plancode
  2006. AND mtrlcuscode = :mtrlcuscode
  2007. AND location = :Location
  2008. USING commit_transaction;
  2009. IF commit_transaction.SQLCode <> 0 THEN
  2010. rslt = 0
  2011. arg_msg = '更新库存最近进仓日期失败,'+commit_transaction.SQLErrText
  2012. GOTO ext
  2013. END IF
  2014. END IF
  2015. ELSEIF Kind = 4 THEN
  2016. FOR i = 1 TO it_mxbt
  2017. SELECT waredate INTO :ld_waradate_mx
  2018. FROM u_mtrlware
  2019. WHERE scid = :scid
  2020. AND mtrlwareid = :billmx[i].mtrlwareid
  2021. USING commit_transaction;
  2022. IF commit_transaction.SQLCode <> 0 THEN
  2023. rslt = 0
  2024. arg_msg = '查询明细调出库存最近进仓日期失败,'+commit_transaction.SQLErrText
  2025. GOTO ext
  2026. END IF
  2027. SELECT waredate INTO :ld_waredate
  2028. FROM u_mtrlware
  2029. WHERE scid = :scid
  2030. AND storageid = :storageid
  2031. AND sptid = :relid
  2032. AND mtrlid = :billmx[i].mtrlid
  2033. AND status = :billmx[i].status
  2034. AND woodcode = :billmx[i].woodcode
  2035. AND pcode = :billmx[i].pcode
  2036. AND plancode = :billmx[i].plancode2
  2037. AND mtrlcuscode = :billmx[i].mtrlcuscode2
  2038. AND location = :billmx[i].location2
  2039. USING commit_transaction;
  2040. IF commit_transaction.SQLCode <> 0 THEN
  2041. rslt = 0
  2042. arg_msg = '查询明细调入库存最近进仓日期失败,'+commit_transaction.SQLErrText
  2043. GOTO ext
  2044. END IF
  2045. ls_waredate = String(ld_waredate,'yyyy-mm-dd hh:mm')
  2046. IF ls_auditdate = ls_waredate THEN
  2047. UPDATE u_mtrlware
  2048. SET waredate = :ld_waredate_max
  2049. WHERE storageid = :storageid
  2050. AND mtrlid = :mtrlid
  2051. AND sptid = :relid
  2052. AND scid = :scid
  2053. AND status = :status
  2054. AND woodcode = :woodcode
  2055. AND pcode = :pcode
  2056. AND plancode = :plancode
  2057. AND mtrlcuscode = :mtrlcuscode
  2058. AND location = :Location
  2059. USING commit_transaction;
  2060. IF commit_transaction.SQLCode <> 0 THEN
  2061. rslt = 0
  2062. arg_msg = '更新库存最近进仓日期失败,'+commit_transaction.SQLErrText
  2063. GOTO ext
  2064. END IF
  2065. END IF
  2066. NEXT
  2067. END IF
  2068. ext:
  2069. IF rslt = 0 THEN
  2070. ROLLBACK USING commit_transaction;
  2071. ELSEIF rslt = 1 AND arg_ifcommit THEN
  2072. COMMIT USING commit_transaction;
  2073. END IF
  2074. RETURN rslt
  2075. end function
  2076. public function integer acceptmx (long arg_printid, long arg_mtrlwareid, long arg_mtrlid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_fprice, decimal arg_rebate, string arg_mxdscrp, long arg_rel_cusid_sptid, ref string arg_msg, string arg_woodcode, string arg_pcode, long arg_relid, long arg_relprintid, string arg_mtrlcuscode, string arg_location, string arg_waredscrp, string arg_plancode2, string arg_location2, string arg_mtrlcuscode2);Int rslt = 1
  2077. Long cnt = 0
  2078. String i_mtrlcode
  2079. Int li_noallocflag
  2080. Decimal ld_noallocqty,ld_notauditqty
  2081. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  2082. rslt = 0
  2083. arg_msg = "非编辑状态不可以使用,操作取消"
  2084. GOTO ext
  2085. END IF
  2086. //清除空值
  2087. IF IsNull(arg_printid) THEN arg_printid = 0
  2088. IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
  2089. IF IsNull(arg_plancode) THEN arg_plancode = ''
  2090. IF IsNull(arg_status) THEN arg_status = ''
  2091. IF IsNull(arg_qty) THEN arg_qty = 0
  2092. IF IsNull(arg_fprice) THEN arg_fprice = 0
  2093. IF IsNull(arg_rebate) THEN arg_rebate = 0
  2094. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  2095. IF IsNull(arg_woodcode) THEN arg_woodcode = ''
  2096. IF IsNull(arg_pcode) THEN arg_pcode = ''
  2097. IF IsNull(arg_rel_cusid_sptid) THEN arg_rel_cusid_sptid = 0
  2098. IF IsNull(arg_mtrlwareid) THEN arg_mtrlwareid = 0
  2099. IF IsNull(arg_relprintid) THEN arg_relprintid = 0
  2100. IF IsNull(arg_relid) THEN arg_relid = 0
  2101. IF IsNull(arg_mtrlcuscode) THEN arg_mtrlcuscode = ''
  2102. IF IsNull(arg_location) THEN arg_location = ''
  2103. IF IsNull(arg_waredscrp) THEN arg_waredscrp = ''
  2104. IF IsNull(arg_mtrlcuscode2) THEN arg_mtrlcuscode2 = ''
  2105. IF IsNull(arg_location2) THEN arg_location2 = ''
  2106. IF IsNull(arg_plancode2) THEN arg_plancode2 = ''
  2107. // 如果进仓数量为 0,或物料编号为空,则不作任何处理
  2108. IF arg_mtrlid = 0 OR arg_qty = 0 THEN
  2109. rslt = 1
  2110. GOTO ext
  2111. END IF
  2112. IF (Kind = 1 OR Kind = 2 OR Kind = 4 ) AND arg_mtrlwareid = 0 THEN
  2113. rslt = 1
  2114. GOTO ext
  2115. END IF
  2116. //检查物料id
  2117. SELECT mtrlcode
  2118. INTO :i_mtrlcode
  2119. FROM u_mtrldef
  2120. Where u_mtrldef.mtrlid = :arg_mtrlid USING commit_transaction ;
  2121. IF commit_transaction.SQLCode <> 0 THEN
  2122. rslt = 0
  2123. arg_msg = "查询操作失败,物料或产品资料"
  2124. GOTO ext
  2125. END IF
  2126. cnt = 0
  2127. SELECT count(*) INTO :cnt
  2128. FROM u_cust
  2129. Where cusid = :arg_rel_cusid_sptid USING commit_transaction ;
  2130. IF commit_transaction.SQLCode <> 0 THEN
  2131. arg_msg = '查询客户资料失败'
  2132. rslt = 0
  2133. GOTO ext
  2134. END IF
  2135. IF arg_fprice * arg_rebate < 0 THEN //检查进仓价
  2136. rslt = 0
  2137. arg_msg = "物料或产品:" + String(i_mtrlcode)+" 单价错误"
  2138. GOTO ext
  2139. END IF
  2140. IF Kind = 3 THEN
  2141. cnt = 0
  2142. SELECT count(*) INTO :cnt
  2143. FROM u_mtrlware_transmx
  2144. WHERE scid = :scid
  2145. AND billid = :arg_relid
  2146. AND printid = :arg_relprintid USING commit_transaction;
  2147. IF commit_transaction.SQLCode <> 0 THEN
  2148. arg_msg = '明细行:'+String(arg_printid)+',查询相关借货单失败,'+commit_transaction.SQLErrText
  2149. rslt = 0
  2150. GOTO ext
  2151. END IF
  2152. ELSEIF ( Kind = 1 OR Kind = 2 OR Kind = 4 )THEN
  2153. SELECT noallocflag
  2154. INTO :li_noallocflag
  2155. FROM u_storage
  2156. Where storageid = :storageid USING commit_transaction;
  2157. IF commit_transaction.SQLCode <> 0 THEN
  2158. arg_msg = '查询仓库使用未开单库存属性失败,'+commit_transaction.SQLErrText
  2159. rslt = 0
  2160. GOTO ext
  2161. END IF
  2162. IF li_noallocflag = 1 THEN
  2163. SELECT u_mtrlware.noallocqty,
  2164. u_mtrlware.noauditingqty
  2165. INTO :ld_noallocqty,
  2166. :ld_notauditqty
  2167. FROM u_mtrlware
  2168. WHERE u_mtrlware.scid = :scid
  2169. AND u_mtrlware.mtrlwareid = :arg_mtrlwareid
  2170. USING commit_transaction;
  2171. IF commit_transaction.SQLCode <> 0 THEN
  2172. arg_msg = '查询相关转换库存失败>>' + commit_transaction.SQLErrText
  2173. rslt = 0
  2174. GOTO ext
  2175. END IF
  2176. IF IsNull(ld_notauditqty) THEN ld_notauditqty = 0
  2177. IF IsNull(ld_noallocqty) THEN ld_noallocqty = 0
  2178. IF ld_noallocqty - ld_notauditqty < arg_qty THEN
  2179. arg_msg = '行:'+String(arg_printid)+'库存未开单数不足,不能调货,请检查'
  2180. rslt = 0
  2181. GOTO ext
  2182. END IF
  2183. END IF
  2184. END IF
  2185. //写入内容
  2186. it_mxbt++
  2187. billmx[it_mxbt].printid = arg_printid
  2188. billmx[it_mxbt].mtrlid = arg_mtrlid
  2189. billmx[it_mxbt].mtrlcode = i_mtrlcode
  2190. billmx[it_mxbt].plancode = arg_plancode
  2191. billmx[it_mxbt].status = arg_status
  2192. billmx[it_mxbt].qty = arg_qty
  2193. billmx[it_mxbt].fprice = arg_fprice
  2194. billmx[it_mxbt].rebate = arg_rebate
  2195. billmx[it_mxbt].price = arg_fprice * arg_rebate
  2196. billmx[it_mxbt].mxdscrp = arg_mxdscrp
  2197. billmx[it_mxbt].rel_cusid_sptid = arg_rel_cusid_sptid
  2198. billmx[it_mxbt].woodcode = arg_woodcode
  2199. billmx[it_mxbt].pcode = arg_pcode
  2200. billmx[it_mxbt].mtrlwareid = arg_mtrlwareid
  2201. billmx[it_mxbt].relid = arg_relid
  2202. billmx[it_mxbt].relprintid = arg_relprintid
  2203. billmx[it_mxbt].mtrlcuscode = arg_mtrlcuscode
  2204. billmx[it_mxbt].Location = arg_location
  2205. billmx[it_mxbt].waredscrp = arg_waredscrp
  2206. billmx[it_mxbt].mtrlcuscode2 = arg_mtrlcuscode2
  2207. billmx[it_mxbt].location2 = arg_location2
  2208. billmx[it_mxbt].plancode2 = arg_plancode2
  2209. sum_transqty = sum_transqty + arg_qty
  2210. sum_transamt = sum_transamt + arg_qty * arg_fprice * arg_rebate
  2211. ext:
  2212. IF rslt = 0 THEN p_clearmx()
  2213. RETURN(rslt)
  2214. end function
  2215. public function integer priceaudit (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i
  2216. if kind <> 5 then
  2217. rslt = 0
  2218. arg_msg = "非一调一单据类型不能使用确认功能"
  2219. GOTO ext
  2220. end if
  2221. IF arg_scid < 0 THEN
  2222. rslt = 0
  2223. arg_msg = "错误的分部ID"
  2224. GOTO ext
  2225. END IF
  2226. IF arg_billid <= 0 THEN
  2227. rslt = 0
  2228. arg_msg = "没有确认对象"
  2229. GOTO ext
  2230. END IF
  2231. IF getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
  2232. rslt = 0
  2233. GOTO ext
  2234. END IF
  2235. IF priceflag = 1 THEN
  2236. rslt = 0
  2237. arg_msg = "单据已经确认"
  2238. GOTO ext
  2239. END IF
  2240. UPDATE u_mtrlware_trans
  2241. SET priceemp = :publ_operator,
  2242. pricedate = getdate(),
  2243. priceflag = 1
  2244. WHERE u_mtrlware_trans.billid = :arg_billid
  2245. AND priceflag = 0
  2246. AND scid = :arg_scid USING commit_transaction;
  2247. IF commit_transaction.SQLCode <> 0 THEN
  2248. rslt = 0
  2249. arg_msg = "因网络或其它原因导致确认单据操作失败"+"~n"+commit_transaction.SQLErrText
  2250. GOTO ext
  2251. ELSEIF commit_transaction.SQLNRows = 0 THEN
  2252. rslt = 0
  2253. arg_msg = "单据正在确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  2254. GOTO ext
  2255. END IF
  2256. priceflag = 1
  2257. ext:
  2258. IF rslt = 0 THEN
  2259. ROLLBACK USING commit_transaction;
  2260. ELSEIF rslt = 1 AND arg_ifcommit THEN
  2261. COMMIT USING commit_transaction;
  2262. END IF
  2263. RETURN rslt
  2264. end function
  2265. public function integer c_priceaudit (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i
  2266. DateTime null_dt
  2267. SetNull(null_dt)
  2268. IF Kind <> 5 THEN
  2269. rslt = 0
  2270. arg_msg = "非一调一单据类型不能使用确认功能"
  2271. GOTO ext
  2272. END IF
  2273. IF arg_scid < 0 THEN
  2274. rslt = 0
  2275. arg_msg = "错误的分部ID"
  2276. GOTO ext
  2277. END IF
  2278. IF arg_billid <= 0 THEN
  2279. rslt = 0
  2280. arg_msg = "没有反确认对象"
  2281. GOTO ext
  2282. END IF
  2283. IF getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
  2284. rslt = 0
  2285. GOTO ext
  2286. END IF
  2287. IF priceflag = 0 THEN
  2288. rslt = 0
  2289. arg_msg = "单据还未确认,不能反确认"
  2290. GOTO ext
  2291. END IF
  2292. IF flag = 1 THEN
  2293. rslt = 0
  2294. arg_msg = "单据已审核,不能反确认"
  2295. GOTO ext
  2296. END IF
  2297. UPDATE u_mtrlware_trans
  2298. SET priceemp = '',
  2299. pricedate = :null_dt,
  2300. priceflag = 0
  2301. WHERE u_mtrlware_trans.billid = :arg_billid
  2302. AND priceflag = 1
  2303. AND scid = :arg_scid USING commit_transaction;
  2304. IF commit_transaction.SQLCode <> 0 THEN
  2305. rslt = 0
  2306. arg_msg = "因网络或其它原因导致反确认单据操作失败"+"~n"+commit_transaction.SQLErrText
  2307. GOTO ext
  2308. ELSEIF commit_transaction.SQLNRows = 0 THEN
  2309. rslt = 0
  2310. arg_msg = "单据正在反确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  2311. GOTO ext
  2312. END IF
  2313. priceflag = 0
  2314. ext:
  2315. IF rslt = 0 THEN
  2316. ROLLBACK USING commit_transaction;
  2317. ELSEIF rslt = 1 AND arg_ifcommit THEN
  2318. COMMIT USING commit_transaction;
  2319. END IF
  2320. RETURN rslt
  2321. end function
  2322. on uo_mtrlware_trans.create
  2323. call super::create
  2324. TriggerEvent( this, "constructor" )
  2325. end on
  2326. on uo_mtrlware_trans.destroy
  2327. TriggerEvent( this, "destructor" )
  2328. call super::destroy
  2329. end on