uo_spt_wfjg.sru 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. $PBExportHeader$uo_spt_wfjg.sru
  2. forward
  3. global type uo_spt_wfjg from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_spt_wfjg from nonvisualobject
  7. end type
  8. global uo_spt_wfjg uo_spt_wfjg
  9. type variables
  10. public protectedwrite long scid //罚款单scid
  11. public protectedwrite long billid //罚款单自动增量id
  12. public protectedwrite string billcode //罚款单的唯一编号
  13. public protectedwrite datetime opdate //建立时间,自动
  14. public protectedwrite string opemp //建立人
  15. public protectedwrite datetime moddate //修改时间,自动
  16. public protectedwrite string modemp //修改人
  17. public protectedwrite int flag=0 //审核标志
  18. public protectedwrite datetime auditingdate //审核时间
  19. public protectedwrite string auditingrep //审核操作员
  20. long sptid
  21. long relid
  22. string inwarecode
  23. datetime billdate
  24. decimal amt
  25. string dscrp
  26. string relcode
  27. int payid
  28. int banktypeid
  29. string inrep
  30. private:
  31. boolean it_newbegin=false //新建标志
  32. boolean it_updatebegin=false//修改标志
  33. end variables
  34. forward prototypes
  35. public function integer p_reset ()
  36. public function integer save (ref string arg_msg, boolean arg_ifcommit)
  37. public function integer updatebegin (long arg_scid, long arg_billid, ref string arg_msg)
  38. public function integer newbegin (long arg_scid, ref string arg_msg)
  39. public function integer del (long arg_scid, long arg_billid, ref string arg_msg)
  40. public function integer getinfo (long arg_scid, long arg_billid, ref string arg_msg)
  41. public function integer auditing (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  42. public function integer c_auditing (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  43. public function integer add_dscrp (long arg_scid, long arg_billid, string arg_newdescppart, ref string arg_msg)
  44. end prototypes
  45. public function integer p_reset ();//INT p_RESET()
  46. //清除对象及其明细
  47. billid = 0
  48. billcode = ''
  49. opemp = ''
  50. auditingrep = ''
  51. flag = 0
  52. sptid = 0
  53. amt = 0
  54. dscrp = ''
  55. relcode = ''
  56. inwarecode = ''
  57. relid = 0
  58. it_newbegin = FALSE
  59. it_updatebegin = FALSE
  60. RETURN 1
  61. end function
  62. public function integer save (ref string arg_msg, boolean arg_ifcommit);//====================================================================
  63. // Function: save(arg_msg,arg_ifcommit)
  64. //--------------------------------------------------------------------
  65. // Description:
  66. //--------------------------------------------------------------------
  67. // Arguments:
  68. // reference string arg_msg
  69. // value boolean arg_ifcommit
  70. //--------------------------------------------------------------------
  71. // Returns: integer
  72. //--------------------------------------------------------------------
  73. // Author: yyx Date: 2003.11.21
  74. //--------------------------------------------------------------------
  75. // Modify History:
  76. //
  77. //====================================================================
  78. integer rslt = 1,cnt = 0,i
  79. datetime server_dt
  80. long ls_newid
  81. string ls_sccode
  82. if isnull(sptid) then sptid = 0
  83. if isnull(relid) then relid = 0
  84. if isnull(amt) then amt = 0
  85. if isnull(banktypeid) then banktypeid = 0
  86. if isnull(dscrp) then dscrp = ''
  87. if isnull(relcode) then relcode = ''
  88. if isnull(inwarecode) then inwarecode = ''
  89. if isnull(inrep) then inrep = ''
  90. if it_newbegin = false and it_updatebegin = false then
  91. rslt = 0
  92. arg_msg = "非编辑状态不可以提交"
  93. goto ext
  94. end if
  95. select count(*) into :cnt
  96. from u_spt
  97. where sptid = :sptid;
  98. if sqlca.sqlcode <> 0 then
  99. arg_msg = '查询供应商资料失败'
  100. rslt = 0
  101. goto ext
  102. end if
  103. if cnt > 1 then
  104. arg_msg = '供应商资料重复'
  105. rslt = 0
  106. goto ext
  107. end if
  108. if amt = 0 then
  109. arg_msg = '请输入正确的金额'
  110. rslt = 0
  111. goto ext
  112. end if
  113. if inrep = '' then
  114. arg_msg = '请输入经手人'
  115. rslt = 0
  116. goto ext
  117. end if
  118. if banktypeid = 0 then
  119. arg_msg = '请请选择结算方式'
  120. rslt = 0
  121. goto ext
  122. end if
  123. select count(*) into :cnt
  124. from u_inware
  125. where scid = :scid
  126. and inwareid = :relid;
  127. if sqlca.sqlcode <> 0 then
  128. arg_msg = '查询相关采购收货单资料失败'
  129. rslt = 0
  130. goto ext
  131. end if
  132. if cnt <> 1 then
  133. arg_msg = '不存在相关采购收货单或单据重复'
  134. rslt = 0
  135. goto ext
  136. end if
  137. select top 1 getdate() into :server_dt from u_user;
  138. //取得系统时间,借用操作员表
  139. if sqlca.sqlcode <> 0 then
  140. rslt = 0
  141. arg_msg = "查询操作失败,日期 "
  142. goto ext
  143. end if
  144. if year(date(billdate)) < 2000 or isnull(billdate) then
  145. rslt = 0
  146. arg_msg = "时间不合理"
  147. goto ext
  148. end if
  149. ////////////////////////////////////////////////开始区分:新建/更新 处理
  150. if billid = 0 then //新建
  151. ls_newid = f_sys_scidentity(scid,"u_spt_wfjg","billid",arg_msg,TRUE,id_sqlca)
  152. if ls_newid <= 0 then
  153. rslt = 0
  154. goto ext
  155. end if
  156. //取分部代号
  157. if f_get_sccode(scid,sqlca,ls_sccode,arg_msg) = 0 then
  158. rslt = 0
  159. goto ext
  160. end if
  161. billcode = getid(scid,ls_sccode + "JG",date(server_dt),true,sqlca) //取得新单据编号
  162. if billcode = "err" then
  163. billcode = ''
  164. rslt = 0
  165. arg_msg = "无法获取加工单编号"
  166. goto ext
  167. end if
  168. insert into u_spt_wfjg (
  169. scid,
  170. billid,
  171. billcode,
  172. billdate,
  173. sptid,
  174. amt,
  175. banktypeid,
  176. inrep,
  177. dscrp,
  178. relcode,
  179. opdate,
  180. opemp,
  181. relid,
  182. inwarecode)
  183. values (
  184. :scid,
  185. :ls_newid,
  186. :billcode,
  187. :billdate,
  188. :sptid,
  189. :amt,
  190. :banktypeid,
  191. :inrep,
  192. :dscrp,
  193. :relcode,
  194. :server_dt,
  195. :publ_operator,
  196. :relid,
  197. :inwarecode);
  198. if sqlca.sqlcode <> 0 then
  199. rslt = 0
  200. arg_msg = "因网络或其它原因导致插入操作失败>>"+"~n"+sqlca.sqlerrtext
  201. goto ext
  202. end if
  203. insert into u_spt_wfjgMx
  204. (scid,billid,mtrlid,status,Qty,mxdscrp,printid)
  205. select :scid,:ls_newid,mtrlid,status,Qty,mxdscrp,printid
  206. from u_inwaremx
  207. where u_inwaremx.scid = :scid
  208. and u_inwaremx.inwareid =:relid;
  209. if sqlca.sqlcode <> 0 then
  210. arg_msg = '加入单据明细失败,'+sqlca.sqlerrtext
  211. rslt = 0
  212. goto ext
  213. end if
  214. billid = ls_newid
  215. else //////////////////////////////////////////////////更新
  216. update u_spt_wfjg
  217. set billdate = :billdate,
  218. sptid = :sptid,
  219. amt = :amt,
  220. dscrp = :dscrp,
  221. banktypeid = :banktypeid,
  222. inrep = :inrep,
  223. relcode = :relcode,
  224. moddate = :server_dt,
  225. modemp = :modemp,
  226. relid = :relid,
  227. inwarecode = :inwarecode
  228. where u_spt_wfjg.billid = :billid
  229. and u_spt_wfjg.scid = :scid
  230. and u_spt_wfjg.flag = 0;
  231. if sqlca.sqlcode <> 0 or sqlca.sqlnrows <= 0 then
  232. rslt = 0
  233. arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+sqlca.sqlerrtext
  234. goto ext
  235. end if
  236. delete from u_spt_wfjgMx
  237. where scid = :scid
  238. and billid = :billid;
  239. if sqlca.sqlcode <> 0 then
  240. arg_msg = '删除单据原明细内容失败,'+sqlca.sqlerrtext
  241. rslt = 0
  242. goto ext
  243. end if
  244. insert into u_spt_wfjgMx
  245. (scid,billid,mtrlid,status,Qty,mxdscrp,printid)
  246. select :scid,:billid,mtrlid,status,Qty,mxdscrp,printid
  247. from u_inwaremx
  248. where u_inwaremx.scid = :scid
  249. and u_inwaremx.inwareid =:relid;
  250. if sqlca.sqlcode <> 0 then
  251. arg_msg = '加入单据明细失败,'+sqlca.sqlerrtext
  252. rslt = 0
  253. goto ext
  254. end if
  255. end if
  256. it_newbegin = false
  257. it_updatebegin = false
  258. ext:
  259. if rslt = 0 then
  260. rollback;
  261. elseif rslt=1 and arg_ifcommit then
  262. commit;
  263. end if
  264. return(rslt)
  265. end function
  266. public function integer updatebegin (long arg_scid, long arg_billid, ref string arg_msg);//====================================================================
  267. // Function: updatebegin(arg_billid,arg_msg)
  268. //--------------------------------------------------------------------
  269. // Description:
  270. //--------------------------------------------------------------------
  271. // Arguments:
  272. // value long arg_billid
  273. // reference string arg_msg
  274. //--------------------------------------------------------------------
  275. // Returns: integer
  276. //--------------------------------------------------------------------
  277. // Author: yyx Date: 2003.11.21
  278. //--------------------------------------------------------------------
  279. // Modify History:
  280. //
  281. //====================================================================
  282. int rslt = 1
  283. if getinfo(arg_scid,arg_billid,arg_msg) = 0 then
  284. rslt = 0
  285. goto ext
  286. end if
  287. if flag = 1 then
  288. rslt = 0
  289. arg_msg = '单据已经审核,不可以修改'
  290. goto ext
  291. end if
  292. billid = arg_billid
  293. scid = arg_scid
  294. it_newbegin = false
  295. it_updatebegin = true
  296. ext:
  297. if rslt = 0 then p_reset()
  298. return rslt
  299. end function
  300. public function integer newbegin (long arg_scid, ref string arg_msg);int rslt = 1
  301. if arg_scid < 0 then
  302. arg_msg = '请选择分部'
  303. rslt = 0
  304. goto ext
  305. end if
  306. p_reset()
  307. scid=arg_scid
  308. it_newbegin=TRUE
  309. it_updatebegin=FALSE
  310. ext:
  311. if rslt = 0 then p_reset()
  312. return rslt
  313. end function
  314. public function integer del (long arg_scid, long arg_billid, ref string arg_msg);//====================================================================
  315. // Function: del(arg_billid,arg_msg)
  316. //--------------------------------------------------------------------
  317. // Description:
  318. //--------------------------------------------------------------------
  319. // Arguments:
  320. // value long arg_billid
  321. // reference string arg_msg
  322. //--------------------------------------------------------------------
  323. // Returns: integer
  324. //--------------------------------------------------------------------
  325. // Author: yyx Date: 2003.11.21
  326. //--------------------------------------------------------------------
  327. // Modify History:
  328. //
  329. //====================================================================
  330. int rslt = 1
  331. if arg_billid <= 0 then
  332. rslt = 0
  333. arg_msg = "没有删除对象,操作取消"
  334. goto ext
  335. end if
  336. if it_newbegin or it_updatebegin then
  337. rslt=0
  338. arg_msg="编辑状态下不可以执行,操作取消"
  339. goto ext
  340. end if
  341. select u_spt_wfjg.flag
  342. into :flag
  343. from u_spt_wfjg
  344. where u_spt_wfjg.billid = :arg_billid;
  345. if sqlca.sqlcode <> 0 then
  346. rslt = 0
  347. arg_msg = '查询单据操作失败'
  348. goto ext
  349. end if
  350. if flag = 1 then
  351. rslt = 0
  352. arg_msg = "单据已经审核,不可以删除"
  353. goto ext
  354. end if
  355. delete from u_spt_wfjg
  356. where u_spt_wfjg.billid = :arg_billid
  357. and u_spt_wfjg.scid = :arg_scid;
  358. if sqlca.sqlcode <> 0 then
  359. rslt = 0
  360. arg_msg = "删除罚款单操作失败"+"~n"+sqlca.sqlerrtext
  361. goto ext
  362. end if
  363. commit;
  364. it_newbegin = false
  365. it_updatebegin = false
  366. if rslt = 0 then
  367. rollback;
  368. p_reset()
  369. end if
  370. ext:
  371. return (rslt)
  372. end function
  373. public function integer getinfo (long arg_scid, long arg_billid, ref string arg_msg);int rslt = 1
  374. if arg_billid <= 0 then
  375. billid = 0
  376. arg_msg = '错误的单据id'
  377. goto ext
  378. end if
  379. select
  380. u_spt_wfjg.billcode,
  381. u_spt_wfjg.billdate,
  382. u_spt_wfjg.sptid,
  383. u_spt_wfjg.amt,
  384. u_spt_wfjg.banktypeid,
  385. u_spt_wfjg.inrep,
  386. u_spt_wfjg.dscrp,
  387. u_spt_wfjg.payid,
  388. u_spt_wfjg.relcode,
  389. u_spt_wfjg.flag,
  390. u_spt_wfjg.relid,
  391. u_spt_wfjg.inwarecode
  392. into
  393. :billcode,
  394. :billdate,
  395. :sptid,
  396. :amt,
  397. :banktypeid,
  398. :inrep,
  399. :dscrp,
  400. :payid,
  401. :relcode,
  402. :flag,
  403. :relid,
  404. :inwarecode
  405. from u_spt_wfjg
  406. where u_spt_wfjg.billid = :arg_billid
  407. and u_spt_wfjg.scid = :arg_scid;
  408. if sqlca.sqlcode <> 0 then
  409. rslt = 0
  410. arg_msg = '查询数据操作失败,加工单'+sqlca.sqlerrtext
  411. goto ext
  412. end if
  413. scid = arg_scid
  414. billid = arg_billid
  415. ext:
  416. if rslt=0 then p_reset()
  417. return rslt
  418. end function
  419. public function integer auditing (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);//====================================================================
  420. // Function: auditing()
  421. //--------------------------------------------------------------------
  422. // Description:
  423. //--------------------------------------------------------------------
  424. // Arguments:
  425. // value long arg_scid
  426. // value long arg_billid
  427. // reference string arg_msg
  428. // value boolean arg_ifcommit
  429. //--------------------------------------------------------------------
  430. // Returns: integer
  431. //--------------------------------------------------------------------
  432. // Author: yyx Date: 2004.12.07
  433. //--------------------------------------------------------------------
  434. // Modify History:
  435. //
  436. //====================================================================
  437. Int rslt = 1
  438. String ls_dscrp
  439. uo_mustpay uo_pay
  440. uo_pay = CREATE uo_mustpay
  441. IF getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
  442. rslt = 0
  443. GOTO ext
  444. END IF
  445. IF flag = 1 THEN
  446. rslt = 0
  447. arg_msg = '单据已经审核,不可以再审核'
  448. GOTO ext
  449. END IF
  450. IF it_newbegin OR it_updatebegin THEN
  451. rslt = 0
  452. arg_msg = "编辑状态下不可以执行审核"
  453. GOTO ext
  454. END IF
  455. UPDATE u_spt_wfjg
  456. SET auditingrep = :publ_operator,
  457. auditingdate = getdate(),
  458. flag = 1
  459. WHERE u_spt_wfjg.billid = :arg_billid
  460. AND flag = 0 AND scid = :arg_scid;
  461. IF sqlca.SQLCode <> 0 THEN
  462. rslt = 0
  463. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+sqlca.SQLErrText
  464. GOTO ext
  465. ELSEIF sqlca.SQLNRows = 0 THEN
  466. rslt = 0
  467. arg_msg = "单据正在审核,请稍后查询。"+"~n"+sqlca.SQLErrText
  468. GOTO ext
  469. END IF
  470. IF amt <> 0 THEN
  471. ls_dscrp = billcode + "罚款"
  472. datetime plandate
  473. setnull(plandate)
  474. // if uo_pay.add_payrec (scid,sptid,billdate,inrep,amt,amt,0,ls_dscrp,&
  475. // billcode,banktypeid,1,publ_operator,billid,arg_msg,false,plandate,0,0)=0 then
  476. // rslt=0
  477. // goto ext
  478. // end if
  479. UPDATE u_spt_wfjg
  480. SET payid = :uo_pay.ref_payid
  481. WHERE u_spt_wfjg.billid = :arg_billid
  482. AND scid = :scid
  483. AND flag = 1 ;
  484. IF sqlca.SQLCode <> 0 THEN
  485. arg_msg = '更新罚款单相关应收帐ID失败'
  486. rslt = 0
  487. GOTO ext
  488. END IF
  489. END IF
  490. flag = 1
  491. ext:
  492. IF rslt = 0 THEN
  493. ROLLBACK;
  494. ELSEIF rslt = 1 AND arg_ifcommit THEN
  495. COMMIT;
  496. END IF
  497. DESTROY uo_pay
  498. RETURN rslt
  499. end function
  500. public function integer c_auditing (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);int rslt=1
  501. string str_dscrp
  502. datetime null_dt
  503. setnull(null_dt)
  504. uo_mustpay uo_pay
  505. uo_pay = create uo_mustpay
  506. if getinfo(arg_scid,arg_billid,arg_msg) = 0 then
  507. rslt = 0
  508. goto ext
  509. end if
  510. if flag = 0 then
  511. rslt = 0
  512. arg_msg = '单据还未审核,不可以撤审'
  513. goto ext
  514. end if
  515. if it_newbegin or it_updatebegin then
  516. rslt = 0
  517. arg_msg = "编辑状态下不可以执行审核"
  518. goto ext
  519. end if
  520. update u_spt_wfjg
  521. set auditingrep = '',
  522. auditingdate = :null_dt,
  523. flag = 0
  524. where u_spt_wfjg.billid = :arg_billid
  525. and flag = 1 and scid = :arg_scid;
  526. if sqlca.sqlcode <> 0 then
  527. rslt = 0
  528. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+sqlca.sqlerrtext
  529. goto ext
  530. elseif sqlca.sqlnrows = 0 then
  531. rslt = 0
  532. arg_msg = "单据正在撤消审核,请稍后查询。"+"~n"+sqlca.sqlerrtext
  533. goto ext
  534. end if
  535. if amt <> 0 then
  536. if uo_pay.del_payrec(scid,1,payid,sptid,arg_msg,false)=0 then
  537. rslt=0
  538. goto ext
  539. end if
  540. end if
  541. flag = 0
  542. ext:
  543. if rslt=0 then
  544. rollback;
  545. elseif rslt=1 and arg_ifcommit then
  546. commit;
  547. end if
  548. destroy uo_pay
  549. return rslt
  550. end function
  551. public function integer add_dscrp (long arg_scid, long arg_billid, string arg_newdescppart, ref string arg_msg);//add_dscrp(string arg_newdescppart)
  552. //0 fail 1 success
  553. int rslt=1
  554. arg_newdescppart=trim(arg_newdescppart)
  555. if it_updatebegin or it_newbegin then
  556. rslt=0
  557. arg_msg="编辑状态下不可用"
  558. goto ext
  559. end if
  560. if arg_newdescppart='' then
  561. rslt=0
  562. arg_msg="要添加内容为空,操作取消"
  563. goto ext
  564. end if
  565. rslt=getinfo(arg_scid,arg_billid,arg_msg)
  566. if rslt=0 then goto ext
  567. if flag=0 then
  568. rslt=0
  569. arg_msg="非审核状态下不可用"
  570. goto ext
  571. end if
  572. update u_spt_wfjg
  573. set dscrp = dscrp+' '+:arg_newdescppart
  574. where billid = :arg_billid
  575. and scid=:arg_scid;
  576. if sqlca.sqlcode<>0 then
  577. rollback ;
  578. rslt=0
  579. arg_msg="因网络或其它原因导致添加单据备注操作失败"+"~n"+sqlca.sqlerrtext
  580. goto ext
  581. end if
  582. commit ;
  583. dscrp = dscrp+' '+arg_newdescppart
  584. ext: return (rslt)
  585. end function
  586. on uo_spt_wfjg.create
  587. call super::create
  588. TriggerEvent( this, "constructor" )
  589. end on
  590. on uo_spt_wfjg.destroy
  591. TriggerEvent( this, "destructor" )
  592. call super::destroy
  593. end on