uo_update_cost_wfjg.sru 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906
  1. $PBExportHeader$uo_update_cost_wfjg.sru
  2. forward
  3. global type uo_update_cost_wfjg from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_update_cost_wfjg from nonvisualobject
  7. end type
  8. global uo_update_cost_wfjg uo_update_cost_wfjg
  9. type variables
  10. PUBLIC PROTECTEDWRITE Long billid
  11. PUBLIC PROTECTEDWRITE string billcode
  12. PUBLIC PROTECTEDWRITE datetime opdate
  13. PUBLIC PROTECTEDWRITE datetime moddate
  14. PUBLIC PROTECTEDWRITE datetime auditingdate
  15. PUBLIC PROTECTEDWRITE string opemp
  16. PUBLIC PROTECTEDWRITE string modemp
  17. PUBLIC PROTECTEDWRITE string auditingrep
  18. PUBLIC PROTECTEDWRITE int flag
  19. int sptid
  20. string relcode
  21. string dscrp
  22. datetime billdate
  23. string rep
  24. s_updatecostmx_wfjg s_mx[]
  25. Boolean if_getid_ture = TRUE
  26. Transaction commit_transaction //数据commit事务
  27. Long it_mxbt = 0 //明细结构数组末指针
  28. Boolean it_newbegin = FALSE //新建标志
  29. Boolean it_updatebegin = FALSE //修改标志
  30. end variables
  31. forward prototypes
  32. public function integer acceptmx (long arg_printid, long arg_mtrlwareid, string arg_mtrlcode, decimal arg_newcost, string arg_mxdscrp, ref string arg_msg)
  33. public function integer p_clearmx ()
  34. public function integer p_reset ()
  35. public function integer newbegin ()
  36. public function integer p_getinfo (long arg_billid, ref string arg_msg)
  37. public function integer updatebegin (long arg_billid, ref string arg_msg)
  38. public function integer getinfo (long arg_billid, ref string arg_msg)
  39. public function integer del (long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  40. public function integer save (boolean arg_ifcommit, ref string arg_msg)
  41. public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg)
  42. public function integer auditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  43. end prototypes
  44. public function integer acceptmx (long arg_printid, long arg_mtrlwareid, string arg_mtrlcode, decimal arg_newcost, string arg_mxdscrp, ref string arg_msg);Long rslt = 1,cnt = 0
  45. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  46. rslt = 0
  47. arg_msg = "非编辑状态不可以使用,操作取消"
  48. GOTO ext
  49. END IF
  50. Long i_mtrlid,i_sptid,i_scid
  51. String i_plancode,i_status,i_woodcode,i_pcode
  52. Decimal i_cost,i_noallocqty
  53. IF IsNull(arg_printid) THEN arg_printid = 0
  54. IF IsNull(arg_mtrlcode) THEN arg_mtrlcode = ''
  55. IF IsNull(arg_mtrlwareid) THEN arg_mtrlwareid = 0
  56. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  57. IF IsNull(arg_newcost) THEN arg_newcost = 0
  58. IF arg_mtrlwareid <= 0 THEN
  59. rslt = 0
  60. GOTO ext
  61. END IF
  62. SELECT mtrlid,
  63. status,
  64. woodcode,
  65. pcode,
  66. sptid,
  67. noallocqty,
  68. plancode,
  69. cost,
  70. scid
  71. INTO :i_mtrlid,
  72. :i_status,
  73. :i_woodcode,
  74. :i_pcode,
  75. :i_sptid,
  76. :i_noallocqty,
  77. :i_plancode,
  78. :i_cost,
  79. :i_scid
  80. FROM ow_wfjgware
  81. WHERE mtrlwareid = :arg_mtrlwareid
  82. USING commit_transaction;
  83. IF commit_transaction.SQLCode <> 0 THEN
  84. rslt = 0
  85. arg_msg = "查询物料:"+arg_mtrlcode+"外协商库存资料失败,"+commit_transaction.SQLErrText
  86. GOTO ext
  87. END IF
  88. IF i_sptid <> sptid THEN
  89. arg_msg = '外协商资料与明细库存所属外协商不相符'
  90. rslt = 0
  91. GOTO ext
  92. END IF
  93. it_mxbt++
  94. s_mx[it_mxbt].printid = arg_printid
  95. s_mx[it_mxbt].mtrlwarescid = i_scid
  96. s_mx[it_mxbt].mtrlwareid = arg_mtrlwareid
  97. s_mx[it_mxbt].mtrlid = i_mtrlid
  98. s_mx[it_mxbt].sptid = i_sptid
  99. s_mx[it_mxbt].status = i_status
  100. s_mx[it_mxbt].woodcode = i_woodcode
  101. s_mx[it_mxbt].pcode = i_pcode
  102. s_mx[it_mxbt].plancode = i_plancode
  103. s_mx[it_mxbt].noallocqty = i_noallocqty
  104. s_mx[it_mxbt].cost = i_cost
  105. s_mx[it_mxbt].mxdscrp = arg_mxdscrp
  106. s_mx[it_mxbt].newcost = arg_newcost
  107. ext:
  108. IF rslt = 0 THEN p_clearmx()
  109. Return(rslt)
  110. end function
  111. public function integer p_clearmx ();it_mxbt=0
  112. return 1
  113. end function
  114. public function integer p_reset ();billid = 0
  115. billcode = ''
  116. opemp = ''
  117. modemp = ''
  118. auditingrep = ''
  119. flag = 0
  120. sptid = 0
  121. rep = ''
  122. relcode = ''
  123. dscrp = ''
  124. it_newbegin = FALSE
  125. it_updatebegin = FALSE
  126. //清除明细
  127. p_clearmx()
  128. RETURN 1
  129. end function
  130. public function integer newbegin ();Int rslt = 1
  131. p_reset()
  132. it_newbegin = TRUE
  133. it_updatebegin = FALSE
  134. RETURN rslt
  135. end function
  136. public function integer p_getinfo (long arg_billid, ref string arg_msg);Int rslt = 1
  137. IF arg_billid <= 0 THEN
  138. rslt = 0
  139. arG_MSG = "非法单据唯一码"
  140. GOTO ext
  141. END IF
  142. SELECT billid,
  143. billcode,
  144. sptid,
  145. relcode,
  146. dscrp,
  147. billdate,
  148. rep,
  149. opdate,
  150. moddate,
  151. auditingdate,
  152. opemp,
  153. modemp,
  154. auditingrep,
  155. flag
  156. INTO
  157. :billid,
  158. :billcode,
  159. :sptid,
  160. :relcode,
  161. :dscrp,
  162. :billdate,
  163. :rep,
  164. :opdate,
  165. :moddate,
  166. :auditingdate,
  167. :opemp,
  168. :modemp,
  169. :auditingrep,
  170. :flag
  171. FROM u_updatecost_wfjg
  172. Where billid = :arg_billid USING commit_transaction;
  173. IF commit_transaction.SQLCode <> 0 THEN
  174. rslt = 0
  175. arG_MSG = "查询操作失败(错误单据唯一码)"+commit_transaction.SQLErrText
  176. GOTO ext
  177. END IF
  178. ext:
  179. IF rslt = 0 THEN p_reset()
  180. RETURN rslt
  181. end function
  182. public function integer updatebegin (long arg_billid, ref string arg_msg);Long rslt = 1
  183. IF arg_billid <= 0 THEN
  184. rslt = 0
  185. GOTO ext
  186. END IF
  187. rslt = p_getinfo(arg_billid,arg_msg)
  188. IF rslt = 0 THEN GOTO ext
  189. IF flag = 1 THEN
  190. rslt = 0
  191. arg_msg = '单据已经审核,不可以修改'
  192. GOTO ext
  193. END IF
  194. billid = arg_billid
  195. it_newbegin = FALSE
  196. it_updatebegin = TRUE
  197. p_clearmx() //清除明细
  198. ext:
  199. IF rslt = 0 THEN p_reset()
  200. RETURN rslt
  201. end function
  202. public function integer getinfo (long arg_billid, ref string arg_msg);Int rslt = 1,i = 1,no_mxcheck = 0
  203. IF arg_billid <= 0 THEN
  204. rslt = 0
  205. arg_msg = "非法单据唯一码"
  206. GOTO ext
  207. END IF
  208. rslt = p_getinfo(arg_billid,arg_msg)
  209. IF rslt = 0 THEN GOTO ext
  210. DECLARE cur_mx CURSOR FOR
  211. SELECT u_updatecostmx_wfjg.printid, u_updatecostmx_wfjg.mtrlwarescid,
  212. u_updatecostmx_wfjg.mtrlwareid, u_updatecostmx_wfjg.mtrlid,
  213. u_updatecostmx_wfjg.status, u_updatecostmx_wfjg.woodcode,
  214. u_updatecostmx_wfjg.pcode, u_updatecostmx_wfjg.sptid,
  215. u_updatecostmx_wfjg.plancode, u_updatecostmx_wfjg.noallocqty,
  216. u_updatecostmx_wfjg.cost, u_updatecostmx_wfjg.newcost,
  217. u_updatecostmx_wfjg.mxdscrp, u_mtrldef.mtrlcode, u_mtrldef.unit
  218. FROM u_updatecostmx_wfjg INNER JOIN
  219. u_mtrldef ON u_updatecostmx_wfjg.mtrlid = u_mtrldef.mtrlid
  220. WHERE u_updatecostmx_wfjg.billid = :arg_billid
  221. USING commit_transaction;
  222. OPEN cur_mx;
  223. FETCH cur_mx INTO :s_mx[i].printid,
  224. :s_mx[i].mtrlwarescid,
  225. :s_mx[i].mtrlwareid,
  226. :s_mx[i].mtrlid,
  227. :s_mx[i].status,
  228. :s_mx[i].woodcode,
  229. :s_mx[i].pcode,
  230. :s_mx[i].sptid,
  231. :s_mx[i].plancode,
  232. :s_mx[i].noallocqty,
  233. :s_mx[i].cost,
  234. :s_mx[i].newcost,
  235. :s_mx[i].mxdscrp,
  236. :s_mx[i].mtrlcode,
  237. :s_mx[i].unit;
  238. DO WHILE commit_transaction.SQLCode = 0
  239. i++
  240. FETCH cur_mx INTO :s_mx[i].printid,
  241. :s_mx[i].mtrlwarescid,
  242. :s_mx[i].mtrlwareid,
  243. :s_mx[i].mtrlid,
  244. :s_mx[i].status,
  245. :s_mx[i].woodcode,
  246. :s_mx[i].pcode,
  247. :s_mx[i].sptid,
  248. :s_mx[i].plancode,
  249. :s_mx[i].noallocqty,
  250. :s_mx[i].cost,
  251. :s_mx[i].newcost,
  252. :s_mx[i].mxdscrp,
  253. :s_mx[i].mtrlcode,
  254. :s_mx[i].unit;
  255. LOOP
  256. CLOSE cur_mx;
  257. //检验明细是否读入完整
  258. SELECT count(*) INTO :no_mxcheck
  259. FROM u_updatecostmx_wfjg
  260. WHERE billid = :arg_billid
  261. USING commit_transaction;
  262. IF commit_transaction.SQLCode <> 0 THEN
  263. rslt = 0
  264. arg_msg = "查询操作失败,单据明细数量"
  265. GOTO ext
  266. END IF
  267. IF i <> (no_mxcheck+1) THEN
  268. rslt = 0
  269. arg_msg = "查询操作失败,单据明细"
  270. GOTO ext
  271. END IF
  272. billid = arg_billid
  273. it_mxbt = i - 1
  274. it_newbegin = FALSE
  275. it_updatebegin = FALSE
  276. ext:
  277. IF rslt = 0 THEN p_reset()
  278. RETURN rslt
  279. end function
  280. public function integer del (long arg_billid, ref string arg_msg, boolean arg_ifcommit);//del(arg_scid,arg_inwareid,arg_msg)
  281. //如果单据还没有审核删除单据极其明细
  282. //0 fail, 1 success
  283. Int rslt = 1
  284. IF arg_billid = 0 THEN
  285. rslt = 0
  286. arg_msg = "没有删除对象,操作取消"
  287. GOTO ext
  288. END IF
  289. rslt = p_getinfo(arg_billid,arg_msg)
  290. IF rslt = 0 THEN GOTO ext
  291. IF flag = 1 THEN
  292. rslt = 0
  293. arg_msg = "单据已经审核,不可以删除"
  294. GOTO ext
  295. END IF
  296. DELETE FROM u_updatecostmx_wfjg
  297. WHERE u_updatecostmx_wfjg.billid = :arg_billid
  298. USING commit_transaction;
  299. IF commit_transaction.SQLCode <> 0 THEN
  300. rslt = 0
  301. arg_msg = "删除外协商库存成本价调整单明细操作失败"+"~n"+commit_transaction.SQLErrText
  302. GOTO ext
  303. END IF
  304. DELETE FROM u_updatecost_wfjg
  305. WHERE u_updatecost_wfjg.billid = :arg_billid
  306. USING commit_transaction;
  307. IF commit_transaction.SQLCode <> 0 THEN
  308. rslt = 0
  309. arg_msg = "删除外协商库存成本价调整单操作失败"+"~n"+commit_transaction.SQLErrText
  310. GOTO ext
  311. END IF
  312. it_newbegin = FALSE
  313. it_updatebegin = FALSE
  314. ext:
  315. IF rslt = 0 THEN
  316. ROLLBACK USING commit_transaction;
  317. ELSEIF rslt = 1 AND arg_ifcommit THEN
  318. COMMIT USING commit_transaction;
  319. END IF
  320. p_reset()
  321. RETURN rslt
  322. end function
  323. public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1,cnt = 0,i
  324. DateTime server_dt
  325. Long ls_newid
  326. String ls_sccode
  327. IF IsNull(sptid) THEN sptid = 0
  328. IF IsNull(relcode) THEN relcode = ''
  329. IF IsNull(dscrp) THEN dscrp = ''
  330. IF IsNull(rep) THEN rep = ''
  331. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  332. rslt = 0
  333. arg_msg = "非编辑状态不可以提交"
  334. GOTO ext
  335. END IF
  336. SELECT Top 1 getdate() INTO :server_dt FROM u_user USING commit_transaction ;
  337. //取得系统时间,借用操作员表
  338. IF commit_transaction.SQLCode <> 0 THEN
  339. rslt = 0
  340. arg_msg = "查询操作失败,日期 "
  341. GOTO ext
  342. END IF
  343. IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
  344. rslt = 0
  345. arg_msg = "没有正确单据明细内容"
  346. GOTO ext
  347. END IF
  348. cnt = 0
  349. SELECT count(*)
  350. INTO :cnt
  351. FROM u_spt
  352. Where sptid = :sptid USING commit_transaction ;
  353. IF commit_transaction.SQLCode <> 0 THEN
  354. rslt = 0
  355. arg_msg = "查询操作失败,外协商"
  356. GOTO ext
  357. END IF
  358. IF cnt = 0 THEN
  359. rslt = 0
  360. arg_msg = "错误的外协商唯一码: "+String(sptid)
  361. GOTO ext
  362. END IF
  363. IF Year(Date(billdate)) < 2000 OR IsNull(billdate) THEN
  364. rslt = 0
  365. arg_msg = "缺少更新发生时间或不合理"
  366. GOTO ext
  367. END IF
  368. IF billid = 0 THEN
  369. ls_newid = f_sys_scidentity(0,"u_updatecost_wfjg","billid",arg_msg,TRUE,id_sqlca)
  370. IF ls_newid <= 0 THEN
  371. rslt = 0
  372. GOTO ext
  373. END IF
  374. //取分部代号
  375. IF f_get_sccode(0,commit_transaction,ls_sccode,arg_msg) = 0 THEN
  376. rslt = 0
  377. GOTO ext
  378. END IF
  379. billcode = getid(0,ls_sccode + 'FC',Date(server_dt),if_getid_ture,commit_transaction)
  380. IF billcode = "err" THEN
  381. billcode = ''
  382. rslt = 0
  383. arg_msg = "无法获取单据编号"+"~n"+commit_transaction.SQLErrText
  384. GOTO ext
  385. END IF
  386. INSERT INTO u_updatecost_wfjg
  387. (billid,
  388. billcode,
  389. sptid,
  390. relcode,
  391. dscrp,
  392. billdate,
  393. rep,
  394. opdate,
  395. opemp)
  396. VALUES (:ls_newid,
  397. :billcode,
  398. :sptid,
  399. :relcode,
  400. :dscrp,
  401. :billdate,
  402. :rep,
  403. :server_dt,
  404. :publ_operator) USING commit_transaction ;
  405. IF commit_transaction.SQLCode <> 0 THEN
  406. rslt = 0
  407. arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
  408. GOTO ext
  409. END IF
  410. billid = ls_newid
  411. FOR i = 1 TO it_mxbt
  412. INSERT INTO u_updatecostmx_wfjg
  413. (billid,
  414. printid,
  415. mtrlwarescid,
  416. mtrlwareid,
  417. mtrlid,
  418. status,
  419. woodcode,
  420. pcode,
  421. sptid,
  422. plancode,
  423. noallocqty,
  424. cost,
  425. newcost,
  426. mxdscrp)
  427. VALUES (:ls_newid,
  428. :s_mx[i].printid,
  429. :s_mx[i].mtrlwarescid,
  430. :s_mx[i].mtrlwareid,
  431. :s_mx[i].mtrlid,
  432. :s_mx[i].status,
  433. :s_mx[i].woodcode,
  434. :s_mx[i].pcode,
  435. :s_mx[i].sptid,
  436. :s_mx[i].plancode,
  437. :s_mx[i].noallocqty,
  438. :s_mx[i].cost,
  439. :s_mx[i].newcost,
  440. :s_mx[i].mxdscrp) USING commit_transaction;
  441. IF commit_transaction.SQLCode <> 0 THEN
  442. billid = 0
  443. rslt = 0
  444. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  445. GOTO ext
  446. END IF
  447. NEXT
  448. ELSE
  449. UPDATE u_updatecost_wfjg
  450. SET sptid = :sptid,
  451. billdate = :billdate,
  452. relcode = :relcode,
  453. rep = :rep,
  454. dscrp = :dscrp,
  455. moddate = :server_dt,
  456. modemp = :publ_operator
  457. WHERE billid = :billid
  458. AND flag = 0 USING commit_transaction;
  459. IF commit_transaction.SQLCode <> 0 OR commit_transaction.SQLNRows <= 0 THEN
  460. rslt = 0
  461. arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+commit_transaction.SQLErrText
  462. GOTO ext
  463. END IF
  464. //删除原有明细
  465. DELETE FROM u_updatecostmx_wfjg
  466. WHERE billid = :billid
  467. USING commit_transaction;
  468. IF commit_transaction.SQLCode <> 0 THEN
  469. rslt = 0
  470. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  471. GOTO ext
  472. END IF
  473. FOR i = 1 TO it_mxbt
  474. INSERT INTO u_updatecostmx_wfjg
  475. (billid,
  476. printid,
  477. mtrlwarescid,
  478. mtrlwareid,
  479. mtrlid,
  480. status,
  481. woodcode,
  482. pcode,
  483. sptid,
  484. plancode,
  485. noallocqty,
  486. cost,
  487. newcost,
  488. mxdscrp)
  489. VALUES (:billid,
  490. :s_mx[i].printid,
  491. :s_mx[i].mtrlwarescid,
  492. :s_mx[i].mtrlwareid,
  493. :s_mx[i].mtrlid,
  494. :s_mx[i].status,
  495. :s_mx[i].woodcode,
  496. :s_mx[i].pcode,
  497. :s_mx[i].sptid,
  498. :s_mx[i].plancode,
  499. :s_mx[i].noallocqty,
  500. :s_mx[i].cost,
  501. :s_mx[i].newcost,
  502. :s_mx[i].mxdscrp) USING commit_transaction;
  503. IF commit_transaction.SQLCode <> 0 THEN
  504. billid = 0
  505. rslt = 0
  506. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  507. GOTO ext
  508. END IF
  509. NEXT
  510. END IF
  511. it_newbegin = FALSE
  512. it_updatebegin = FALSE
  513. ext:
  514. IF rslt = 0 THEN
  515. ROLLBACK USING commit_transaction;
  516. p_clearmx()
  517. ELSEIF rslt = 1 AND arg_ifcommit THEN
  518. COMMIT USING commit_transaction;
  519. END IF
  520. RETURN rslt
  521. end function
  522. public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg);
  523. Int rslt = 1
  524. arg_newdescppart = Trim(arg_newdescppart)
  525. IF it_updatebegin OR it_newbegin THEN
  526. rslt = 0
  527. arg_msg = "编辑状态下不可用"
  528. GOTO ext
  529. END IF
  530. IF arg_newdescppart = '' THEN
  531. rslt = 0
  532. arg_msg = "要添加内容为空,操作取消"
  533. GOTO ext
  534. END IF
  535. rslt = p_getinfo(arg_billid,arg_msg)
  536. IF rslt = 0 THEN GOTO ext
  537. IF flag = 0 THEN
  538. rslt = 0
  539. arg_msg = "非审核状态下不可用"
  540. GOTO ext
  541. END IF
  542. UPDATE u_updatecost_wfjg
  543. SET dscrp = dscrp+' '+:arg_newdescppart
  544. WHERE billid = :arg_billid
  545. USING commit_transaction;
  546. IF commit_transaction.SQLCode <> 0 THEN
  547. ROLLBACK USING commit_transaction;
  548. rslt = 0
  549. arg_msg = "因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.SQLErrText
  550. GOTO ext
  551. END IF
  552. COMMIT USING commit_transaction;
  553. dscrp = dscrp+' '+arg_newdescppart
  554. ext:
  555. Return (rslt)
  556. end function
  557. public function integer auditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1 ,cnt = 0 ,i
  558. long ll_printid
  559. IF arg_billid <= 0 THEN
  560. rslt = 0
  561. arg_msg = "没有审核对象"
  562. GOTO ext
  563. END IF
  564. IF getinfo(arg_billid,arg_msg) = 0 THEN
  565. rslt = 0
  566. GOTO ext
  567. END IF
  568. IF flag = 1 THEN
  569. rslt = 0
  570. arg_msg = "单据已经审核"
  571. GOTO ext
  572. END IF
  573. UPDATE u_updatecost_wfjg
  574. SET auditingrep = :publ_operator,
  575. auditingdate = getdate(),
  576. flag = 1
  577. WHERE billid = :arg_billid
  578. AND flag = 0
  579. USING commit_transaction;
  580. IF commit_transaction.SQLCode <> 0 THEN
  581. rslt = 0
  582. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  583. GOTO ext
  584. ELSEIF commit_transaction.SQLNRows = 0 THEN
  585. rslt = 0
  586. arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  587. GOTO ext
  588. END IF
  589. uo_wfjg_py uo_ware,uo_ware_in
  590. uo_ware = CREATE uo_wfjg_py
  591. uo_ware.commit_transaction = sqlca
  592. uo_ware.if_getid_ture = false
  593. uo_ware_in = CREATE uo_wfjg_py
  594. uo_ware_in.commit_transaction = sqlca
  595. uo_ware_in.if_getid_ture = false
  596. //生成外协库存进仓单(负)
  597. IF uo_ware.newbegin(0,9,arg_msg) = 0 THEN
  598. rslt = 0
  599. GOTO ext
  600. END IF
  601. uo_ware.outdate = billdate
  602. uo_ware.outrep = rep
  603. uo_ware.dscrp = "库存成本价调整单审核自动生成"
  604. uo_ware.sptid = sptid
  605. uo_ware.part = relcode
  606. //负
  607. FOR i = 1 TO it_mxbt
  608. IF s_mx[i].mtrlwareid > 0 AND s_mx[i].noallocqty <> 0 THEN
  609. ll_printid++
  610. IF uo_ware.acceptmx(0,&
  611. 0 - s_mx[i].noallocqty,&
  612. s_mx[i].unit,&
  613. 0 - s_mx[i].noallocqty,&
  614. s_mx[i].mxdscrp,&
  615. ll_printid,&
  616. arg_msg,&
  617. 0,&
  618. 0,&
  619. s_mx[i].mtrlid,&
  620. 0,&
  621. 0,&
  622. s_mx[i].plancode,&
  623. s_mx[i].mtrlcode,&
  624. s_mx[i].status,&
  625. s_mx[i].woodcode,&
  626. s_mx[i].pcode,&
  627. s_mx[i].cost,&
  628. 1,&
  629. 0,&
  630. 1,'','') = 0 THEN
  631. rslt = 0
  632. GOTO ext
  633. END IF
  634. END IF
  635. NEXT
  636. //正
  637. FOR i = 1 TO it_mxbt
  638. IF s_mx[i].mtrlwareid > 0 AND s_mx[i].noallocqty <> 0 THEN
  639. ll_printid++
  640. IF uo_ware.acceptmx(0,&
  641. s_mx[i].noallocqty,&
  642. s_mx[i].unit,&
  643. s_mx[i].noallocqty,&
  644. s_mx[i].mxdscrp,&
  645. ll_printid,&
  646. arg_msg,&
  647. 0,&
  648. 0,&
  649. s_mx[i].mtrlid,&
  650. 0,&
  651. 0,&
  652. s_mx[i].plancode,&
  653. s_mx[i].mtrlcode,&
  654. s_mx[i].status,&
  655. s_mx[i].woodcode,&
  656. s_mx[i].pcode,&
  657. s_mx[i].newcost,&
  658. 1,&
  659. 0,&
  660. 1,'','') = 0 THEN
  661. rslt = 0
  662. GOTO ext
  663. END IF
  664. END IF
  665. NEXT
  666. IF uo_ware.it_mxbt > 0 THEN
  667. IF uo_ware.Save(FALSE,arg_msg) = 0 THEN
  668. rslt = 0
  669. GOTO ext
  670. END IF
  671. IF uo_ware.getinfo(uo_ware.scid,uo_ware.outwareid,arg_msg) = 0 THEN
  672. rslt = 0
  673. GOTO ext
  674. END IF
  675. IF uo_ware.auditing(FALSE,arg_msg) = 0 THEN
  676. rslt = 0
  677. GOTO ext
  678. END IF
  679. END IF
  680. DESTROY uo_ware
  681. ////生成外协库存进仓单(正)
  682. //IF uo_ware_in.newbegin(0,9,arg_msg) = 0 THEN
  683. // rslt = 0
  684. // GOTO ext
  685. //END IF
  686. //
  687. //uo_ware_in.outdate = billdate
  688. //uo_ware_in.outrep = rep
  689. //uo_ware_in.dscrp = "库存成本价调整单审核自动生成"
  690. //
  691. //uo_ware_in.sptid = sptid
  692. //uo_ware_in.part = relcode
  693. //
  694. //FOR i = 1 TO it_mxbt
  695. // IF s_mx[i].mtrlwareid > 0 AND s_mx[i].noallocqty <> 0 THEN
  696. //
  697. // IF uo_ware_in.acceptmx(0,&
  698. // s_mx[i].noallocqty,&
  699. // s_mx[i].unit,&
  700. // s_mx[i].noallocqty,&
  701. // s_mx[i].mxdscrp,&
  702. // s_mx[i].printid,&
  703. // arg_msg,&
  704. // 0,&
  705. // 0,&
  706. // s_mx[i].mtrlid,&
  707. // 0,&
  708. // 0,&
  709. // s_mx[i].plancode,&
  710. // s_mx[i].mtrlcode,&
  711. // s_mx[i].status,&
  712. // s_mx[i].woodcode,&
  713. // s_mx[i].pcode,&
  714. // s_mx[i].newcost,&
  715. // 1,&
  716. // 0,&
  717. // 1,'','') = 0 THEN
  718. // rslt = 0
  719. // GOTO ext
  720. // END IF
  721. // END IF
  722. //
  723. //NEXT
  724. //
  725. //IF uo_ware_in.it_mxbt > 0 THEN
  726. // IF uo_ware_in.Save(FALSE,arg_msg) = 0 THEN
  727. // rslt = 0
  728. // GOTO ext
  729. // END IF
  730. //
  731. // IF uo_ware_in.getinfo(uo_ware_in.scid,uo_ware_in.outwareid,arg_msg) = 0 THEN
  732. // rslt = 0
  733. // GOTO ext
  734. // END IF
  735. //
  736. // IF uo_ware_in.auditing(FALSE,arg_msg) = 0 THEN
  737. // rslt = 0
  738. // GOTO ext
  739. // END IF
  740. //END IF
  741. DESTROY uo_ware_in
  742. flag = 1
  743. ext:
  744. IF rslt = 0 THEN
  745. ROLLBACK USING commit_transaction;
  746. ELSEIF rslt = 1 AND arg_ifcommit THEN
  747. COMMIT USING commit_transaction;
  748. END IF
  749. RETURN rslt
  750. end function
  751. on uo_update_cost_wfjg.create
  752. call super::create
  753. TriggerEvent( this, "constructor" )
  754. end on
  755. on uo_update_cost_wfjg.destroy
  756. TriggerEvent( this, "destructor" )
  757. call super::destroy
  758. end on