uo_outware_waste.sru 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  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. addqty,
  116. fprice,
  117. rebate,
  118. price,
  119. costamt,
  120. planprice,
  121. mxdscrp,
  122. Sptid,
  123. Dxflag,
  124. printid,
  125. sys_changetime,
  126. ifrel,
  127. olmtrlid,
  128. relid,
  129. packqty,
  130. woodcode,
  131. relcode,
  132. pcode,
  133. enprice,
  134. newpriceamt,
  135. ctmint,
  136. outtype,
  137. dftsaleprice,
  138. cost)
  139. SELECT :ll_wastenum,
  140. scid,
  141. outwareid,
  142. mtrlwareid,
  143. mtrlid,
  144. storageid,
  145. plancode,
  146. status,
  147. qty,
  148. addqty,
  149. fprice,
  150. rebate,
  151. price,
  152. costamt,
  153. planprice,
  154. mxdscrp,
  155. Sptid,
  156. Dxflag,
  157. printid,
  158. sys_changetime,
  159. ifrel,
  160. olmtrlid,
  161. relid,
  162. packqty,
  163. woodcode,
  164. relcode,
  165. pcode,
  166. enprice,
  167. newpriceamt,
  168. ctmint,
  169. outtype,
  170. dftsaleprice,
  171. cost
  172. FROM u_outwaremx
  173. Where scid = :arg_scid AND outwareid = :arg_outwareid USING commit_transaction;
  174. IF commit_transaction.SQLCode <> 0 THEN
  175. rslt = 0
  176. IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_outwaremx_waste') > 0 THEN
  177. arg_msg = '插入单据明细资料失败,关键字ID重复'
  178. ELSE
  179. arg_msg = '插入单据明细资料失败,'+commit_transaction.SQLErrText
  180. END IF
  181. GOTO ext
  182. END IF
  183. INSERT INTO u_outware_waste
  184. (wastenum,
  185. wastedate,
  186. wasterep,
  187. wastetype,
  188. scid,
  189. outwareid,
  190. outwarecode,
  191. billtype,
  192. relid,
  193. StorageID,
  194. opdate,
  195. opemp,
  196. Modemp,
  197. moddate,
  198. flag,
  199. auditingdate,
  200. auditingrep,
  201. outdate,
  202. outrep,
  203. part,
  204. dscrp,
  205. cusid,
  206. cusname,
  207. balcflag,
  208. balcdateint,
  209. thflag,
  210. secflag,
  211. secauditingdate,
  212. secauditingrep,
  213. sys_changetime,
  214. ctmint,
  215. printnum,
  216. wagemth,
  217. otheramt,
  218. relstr_1,
  219. relstr_2,
  220. relstr_3,
  221. relint_1,
  222. relint_2,
  223. relint_3,
  224. priceflag,
  225. pricedate,
  226. priceemp,
  227. rel_address,
  228. rel_tele,
  229. rel_fax,
  230. rel_rep,
  231. mrate)
  232. SELECT :ll_wastenum,
  233. :server_dt,
  234. :publ_operator,
  235. :arg_wastetype,
  236. scid,
  237. outwareid,
  238. outwarecode,
  239. billtype,
  240. relid,
  241. StorageID,
  242. opdate,
  243. opemp,
  244. Modemp,
  245. moddate,
  246. flag,
  247. auditingdate,
  248. auditingrep,
  249. outdate,
  250. outrep,
  251. part,
  252. dscrp,
  253. cusid,
  254. cusname,
  255. balcflag,
  256. balcdateint,
  257. thflag,
  258. secflag,
  259. secauditingdate,
  260. secauditingrep,
  261. sys_changetime,
  262. ctmint,
  263. printnum,
  264. wagemth,
  265. otheramt,
  266. relstr_1,
  267. relstr_2,
  268. relstr_3,
  269. relint_1,
  270. relint_2,
  271. relint_3,
  272. priceflag,
  273. pricedate,
  274. priceemp,
  275. rel_address,
  276. rel_tele,
  277. rel_fax,
  278. rel_rep,
  279. mrate
  280. FROM u_outware
  281. Where scid = :arg_scid AND outwareid = :arg_outwareid USING commit_transaction;
  282. IF commit_transaction.SQLCode <> 0 THEN
  283. rslt = 0
  284. IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_outware_waste') > 0 THEN
  285. arg_msg = '插入发货单据资料失败,关键字ID重复'
  286. ELSE
  287. arg_msg = '插入发货单据资料失败,'+commit_transaction.SQLErrText
  288. END IF
  289. GOTO ext
  290. END IF
  291. ext:
  292. IF rslt = 0 THEN
  293. ROLLBACK USING commit_transaction;
  294. ELSEIF rslt = 1 AND arg_ifcommit THEN
  295. COMMIT USING commit_transaction;
  296. END IF
  297. RETURN rslt
  298. end function
  299. public function integer wastemove (boolean arg_ifcommit, ref string arg_msg);long rslt=1
  300. //long cnt
  301. //datetime server_dt
  302. //
  303. //SELECT Top 1 getdate() INTO :server_dt FROM u_user USING commit_transaction ;
  304. ////取得系统时间,借用操作员表
  305. //IF commit_transaction.SQLCode <> 0 THEN
  306. // rslt = 0
  307. // arg_msg = "查询操作失败,日期 "
  308. // GOTO ext
  309. //END IF
  310. //
  311. //datetime ld_3day_before
  312. //ld_3day_before=datetime(RelativeDate(date(server_dt), -3),time(0))
  313. //
  314. //long ll_ds_rowcount
  315. //datastore ds_waste
  316. //ds_waste = CREATE datastore
  317. //ds_waste.DataObject = "ds_outware_waste"
  318. //ds_waste.SetTransObject(sqlca)
  319. //ds_waste.Retrieve(ld_3day_before)
  320. //ds_waste.accepttext()
  321. //ll_ds_rowcount=ds_waste.rowcount()
  322. ////没有,不用转移
  323. //if ll_ds_rowcount<=0 then
  324. // rslt=1
  325. // goto ext
  326. //end if
  327. //uo_outware_sale uo_sale
  328. //uo_sale = create uo_outware_sale
  329. //uo_sale.commit_transaction=commit_transaction
  330. //long ls_i
  331. //long ls_temp_scid,ls_temp_outwareid
  332. //string ls_temp_outwarecode
  333. //
  334. ////循环转移
  335. //for ls_i=1 to ll_ds_rowcount
  336. // ls_temp_scid=ds_waste.object.scid[ls_i]
  337. // ls_temp_outwareid=ds_waste.object.outwareid[ls_i]
  338. // ls_temp_outwarecode=ds_waste.object.outwarecode[ls_i]
  339. //
  340. // if uo_sale.del(ls_temp_scid,ls_temp_outwareid,arg_msg,false)=0 then
  341. // rslt=0
  342. // goto ext
  343. // else
  344. // //日志
  345. // f_setsysoplog('销售发货单','销售发货单删除,id:'+string(ls_temp_outwareid)+',code:'+ls_temp_outwarecode,arg_msg,true)
  346. // end if
  347. //next
  348. //DESTROY uo_sale
  349. //ext:
  350. //IF rslt = 0 THEN
  351. // ROLLBACK USING commit_transaction;
  352. //ELSEIF rslt = 1 AND arg_ifcommit THEN
  353. // COMMIT USING commit_transaction;
  354. //END IF
  355. RETURN rslt
  356. end function
  357. public function integer wastemoveback (long arg_wastenum, long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);int rslt=1
  358. long cnt
  359. int ll_wastetype
  360. select wastetype
  361. into :ll_wastetype
  362. from u_outware_waste
  363. where u_outware_waste.wastenum=:arg_wastenum and u_outware_waste.scid=:arg_scid and u_outware_waste.outwareid=:arg_outwareid using commit_transaction;
  364. if commit_transaction.sqlcode<>0 then
  365. rslt=0
  366. arg_msg='查询操作失败,废弃单据的废弃原因'+commit_transaction.sqlerrtext
  367. goto ext
  368. end if
  369. if ll_wastetype=1 then
  370. rslt=0
  371. arg_msg='废弃单据的废弃原因是修改废弃,不能还原'
  372. goto ext
  373. end if
  374. INSERT INTO u_outwaremx
  375. (scid,
  376. outwareid,
  377. mtrlwareid,
  378. mtrlid,
  379. storageid,
  380. plancode,
  381. status,
  382. qty,
  383. addqty,
  384. fprice,
  385. rebate,
  386. price,
  387. costamt,
  388. planprice,
  389. mxdscrp,
  390. Sptid,
  391. Dxflag,
  392. printid,
  393. sys_changetime,
  394. ifrel,
  395. olmtrlid,
  396. relid,
  397. packqty,
  398. woodcode,
  399. relcode,
  400. pcode,
  401. enprice,
  402. newpriceamt,
  403. ctmint,
  404. outtype,
  405. dftsaleprice,
  406. cost)
  407. select scid,
  408. outwareid,
  409. mtrlwareid,
  410. mtrlid,
  411. storageid,
  412. plancode,
  413. status,
  414. qty,
  415. addqty,
  416. fprice,
  417. rebate,
  418. price,
  419. costamt,
  420. planprice,
  421. mxdscrp,
  422. Sptid,
  423. Dxflag,
  424. printid,
  425. sys_changetime,
  426. ifrel,
  427. olmtrlid,
  428. relid,
  429. packqty,
  430. woodcode,
  431. relcode,
  432. pcode,
  433. enprice,
  434. newpriceamt,
  435. ctmint,
  436. outtype,
  437. dftsaleprice,
  438. cost
  439. from u_outwaremx_waste
  440. where u_outwaremx_waste.wastenum=:arg_wastenum and u_outwaremx_waste.scid=:arg_scid and u_outwaremx_waste.outwareid=:arg_outwareid using commit_transaction;
  441. if commit_transaction.sqlcode<>0 then
  442. rslt=0
  443. arg_msg='插入操作失败,废弃发货单/明细'+commit_transaction.sqlerrtext
  444. goto ext
  445. end if
  446. INSERT INTO u_outware
  447. (scid,
  448. outwareid,
  449. outwarecode,
  450. billtype,
  451. relid,
  452. StorageID,
  453. opdate,
  454. opemp,
  455. Modemp,
  456. moddate,
  457. flag,
  458. auditingdate,
  459. auditingrep,
  460. outdate,
  461. outrep,
  462. part,
  463. dscrp,
  464. cusid,
  465. cusname,
  466. balcflag,
  467. balcdateint,
  468. thflag,
  469. secflag,
  470. secauditingdate,
  471. secauditingrep,
  472. sys_changetime,
  473. ctmint,
  474. printnum,
  475. wagemth,
  476. otheramt,
  477. relstr_1,
  478. relstr_2,
  479. relstr_3,
  480. relint_1,
  481. relint_2,
  482. relint_3,
  483. priceflag,
  484. pricedate,
  485. priceemp,
  486. rel_address,
  487. rel_tele,
  488. rel_fax,
  489. rel_rep,
  490. mrate)
  491. select scid,
  492. outwareid,
  493. outwarecode,
  494. billtype,
  495. relid,
  496. StorageID,
  497. opdate,
  498. opemp,
  499. Modemp,
  500. moddate,
  501. flag,
  502. auditingdate,
  503. auditingrep,
  504. outdate,
  505. outrep,
  506. part,
  507. dscrp,
  508. cusid,
  509. cusname,
  510. balcflag,
  511. balcdateint,
  512. thflag,
  513. secflag,
  514. secauditingdate,
  515. secauditingrep,
  516. sys_changetime,
  517. ctmint,
  518. printnum,
  519. wagemth,
  520. otheramt,
  521. relstr_1,
  522. relstr_2,
  523. relstr_3,
  524. relint_1,
  525. relint_2,
  526. relint_3,
  527. priceflag,
  528. pricedate,
  529. priceemp,
  530. rel_address,
  531. rel_tele,
  532. rel_fax,
  533. rel_rep,
  534. mrate
  535. from u_outware_waste
  536. where u_outware_waste.wastenum=:arg_wastenum and u_outware_waste.scid=:arg_scid and u_outware_waste.outwareid=:arg_outwareid using commit_transaction;
  537. if commit_transaction.sqlcode<>0 then
  538. rslt=0
  539. arg_msg='插入操作失败,废弃发货单'+commit_transaction.sqlerrtext
  540. goto ext
  541. end if
  542. if wastedel(arg_wastenum,arg_scid,arg_outwareid,arg_msg,false) =0 then
  543. rslt=0
  544. goto ext
  545. end if
  546. ext:
  547. IF rslt = 0 THEN
  548. ROLLBACK USING commit_transaction;
  549. ELSEIF rslt = 1 AND arg_ifcommit THEN
  550. COMMIT USING commit_transaction;
  551. END IF
  552. RETURN rslt
  553. end function
  554. on uo_outware_waste.create
  555. call super::create
  556. TriggerEvent( this, "constructor" )
  557. end on
  558. on uo_outware_waste.destroy
  559. TriggerEvent( this, "destructor" )
  560. call super::destroy
  561. end on