uo_incase.sru 26 KB

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