uo_incase.sru 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931
  1. $PBExportHeader$uo_incase.sru
  2. forward
  3. global type uo_incase from nonvisualobject
  4. end type
  5. type s_incasemx_array from structure within uo_incase
  6. end type
  7. type s_incasemx from structure within uo_incase
  8. end type
  9. end forward
  10. type s_incasemx from structure
  11. long mtrlid
  12. string mtrlstatus
  13. string pfcode
  14. string mtrlmode
  15. string packunit
  16. long printid
  17. decimal { 10 } qty
  18. decimal { 10 } packqty
  19. decimal { 10 } grossweight
  20. string mxdscrp
  21. decimal { 10 } netweight
  22. decimal { 10 } cubage
  23. integer ifson_flag
  24. long fathermtrlid
  25. string packsize
  26. string packcode
  27. decimal { 10 } price
  28. long relid
  29. long relprintid
  30. string relcode
  31. string mxdscrp2
  32. string mxdscrp3
  33. string status
  34. string woodcode
  35. string pcode
  36. decimal { 10 } onepackqty
  37. end type
  38. global type uo_incase from nonvisualobject
  39. end type
  40. global uo_incase uo_incase
  41. type variables
  42. PUBLIC PROTECTEDWRITE Long scid = 0
  43. PUBLIC PROTECTEDWRITE Long incaseID = 0
  44. PUBLIC PROTECTEDWRITE String incaseCode = ''
  45. PUBLIC PROTECTEDWRITE DateTime opdate
  46. PUBLIC PROTECTEDWRITE String operator = ''
  47. PUBLIC PROTECTEDWRITE String Permit_emp = ''//审核操作员
  48. public protectedwrite datetime moddate //修改时间,自动
  49. public protectedwrite string modemp //修改操作员
  50. public protectedwrite int flag=0 //审核标志
  51. public protectedwrite datetime auditingdate //审核时间
  52. Long relid = 0
  53. Long custID = 0
  54. String Assign_emp
  55. DateTime incasedate
  56. String dscrp
  57. string relcode
  58. string freight
  59. string freight_tele
  60. Transaction commit_transaction
  61. PRIVATE:
  62. s_incasemx incasemx[] //明细结构数组
  63. Long it_MXBT = 0 //明细结构数组末指针
  64. Boolean IT_NEWBEGIN = FALSE //新建标志
  65. Boolean IT_UPDATEBEGIN = FALSE//修改标志
  66. end variables
  67. forward prototypes
  68. public function integer p_reset ()
  69. public function integer p_clearmx ()
  70. public function integer newbegin (long arg_scid, ref string arg_msg)
  71. public function integer save (string arg_operator, ref string arg_msg, boolean arg_ifcommit)
  72. public function integer updatebegin (long arg_scid, long arg_incased, ref string arg_msg)
  73. public function integer p_getinfo (long arg_scid, long arg_incaseid, ref string arg_msg)
  74. public function integer cancel (long arg_scid, long arg_incaseid, ref string arg_msg, boolean arg_ifcommit)
  75. public function integer add_dscrp (long arg_scid, long arg_incaseid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit)
  76. public function integer audit (long arg_scid, long arg_incaseid, string arg_emp, ref string arg_msg, boolean arg_ifcommit)
  77. public function integer cancelaudit (long arg_scid, long arg_incaseid, ref string arg_msg, boolean arg_ifcommit)
  78. public function integer getinfo (integer arg_scid, long arg_incaseid, ref string arg_msg)
  79. public function integer acceptmx (long arg_mtrlid, string arg_mtrlstatus, string arg_pfcode, decimal arg_qty, decimal arg_price, string arg_packunit, string arg_packcode, string arg_packsize, string arg_mxdscrp, decimal arg_packqty, ref string arg_msg, long arg_printid, decimal arg_grossweight, decimal arg_netweight, decimal arg_cubage, integer arg_ifson_flag, integer arg_fathermtrlid, long arg_relid, long arg_relprintid, string arg_relcode, string arg_mxdscrp2, string arg_mxdscrp3, decimal arg_onepackqty, string arg_status, string arg_woodcode, string arg_pcode)
  80. end prototypes
  81. public function integer p_reset ();//INT p_RESET()
  82. //清除对象及其明细
  83. scid = 0
  84. incaseID = 0
  85. incaseCode = ''
  86. relid = 0
  87. custID = 0
  88. Assign_emp = ''
  89. dscrp = ''
  90. relcode = ''
  91. freight = ''
  92. freight_tele = ''
  93. it_newbegin=FALSE
  94. it_updatebegin=FALSE
  95. //清除明细
  96. P_CLEARMX()
  97. RETURN 1
  98. end function
  99. public function integer p_clearmx ();//INT p_clearmx()
  100. //清除明细
  101. it_mxbt=0
  102. RETURN 1
  103. end function
  104. public function integer newbegin (long arg_scid, ref string arg_msg);//重置对象,设定业务类型与关联ID,准备建立新单
  105. //0 fail 1 success
  106. long rslt=1,CNT=0
  107. if arg_scid < 0 then
  108. arg_msg = '请选择分部'
  109. rslt = 0
  110. goto ext
  111. end if
  112. p_reset()
  113. it_newbegin=TRUE
  114. it_updatebegin=FALSE
  115. scid=arg_scid
  116. ext:
  117. if rslt = 0 then p_reset()
  118. return rslt
  119. end function
  120. public function integer save (string arg_operator, ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1,cnt = 0,i
  121. DateTime server_dt
  122. Long ll_incaseid
  123. String ls_sccode
  124. IF IsNull(dscrp) THEN dscrp = ''
  125. IF IsNull(assign_emp) THEN assign_emp = ''
  126. IF IsNull(arg_operator) THEN arg_operator = ''
  127. //====================================================================
  128. // Script - save ( ref string arg_msg, boolean arg_ifcommit )
  129. // Reason:
  130. //--------------------------------------------------------------------
  131. // Modified By: yyx Date: 2004.02.20
  132. //--------------------------------------------------------------------
  133. //IF Len(dscrp) > 0 THEN dscrp = ' ' + dscrp
  134. //====================================================================
  135. operator = arg_operator
  136. IF it_newbegin = False And it_updatebegin = False THEN
  137. rslt = 0
  138. arG_MSG = "非编辑状态不可以提交"
  139. GOTO ext
  140. END IF
  141. IF Trim(assign_emp) = '' THEN
  142. rslt = 0
  143. arG_MSG = "请输入装箱单经手人"
  144. GOTO ext
  145. END IF
  146. cnt = 0
  147. SELECT count(*) INTO :cnt
  148. FROM u_cust
  149. Where cusid = :custID Using commit_transaction;
  150. IF commit_transaction.SQLCode <> 0 THEN
  151. rslt = 0
  152. arG_MSG = "查询操作失败,客户资料"
  153. GOTO ext
  154. END IF
  155. IF cnt = 0 THEN
  156. rslt = 0
  157. arG_MSG = "客户未定义或错误"
  158. GOTO ext
  159. END IF
  160. SELECT Top 1 getdate() Into :server_dt From u_user Using commit_transaction;
  161. //取得系统时间,借用操作员表
  162. IF commit_transaction.SQLCode <> 0 THEN
  163. rslt = 0
  164. arG_MSG = "查询操作失败,日期 "
  165. GOTO ext
  166. END IF
  167. IF Year(Date(incasedate)) < 2000 Or IsNull(incasedate) THEN
  168. rslt = 0
  169. arG_MSG = "缺少装箱发生时间或不合理"
  170. GOTO ext
  171. END IF
  172. IF DaysAfter(Date(String(server_dt,'yyyy-mm-dd')),Date(String(incasedate,'yyyy-mm-dd'))) > 30 THEN
  173. rslt = 0
  174. arG_MSG = '装箱单日期错误,日期不能超前系统日期'
  175. GOTO ext
  176. END IF
  177. IF DaysAfter(Date(String(incasedate,'yyyy-mm-dd')),Date(String(server_dt,'yyyy-mm-dd'))) > 30 THEN
  178. rslt = 0
  179. arG_MSG = '装箱单日期错误,日期不能落后系统日期'
  180. GOTO ext
  181. END IF
  182. IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
  183. rslt = 0
  184. arG_MSG = "没有正确装箱单单明细内容"
  185. GOTO ext
  186. END IF
  187. cnt = 0
  188. SELECT count(*) INTO :cnt
  189. FROM u_user
  190. Where username = :operator Using commit_transaction ;
  191. IF commit_transaction.SQLCode <> 0 THEN
  192. rslt = 0
  193. arG_MSG = "查询操作失败,操作员!"
  194. GOTO ext
  195. END IF
  196. IF cnt = 0 THEN
  197. rslt = 0
  198. arG_MSG = "操作员姓名未登记或已取消!"
  199. GOTO ext
  200. END IF
  201. opdate = server_dt //填写单据建立时间(最近修改时间)
  202. //////////////////////////////////////////////// //开始区分:新建/更新 处理
  203. IF incaseID = 0 THEN //新建
  204. ll_incaseid = f_sys_scidentity(scid,"u_incase","incaseid",arG_MSG,True,id_sqlca) //数据commit事务)
  205. IF ll_incaseid <= 0 THEN
  206. rslt = 0
  207. GOTO ext
  208. END IF
  209. IF f_get_sccode(scid,commit_transaction,ls_sccode,arG_MSG) = 0 THEN
  210. rslt = 0
  211. GOTO ext
  212. END IF
  213. incaseCode = getid(scid,ls_sccode + 'ZX',Date(server_dt),False,commit_transaction)
  214. IF incaseCode = "err" THEN
  215. incaseCode = ''
  216. rslt = 0
  217. arG_MSG = "无法获取装箱单编号"+"~n"+commit_transaction.SQLErrText
  218. GOTO ext
  219. END IF
  220. INSERT INTO u_incase
  221. ( scid,
  222. incaseid,
  223. incaseCode,
  224. cusID,
  225. incasedate,
  226. Assign_Emp,
  227. relcode,
  228. Dscrp,
  229. opemp,
  230. opdate,
  231. relid,
  232. freight,
  233. freight_tele
  234. )
  235. VALUES ( :scid,
  236. :ll_incaseid,
  237. :incaseCode,
  238. :custID,
  239. :incasedate,
  240. :Assign_Emp,
  241. :relcode,
  242. :Dscrp,
  243. :operator,
  244. :server_dt,
  245. :relid,
  246. :freight,
  247. :freight_tele) Using commit_transaction ;
  248. IF commit_transaction.SQLCode <> 0 THEN
  249. rslt = 0
  250. arG_MSG = "因网络或其它原因导致插入装箱单操作失败"+"~n"+commit_transaction.SQLErrText
  251. ROLLBACK Using commit_transaction;
  252. GOTO ext
  253. END IF
  254. //读取新incaseid
  255. incaseID = ll_incaseid
  256. ELSE //////////////////////////////////////////////// //更新
  257. UPDATE u_incase
  258. SET cusID = :custID,
  259. incasedate = :incasedate,
  260. Assign_Emp = :Assign_Emp,
  261. Dscrp = :Dscrp,
  262. moddate = getdate(),
  263. Modemp = :publ_operator,
  264. relcode = :relcode,
  265. freight = :freight,
  266. freight_tele = :freight_tele
  267. WHERE u_incase.incaseid = :incaseID
  268. AND scid = :scid
  269. And flag = 0 Using commit_transaction;
  270. IF commit_transaction.SQLCode <> 0 Or sqlca.SQLNRows <= 0 THEN
  271. rslt = 0
  272. arG_MSG = "因网络或其它原因导致更新装箱单操作失败"+"~n"+commit_transaction.SQLErrText
  273. ROLLBACK Using commit_transaction;
  274. GOTO ext
  275. END IF
  276. //删除原有明细
  277. DELETE FROM u_incasemx
  278. Where u_incasemx.incaseID = :incaseID And scid = :scid Using commit_transaction;
  279. IF commit_transaction.SQLCode <> 0 THEN
  280. rslt = 0
  281. arG_MSG = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  282. ROLLBACK Using commit_transaction;
  283. GOTO ext
  284. END IF
  285. END IF
  286. FOR i = 1 To it_mxbt
  287. INSERT INTO u_incasemx
  288. ( scid,
  289. incaseid,
  290. mtrlid,
  291. mtrlstatus,
  292. pfcode,
  293. printid,
  294. packunit,
  295. packcode,
  296. packsize,
  297. qty,
  298. packqty,
  299. grossweight,
  300. netweight,
  301. cubage,
  302. ifson_flag,
  303. fathermtrlid,
  304. mxdscrp,
  305. price,
  306. relid,
  307. relprintid,
  308. relcode,
  309. mxdscrp2,
  310. mxdscrp3,
  311. onepackqty,
  312. status,
  313. woodcode,
  314. pcode)
  315. VALUES (:scid,
  316. :incaseID,
  317. :incasemx[i].mtrlid,
  318. :incasemx[i].mtrlstatus,
  319. :incasemx[i].pfcode,
  320. :incasemx[i].printid,
  321. :incasemx[i].packunit ,
  322. :incasemx[i].packcode,
  323. :incasemx[i].packsize ,
  324. :incasemx[i].qty,
  325. :incasemx[i].packqty,
  326. :incasemx[i].grossweight,
  327. :incasemx[i].netweight,
  328. :incasemx[i].cubage,
  329. :incasemx[i].ifson_flag,
  330. :incasemx[i].fathermtrlid,
  331. :incasemx[i].mxdscrp,
  332. :incasemx[i].price,
  333. :incasemx[I].relid,
  334. :incasemx[I].relprintid,
  335. :incasemx[I].relcode,
  336. :incasemx[I].mxdscrp2,
  337. :incasemx[I].mxdscrp3,
  338. :incasemx[I].onepackqty,
  339. :incasemx[I].status,
  340. :incasemx[I].woodcode,
  341. :incasemx[I].pcode) Using commit_transaction;
  342. IF commit_transaction.SQLCode <> 0 THEN
  343. IF it_newbegin THEN incaseID = 0 //还原incaseID
  344. rslt = 0
  345. arG_MSG = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  346. //ROLLBACK USING commit_transaction;
  347. GOTO ext
  348. END IF
  349. NEXT
  350. it_newbegin = False
  351. it_updatebegin = False
  352. ext:
  353. IF rslt = 0 THEN
  354. p_clearmx()
  355. ROLLBACK Using commit_transaction;
  356. ELSEIF arg_ifcommit And rslt = 1 THEN
  357. COMMIT Using commit_transaction;
  358. END IF
  359. Return(rslt)
  360. end function
  361. public function integer updatebegin (long arg_scid, long arg_incased, ref string arg_msg);//UPDATEbegin(long arg_taskid,ref string arg_msg)
  362. //从置对象,设定业务类型与关联ID,准备更新进仓单
  363. //0 fail 1 success
  364. long rslt=1,CNT=0
  365. if arg_scid < 0 then
  366. arg_msg = '请选择分部'
  367. rslt = 0
  368. goto ext
  369. end if
  370. IF arg_incased<=0 THEN
  371. rslt=0
  372. ARG_MSG='错误装箱单唯一码'
  373. goto ext
  374. end if
  375. if p_getinfo(arg_scid,arg_incased,arg_msg)=0 then
  376. rslt=0
  377. goto ext
  378. end if
  379. if flag=1 then
  380. rslt=0
  381. ARG_MSG='已经处于审核状态,不可以修改,要修改请先撤销审核'
  382. goto ext
  383. end if
  384. it_newbegin=FALSE
  385. it_updatebegin=TRUE
  386. p_clearmx() //清除明细
  387. scid=arg_scid
  388. incaseID=arg_incased
  389. ext:
  390. if rslt=0 then p_reset()
  391. return rslt
  392. end function
  393. public function integer p_getinfo (long arg_scid, long arg_incaseid, ref string arg_msg);Int rslt = 1
  394. SELECT
  395. incaseid,
  396. incasecode,
  397. cusid,
  398. incasedate,
  399. assign_emp,
  400. relcode,
  401. dscrp,
  402. opemp,
  403. opdate,
  404. flag
  405. INTO :incaseid,
  406. :incasecode,
  407. :custid,
  408. :incasedate,
  409. :assign_emp,
  410. :relcode,
  411. :dscrp,
  412. :operator,
  413. :opdate,
  414. :flag
  415. FROM u_incase
  416. Where u_incase.incaseid = :arg_incaseid AND
  417. u_incase.scid = :arg_scid USING commit_transaction;
  418. IF commit_transaction.SQLCode <> 0 THEN
  419. rslt = 0
  420. ARG_MSG = '查询装箱单内容失败(错误订单唯一码)'+sqlca.sqlerrtext
  421. GOTO ext
  422. END IF
  423. scid = arg_scid
  424. incaseID= arg_incaseid
  425. ext:
  426. RETURN rslt
  427. end function
  428. public function integer cancel (long arg_scid, long arg_incaseid, ref string arg_msg, boolean arg_ifcommit);//删除未审核的装箱单
  429. //0 FAIL, 1 SUCCESS
  430. INT rslt=1
  431. IF arg_incaseid<=0 THEN
  432. rslt=0
  433. ARG_MSG='错误装箱单唯一码'
  434. goto ext
  435. end if
  436. if p_getinfo(arg_scid,arg_incaseid,arg_msg)=0 then
  437. rslt=0
  438. goto ext
  439. end if
  440. IF flag=1 THEN
  441. rslt=0
  442. arG_MSG="装箱单已经审核,不可以删除"
  443. goto ext
  444. END IF
  445. DELETE FROM u_incase
  446. WHERE u_incase.incaseid = :arg_incaseid and u_incase.scid=:arg_scid using commit_transaction;
  447. if commit_transaction.sqlcode<>0 then
  448. rslt=0
  449. arG_MSG="删除装箱单操作失败"+"~n"+commit_transaction.SQLErrText
  450. ROLLBACK using commit_transaction;
  451. goto ext
  452. end if
  453. DELETE FROM u_incasemx
  454. WHERE u_incasemx.incaseid = :arg_incaseid and u_incasemx.scid=:arg_scid using commit_transaction;
  455. if commit_transaction.sqlcode<>0 then
  456. rslt=0
  457. arG_MSG="删除装箱单明细操作失败"+"~n"+SQLCA.SQLErrText
  458. ROLLBACK using commit_transaction;
  459. goto ext
  460. end if
  461. it_newbegin=FALSE
  462. it_updatebegin=FALSE
  463. if arg_ifcommit then
  464. COMMIT using commit_transaction;
  465. end if
  466. EXT:
  467. p_reset()
  468. return (rslt)
  469. end function
  470. public function integer add_dscrp (long arg_scid, long arg_incaseid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit);//add_dscrp(string arg_newdescppart)
  471. //0 fail 1 SUCCESS
  472. INT rslt=1
  473. arg_newdescppart=TRIM(arg_newdescppart)
  474. IF it_updatebegin OR it_newbegin THEN
  475. rslt=0
  476. arG_MSG="编辑状态下不可用"
  477. goto ext
  478. END IF
  479. IF arg_newdescppart='' THEN
  480. rslt=0
  481. arG_MSG="要添加内容为空,操作取消"
  482. goto ext
  483. END IF
  484. if p_getinfo(arg_scid,arg_incaseid,arg_msg)=0 then
  485. rslt=0
  486. goto ext
  487. end if
  488. IF flag=0 THEN
  489. rslt=0
  490. arG_MSG="待审核状态下不可用"
  491. goto ext
  492. END IF
  493. UPDATE u_incase
  494. SET DSCRP = DSCRP+' '+:arg_newdescppart
  495. WHERE u_incase.incaseid = :arg_incaseid using commit_transaction;
  496. if commit_transaction.SQLCode<>0 then
  497. rslt=0
  498. arG_MSG="因网络或其它原因导致添加装箱单备注操作失败"+"~n"+commit_transaction.SQLErrText
  499. rollback using commit_transaction;
  500. goto ext
  501. end if
  502. DSCRP = DSCRP+' '+arg_newdescppart
  503. it_newbegin=FALSE
  504. it_updatebegin=FALSE
  505. EXT:
  506. if arg_ifcommit and rslt=1 then
  507. COMMIT using commit_transaction;
  508. end if
  509. p_reset()
  510. return (rslt)
  511. end function
  512. public function integer audit (long arg_scid, long arg_incaseid, string arg_emp, ref string arg_msg, boolean arg_ifcommit);
  513. Int rslt = 1,cnt = 0
  514. IF arg_incaseid <= 0 THEN
  515. rslt = 0
  516. ARG_MSG = '错误装箱单唯一码'
  517. GOTO ext
  518. END IF
  519. IF getinfo(arg_scid,arg_incaseid,ARG_MSG) = 0 THEN
  520. rslt = 0
  521. GOTO ext
  522. END IF
  523. IF flag = 1 THEN
  524. rslt = 0
  525. ARG_MSG = "装箱单已经审核,操作取消"
  526. GOTO ext
  527. END IF
  528. IF it_MXBT <= 0 THEN
  529. rslt = 0
  530. ARG_MSG = "装箱单明细错误,操作取消"
  531. GOTO ext
  532. END IF
  533. cnt = 0
  534. SELECT count(*) INTO :cnt
  535. FROM u_user
  536. Where username = :arg_emp USING commit_transaction;
  537. IF commit_transaction.SQLCode <> 0 THEN
  538. rslt = 0
  539. ARG_MSG = "查询操作失败,操作员!"
  540. GOTO ext
  541. END IF
  542. IF cnt = 0 THEN
  543. rslt = 0
  544. ARG_MSG = "操作员姓名未登记或已取消!"
  545. GOTO ext
  546. END IF
  547. //更新审核标记
  548. UPDATE u_incase
  549. SET auditingrep = :arg_emp, auditingdate = getdate(),
  550. flag = 1
  551. Where u_incase.incaseid = :arg_incaseid AND u_incase.scid = :arg_scid AND u_incase.flag = 0 USING commit_transaction;
  552. IF commit_transaction.SQLCode <> 0 THEN
  553. rslt = 0
  554. ARG_MSG = "因网络或其它原因导致单据审核操作失败"+"~n"+commit_transaction.SQLErrText
  555. GOTO ext
  556. END IF
  557. it_newbegin = FALSE
  558. it_updatebegin = FALSE
  559. ext:
  560. IF rslt = 0 THEN
  561. ROLLBACK USING commit_transaction;
  562. ELSEIF arg_ifcommit THEN
  563. COMMIT USING commit_transaction;
  564. END IF
  565. p_reset()
  566. Return (rslt)
  567. end function
  568. public function integer cancelaudit (long arg_scid, long arg_incaseid, ref string arg_msg, boolean arg_ifcommit);INT rslt=1,cnt=0
  569. datetime ls_auditingdate
  570. setnull(ls_auditingdate)
  571. IF arg_incaseid<=0 THEN
  572. rslt=0
  573. ARG_MSG='错误装箱单唯一码'
  574. goto ext
  575. end if
  576. if p_getinfo(arg_scid,arg_incaseid,arg_msg)=0 then
  577. rslt=0
  578. goto ext
  579. end if
  580. IF flag = 0 THEN
  581. rslt=0
  582. arG_MSG="装箱只有在已审核状态才可以执行撤消审核,请核对"
  583. goto ext
  584. END IF
  585. UPDATE u_incase
  586. SET flag = 0,auditingrep='',auditingdate=:ls_auditingdate
  587. WHERE u_incase.incaseid = :arg_incaseid and u_incase.scid=:arg_scid and u_incase.flag=1 using commit_transaction ;
  588. if commit_transaction.sqlcode<>0 then
  589. rslt=0
  590. arG_MSG="因网络或其它原因导致装箱单撤消审核操作失败"+"~n"+commit_transaction.SQLErrText
  591. goto ext
  592. end if
  593. it_newbegin=FALSE
  594. it_updatebegin=FALSE
  595. EXT:
  596. if rslt=0 then
  597. rollback using commit_transaction;
  598. elseif arg_ifcommit then
  599. COMMIT using commit_transaction;
  600. end if
  601. p_reset()
  602. return (rslt)
  603. end function
  604. public function integer getinfo (integer arg_scid, long arg_incaseid, ref string arg_msg);//getinfo(long arg_taskid,string arg_msg)
  605. //0 失败 1成功
  606. Int rslt = 1,I = 1,NO_MXCHECK = 0
  607. IF arg_incaseid <= 0 THEN
  608. rslt = 0
  609. ARG_MSG = '错误采购订单唯一码'
  610. GOTO ext
  611. END IF
  612. IF p_getinfo(arg_scid,arg_incaseid,ARG_MSG) = 0 THEN
  613. rslt = 0
  614. GOTO ext
  615. END IF
  616. //用游标读取明细
  617. DECLARE CUR_INCASEMX CURSOR FOR
  618. SELECT
  619. mtrlid,
  620. mtrlstatus,
  621. printid,
  622. packunit,
  623. pfcode,
  624. packcode,
  625. packsize,
  626. qty,
  627. packqty,
  628. grossweight,
  629. netweight,
  630. cubage,
  631. ifson_flag,
  632. fathermtrlid,
  633. mxDscrp,
  634. price,
  635. relid,
  636. relprintid,
  637. relcode
  638. FROM u_incasemx
  639. WHERE u_incasemx.INCASEid = :arg_incaseid AND
  640. u_incasemx.scid = :arg_scid
  641. order by u_incasemx.printid USING commit_transaction;
  642. OPEN CUR_INCASEMX;
  643. FETCH CUR_INCASEMX INTO :incasemx[I].mtrlid,:incasemx[I].mtrlstatus,:incasemx[I].printid,
  644. :incasemx[I].packunit,:incasemx[I].pfcode,
  645. :incasemx[I].packcode,:incasemx[I].packsize,:incasemx[I].qty,
  646. :incasemx[I].packqty,:incasemx[I].grossweight,:incasemx[I].netweight,
  647. :incasemx[I].cubage,:incasemx[I].ifson_flag,:incasemx[I].fathermtrlid,:incasemx[I].mxDscrp,
  648. :incasemx[I].price,:incasemx[I].relid,:incasemx[I].relprintid,:incasemx[I].relcode;
  649. DO WHILE commit_transaction.SQLCode = 0
  650. I++
  651. FETCH CUR_INCASEMX INTO :incasemx[I].mtrlid,:incasemx[I].mtrlstatus,:incasemx[I].printid,
  652. :incasemx[I].packunit,:incasemx[I].pfcode,
  653. :incasemx[I].packcode,:incasemx[I].packsize,:incasemx[I].qty,
  654. :incasemx[I].packqty,:incasemx[I].grossweight,:incasemx[I].netweight,
  655. :incasemx[I].cubage,:incasemx[I].ifson_flag,:incasemx[I].fathermtrlid,:incasemx[I].mxDscrp,
  656. :incasemx[I].price,:incasemx[I].relid,:incasemx[I].relprintid,:incasemx[I].relcode;
  657. LOOP
  658. CLOSE CUR_INCASEMX;
  659. //检验明细是否读入完整
  660. SELECT COUNT(*) INTO :NO_MXCHECK
  661. FROM u_incasemx
  662. WHERE u_incasemx.incaseid = :arg_incaseid AND
  663. u_incasemx.scid = :arg_scid USING commit_transaction;
  664. IF commit_transaction.SQLCode <> 0 THEN
  665. rslt = 0
  666. ARG_MSG = "查询操作失败,装箱单明细数量"
  667. GOTO ext
  668. END IF
  669. IF I <> (NO_MXCHECK+1) THEN
  670. rslt = 0
  671. ARG_MSG = "查询操作失败,装箱单明细"
  672. GOTO ext
  673. END IF
  674. it_mxbt = I - 1
  675. it_newbegin = FALSE
  676. it_updatebegin = FALSE
  677. ext:
  678. IF rslt = 0 THEN p_reset()
  679. RETURN rslt
  680. end function
  681. public function integer acceptmx (long arg_mtrlid, string arg_mtrlstatus, string arg_pfcode, decimal arg_qty, decimal arg_price, string arg_packunit, string arg_packcode, string arg_packsize, string arg_mxdscrp, decimal arg_packqty, ref string arg_msg, long arg_printid, decimal arg_grossweight, decimal arg_netweight, decimal arg_cubage, integer arg_ifson_flag, integer arg_fathermtrlid, long arg_relid, long arg_relprintid, string arg_relcode, string arg_mxdscrp2, string arg_mxdscrp3, decimal arg_onepackqty, string arg_status, string arg_woodcode, string arg_pcode);Long rslt = 1,cnt = 0,LS_i
  682. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  683. rslt = 0
  684. arG_MSG = "非编辑状态不可以使用,操作取消"
  685. GOTO ext
  686. END IF
  687. //清除空值
  688. IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
  689. IF IsNull(arg_fathermtrlid) THEN arg_fathermtrlid = 0
  690. IF IsNull(arg_qty) THEN arg_qty = 0
  691. IF IsNull(arg_price) THEN arg_qty = 0
  692. IF IsNull(arg_packqty) THEN arg_packqty = 0
  693. IF IsNull(arg_mtrlstatus) THEN arg_mtrlstatus = ''
  694. IF IsNull(arg_packunit) THEN arg_packunit = ''
  695. IF IsNull(arg_packcode) THEN arg_packcode = ''
  696. IF IsNull(arg_packsize) THEN arg_packsize = ''
  697. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  698. IF IsNull(arg_ifson_flag) THEN arg_ifson_flag = 0
  699. IF IsNull(arg_grossweight) THEN arg_grossweight = 0
  700. IF IsNull(arg_netweight) THEN arg_netweight = 0
  701. IF IsNull(arg_cubage) THEN arg_cubage = 0
  702. IF IsNull(arg_printid) THEN arg_printid = 0
  703. IF IsNull(arg_pfcode) THEN arg_pfcode = ''
  704. IF IsNull(arg_relid) THEN arg_relid = 0
  705. IF IsNull(arg_relprintid) THEN arg_relprintid = 0
  706. IF IsNull(arg_relcode) THEN arg_relcode = ''
  707. IF IsNull(arg_mxdscrp2) THEN arg_mxdscrp2 = ''
  708. IF IsNull(arg_mxdscrp3) THEN arg_mxdscrp3 = ''
  709. IF IsNull(arg_status) THEN arg_status = ''
  710. IF IsNull(arg_woodcode) THEN arg_woodcode = ''
  711. IF IsNull(arg_pcode) THEN arg_pcode = ''
  712. IF IsNull(arg_onepackqty) THEN arg_onepackqty = 0
  713. IF arg_mtrlid = 0 THEN // 如果物料编号为空,则不作任何处理
  714. rslt = 1
  715. GOTO ext
  716. END IF
  717. IF arg_printid = 0 THEN // 如果序号为空,则不作任何处理
  718. rslt = 1
  719. GOTO ext
  720. END IF
  721. ////检查物料ID
  722. //SELECT COUNT(*)
  723. // INTO :cnt
  724. // FROM u_mtrldef
  725. // Where u_mtrldef.mtrlid = :arg_mtrlid ;
  726. //IF sqlca.SQLCode <> 0 THEN
  727. // rslt = 0
  728. // arG_MSG = "查询操作失败,物料编号"
  729. // GOTO ext
  730. //END IF
  731. //
  732. //IF cnt = 0 THEN
  733. // rslt = 0
  734. // arG_MSG = "错误的构成配方: "+String(arg_mtrlstatus)
  735. // GOTO ext
  736. //END IF
  737. //
  738. ////检查配方
  739. //if arg_ifson_flag=1 then
  740. // cnt=0
  741. // select count(*)
  742. // into :cnt
  743. // from u_prdpf
  744. // where u_prdpf.mtrlid=:arg_fathermtrlid and u_prdpf.sonmtrlid=:arg_mtrlid;
  745. // IF sqlca.SQLCode <> 0 THEN
  746. // rslt = 0
  747. // arG_MSG = "查询操作失败,配方"
  748. // GOTO ext
  749. // END IF
  750. // IF cnt = 0 THEN
  751. // rslt = 0
  752. // arG_MSG = "错误的配方: "+string(arg_pfcode)+String(arg_mtrlstatus)
  753. // GOTO ext
  754. // END IF
  755. //end if
  756. //FOR LS_i = 1 TO it_mxbt //合并重复项(产品)
  757. // IF incasemx[it_mxbt].mtrlid = arg_mtrlid AND &
  758. // incasemx[it_mxbt].ifson_flag = arg_ifson_flag AND &
  759. // arg_ifson_flag = 0 THEN
  760. // rslt = 0
  761. // arG_MSG = "存在相同的产品,在"+incasemx[it_mxbt].mtrlstatus+",请自行手动合并"
  762. // GOTO ext
  763. // END IF
  764. //NEXT
  765. //写入内容
  766. it_mxbt++
  767. incasemx[it_mxbt].mtrlid = arg_mtrlid
  768. incasemx[it_mxbt].mtrlstatus = arg_mtrlstatus
  769. incasemx[it_mxbt].pfcode = arg_pfcode
  770. incasemx[it_mxbt].Qty = arg_qty
  771. incasemx[it_mxbt].packunit = arg_packunit
  772. incasemx[it_mxbt].packcode = arg_packcode
  773. incasemx[it_mxbt].packsize = arg_packsize
  774. incasemx[it_mxbt].mxdscrp = arg_mxdscrp
  775. incasemx[it_mxbt].packqty = arg_packqty
  776. incasemx[it_mxbt].printid = arg_printid
  777. incasemx[it_mxbt].grossweight = arg_grossweight
  778. incasemx[it_mxbt].netweight = arg_netweight
  779. incasemx[it_mxbt].cubage = arg_cubage
  780. incasemx[it_mxbt].ifson_flag = arg_ifson_flag
  781. incasemx[it_mxbt].fathermtrlid = arg_fathermtrlid
  782. incasemx[it_mxbt].price = arg_price
  783. incasemx[it_mxbt].relid = arg_relid
  784. incasemx[it_mxbt].relprintid = arg_relprintid
  785. incasemx[it_mxbt].relcode = arg_relcode
  786. incasemx[it_mxbt].mxdscrp2 = arg_mxdscrp2
  787. incasemx[it_mxbt].mxdscrp3 = arg_mxdscrp3
  788. incasemx[it_mxbt].onepackqty = arg_onepackqty
  789. incasemx[it_mxbt].status = arg_status
  790. incasemx[it_mxbt].woodcode = arg_woodcode
  791. incasemx[it_mxbt].pcode = arg_pcode
  792. ext:
  793. IF rslt = 0 THEN p_clearmx()
  794. Return(rslt)
  795. end function
  796. on uo_incase.create
  797. call super::create
  798. TriggerEvent( this, "constructor" )
  799. end on
  800. on uo_incase.destroy
  801. TriggerEvent( this, "destructor" )
  802. call super::destroy
  803. end on