uo_spt_price_change.sru 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  1. $PBExportHeader$uo_spt_price_change.sru
  2. forward
  3. global type uo_spt_price_change from nonvisualobject
  4. end type
  5. type s_spt_price_changemx from structure within uo_spt_price_change
  6. end type
  7. end forward
  8. type s_spt_price_changemx from structure
  9. long mtrlid
  10. string status
  11. decimal { 5 } rate
  12. decimal { 5 } price
  13. decimal { 5 } wareprice
  14. decimal { 5 } lastprice
  15. string dscrp
  16. long sptid
  17. long printid
  18. string mtrlcode
  19. string unit
  20. string sptmtrlname
  21. datetime lastdate
  22. string woodcode
  23. string pcode
  24. decimal { 5 } qty
  25. decimal { 5 } rebate
  26. end type
  27. global type uo_spt_price_change from nonvisualobject
  28. end type
  29. global uo_spt_price_change uo_spt_price_change
  30. type variables
  31. public protectedwrite long billid
  32. public protectedwrite string billcode
  33. public protectedwrite datetime opdate
  34. public protectedwrite string opemp
  35. public protectedwrite datetime moddate
  36. public protectedwrite string modemp
  37. public protectedwrite int flag=0
  38. public protectedwrite datetime auditingdate
  39. public protectedwrite string auditingrep
  40. long mtrlid
  41. datetime billdate
  42. long sptid
  43. string dscrp
  44. string inrep
  45. int billtype
  46. long moneyid
  47. Transaction commit_transaction //数据commit事务
  48. private:
  49. boolean it_newbegin=false //新建标志
  50. boolean it_updatebegin=false//修改标志
  51. Boolean if_getid_ture = TRUE
  52. s_spt_price_changemx changemx[] //明细结构数组
  53. Long it_mxbt = 0 //明细结构数组末指针
  54. uo_spt_price uo_price
  55. end variables
  56. forward prototypes
  57. public function integer p_reset ()
  58. public function integer updatebegin (long arg_billid, ref string arg_msg)
  59. public function integer save (ref string arg_msg, boolean arg_ifcommit)
  60. public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg)
  61. public function integer newbegin ()
  62. public function integer p_clearmx ()
  63. public function integer getinfo (long arg_billid, ref string arg_msg)
  64. public function integer p_getinfo (long arg_billid, ref string arg_msg)
  65. public function integer del (long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  66. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
  67. public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
  68. public function integer acceptmx (long arg_printid, long arg_mtrlid, string arg_mtrlcode, string arg_unit, decimal arg_qty, decimal arg_price, decimal arg_rebate, decimal arg_rate, string arg_status, string arg_woodcode, string arg_pcode, string arg_sptmtrlname, string arg_dscrp, ref string arg_msg)
  69. end prototypes
  70. public function integer p_reset ();//INT p_RESET()
  71. //清除对象及其明细
  72. billid = 0
  73. billcode = ''
  74. flag = 0
  75. inrep = ''
  76. sptid = 0
  77. billtype = 0
  78. dscrp = ''
  79. it_newbegin = FALSE
  80. it_updatebegin = FALSE
  81. p_clearmx( )
  82. RETURN 1
  83. end function
  84. public function integer updatebegin (long arg_billid, ref string arg_msg);Int rslt = 1
  85. IF arg_billid <= 0 THEN
  86. billid = 0
  87. arg_msg = '错误的单据ID'
  88. GOTO ext
  89. END IF
  90. rslt = p_getinfo(arg_billid,arg_msg)
  91. IF rslt = 0 THEN GOTO ext
  92. IF flag = 1 THEN
  93. rslt = 0
  94. arg_msg = '单据已经审核,不可以修改'
  95. GOTO ext
  96. END IF
  97. billid = arg_billid
  98. it_newbegin = FALSE
  99. it_updatebegin = TRUE
  100. p_clearmx() //清除明细
  101. ext:
  102. IF rslt = 0 THEN p_reset()
  103. RETURN rslt
  104. end function
  105. public function integer save (ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1,cnt = 0,i
  106. DateTime server_dt
  107. Long ls_newid
  108. IF IsNull(sptid) THEN sptid = 0
  109. IF IsNull(moneyid) THEN moneyid = 0
  110. IF IsNull(dscrp) THEN dscrp = ''
  111. IF IsNull(inrep) THEN inrep = ''
  112. IF it_newbegin = False And it_updatebegin = False THEN
  113. rslt = 0
  114. arg_msg = "非编辑状态不可以提交"
  115. GOTO ext
  116. END IF
  117. IF billtype <> 1 And billtype <> 2 THEN
  118. arg_msg = '错误的单据类型,1-调价单,2-报价单'
  119. rslt = 0
  120. GOTO ext
  121. END IF
  122. cnt = 0
  123. SELECT count(*) INTO :cnt
  124. FROM u_spt
  125. Where sptid = :sptid;
  126. IF sqlca.SQLCode <> 0 THEN
  127. arg_msg = '查询供应商资料失败'
  128. rslt = 0
  129. GOTO ext
  130. END IF
  131. IF cnt <> 1 THEN
  132. arg_msg = '供应商资料重复或不存在'
  133. rslt = 0
  134. GOTO ext
  135. END IF
  136. //币种, 默认本位币
  137. cnt = 0
  138. SELECT count(*) INTO :cnt
  139. FROM cw_currency
  140. Where moneyid = :moneyid;
  141. IF sqlca.SQLCode <> 0 THEN
  142. rslt = 0
  143. arg_msg = '查询币种失败! '+sqlca.SQLErrText
  144. GOTO ext
  145. END IF
  146. IF cnt <> 1 THEN
  147. arg_msg = '币种重复或不存在'
  148. rslt = 0
  149. GOTO ext
  150. END IF
  151. SELECT Top 1 getdate() Into :server_dt From u_user;
  152. //取得系统时间,借用操作员表
  153. IF sqlca.SQLCode <> 0 THEN
  154. rslt = 0
  155. arg_msg = "查询操作失败,日期 "
  156. GOTO ext
  157. END IF
  158. IF Year(Date(billdate)) < 2000 Or IsNull(billdate) THEN
  159. rslt = 0
  160. arg_msg = "时间不合理"
  161. GOTO ext
  162. END IF
  163. IF billid = 0 THEN //新建
  164. ls_newid = f_sys_scidentity(0,"u_spt_price_change","billid",arg_msg,False,sqlca)
  165. IF ls_newid <= 0 THEN
  166. rslt = 0
  167. GOTO ext
  168. END IF
  169. billcode = getid(0,"SP",Date(server_dt),False,sqlca) //取得新单据编号
  170. IF billcode = "err" THEN
  171. billcode = ''
  172. rslt = 0
  173. arg_msg = "无法获取单据编号"
  174. GOTO ext
  175. END IF
  176. INSERT INTO u_spt_price_change
  177. (billid,
  178. billcode,
  179. billdate,
  180. sptid,
  181. dscrp,
  182. opemp,
  183. opdate,
  184. inrep,
  185. billtype,
  186. moneyid)
  187. VALUES (
  188. :ls_newid,
  189. :billcode,
  190. :billdate,
  191. :sptid,
  192. :dscrp,
  193. :publ_operator,
  194. :server_dt,
  195. :inrep,
  196. :billtype,
  197. :moneyid) Using commit_transaction;
  198. IF commit_transaction.SQLCode <> 0 THEN
  199. rslt = 0
  200. IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_spt_price_change') > 0 THEN
  201. arg_msg = '插入操作失败,关键字单据ID重复'
  202. ELSE
  203. arg_msg = "插入操作失败"+"~n"+commit_transaction.SQLErrText
  204. END IF
  205. GOTO ext
  206. END IF
  207. billid = ls_newid
  208. ELSE //////////////////////////////////////////////// //更新
  209. UPDATE u_spt_price_change
  210. SET billdate = :billdate,
  211. sptid = :sptid,
  212. moddate = :server_dt,
  213. modemp = :publ_operator,
  214. dscrp = :dscrp,
  215. inrep = :inrep,
  216. billtype = :billtype,
  217. moneyid = :moneyid
  218. WHERE billid = :billid
  219. And flag = 0 Using commit_transaction;
  220. IF sqlca.SQLCode <> 0 Or sqlca.SQLNRows <= 0 THEN
  221. rslt = 0
  222. arg_msg = "更新单据操作失败"+"~n"+commit_transaction.SQLErrText
  223. GOTO ext
  224. END IF
  225. //删除原有明细
  226. DELETE FROM u_spt_price_changemx
  227. WHERE u_spt_price_changemx.billid = :billid
  228. Using commit_transaction;
  229. IF commit_transaction.SQLCode <> 0 THEN
  230. rslt = 0
  231. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  232. GOTO ext
  233. END IF
  234. END IF
  235. FOR i = 1 To it_mxbt
  236. INSERT INTO u_spt_price_changemx
  237. (
  238. billid,
  239. mtrlid,
  240. unit,
  241. qty,
  242. price,
  243. rebate,
  244. status,
  245. lastprice,
  246. wareprice,
  247. rate,
  248. sptmtrlname,
  249. Dscrp,
  250. printid,
  251. lastdate,
  252. woodcode,
  253. pcode)
  254. VALUES
  255. (
  256. :billid,
  257. :changemx[i].mtrlid,
  258. :changemx[i].unit,
  259. :changemx[i].qty,
  260. :changemx[i].price,
  261. :changemx[i].rebate,
  262. :changemx[i].status,
  263. :changemx[i].lastprice,
  264. :changemx[i].wareprice,
  265. :changemx[i].rate,
  266. :changemx[i].sptmtrlname,
  267. :changemx[i].Dscrp,
  268. :changemx[i].printid,
  269. :changemx[i].lastdate,
  270. :changemx[i].woodcode,
  271. :changemx[i].pcode
  272. ) Using commit_transaction ;
  273. IF commit_transaction.SQLCode <> 0 THEN
  274. if it_newbegin then billid = 0
  275. rslt = 0
  276. arg_msg = "插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  277. GOTO ext
  278. END IF
  279. NEXT
  280. it_newbegin = False
  281. it_updatebegin = False
  282. ext:
  283. IF rslt = 0 THEN
  284. ROLLBACK Using commit_transaction ;
  285. p_clearmx()
  286. ELSEIF rslt = 1 And arg_ifcommit THEN
  287. COMMIT Using commit_transaction ;
  288. END IF
  289. Return(rslt)
  290. end function
  291. public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg);Int rslt = 1
  292. arg_newdescppart = Trim(arg_newdescppart)
  293. IF arg_billid <= 0 THEN
  294. rslt = 0
  295. arg_msg = "没有删除对象,操作取消"
  296. GOTO ext
  297. END IF
  298. IF it_newbegin Or it_updatebegin THEN
  299. rslt = 0
  300. arg_msg = "编辑状态下不可以执行,操作取消"
  301. GOTO ext
  302. END IF
  303. rslt = p_getinfo(arg_billid,arg_msg)
  304. IF rslt = 0 THEN GOTO ext
  305. IF flag = 0 THEN
  306. rslt = 0
  307. arg_msg = "非审核状态下不可用"
  308. GOTO ext
  309. END IF
  310. UPDATE u_spt_price_change
  311. SET dscrp = dscrp+' '+:arg_newdescppart
  312. Where u_spt_price_change.billid = :billid Using commit_transaction;
  313. IF commit_transaction.SQLCode <> 0 THEN
  314. ROLLBACK ;
  315. rslt = 0
  316. arg_msg = "因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.SQLErrText
  317. GOTO ext
  318. END IF
  319. dscrp = dscrp+' '+arg_newdescppart
  320. ext:
  321. IF rslt = 0 THEN
  322. ROLLBACK Using commit_transaction ;
  323. ELSE
  324. COMMIT Using commit_transaction ;
  325. END IF
  326. Return(rslt)
  327. end function
  328. public function integer newbegin ();p_reset()
  329. it_newbegin=TRUE
  330. it_updatebegin=FALSE
  331. return 1
  332. end function
  333. public function integer p_clearmx ();//int p_clearmx()
  334. //清除明细
  335. it_mxbt=0
  336. return 1
  337. end function
  338. public function integer getinfo (long arg_billid, ref string arg_msg);//getinfo(arg_scid,arg_billid,arg_msg)
  339. //0 失败 1成功
  340. Int rslt = 1,i = 1,no_mxcheck = 0
  341. IF arg_billid <= 0 THEN
  342. rslt = 0
  343. arg_msg = "非法调价单唯一码"
  344. GOTO ext
  345. END IF
  346. rslt = p_getinfo(arg_billid,arg_msg)
  347. IF rslt = 0 THEN GOTO ext
  348. //用游标读取明细
  349. DECLARE cur_changemx CURSOR FOR
  350. SELECT
  351. u_spt_price_changemx.printid,
  352. u_spt_price_changemx.mtrlid,
  353. u_mtrldef.mtrlcode,
  354. u_spt_price_changemx.unit,
  355. u_spt_price_changemx.qty,
  356. u_spt_price_changemx.price,
  357. u_spt_price_changemx.rebate,
  358. u_spt_price_changemx.status,
  359. u_spt_price_changemx.sptmtrlname,
  360. u_spt_price_changemx.Dscrp,
  361. u_spt_price_changemx.lastprice,
  362. u_spt_price_changemx.wareprice,
  363. u_spt_price_changemx.rate,
  364. u_spt_price_changemx.lastdate,
  365. u_spt_price_changemx.woodcode,
  366. u_spt_price_changemx.pcode
  367. FROM u_spt_price_change
  368. INNER JOIN
  369. u_spt_price_changemx ON
  370. u_spt_price_change.billid = u_spt_price_changemx.billid
  371. INNER JOIN
  372. u_mtrldef ON u_spt_price_changemx.mtrlid = u_mtrldef.mtrlid
  373. WHERE u_spt_price_change.billid = :arg_billid
  374. USING commit_transaction;
  375. OPEN cur_changemx;
  376. FETCH cur_changemx INTO
  377. :changemx[i].printid,
  378. :changemx[i].mtrlid,
  379. :changemx[i].mtrlcode,
  380. :changemx[i].unit,
  381. :changemx[i].qty,
  382. :changemx[i].price,
  383. :changemx[i].rebate,
  384. :changemx[i].status,
  385. :changemx[i].sptmtrlname,
  386. :changemx[i].Dscrp,
  387. :changemx[i].lastprice,
  388. :changemx[i].wareprice,
  389. :changemx[i].rate,
  390. :changemx[i].lastdate,
  391. :changemx[i].woodcode,
  392. :changemx[i].pcode;
  393. DO WHILE commit_transaction.SQLCode = 0
  394. i++
  395. FETCH cur_changemx INTO
  396. :changemx[i].printid,
  397. :changemx[i].mtrlid,
  398. :changemx[i].mtrlcode,
  399. :changemx[i].unit,
  400. :changemx[i].qty,
  401. :changemx[i].price,
  402. :changemx[i].rebate,
  403. :changemx[i].status,
  404. :changemx[i].sptmtrlname,
  405. :changemx[i].Dscrp,
  406. :changemx[i].lastprice,
  407. :changemx[i].wareprice,
  408. :changemx[i].rate,
  409. :changemx[i].lastdate,
  410. :changemx[i].woodcode,
  411. :changemx[i].pcode;
  412. LOOP
  413. CLOSE cur_changemx;
  414. //检验明细是否读入完整
  415. SELECT count(*) INTO :no_mxcheck
  416. FROM u_spt_price_change
  417. INNER JOIN
  418. u_spt_price_changemx ON
  419. u_spt_price_change.billid = u_spt_price_changemx.billid
  420. INNER JOIN
  421. u_mtrldef ON u_spt_price_changemx.mtrlid = u_mtrldef.mtrlid
  422. WHERE u_spt_price_change.billid = :arg_billid
  423. USING commit_transaction;
  424. IF commit_transaction.SQLCode <> 0 THEN
  425. rslt = 0
  426. arg_msg = "查询操作失败,调价单明细数量"
  427. GOTO ext
  428. END IF
  429. IF i <> (no_mxcheck+1) THEN
  430. rslt = 0
  431. arg_msg = "查询操作失败,调价单明细"
  432. GOTO ext
  433. END IF
  434. billid = arg_billid
  435. it_mxbt = i - 1
  436. it_newbegin = FALSE
  437. it_updatebegin = FALSE
  438. ext:
  439. IF rslt = 0 THEN p_reset()
  440. RETURN rslt
  441. end function
  442. public function integer p_getinfo (long arg_billid, ref string arg_msg);Int rslt = 1
  443. IF arg_billid <= 0 THEN
  444. rslt = 0
  445. arG_MSG = "非法调价单唯一码"
  446. GOTO ext
  447. END IF
  448. SELECT
  449. Billcode,
  450. billdate,
  451. sptid,
  452. flag,
  453. dscrp,
  454. inrep,
  455. billtype,
  456. moneyid
  457. Into
  458. :Billcode,
  459. :billdate,
  460. :sptid,
  461. :flag,
  462. :dscrp,
  463. :inrep,
  464. :billtype,
  465. :moneyid
  466. From u_spt_price_change
  467. Where billid = :arg_billid
  468. Using commit_transaction;
  469. IF commit_transaction.SQLCode <> 0 THEN
  470. rslt = 0
  471. arG_MSG = "查询操作失败(错误调价单唯一码),调价单"+commit_transaction.SQLErrText
  472. GOTO ext
  473. END IF
  474. billid = arg_billid
  475. ext:
  476. IF rslt = 0 THEN p_reset()
  477. RETURN rslt
  478. end function
  479. public function integer del (long arg_billid, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  480. IF arg_billid <= 0 THEN
  481. rslt = 0
  482. arg_msg = "没有删除对象,操作取消"
  483. GOTO ext
  484. END IF
  485. IF it_newbegin OR it_updatebegin THEN
  486. rslt = 0
  487. arg_msg = "编辑状态下不可以执行,操作取消"
  488. GOTO ext
  489. END IF
  490. rslt = p_getinfo(arg_billid,arg_msg)
  491. IF rslt = 0 THEN GOTO ext
  492. IF flag = 1 THEN
  493. rslt = 0
  494. arg_msg = "单据已经审核,不可以删除"
  495. GOTO ext
  496. END IF
  497. DELETE FROM u_spt_price_change WHERE u_spt_price_change.billid = :arg_billid
  498. USING commit_transaction;
  499. IF commit_transaction.SQLCode <> 0 THEN
  500. rslt = 0
  501. arg_msg = "删除单据操作失败"+"~n"+commit_transaction.SQLErrText
  502. GOTO ext
  503. END IF
  504. DELETE FROM u_spt_price_changemx WHERE u_spt_price_changemx.billid = :arg_billid
  505. USING commit_transaction;
  506. IF commit_transaction.SQLCode <> 0 THEN
  507. rslt = 0
  508. arg_msg = "删除单据操作失败"+"~n"+commit_transaction.SQLErrText
  509. GOTO ext
  510. END IF
  511. it_newbegin = FALSE
  512. it_updatebegin = FALSE
  513. ext:
  514. if rslt=0 then
  515. rollback using commit_transaction;
  516. elseif rslt=1 and arg_ifcommit then
  517. commit using commit_transaction;
  518. end if
  519. Return (rslt)
  520. end function
  521. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);
  522. Long cnt = 0,i
  523. Int rslt = 1
  524. DateTime null_server_dt
  525. SetNull(null_server_dt)
  526. IF billid = 0 THEN
  527. rslt = 0
  528. arg_msg = "没有审核对象"
  529. GOTO ext
  530. END IF
  531. IF it_newbegin OR it_updatebegin THEN
  532. rslt = 0
  533. arg_msg = "编辑状态下不可以执行审核"
  534. GOTO ext
  535. END IF
  536. IF flag = 0 THEN
  537. rslt = 0
  538. arg_msg = '该单价调整未审核,不用撤审!'
  539. GOTO ext
  540. END IF
  541. UPDATE u_spt_price_change SET
  542. flag = 0,
  543. Auditemp = '',
  544. Auditdate = :null_server_dt
  545. Where flag = 1 AND billid = :billid USING commit_transaction;
  546. IF commit_transaction.SQLCode <> 0 THEN
  547. arg_msg = '更新单价调整失败,原因:'+commit_transaction.SQLErrText
  548. rslt = 0
  549. GOTO ext
  550. END IF
  551. //
  552. ////币种, 默认本位币
  553. //Long moneyid
  554. //SELECT moneyid INTO :moneyid
  555. // FROM cw_currency
  556. // WHERE native = 1
  557. // USING commit_transaction;
  558. //IF commit_transaction.SQLCode <> 0 THEN
  559. // rslt = 0
  560. // arg_msg = '查询本位币失败! '+commit_transaction.SQLErrText
  561. // GOTO ext
  562. //END IF
  563. FOR i = 1 TO it_mxbt
  564. IF uo_price.uf_del_sptprice(0,sptid,changemx[i].mtrlid,changemx[i].unit,changemx[i].status,changemx[i].woodcode,changemx[i].pcode,billid,&
  565. i,moneyid,FALSE,arg_msg) = 0 THEN
  566. rslt = 0
  567. GOTO ext
  568. END IF
  569. // IF uo_price.uf_update_sptmtrlname(sptid,changemx[i].mtrlid,changemx[i].unit,changemx[i].sptmtrlname,false,arg_msg) = 0 THEN
  570. // rslt = 0
  571. // GOTO ext
  572. // END IF
  573. NEXT
  574. ext:
  575. IF rslt = 0 THEN
  576. ROLLBACK USING commit_transaction;
  577. ELSEIF rslt = 1 AND arg_ifcommit THEN
  578. COMMIT USING commit_transaction;
  579. END IF
  580. RETURN rslt
  581. end function
  582. public function integer auditing (boolean arg_ifcommit, ref string arg_msg);
  583. Long cnt = 0,i
  584. Int rslt = 1
  585. IF billid = 0 THEN
  586. rslt = 0
  587. arg_msg = "没有审核对象"
  588. GOTO ext
  589. END IF
  590. IF it_newbegin Or it_updatebegin THEN
  591. rslt = 0
  592. arg_msg = "编辑状态下不可以执行审核"
  593. GOTO ext
  594. END IF
  595. IF flag = 1 THEN
  596. rslt = 0
  597. arg_msg = '该单价调整已审核,审核前请先执行撤审!'
  598. GOTO ext
  599. END IF
  600. UPDATE u_spt_price_change SET
  601. flag = 1,
  602. auditemp = :publ_operator,
  603. Auditdate = getdate()
  604. WHERE billid = :billid
  605. And flag = 0 Using commit_transaction;
  606. IF commit_transaction.SQLCode <> 0 THEN
  607. arg_msg = '更新单价调整失败,原因>>'+commit_transaction.SQLErrText
  608. rslt = 0
  609. GOTO ext
  610. END IF
  611. ////币种, 默认本位币
  612. //Long moneyid
  613. //SELECT moneyid INTO :moneyid
  614. // FROM cw_currency
  615. // WHERE native = 1
  616. // Using commit_transaction;
  617. //IF commit_transaction.SQLCode <> 0 THEN
  618. // rslt = 0
  619. // arg_msg = '查询本位币失败! '+commit_transaction.SQLErrText
  620. // GOTO ext
  621. //END IF
  622. FOR i = 1 To it_mxbt
  623. IF uo_price.uf_update_sptprice(0,sptid,changemx[i].mtrlid,changemx[i].unit,changemx[i].status,changemx[i].woodcode,changemx[i].pcode,billid,moneyid,changemx[i].price,changemx[i].rebate,&
  624. changemx[i].rate,changemx[i].wareprice,billdate,billcode,1,'报价/调价单',i,2,False,arg_msg) = 0 THEN
  625. rslt = 0
  626. GOTO ext
  627. END IF
  628. IF uo_price.uf_update_sptmtrlname(sptid,changemx[i].mtrlid,changemx[i].unit,changemx[i].sptmtrlname,False,arg_msg) = 0 THEN
  629. rslt = 0
  630. GOTO ext
  631. END IF
  632. NEXT
  633. ext:
  634. IF rslt = 0 THEN
  635. ROLLBACK Using commit_transaction;
  636. ELSEIF rslt = 1 And arg_ifcommit THEN
  637. COMMIT Using commit_transaction;
  638. END IF
  639. RETURN rslt
  640. end function
  641. public function integer acceptmx (long arg_printid, long arg_mtrlid, string arg_mtrlcode, string arg_unit, decimal arg_qty, decimal arg_price, decimal arg_rebate, decimal arg_rate, string arg_status, string arg_woodcode, string arg_pcode, string arg_sptmtrlname, string arg_dscrp, ref string arg_msg);Int rslt = 1
  642. Decimal i_lastprice,i_lastrate,i_rate
  643. datetime ld_lastdate
  644. string ls_unit
  645. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  646. rslt = 0
  647. arg_msg = "非编辑状态不可以使用,操作取消"
  648. GOTO ext
  649. END IF
  650. //清除空值
  651. IF IsNull(arg_printid) THEN arg_printid = 0
  652. IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
  653. IF IsNull(arg_mtrlcode) THEN arg_mtrlcode = ''
  654. IF IsNull(arg_status) THEN arg_status = ''
  655. IF IsNull(arg_dscrp) THEN arg_dscrp = ''
  656. IF IsNull(arg_price) THEN arg_price = 0
  657. IF IsNull(arg_qty) THEN arg_qty = 0
  658. IF IsNull(arg_unit) THEN arg_unit = ''
  659. if IsNull(arg_rate) THEN arg_rate = 1
  660. if IsNull(arg_rebate) THEN arg_rebate = 1
  661. IF IsNull(arg_woodcode) THEN arg_woodcode = ''
  662. IF IsNull(arg_pcode) THEN arg_pcode = ''
  663. if arg_rate = 0 THEN arg_rate = 1
  664. ls_unit = arg_unit
  665. IF arg_mtrlid = 0 and arg_price = 0 THEN
  666. rslt = 1
  667. GOTO ext
  668. END IF
  669. IF f_check_status(1, arg_status) = 0 THEN
  670. rslt = 0
  671. arg_msg ="第" + string(arg_printid) + "行,查询操作失败,可能配置未定义,编码:"+arg_mtrlcode+",配置:"+arg_status
  672. GOTO ext
  673. END IF
  674. IF uo_price.uf_getmtrlsptprice_ch(sptid,arg_mtrlid,ls_unit,arg_status,arg_woodcode,arg_pcode,i_lastprice,i_rate,ld_lastdate,arg_msg) = 0 THEN
  675. rslt = 0
  676. GOTO ext
  677. END IF
  678. it_mxbt++
  679. changemx[it_mxbt].printid = it_mxbt
  680. changemx[it_mxbt].mtrlid = arg_mtrlid
  681. changemx[it_mxbt].unit = arg_unit
  682. changemx[it_mxbt].qty = arg_qty
  683. changemx[it_mxbt].rebate = arg_rebate
  684. changemx[it_mxbt].price = arg_price
  685. changemx[it_mxbt].lastprice = i_lastprice
  686. changemx[it_mxbt].wareprice = round((arg_price * arg_rebate) /arg_rate,10)
  687. changemx[it_mxbt].rate = arg_rate
  688. changemx[it_mxbt].sptmtrlname = arg_sptmtrlname
  689. changemx[it_mxbt].Dscrp = arg_dscrp
  690. changemx[it_mxbt].lastdate = ld_lastdate
  691. changemx[it_mxbt].status = arg_status
  692. changemx[it_mxbt].woodcode = arg_woodcode
  693. changemx[it_mxbt].pcode = arg_pcode
  694. ext:
  695. RETURN rslt
  696. end function
  697. on uo_spt_price_change.create
  698. call super::create
  699. TriggerEvent( this, "constructor" )
  700. end on
  701. on uo_spt_price_change.destroy
  702. TriggerEvent( this, "destructor" )
  703. call super::destroy
  704. end on
  705. event constructor;uo_price = CREATE uo_spt_price
  706. end event
  707. event destructor;destroy uo_price
  708. end event