uo_changed_planprice.sru 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. $PBExportHeader$uo_changed_planprice.sru
  2. forward
  3. global type uo_changed_planprice from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_changed_planprice from nonvisualobject
  7. end type
  8. global uo_changed_planprice uo_changed_planprice
  9. type variables
  10. Boolean it_newbegin = FALSE //新建标志
  11. Boolean it_updatebegin = FALSE //修改标志
  12. Long it_mxbt = 0
  13. long billid
  14. string billcode
  15. string billrep
  16. string dscrp
  17. long flag
  18. string opemp,modemp
  19. string auditemp
  20. datetime billdate,opdate,auditdate,moddate
  21. Transaction commit_transaction //数据commit事务
  22. s_planprice_changed s_changed[]
  23. Boolean if_getid_ture = TRUE
  24. end variables
  25. forward prototypes
  26. public function integer newbegin (ref string arg_msg)
  27. public function integer p_reset ()
  28. public function integer p_clearmx ()
  29. public function integer updatebegin (long arg_billid, ref string arg_msg)
  30. public function integer p_getinfo (long arg_billid, ref string arg_msg)
  31. public function integer save (boolean arg_ifcommit, ref string arg_msg)
  32. public function integer del (long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  33. public function integer getinfo (long arg_billid, ref string arg_msg)
  34. public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
  35. public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg)
  36. public function integer acceptmx (long arg_mtrlid, decimal arg_lastprice, decimal arg_planprice, string arg_reason, string arg_mxdscrp, ref string arg_msg, string arg_status, string arg_woodcode, string arg_pcode, long arg_printid)
  37. end prototypes
  38. public function integer newbegin (ref string arg_msg);//====================================================================
  39. // Function: newbegin(long arg_scid,int arg_billtype,ref string arg_msg)
  40. //--------------------------------------------------------------------
  41. // Description: 从置对象,设定业务类型,准备建立新进仓单
  42. //--------------------------------------------------------------------
  43. // Arguments:
  44. // value long arg_scid
  45. // value integer arg_billtype
  46. // reference string arg_msg
  47. //--------------------------------------------------------------------
  48. // Returns: integer
  49. //--------------------------------------------------------------------
  50. // Author: yyx Date: 2003.11.12
  51. //--------------------------------------------------------------------
  52. // Modify History:
  53. //
  54. //====================================================================
  55. int rslt=1
  56. p_reset()
  57. it_newbegin=true
  58. it_updatebegin=false
  59. if rslt=0 then p_reset()
  60. return rslt
  61. end function
  62. public function integer p_reset ();//int p_reset()
  63. //清除对象及其明细
  64. billid = 0
  65. billcode = ''
  66. dscrp = ''
  67. billrep = ''
  68. flag = 0
  69. opemp = ''
  70. auditemp = ''
  71. modemp = ''
  72. it_newbegin = FALSE
  73. it_updatebegin = FALSE
  74. //清除明细
  75. p_clearmx()
  76. RETURN 1
  77. end function
  78. public function integer p_clearmx ();//int p_clearmx()
  79. //清除明细
  80. it_mxbt=0
  81. return 1
  82. end function
  83. public function integer updatebegin (long arg_billid, ref string arg_msg);//====================================================================
  84. // Function: updatebegin(arg_scid,arg_inwareid,arg_billtype,arg_msg)
  85. //--------------------------------------------------------------------
  86. // Description: 从置对象,设定业务类型与关联ID,准备更新进仓单
  87. //--------------------------------------------------------------------
  88. // Arguments:
  89. // value long arg_scid
  90. // value long arg_inwareid
  91. // value integer arg_billtype
  92. // reference string arg_msg
  93. //--------------------------------------------------------------------
  94. // Returns: integer
  95. //--------------------------------------------------------------------
  96. // Author: yyx Date: 2003.11.12
  97. //--------------------------------------------------------------------
  98. // Modify History:
  99. //
  100. //====================================================================
  101. long rslt=1
  102. if arg_billid<=0 then
  103. rslt=0
  104. goto ext
  105. end if
  106. rslt=p_getinfo(arg_billid,arg_msg)
  107. if rslt=0 then goto ext
  108. if flag = 1 then
  109. rslt = 0
  110. arg_msg = '单据已经审核,不能修改'
  111. goto ext
  112. end if
  113. billid=arg_billid
  114. it_newbegin=false
  115. it_updatebegin=true
  116. p_clearmx() //清除明细
  117. ext:
  118. if rslt=0 then p_reset()
  119. return rslt
  120. end function
  121. public function integer p_getinfo (long arg_billid, ref string arg_msg);//p_getinfo(arg_scid,arg_outwareid,arg_msg)
  122. //0 失败 1成功
  123. INT rslt=1
  124. IF arg_billid<=0 THEN
  125. rslt=0
  126. arG_MSG="非法出仓单唯一码"
  127. goto ext
  128. end if
  129. select u_planprice_changed.billcode,
  130. u_planprice_changed.billdate,
  131. u_planprice_changed.billrep,
  132. u_planprice_changed.dscrp,
  133. u_planprice_changed.opemp,
  134. u_planprice_changed.opdate,
  135. u_planprice_changed.flag,
  136. u_planprice_changed.auditemp,
  137. u_planprice_changed.auditdate,
  138. u_planprice_changed.modemp,
  139. u_planprice_changed.moddate
  140. into :billcode,
  141. :billdate,
  142. :billrep,
  143. :dscrp,
  144. :opemp,
  145. :opdate,
  146. :flag,
  147. :auditemp,
  148. :auditdate,
  149. :modemp,
  150. :moddate
  151. from u_planprice_changed
  152. where u_planprice_changed.billid = :arg_billid using commit_transaction;
  153. if commit_transaction.sqlcode<>0 then
  154. rslt=0
  155. arG_MSG="查询操作失败(错误出仓单唯一码),出仓单"+commit_transaction.sqlerrtext
  156. goto ext
  157. end if
  158. billid = arg_billid
  159. ext:
  160. IF rslt=0 THEN p_reset()
  161. return rslt
  162. end function
  163. public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1,cnt = 0,i
  164. DateTime server_dt
  165. Long ls_newid
  166. String ls_sccode
  167. IF IsNull(billrep) THEN billrep = ''
  168. IF IsNull(dscrp) THEN dscrp = ''
  169. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  170. rslt = 0
  171. arg_msg = "非编辑状态不可以提交"
  172. GOTO ext
  173. END IF
  174. SELECT Top 1 getdate() INTO :server_dt FROM u_user USING commit_transaction ;
  175. //取得系统时间,借用操作员表
  176. IF commit_transaction.SQLCode <> 0 THEN
  177. rslt = 0
  178. arg_msg = "查询操作失败,日期 "
  179. GOTO ext
  180. END IF
  181. IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
  182. rslt = 0
  183. arg_msg = "没有正确单据明细内容"
  184. GOTO ext
  185. END IF
  186. IF Year(Date(billdate)) < 2000 OR IsNull(billdate) THEN
  187. rslt = 0
  188. arg_msg = "缺少单据发生时间或不合理"
  189. GOTO ext
  190. END IF
  191. ////////////////////////////////////////////////开始区分:新建/更新 处理
  192. IF billid = 0 THEN //新建
  193. ls_newid = f_sys_scidentity(0,"u_planprice_changed","billid",arg_msg,if_getid_ture,commit_transaction)
  194. IF ls_newid <= 0 THEN
  195. rslt = 0
  196. GOTO ext
  197. END IF
  198. billcode = getid(0,ls_sccode + 'pc',Date(server_dt),if_getid_ture,commit_transaction)
  199. IF billcode = "err" THEN
  200. billcode = ''
  201. rslt = 0
  202. arg_msg = "无法获取单据编号"+"~n"+commit_transaction.SQLErrText
  203. GOTO ext
  204. END IF
  205. INSERT INTO u_planprice_changed (
  206. billid,
  207. billcode,
  208. billdate,
  209. billrep,
  210. dscrp,
  211. opdate,
  212. opemp)
  213. values (
  214. :ls_newid,
  215. :billcode,
  216. :billdate,
  217. :billrep,
  218. :dscrp,
  219. :server_dt,
  220. :publ_operator) USING commit_transaction ;
  221. IF commit_transaction.SQLCode <> 0 THEN
  222. rslt = 0
  223. IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_planprice_changed') > 0 THEN
  224. arg_msg = '插入操作失败,关键字单据ID重复'
  225. ELSE
  226. arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
  227. END IF
  228. GOTO ext
  229. END IF
  230. //读取新billid
  231. billid = ls_newid
  232. FOR i = 1 TO it_mxbt
  233. INSERT INTO u_planprice_changedmx (
  234. billid,
  235. mtrlid,
  236. lastprice,
  237. planprice,
  238. reason,
  239. mxdscrp,
  240. printid,
  241. status,
  242. woodcode,
  243. pcode)
  244. values (
  245. :billid,
  246. :s_changed[i].mtrlid,
  247. :s_changed[i].lastprice,
  248. :s_changed[i].planprice,
  249. :s_changed[i].reason,
  250. :s_changed[i].mxdscrp,
  251. :s_changed[i].printid,
  252. :s_changed[i].status,
  253. :s_changed[i].woodcode,
  254. :s_changed[i].pcode ) USING commit_transaction ;
  255. IF commit_transaction.SQLCode <> 0 THEN
  256. billid = 0 //还原billid
  257. rslt = 0
  258. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  259. GOTO ext
  260. END IF
  261. NEXT
  262. ELSE //////////////////////////////////////////////////更新
  263. update u_planprice_changed
  264. set billdate = :billdate,
  265. billrep = :billrep,
  266. dscrp = :dscrp,
  267. modemp = :publ_operator,
  268. moddate = :server_dt
  269. where billid = :billid and
  270. flag = 0 USING commit_transaction;
  271. IF commit_transaction.SQLCode <> 0 OR commit_transaction.SQLNRows <= 0 THEN
  272. rslt = 0
  273. arg_msg = "因网络或其它原因导致更新单据操作失败(1)"+"~n"+commit_transaction.SQLErrText
  274. GOTO ext
  275. END IF
  276. //删除原有明细
  277. DELETE FROM u_planprice_changedmx
  278. WHERE u_planprice_changedmx.billid = :billid USING commit_transaction;
  279. IF commit_transaction.SQLCode <> 0 THEN
  280. rslt = 0
  281. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  282. GOTO ext
  283. END IF
  284. FOR i = 1 TO it_mxbt
  285. INSERT INTO u_planprice_changedmx (
  286. billid,
  287. mtrlid,
  288. lastprice,
  289. planprice,
  290. reason,
  291. mxdscrp,
  292. printid,
  293. status,
  294. woodcode,
  295. pcode )
  296. values (
  297. :billid,
  298. :s_changed[i].mtrlid,
  299. :s_changed[i].lastprice,
  300. :s_changed[i].planprice,
  301. :s_changed[i].reason,
  302. :s_changed[i].mxdscrp,
  303. :s_changed[i].printid,
  304. :s_changed[i].status,
  305. :s_changed[i].woodcode,
  306. :s_changed[i].pcode ) USING commit_transaction ;
  307. IF commit_transaction.SQLCode <> 0 THEN
  308. billid = 0 //还原billid
  309. rslt = 0
  310. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  311. GOTO ext
  312. END IF
  313. NEXT
  314. end if
  315. it_newbegin = FALSE
  316. it_updatebegin = FALSE
  317. ext:
  318. IF rslt = 0 THEN
  319. ROLLBACK USING commit_transaction;
  320. p_clearmx()
  321. ELSEIF rslt = 1 AND arg_ifcommit THEN
  322. COMMIT USING commit_transaction;
  323. END IF
  324. RETURN rslt
  325. end function
  326. public function integer del (long arg_billid, boolean arg_ifcommit, ref string arg_msg);//如果单据还没有审核删除单据极其明细
  327. //0 FAIL, 1 SUCCESS
  328. Int rslt = 1
  329. IF arg_billid <= 0 THEN
  330. rslt = 0
  331. arG_MSG = "没有删除对象,操作取消"
  332. GOTO ext
  333. END IF
  334. IF p_getinfo(arg_billid,arG_MSG) = 0 THEN
  335. rslt = 0
  336. GOTO ext
  337. END IF
  338. IF flag = 1 THEN
  339. rslt = 0
  340. arG_MSG = "单据已经审核,不可以删除"
  341. GOTO ext
  342. END IF
  343. DELETE FROM u_planprice_changed
  344. WHERE u_planprice_changed.billid = :arg_billid USING commit_transaction;
  345. IF commit_transaction.SQLCode <> 0 THEN
  346. rslt = 0
  347. arG_MSG = "删除计划价调整单操作失败"+"~n"+commit_transaction.SQLErrText
  348. GOTO ext
  349. END IF
  350. DELETE FROM u_planprice_changedmx
  351. WHERE u_planprice_changedmx.billid = :arg_billid USING commit_transaction;
  352. IF commit_transaction.SQLCode <> 0 THEN
  353. rslt = 0
  354. arG_MSG = "删除计划价调整单明细操作失败"+"~n"+commit_transaction.SQLErrText
  355. GOTO ext
  356. END IF
  357. it_newbegin = FALSE
  358. it_updatebegin = FALSE
  359. ext:
  360. IF rslt = 0 THEN
  361. ROLLBACK USING commit_transaction;
  362. p_reset()
  363. ELSEIF rslt = 1 AND arg_ifcommit THEN
  364. COMMIT USING commit_transaction;
  365. END IF
  366. RETURN (rslt)
  367. end function
  368. public function integer getinfo (long arg_billid, ref string arg_msg);//getinfo(arg_scid,arg_outwareid,arg_msg)
  369. //0 失败 1成功
  370. Int rslt = 1,i = 1,no_mxcheck = 0
  371. IF arg_billid <= 0 THEN
  372. rslt = 0
  373. arg_msg = "非法出仓单唯一码"
  374. GOTO ext
  375. END IF
  376. rslt = p_getinfo(arg_billid,arg_msg)
  377. IF rslt = 0 THEN GOTO ext
  378. //用游标读取明细
  379. DECLARE cur_inwaermx CURSOR FOR
  380. select u_planprice_changedmx.mtrlid,
  381. u_planprice_changedmx.lastprice,
  382. u_planprice_changedmx.planprice,
  383. u_planprice_changedmx.reason,
  384. u_planprice_changedmx.mxdscrp,
  385. u_mtrldef.mtrlcode,
  386. u_planprice_changedmx.pcode,
  387. u_planprice_changedmx.woodcode,
  388. u_planprice_changedmx.status
  389. from u_planprice_changedmx,u_mtrldef
  390. where u_planprice_changedmx.mtrlid = u_mtrldef.mtrlid and
  391. u_planprice_changedmx.billid = :arg_billid USING commit_transaction;
  392. OPEN cur_inwaermx;
  393. FETCH cur_inwaermx INTO :s_changed[i].mtrlid,:s_changed[i].lastprice,
  394. :s_changed[i].planprice,:s_changed[i].reason,:s_changed[i].mxdscrp,
  395. :s_changed[i].mtrlcode,:s_changed[i].pcode,:s_changed[i].woodcode,:s_changed[i].status;
  396. DO WHILE commit_transaction.SQLCode = 0
  397. i++
  398. FETCH cur_inwaermx INTO :s_changed[i].mtrlid,:s_changed[i].lastprice,
  399. :s_changed[i].planprice,:s_changed[i].reason,:s_changed[i].mxdscrp,
  400. :s_changed[i].mtrlcode,:s_changed[i].pcode,:s_changed[i].woodcode,:s_changed[i].status;
  401. LOOP
  402. CLOSE cur_inwaermx;
  403. //检验明细是否读入完整
  404. SELECT count(*) INTO :no_mxcheck
  405. FROM u_planprice_changedmx
  406. WHERE u_planprice_changedmx.billid = :arg_billid USING commit_transaction;
  407. IF commit_transaction.SQLCode <> 0 THEN
  408. rslt = 0
  409. arg_msg = "查询操作失败,出仓单明细数量"
  410. GOTO ext
  411. END IF
  412. IF i <> (no_mxcheck+1) THEN
  413. rslt = 0
  414. arg_msg = "查询操作失败,出仓单明细"
  415. GOTO ext
  416. END IF
  417. billid = arg_billid
  418. it_mxbt = i - 1
  419. it_newbegin = FALSE
  420. it_updatebegin = FALSE
  421. ext:
  422. IF rslt = 0 THEN p_reset()
  423. RETURN rslt
  424. end function
  425. public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i
  426. Dec new_noallocqty = 0
  427. Long ls_newid
  428. IF billid = 0 THEN
  429. rslt = 0
  430. arg_msg = "没有审核对象"
  431. GOTO ext
  432. END IF
  433. IF it_newbegin OR it_updatebegin THEN
  434. rslt = 0
  435. arg_msg = "编辑状态下不可以执行审核"
  436. GOTO ext
  437. END IF
  438. IF flag = 1 THEN
  439. rslt = 0
  440. arg_msg = "单据已经审核"
  441. GOTO ext
  442. END IF
  443. UPDATE u_planprice_changed
  444. SET Auditemp = :publ_operator,
  445. Auditdate = getdate(),
  446. flag = 1
  447. WHERE u_planprice_changed.billid = :billid
  448. AND flag = 0 USING commit_transaction;
  449. IF commit_transaction.SQLCode <> 0 THEN
  450. rslt = 0
  451. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  452. GOTO ext
  453. ELSEIF commit_transaction.SQLNRows = 0 THEN
  454. rslt = 0
  455. arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  456. GOTO ext
  457. END IF
  458. FOR i = 1 TO it_mxbt
  459. IF sys_option_planprice_configure = 0 THEN
  460. UPDATE u_mtrldef
  461. SET planprice = :s_changed[i].planprice
  462. Where mtrlid = :s_changed[i].mtrlid USING commit_transaction;
  463. IF commit_transaction.SQLCode <> 0 THEN
  464. rslt = 0
  465. arg_msg = '第'+String(i)+'行,更新产品计划价失败!'+"~n"+commit_transaction.SQLErrText
  466. GOTO ext
  467. END IF
  468. ELSE
  469. UPDATE u_mtrl_planprice
  470. SET planprice = :s_changed[i].planprice
  471. WHERE mtrlid = :s_changed[i].mtrlid AND
  472. status = :s_changed[i].status AND
  473. woodcode = :s_changed[i].woodcode AND
  474. pcode = :s_changed[i].pcode USING commit_transaction;
  475. IF commit_transaction.SQLCode = -1 THEN
  476. rslt = 0
  477. arg_msg = '第'+String(i)+'行,更新产品计划价失败!'+"~n"+commit_transaction.SQLErrText
  478. GOTO ext
  479. ELSEIF commit_transaction.SQLCode = 0 THEN
  480. IF commit_transaction.SQLNRows = 0 THEN
  481. INSERT INTO u_mtrl_planprice
  482. ( mtrlid,
  483. pcode,
  484. woodcode,
  485. status,
  486. planprice,
  487. dscrp )
  488. VALUES ( :s_changed[i].mtrlid,
  489. :s_changed[i].pcode,
  490. :s_changed[i].woodcode,
  491. :s_changed[i].status,
  492. :s_changed[i].planprice,
  493. '' ) USING commit_transaction;
  494. IF commit_transaction.SQLCode <> 0 THEN
  495. rslt = 0
  496. arg_msg = '第'+String(i)+'行,插入产品计划价失败!'+"~n"+commit_transaction.SQLErrText
  497. GOTO ext
  498. END IF
  499. END IF
  500. END IF
  501. END IF
  502. INSERT INTO u_planprice_his (
  503. billid,
  504. mtrlid,
  505. lastprice,
  506. planprice,
  507. relcode,
  508. reason,
  509. changedtime,
  510. changedemp,
  511. printid,
  512. status,
  513. woodcode,
  514. pcode)
  515. VALUES(
  516. :billid,
  517. :s_changed[i].mtrlid,
  518. :s_changed[i].lastprice,
  519. :s_changed[i].planprice,
  520. :billcode,
  521. :s_changed[i].reason,
  522. :billdate,
  523. :billrep,
  524. :s_changed[i].printid,
  525. :s_changed[i].status,
  526. :s_changed[i].woodcode,
  527. :s_changed[i].pcode) USING commit_transaction ;
  528. IF commit_transaction.SQLCode <> 0 THEN
  529. rslt = 0
  530. arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
  531. GOTO ext
  532. END IF
  533. NEXT
  534. flag = 1
  535. ext:
  536. IF rslt = 0 THEN
  537. ROLLBACK USING commit_transaction;
  538. ELSEIF rslt = 1 AND arg_ifcommit THEN
  539. COMMIT USING commit_transaction;
  540. END IF
  541. RETURN rslt
  542. end function
  543. public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg);//add_dscrp(string arg_newdescppart)
  544. //0 fail 1 success
  545. int rslt=1
  546. arg_newdescppart=trim(arg_newdescppart)
  547. if it_updatebegin or it_newbegin then
  548. rslt=0
  549. arg_msg="编辑状态下不可用"
  550. goto ext
  551. end if
  552. if arg_newdescppart='' then
  553. rslt=0
  554. arg_msg="要添加内容为空,操作取消"
  555. goto ext
  556. end if
  557. rslt=p_getinfo(arg_billid,arg_msg)
  558. if rslt=0 then goto ext
  559. if flag=0 then
  560. rslt=0
  561. arg_msg="非审核状态下不可用"
  562. goto ext
  563. end if
  564. update u_planprice_changed
  565. set dscrp = dscrp+' '+:arg_newdescppart
  566. where u_planprice_changed.billid = :billid using commit_transaction;
  567. if commit_transaction.sqlcode<>0 then
  568. rollback ;
  569. rslt=0
  570. arg_msg="因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.sqlerrtext
  571. goto ext
  572. end if
  573. commit using commit_transaction;
  574. dscrp = dscrp+' '+arg_newdescppart
  575. ext: return (rslt)
  576. end function
  577. public function integer acceptmx (long arg_mtrlid, decimal arg_lastprice, decimal arg_planprice, string arg_reason, string arg_mxdscrp, ref string arg_msg, string arg_status, string arg_woodcode, string arg_pcode, long arg_printid);Long rslt = 1,i
  578. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  579. rslt = 0
  580. arg_msg = "非编辑状态不可以使用,操作取消"
  581. GOTO ext
  582. END IF
  583. IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
  584. IF IsNull(arg_lastprice) THEN arg_lastprice = 0
  585. IF IsNull(arg_planprice) THEN arg_planprice = 0
  586. IF IsNull(arg_reason) THEN arg_reason = ''
  587. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  588. IF IsNull(arg_status) THEN arg_status = ''
  589. IF IsNull(arg_woodcode) THEN arg_woodcode = ''
  590. IF IsNull(arg_pcode) THEN arg_pcode = ''
  591. IF arg_mtrlid = 0 THEN
  592. rslt = 1
  593. GOTO ext
  594. END IF
  595. IF arg_planprice = 0 THEN
  596. rslt = 0
  597. arg_msg = '第'+String(it_mxbt + 1)+'行,计划价为0'
  598. GOTO ext
  599. END IF
  600. Decimal ld_lastprice
  601. ld_lastprice = 0
  602. SELECT top 1 planprice
  603. INTO :ld_lastprice
  604. FROM u_planprice_his
  605. WHERE mtrlid = :arg_mtrlid AND
  606. status = :arg_status AND
  607. woodcode = :arg_woodcode AND
  608. pcode = :arg_pcode
  609. Order By changedtime Desc USING commit_transaction;
  610. IF commit_transaction.SQLCode = -1 THEN
  611. rslt = 0
  612. arg_msg = '查询第' + String(it_mxbt + 1) + '行,历史计划价失败!'
  613. GOTO ext
  614. END IF
  615. arg_lastprice = ld_lastprice
  616. FOR i = 1 TO it_mxbt
  617. IF s_changed[i].mtrlid = arg_mtrlid AND &
  618. s_changed[i].status = arg_status AND &
  619. s_changed[i].woodcode = arg_woodcode AND &
  620. s_changed[i].pcode = arg_pcode THEN
  621. rslt = 1
  622. GOTO ext
  623. END IF
  624. NEXT
  625. //写入内容
  626. it_mxbt++
  627. s_changed[it_mxbt].mtrlid = arg_mtrlid
  628. s_changed[it_mxbt].lastprice = arg_lastprice
  629. s_changed[it_mxbt].planprice = arg_planprice
  630. s_changed[it_mxbt].reason = arg_reason
  631. s_changed[it_mxbt].mxdscrp = arg_mxdscrp
  632. s_changed[it_mxbt].status = arg_status
  633. s_changed[it_mxbt].woodcode = arg_woodcode
  634. s_changed[it_mxbt].pcode = arg_pcode
  635. s_changed[it_mxbt].printid = arg_printid
  636. ext:
  637. IF rslt = 0 THEN p_clearmx()
  638. RETURN rslt
  639. end function
  640. on uo_changed_planprice.create
  641. call super::create
  642. TriggerEvent( this, "constructor" )
  643. end on
  644. on uo_changed_planprice.destroy
  645. TriggerEvent( this, "destructor" )
  646. call super::destroy
  647. end on