uo_abnormity_bill.sru 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. $PBExportHeader$uo_abnormity_bill.sru
  2. forward
  3. global type uo_abnormity_bill from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_abnormity_bill from nonvisualobject
  7. end type
  8. global uo_abnormity_bill uo_abnormity_bill
  9. type variables
  10. public protectedwrite long billid //自动增量id
  11. public protectedwrite string billcode //唯一编号
  12. public protectedwrite datetime opdate //建立时间,自动
  13. public protectedwrite string opemp //建立人
  14. public protectedwrite datetime moddate //修改时间,自动
  15. public protectedwrite string modemp //修改人
  16. public protectedwrite int flag=0 //审核标志
  17. public protectedwrite datetime auditingdate //审核时间
  18. public protectedwrite string auditingrep //审核操作员
  19. datetime billdate
  20. string dutydept
  21. string dutyrep
  22. string dutyreason
  23. decimal empwage
  24. decimal mtrlwage
  25. string workdept
  26. long itemid
  27. private:
  28. boolean it_newbegin=false //新建标志
  29. boolean it_updatebegin=false//修改标志
  30. end variables
  31. forward prototypes
  32. public function integer p_reset ()
  33. public function integer newbegin (ref string arg_msg)
  34. public function integer updatebegin (long arg_billid, ref string arg_msg)
  35. public function integer save (ref string arg_msg, boolean arg_ifcommit)
  36. public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg)
  37. private function integer p_getinfo (long arg_billid, ref string arg_msg)
  38. public function integer auditing (long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  39. public function integer c_auditing (long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  40. public function integer del (long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  41. end prototypes
  42. public function integer p_reset ();//INT p_RESET()
  43. //清除对象及其明细
  44. billid=0
  45. billcode=''
  46. opemp=''
  47. auditingrep=''
  48. flag=0
  49. dutydept=''
  50. dutyrep=''
  51. dutyreason=''
  52. empwage=0
  53. mtrlwage=0
  54. workdept=''
  55. itemid=0
  56. it_newbegin=FALSE
  57. it_updatebegin=FALSE
  58. RETURN 1
  59. end function
  60. public function integer newbegin (ref string arg_msg);p_reset()
  61. it_newbegin=TRUE
  62. it_updatebegin=FALSE
  63. return 1
  64. end function
  65. public function integer updatebegin (long arg_billid, ref string arg_msg);//====================================================================
  66. // Function: updatebegin(arg_billid,arg_msg)
  67. //--------------------------------------------------------------------
  68. // Description:
  69. //--------------------------------------------------------------------
  70. // Arguments:
  71. // value long arg_billid
  72. // reference string arg_msg
  73. //--------------------------------------------------------------------
  74. // Returns: integer
  75. //--------------------------------------------------------------------
  76. // Author: yyx Date: 2003.11.21
  77. //--------------------------------------------------------------------
  78. // Modify History:
  79. //
  80. //====================================================================
  81. int rslt = 1
  82. if arg_billid <= 0 then
  83. billid = 0
  84. arg_msg = '错误的单据ID'
  85. goto ext
  86. end if
  87. if p_getinfo(arg_billid,arg_msg) = 0 then
  88. rslt = 0
  89. goto ext
  90. end if
  91. if flag = 1 then
  92. rslt = 0
  93. arg_msg = '单据已经审核,不可以修改'
  94. goto ext
  95. end if
  96. billid = arg_billid
  97. it_newbegin = false
  98. it_updatebegin = true
  99. ext:
  100. if rslt = 0 then p_reset()
  101. return rslt
  102. end function
  103. public function integer save (ref string arg_msg, boolean arg_ifcommit);//====================================================================
  104. // Function: save(arg_msg,arg_ifcommit)
  105. //--------------------------------------------------------------------
  106. // Description:
  107. //--------------------------------------------------------------------
  108. // Arguments:
  109. // reference string arg_msg
  110. // value boolean arg_ifcommit
  111. //--------------------------------------------------------------------
  112. // Returns: integer
  113. //--------------------------------------------------------------------
  114. // Author: yyx Date: 2003.11.21
  115. //--------------------------------------------------------------------
  116. // Modify History:
  117. //
  118. //====================================================================
  119. integer rslt = 1,i
  120. datetime server_dt
  121. long ls_newid,cnt
  122. if isnull(dutydept) then dutydept = ''
  123. if isnull(dutyrep) then dutyrep = ''
  124. if isnull(dutyreason) then dutyreason = ''
  125. if isnull(empwage) then empwage = 0.00
  126. if isnull(mtrlwage) then mtrlwage = 0.00
  127. if isnull(itemid) then itemid = 0
  128. if it_newbegin = false and it_updatebegin = false then
  129. rslt = 0
  130. arg_msg = "非编辑状态不可以提交"
  131. goto ext
  132. end if
  133. select top 1 getdate() into :server_dt from u_user;
  134. //取得系统时间,借用操作员表
  135. if sqlca.sqlcode <> 0 then
  136. rslt = 0
  137. arg_msg = "查询操作失败,日期 "
  138. goto ext
  139. end if
  140. //IF f_check_inoutdate(0,billdate,FALSE,arG_MSG) = 0 THEN
  141. // rslt = 0
  142. // GOTO ext
  143. //END IF
  144. //
  145. select count(*) into :cnt
  146. from u_sc_abnormity_bill_item
  147. where itemid = :itemid;
  148. if sqlca.sqlcode <> 0 then
  149. arg_msg = '查询返工返修项目资料失败'
  150. rslt = 0
  151. goto ext
  152. end if
  153. if cnt = 0 then
  154. arg_msg = '系统不存在项目资料'
  155. rslt = 0
  156. goto ext
  157. end if
  158. ////////////////////////////////////////////////开始区分:新建/更新 处理
  159. if billid = 0 then //新建
  160. ls_newid = f_sys_scidentity(0,"u_sc_abnormity_bill","billid",arg_msg,TRUE,id_sqlca)
  161. if ls_newid <= 0 then
  162. rslt = 0
  163. goto ext
  164. end if
  165. billcode = getid(0,"FG",date(server_dt),true,sqlca) //取得新单据编号
  166. if billcode = "err" then
  167. billcode = ''
  168. rslt = 0
  169. arg_msg = "无法获取返工返修赔偿单编号"
  170. goto ext
  171. end if
  172. insert into u_sc_abnormity_bill (
  173. billid,
  174. billcode,
  175. billdate,
  176. dutydept,
  177. dutyrep,
  178. dutyreason,
  179. empwage,
  180. mtrlwage,
  181. workdept,
  182. opdate,
  183. opemp,
  184. itemid)
  185. values (
  186. :ls_newid,
  187. :billcode,
  188. :billdate,
  189. :dutydept,
  190. :dutyrep,
  191. :dutyreason,
  192. :empwage,
  193. :mtrlwage,
  194. :workdept,
  195. :server_dt,
  196. :publ_operator,
  197. :itemid);
  198. if sqlca.sqlcode <> 0 then
  199. rslt = 0
  200. arg_msg = "因网络或其它原因导致插入操作失败>>"+"~n"+sqlca.sqlerrtext
  201. goto ext
  202. end if
  203. billid = ls_newid
  204. else //////////////////////////////////////////////////更新
  205. update u_sc_abnormity_bill
  206. set billdate = :billdate,
  207. dutydept = :dutydept,
  208. dutyrep = :dutyrep,
  209. dutyreason = :dutyreason,
  210. empwage = :empwage,
  211. mtrlwage = :mtrlwage,
  212. workdept = :workdept,
  213. moddate = :server_dt,
  214. modemp = :modemp,
  215. itemid = :itemid
  216. where u_sc_abnormity_bill.billid = :billid
  217. and flag = 0;
  218. if sqlca.sqlcode <> 0 or sqlca.sqlnrows <= 0 then
  219. rslt = 0
  220. arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+sqlca.sqlerrtext
  221. goto ext
  222. end if
  223. end if
  224. it_newbegin = false
  225. it_updatebegin = false
  226. ext:
  227. if rslt = 0 then
  228. rollback;
  229. elseif rslt=1 and arg_ifcommit then
  230. commit;
  231. end if
  232. return(rslt)
  233. end function
  234. public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg);int rslt = 1
  235. arg_newdescppart = trim(arg_newdescppart)
  236. if arg_billid <= 0 then
  237. rslt = 0
  238. arg_msg = "没有删除对象,操作取消"
  239. goto ext
  240. end if
  241. if it_newbegin or it_updatebegin then
  242. rslt=0
  243. arg_msg="编辑状态下不可以执行,操作取消"
  244. goto ext
  245. end if
  246. if p_getinfo(arg_billid,arg_msg) = 0 then
  247. rslt = 0
  248. goto ext
  249. end if
  250. if flag = 0 then
  251. rslt = 0
  252. arg_msg = "非审核状态下不可用"
  253. goto ext
  254. end if
  255. update u_sc_abnormity_bill
  256. set dutyreason = dutyreason+' '+:arg_newdescppart
  257. where u_sc_abnormity_bill.billid = :billid;
  258. if sqlca.sqlcode <> 0 then
  259. rollback ;
  260. rslt = 0
  261. arg_msg = "因网络或其它原因导致添加单据备注操作失败"+"~n"+sqlca.sqlerrtext
  262. goto ext
  263. end if
  264. commit;
  265. dutyreason = dutyreason+' '+arg_newdescppart
  266. ext:
  267. return (rslt)
  268. end function
  269. private function integer p_getinfo (long arg_billid, ref string arg_msg);//====================================================================
  270. // Function: p_getinfo()
  271. //--------------------------------------------------------------------
  272. // Description:
  273. //--------------------------------------------------------------------
  274. // Arguments:
  275. // value long arg_billid
  276. // reference string arg_msg
  277. //--------------------------------------------------------------------
  278. // Returns: integer
  279. //--------------------------------------------------------------------
  280. // Author: yyx Date: 2004.11.22
  281. //--------------------------------------------------------------------
  282. // Modify History:
  283. //
  284. //====================================================================
  285. INT rslt=1
  286. IF arg_billid<=0 THEN
  287. rslt=0
  288. arG_MSG="非法单据唯一码"
  289. goto ext
  290. end if
  291. select
  292. u_sc_abnormity_bill.billcode,
  293. u_sc_abnormity_bill.billdate,
  294. u_sc_abnormity_bill.dutydept,
  295. u_sc_abnormity_bill.dutyrep,
  296. u_sc_abnormity_bill.dutyreason,
  297. u_sc_abnormity_bill.empwage,
  298. u_sc_abnormity_bill.mtrlwage,
  299. u_sc_abnormity_bill.flag,
  300. u_sc_abnormity_bill.workdept,
  301. u_sc_abnormity_bill.itemid
  302. into
  303. :billcode,
  304. :billdate,
  305. :dutydept,
  306. :dutyrep,
  307. :dutyreason,
  308. :empwage,
  309. :mtrlwage,
  310. :flag,
  311. :workdept,
  312. :itemid
  313. from u_sc_abnormity_bill
  314. where u_sc_abnormity_bill.billid = :arg_billid;
  315. if sqlca.sqlcode <> 0 then
  316. rslt = 0
  317. arg_msg = '查询数据操作失败,返工返修赔偿单'+sqlca.sqlerrtext
  318. goto ext
  319. end if
  320. billid = arg_billid
  321. ext:
  322. IF rslt=0 THEN p_reset()
  323. return rslt
  324. end function
  325. public function integer auditing (long arg_billid, ref string arg_msg, boolean arg_ifcommit);int rslt=1
  326. if arg_billid <= 0 then
  327. rslt = 0
  328. arg_msg = "没有删除对象,操作取消"
  329. goto ext
  330. end if
  331. if p_getinfo(arg_billid,arg_msg) = 0 then
  332. rslt = 0
  333. goto ext
  334. end if
  335. if flag = 1 then
  336. rslt = 0
  337. arg_msg = "单据已审核"
  338. goto ext
  339. end if
  340. update u_sc_abnormity_bill set
  341. flag=1,
  342. auditrep=:publ_operator,
  343. Auditdate=getdate()
  344. where billid = :arg_billid
  345. and flag = 0;
  346. if sqlca.sqlcode<>0 or sqlca.sqlnrows = 0 then
  347. ARG_msg='审核返工返修赔偿单失败,原因>>'+sqlca.sqlerrtext
  348. rslt=0
  349. goto ext
  350. end if
  351. ext:
  352. if rslt=0 then
  353. rollback;
  354. elseif rslt=1 and arg_ifcommit then
  355. commit;
  356. end if
  357. return rslt
  358. end function
  359. public function integer c_auditing (long arg_billid, ref string arg_msg, boolean arg_ifcommit);
  360. int rslt=1
  361. long cnt = 0
  362. datetime null_dt
  363. setnull(null_dt)
  364. if arg_billid <= 0 then
  365. rslt = 0
  366. arg_msg = "没有删除对象,操作取消"
  367. goto ext
  368. end if
  369. if p_getinfo(arg_billid,arg_msg) = 0 then
  370. rslt = 0
  371. goto ext
  372. end if
  373. if flag = 0 then
  374. rslt = 0
  375. arg_msg = "单据还未审核"
  376. goto ext
  377. end if
  378. select count(*) into :cnt
  379. from u_sc_abnormity
  380. where relid = :arg_billid;
  381. if sqlca.sqlcode <> 0 then
  382. arg_msg = '查询返工返修单是否有异常计件单失败,不能撤审'
  383. rslt = 0
  384. goto ext
  385. end if
  386. if cnt > 0 then
  387. arg_msg = '返工返修单已有异常计件单,不能撤审'
  388. rslt = 0
  389. goto ext
  390. end if
  391. update u_sc_abnormity_bill set
  392. flag = 0,
  393. auditrep='',
  394. Auditdate=:null_dt
  395. where billid = :arg_billid
  396. and flag = 1;
  397. if sqlca.sqlcode<>0 or sqlca.sqlnrows = 0 then
  398. ARG_msg='审核返工返修赔偿单失败,原因>>'+sqlca.sqlerrtext
  399. rslt=0
  400. goto ext
  401. end if
  402. ext:
  403. if rslt=0 then
  404. rollback;
  405. elseif rslt=1 and arg_ifcommit then
  406. commit;
  407. end if
  408. return rslt
  409. end function
  410. public function integer del (long arg_billid, ref string arg_msg, boolean arg_ifcommit);//====================================================================
  411. // Function: del(arg_billid,arg_msg)
  412. //--------------------------------------------------------------------
  413. // Description:
  414. //--------------------------------------------------------------------
  415. // Arguments:
  416. // value long arg_billid
  417. // reference string arg_msg
  418. //--------------------------------------------------------------------
  419. // Returns: integer
  420. //--------------------------------------------------------------------
  421. // Author: yyx Date: 2003.11.21
  422. //--------------------------------------------------------------------
  423. // Modify History:
  424. //
  425. //====================================================================
  426. int rslt = 1
  427. long cnt = 0
  428. if arg_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 p_getinfo(arg_billid,arg_msg) = 0 then
  439. rslt = 0
  440. goto ext
  441. end if
  442. if flag = 1 then
  443. rslt = 0
  444. arg_msg = "单据已经审核,不可以删除"
  445. goto ext
  446. end if
  447. //***检查异常工资单
  448. select count(*) into :cnt
  449. from u_sc_abnormity
  450. where relid = :arg_billid;
  451. if sqlca.sqlcode <> 0 then
  452. arg_msg = '查询返工返修赔偿单是否已存在异常计件单失败'
  453. rslt = 0
  454. goto ext
  455. end if
  456. if cnt > 0 then
  457. arg_msg = '单据已有异常计件单,不能删除'
  458. rslt = 0
  459. goto ext
  460. end if
  461. //***
  462. delete from u_sc_abnormity_bill
  463. where u_sc_abnormity_bill.billid = :arg_billid
  464. and u_sc_abnormity_bill.flag = 0;
  465. if sqlca.sqlcode <> 0 or sqlca.sqlnrows = 0 then
  466. rslt = 0
  467. arg_msg = "删除返工返修赔偿单操作失败"+"~n"+sqlca.sqlerrtext
  468. goto ext
  469. end if
  470. ext:
  471. IF rslt = 0 THEN
  472. ROLLBACK ;
  473. p_reset()
  474. ELSEIF rslt = 1 AND arg_ifcommit THEN
  475. COMMIT ;
  476. END IF
  477. Return (rslt)
  478. end function
  479. on uo_abnormity_bill.create
  480. call super::create
  481. TriggerEvent( this, "constructor" )
  482. end on
  483. on uo_abnormity_bill.destroy
  484. TriggerEvent( this, "destructor" )
  485. call super::destroy
  486. end on