uo_outware_waste.sru 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. $PBExportHeader$uo_outware_waste.sru
  2. forward
  3. global type uo_outware_waste from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_outware_waste from nonvisualobject
  7. end type
  8. global uo_outware_waste uo_outware_waste
  9. type variables
  10. Transaction commit_transaction //数据commit事务
  11. end variables
  12. forward prototypes
  13. public function integer wastedel (long arg_wastenum, long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit)
  14. public function integer insertwaste (long arg_wastetype, long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit)
  15. public function integer wastemove (boolean arg_ifcommit, ref string arg_msg)
  16. public function integer wastemoveback (long arg_wastenum, long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit)
  17. end prototypes
  18. public function integer wastedel (long arg_wastenum, long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);long rslt=1
  19. long cnt
  20. int ll_wastetype
  21. select wastetype
  22. into :ll_wastetype
  23. from u_outware_waste
  24. where u_outware_waste.wastenum=:arg_wastenum and u_outware_waste.scid=:arg_scid and u_outware_waste.outwareid=:arg_outwareid using commit_transaction;
  25. if commit_transaction.sqlcode<>0 then
  26. rslt=0
  27. arg_msg='查询操作失败,废弃单据的废弃原因'+commit_transaction.sqlerrtext
  28. goto ext
  29. end if
  30. if ll_wastetype=1 then
  31. rslt=0
  32. arg_msg='废弃单据的废弃原因是修改废弃,不能还原'
  33. goto ext
  34. end if
  35. delete from u_outwaremx_waste
  36. where u_outwaremx_waste.wastenum=:arg_wastenum and u_outwaremx_waste.scid=:arg_scid and u_outwaremx_waste.outwareid=:arg_outwareid using commit_transaction;
  37. if commit_transaction.sqlcode<>0 then
  38. rslt=0
  39. arg_msg='删除操作失败,废弃发货单/明细'+commit_transaction.sqlerrtext
  40. goto ext
  41. end if
  42. delete from u_outware_waste
  43. where u_outware_waste.wastenum=:arg_wastenum and u_outware_waste.scid=:arg_scid and u_outware_waste.outwareid=:arg_outwareid using commit_transaction;
  44. if commit_transaction.sqlcode<>0 then
  45. rslt=0
  46. arg_msg='删除操作失败,废弃发货单'+commit_transaction.sqlerrtext
  47. goto ext
  48. end if
  49. ext:
  50. IF rslt = 0 THEN
  51. ROLLBACK USING commit_transaction;
  52. ELSEIF rslt = 1 AND arg_ifcommit THEN
  53. COMMIT USING commit_transaction;
  54. END IF
  55. return rslt
  56. end function
  57. public function integer insertwaste (long arg_wastetype, long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);int rslt=1
  58. long cnt
  59. long ll_wastenum
  60. datetime server_dt
  61. IF arg_scid < 0 THEN
  62. arg_msg = '错误的分部'
  63. rslt = 0
  64. GOTO ext
  65. END IF
  66. IF arg_outwareid <= 0 THEN
  67. arg_msg = '错误销售单唯一码'
  68. rslt = 0
  69. GOTO ext
  70. END IF
  71. SELECT Top 1 getdate() INTO :server_dt FROM u_user USING commit_transaction;
  72. //取得系统时间,借用操作员表
  73. IF commit_transaction.SQLCode <> 0 THEN
  74. rslt = 0
  75. arG_MSG = "查询操作失败,日期 "
  76. GOTO ext
  77. END IF
  78. //明细
  79. cnt=0
  80. select count(*)
  81. into :cnt
  82. from u_outware_waste
  83. where scid=:arg_scid and outwareid=:arg_outwareid using commit_transaction;
  84. if commit_transaction.sqlcode<>0 then
  85. rslt=0
  86. arg_msg='查询操作失败,明细单据'+commit_transaction.sqlerrtext
  87. goto ext
  88. else
  89. if cnt = 0 then
  90. ll_wastenum = 1
  91. else
  92. select max(wastenum)
  93. into :ll_wastenum
  94. from u_outware_waste
  95. where scid=:arg_scid and outwareid=:arg_outwareid using commit_transaction;
  96. if commit_transaction.sqlcode<>0 then
  97. rslt=0
  98. arg_msg='查询操作失败,明细单据'+commit_transaction.sqlerrtext
  99. goto ext
  100. end if
  101. ll_wastenum++
  102. end if
  103. end if
  104. INSERT INTO u_outwaremx_waste
  105. (
  106. wastenum,
  107. scid,
  108. outwareid,
  109. mtrlwareid,
  110. mtrlid,
  111. storageid,
  112. plancode,
  113. status,
  114. qty,
  115. fprice,
  116. rebate,
  117. price,
  118. costamt,
  119. planprice,
  120. mxdscrp,
  121. Sptid,
  122. Dxflag,
  123. printid,
  124. sys_changetime,
  125. ifrel,
  126. olmtrlid,
  127. relid,
  128. packqty,
  129. woodcode,
  130. relcode,
  131. pcode,
  132. enprice,
  133. newpriceamt,
  134. ctmint,
  135. outtype,
  136. dftsaleprice,
  137. cost )
  138. select :ll_wastenum,
  139. scid,
  140. outwareid,
  141. mtrlwareid,
  142. mtrlid,
  143. storageid,
  144. plancode,
  145. status,
  146. qty,
  147. fprice,
  148. rebate,
  149. price,
  150. costamt,
  151. planprice,
  152. mxdscrp,
  153. Sptid,
  154. Dxflag,
  155. printid,
  156. sys_changetime,
  157. ifrel,
  158. olmtrlid,
  159. relid,
  160. packqty,
  161. woodcode,
  162. relcode,
  163. pcode,
  164. enprice,
  165. newpriceamt,
  166. ctmint,
  167. outtype,
  168. dftsaleprice,
  169. cost
  170. from u_outwaremx
  171. where scid=:arg_scid and outwareid=:arg_outwareid using commit_transaction;
  172. if commit_transaction.sqlcode<>0 then
  173. rslt=0
  174. arg_msg='插入操作失败,发货单三天不发货单据/明细'+commit_transaction.sqlerrtext
  175. goto ext
  176. end if
  177. INSERT INTO u_outware_waste
  178. (wastenum,
  179. wastedate,
  180. wasterep,
  181. wastetype,
  182. scid,
  183. outwareid,
  184. outwarecode,
  185. billtype,
  186. relid,
  187. StorageID,
  188. opdate,
  189. opemp,
  190. Modemp,
  191. moddate,
  192. flag,
  193. auditingdate,
  194. auditingrep,
  195. outdate,
  196. outrep,
  197. part,
  198. dscrp,
  199. cusid,
  200. cusname,
  201. balcflag,
  202. balcdateint,
  203. thflag,
  204. secflag,
  205. secauditingdate,
  206. secauditingrep,
  207. sys_changetime,
  208. ctmint,
  209. printnum,
  210. wagemth,
  211. otheramt,
  212. relstr_1,
  213. relstr_2,
  214. relstr_3,
  215. relint_1,
  216. relint_2,
  217. relint_3,
  218. priceflag,
  219. pricedate,
  220. priceemp,
  221. rel_address,
  222. rel_tele,
  223. rel_fax,
  224. rel_rep)
  225. select :ll_wastenum,
  226. :server_dt,
  227. :publ_operator,
  228. :arg_wastetype,
  229. scid,
  230. outwareid,
  231. outwarecode,
  232. billtype,
  233. relid,
  234. StorageID,
  235. opdate,
  236. opemp,
  237. Modemp,
  238. moddate,
  239. flag,
  240. auditingdate,
  241. auditingrep,
  242. outdate,
  243. outrep,
  244. part,
  245. dscrp,
  246. cusid,
  247. cusname,
  248. balcflag,
  249. balcdateint,
  250. thflag,
  251. secflag,
  252. secauditingdate,
  253. secauditingrep,
  254. sys_changetime,
  255. ctmint,
  256. printnum,
  257. wagemth,
  258. otheramt,
  259. relstr_1,
  260. relstr_2,
  261. relstr_3,
  262. relint_1,
  263. relint_2,
  264. relint_3,
  265. priceflag,
  266. pricedate,
  267. priceemp,
  268. rel_address,
  269. rel_tele,
  270. rel_fax,
  271. rel_rep
  272. from u_outware
  273. where scid=:arg_scid and outwareid=:arg_outwareid using commit_transaction;
  274. if commit_transaction.sqlcode<>0 then
  275. rslt=0
  276. arg_msg='插入操作失败,发货单三天不发货单据'+commit_transaction.sqlerrtext
  277. goto ext
  278. end if
  279. ext:
  280. IF rslt = 0 THEN
  281. ROLLBACK USING commit_transaction;
  282. ELSEIF rslt = 1 AND arg_ifcommit THEN
  283. COMMIT USING commit_transaction;
  284. END IF
  285. RETURN rslt
  286. end function
  287. public function integer wastemove (boolean arg_ifcommit, ref string arg_msg);long rslt=1
  288. long cnt
  289. datetime server_dt
  290. SELECT Top 1 getdate() INTO :server_dt FROM u_user USING commit_transaction ;
  291. //取得系统时间,借用操作员表
  292. IF commit_transaction.SQLCode <> 0 THEN
  293. rslt = 0
  294. arg_msg = "查询操作失败,日期 "
  295. GOTO ext
  296. END IF
  297. datetime ld_3day_before
  298. ld_3day_before=datetime(RelativeDate(date(server_dt), -3),time(0))
  299. long ll_ds_rowcount
  300. datastore ds_waste
  301. ds_waste = CREATE datastore
  302. ds_waste.DataObject = "ds_outware_waste"
  303. ds_waste.SetTransObject(sqlca)
  304. ds_waste.Retrieve(ld_3day_before)
  305. ds_waste.accepttext()
  306. ll_ds_rowcount=ds_waste.rowcount()
  307. //没有,不用转移
  308. if ll_ds_rowcount<=0 then
  309. rslt=1
  310. goto ext
  311. end if
  312. uo_outware_sale uo_sale
  313. uo_sale = create uo_outware_sale
  314. uo_sale.commit_transaction=commit_transaction
  315. long ls_i
  316. long ls_temp_scid,ls_temp_outwareid
  317. string ls_temp_outwarecode
  318. //循环转移
  319. for ls_i=1 to ll_ds_rowcount
  320. ls_temp_scid=ds_waste.object.scid[ls_i]
  321. ls_temp_outwareid=ds_waste.object.outwareid[ls_i]
  322. ls_temp_outwarecode=ds_waste.object.outwarecode[ls_i]
  323. if uo_sale.del(ls_temp_scid,ls_temp_outwareid,0,arg_msg,false)=0 then
  324. rslt=0
  325. goto ext
  326. else
  327. //日志
  328. f_setsysoplog('销售发货单','销售发货单删除,id:'+string(ls_temp_outwareid)+',code:'+ls_temp_outwarecode,arg_msg,true)
  329. end if
  330. next
  331. DESTROY uo_sale
  332. ext:
  333. IF rslt = 0 THEN
  334. ROLLBACK USING commit_transaction;
  335. ELSEIF rslt = 1 AND arg_ifcommit THEN
  336. COMMIT USING commit_transaction;
  337. END IF
  338. RETURN rslt
  339. end function
  340. public function integer wastemoveback (long arg_wastenum, long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);int rslt=1
  341. long cnt
  342. int ll_wastetype
  343. select wastetype
  344. into :ll_wastetype
  345. from u_outware_waste
  346. where u_outware_waste.wastenum=:arg_wastenum and u_outware_waste.scid=:arg_scid and u_outware_waste.outwareid=:arg_outwareid using commit_transaction;
  347. if commit_transaction.sqlcode<>0 then
  348. rslt=0
  349. arg_msg='查询操作失败,废弃单据的废弃原因'+commit_transaction.sqlerrtext
  350. goto ext
  351. end if
  352. if ll_wastetype=1 then
  353. rslt=0
  354. arg_msg='废弃单据的废弃原因是修改废弃,不能还原'
  355. goto ext
  356. end if
  357. INSERT INTO u_outwaremx
  358. (scid,
  359. outwareid,
  360. mtrlwareid,
  361. mtrlid,
  362. storageid,
  363. plancode,
  364. status,
  365. qty,
  366. fprice,
  367. rebate,
  368. price,
  369. costamt,
  370. planprice,
  371. mxdscrp,
  372. Sptid,
  373. Dxflag,
  374. printid,
  375. sys_changetime,
  376. ifrel,
  377. olmtrlid,
  378. relid,
  379. packqty,
  380. woodcode,
  381. relcode,
  382. pcode,
  383. enprice,
  384. newpriceamt,
  385. ctmint,
  386. outtype,
  387. dftsaleprice,
  388. cost)
  389. select scid,
  390. outwareid,
  391. mtrlwareid,
  392. mtrlid,
  393. storageid,
  394. plancode,
  395. status,
  396. qty,
  397. fprice,
  398. rebate,
  399. price,
  400. costamt,
  401. planprice,
  402. mxdscrp,
  403. Sptid,
  404. Dxflag,
  405. printid,
  406. sys_changetime,
  407. ifrel,
  408. olmtrlid,
  409. relid,
  410. packqty,
  411. woodcode,
  412. relcode,
  413. pcode,
  414. enprice,
  415. newpriceamt,
  416. ctmint,
  417. outtype,
  418. dftsaleprice,
  419. cost
  420. from u_outwaremx_waste
  421. where u_outwaremx_waste.wastenum=:arg_wastenum and u_outwaremx_waste.scid=:arg_scid and u_outwaremx_waste.outwareid=:arg_outwareid using commit_transaction;
  422. if commit_transaction.sqlcode<>0 then
  423. rslt=0
  424. arg_msg='插入操作失败,废弃发货单/明细'+commit_transaction.sqlerrtext
  425. goto ext
  426. end if
  427. INSERT INTO u_outware
  428. (scid,
  429. outwareid,
  430. outwarecode,
  431. billtype,
  432. relid,
  433. StorageID,
  434. opdate,
  435. opemp,
  436. Modemp,
  437. moddate,
  438. flag,
  439. auditingdate,
  440. auditingrep,
  441. outdate,
  442. outrep,
  443. part,
  444. dscrp,
  445. cusid,
  446. cusname,
  447. balcflag,
  448. balcdateint,
  449. thflag,
  450. secflag,
  451. secauditingdate,
  452. secauditingrep,
  453. sys_changetime,
  454. ctmint,
  455. printnum,
  456. wagemth,
  457. otheramt,
  458. relstr_1,
  459. relstr_2,
  460. relstr_3,
  461. relint_1,
  462. relint_2,
  463. relint_3,
  464. priceflag,
  465. pricedate,
  466. priceemp,
  467. rel_address,
  468. rel_tele,
  469. rel_fax,
  470. rel_rep)
  471. select scid,
  472. outwareid,
  473. outwarecode,
  474. billtype,
  475. relid,
  476. StorageID,
  477. opdate,
  478. opemp,
  479. Modemp,
  480. moddate,
  481. flag,
  482. auditingdate,
  483. auditingrep,
  484. outdate,
  485. outrep,
  486. part,
  487. dscrp,
  488. cusid,
  489. cusname,
  490. balcflag,
  491. balcdateint,
  492. thflag,
  493. secflag,
  494. secauditingdate,
  495. secauditingrep,
  496. sys_changetime,
  497. ctmint,
  498. printnum,
  499. wagemth,
  500. otheramt,
  501. relstr_1,
  502. relstr_2,
  503. relstr_3,
  504. relint_1,
  505. relint_2,
  506. relint_3,
  507. priceflag,
  508. pricedate,
  509. priceemp,
  510. rel_address,
  511. rel_tele,
  512. rel_fax,
  513. rel_rep
  514. from u_outware_waste
  515. where u_outware_waste.wastenum=:arg_wastenum and u_outware_waste.scid=:arg_scid and u_outware_waste.outwareid=:arg_outwareid using commit_transaction;
  516. if commit_transaction.sqlcode<>0 then
  517. rslt=0
  518. arg_msg='插入操作失败,废弃发货单'+commit_transaction.sqlerrtext
  519. goto ext
  520. end if
  521. if wastedel(arg_wastenum,arg_scid,arg_outwareid,arg_msg,false) =0 then
  522. rslt=0
  523. goto ext
  524. end if
  525. ext:
  526. IF rslt = 0 THEN
  527. ROLLBACK USING commit_transaction;
  528. ELSEIF rslt = 1 AND arg_ifcommit THEN
  529. COMMIT USING commit_transaction;
  530. END IF
  531. RETURN rslt
  532. end function
  533. on uo_outware_waste.create
  534. call super::create
  535. TriggerEvent( this, "constructor" )
  536. end on
  537. on uo_outware_waste.destroy
  538. TriggerEvent( this, "destructor" )
  539. call super::destroy
  540. end on