uo_mtrlware_pzcode_trans.sru 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. $PBExportHeader$uo_mtrlware_pzcode_trans.sru
  2. forward
  3. global type uo_mtrlware_pzcode_trans from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_mtrlware_pzcode_trans from nonvisualobject
  7. end type
  8. global uo_mtrlware_pzcode_trans uo_mtrlware_pzcode_trans
  9. type variables
  10. Long uo_billid
  11. end variables
  12. forward prototypes
  13. public function integer updatebegin (long arg_billid, ref string arg_msg)
  14. public function integer caudit (long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  15. public function integer audit (long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
  16. public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg)
  17. public function integer del (long arg_billid, integer arg_chk_auto, ref string arg_msg, boolean arg_ifcommit)
  18. public function integer p_getinfo (long arg_billid, ref s_mtrlware_pzcode_trans arg_s_trans, ref string arg_msg)
  19. public function integer save (s_mtrlware_pzcode_trans arg_s_trans, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
  20. public function integer getinfo (long arg_billid, ref s_mtrlware_pzcode_trans arg_ref_s_trans, ref long arg_arr_cnt, ref string arg_msg)
  21. public function integer uof_update_waredate (long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  22. end prototypes
  23. public function integer updatebegin (long arg_billid, ref string arg_msg);Int rslt = 1
  24. s_mtrlware_pzcode_trans arg_s_trans
  25. IF arg_billid <= 0 THEN
  26. rslt = 0
  27. ARG_MSG = '错误单据唯一码'
  28. GOTO ext
  29. END IF
  30. IF p_getinfo(arg_billid,arg_s_trans,ARG_MSG) = 0 THEN
  31. rslt = 0
  32. GOTO ext
  33. END IF
  34. IF arg_s_trans.flag = 1 THEN
  35. rslt = 0
  36. ARG_MSG = '单据已经审核,不可以修改,要修改请先撤销审核'
  37. GOTO ext
  38. END IF
  39. ext:
  40. RETURN rslt
  41. end function
  42. public function integer caudit (long arg_billid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  43. DateTime null_dt
  44. long ll_arr_cnt
  45. SetNull(null_dt)
  46. Long ll_inware_out,ll_inware_in
  47. IF arg_billid <= 0 THEN
  48. rslt = 0
  49. arg_msg = '错误单据唯一码'
  50. GOTO ext
  51. END IF
  52. s_mtrlware_pzcode_trans arg_s_trans
  53. IF getinfo(arg_billid,arg_s_trans,ll_arr_cnt,arg_msg) = 0 THEN
  54. rslt = 0
  55. GOTO ext
  56. END IF
  57. IF arg_s_trans.flag = 0 THEN
  58. rslt = 0
  59. arg_msg = '单据未审核,不可以撤审'
  60. GOTO ext
  61. END IF
  62. UPDATE u_mtrlware_pzcode_trans
  63. SET flag = 0,
  64. auditemp = '',
  65. auditdate = :null_dt
  66. WHERE billid = :arg_billid
  67. AND flag = 1;
  68. IF sqlca.SQLCode <> 0 THEN
  69. rslt = 0
  70. arg_msg = "因网络或其它原因导致单据撤消审核操作失败"+"~n"+sqlca.SQLErrText
  71. GOTO ext
  72. END IF
  73. uo_inware uo_in
  74. uo_in = CREATE uo_inware
  75. uo_in.commit_transaction = sqlca
  76. uo_in.if_getid_ture = FALSE
  77. //撤审删除相关进仓单(正)
  78. SELECT inwareid INTO :ll_inware_in
  79. FROM u_inware
  80. WHERE scid = :arg_s_trans.scid
  81. AND relid = :arg_billid
  82. AND billtype = 22
  83. AND relint_2 = 1;
  84. IF sqlca.SQLCode <> 0 THEN
  85. arg_msg = '查询相关进仓单(正)失败'+sqlca.SQLErrText
  86. rslt = 0
  87. GOTO ext
  88. END IF
  89. IF uo_in.getinfo(arg_s_trans.scid,ll_inware_in,arg_msg) = 0 THEN
  90. rslt = 0
  91. GOTO ext
  92. END IF
  93. IF uo_in.c_auditing(FALSE,arg_msg) = 0 THEN
  94. rslt = 0
  95. GOTO ext
  96. END IF
  97. IF uo_in.del(arg_s_trans.scid,ll_inware_in,arg_msg,FALSE) = 0 THEN
  98. rslt = 0
  99. GOTO ext
  100. END IF
  101. //撤审删除相关进仓单(负)
  102. SELECT inwareid INTO :ll_inware_out
  103. FROM u_inware
  104. WHERE scid = :arg_s_trans.scid
  105. AND relid = :arg_billid
  106. AND billtype = 22
  107. AND relint_2 = 0;
  108. IF sqlca.SQLCode <> 0 THEN
  109. arg_msg = '查询相关进仓单(负)失败'+sqlca.SQLErrText
  110. rslt = 0
  111. GOTO ext
  112. END IF
  113. IF uo_in.getinfo(arg_s_trans.scid,ll_inware_out,arg_msg) = 0 THEN
  114. rslt = 0
  115. GOTO ext
  116. END IF
  117. IF uo_in.c_auditing(FALSE,arg_msg) = 0 THEN
  118. rslt = 0
  119. GOTO ext
  120. END IF
  121. IF uo_in.del(arg_s_trans.scid,ll_inware_out,arg_msg,FALSE) = 0 THEN
  122. rslt = 0
  123. GOTO ext
  124. END IF
  125. ext:
  126. IF rslt = 0 THEN
  127. ROLLBACK;
  128. ELSEIF rslt = 1 AND arg_ifcommit THEN
  129. COMMIT;
  130. END IF
  131. DESTROY uo_in
  132. RETURN rslt
  133. end function
  134. public function integer audit (long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  135. Long ll_arr_cnt
  136. String ls_uunit
  137. Decimal ld_rate,ld_uqty,ld_uprice
  138. Long ll_i
  139. Long ll_inwareid_out,ll_inwareid_in
  140. IF arg_billid <= 0 THEN
  141. rslt = 0
  142. arg_msg = '错误单据唯一码'
  143. GOTO ext
  144. END IF
  145. s_mtrlware_pzcode_trans arg_s_trans
  146. IF getinfo(arg_billid,arg_s_trans,ll_arr_cnt,arg_msg) = 0 THEN
  147. rslt = 0
  148. GOTO ext
  149. END IF
  150. IF arg_s_trans.flag = 1 THEN
  151. rslt = 0
  152. arg_msg = '单据已经审核,不可以再审'
  153. GOTO ext
  154. END IF
  155. //更新审核标记
  156. UPDATE u_mtrlware_pzcode_trans
  157. SET auditemp = :arg_opemp,
  158. auditdate = getdate(),
  159. flag = 1
  160. WHERE billid = :arg_billid
  161. AND flag = 0;
  162. IF sqlca.SQLCode <> 0 THEN
  163. rslt = 0
  164. arg_msg = "因网络或其它原因导致单据审核操作失败"+"~n"+sqlca.SQLErrText
  165. GOTO ext
  166. END IF
  167. uo_inware uo_in
  168. uo_in = CREATE uo_inware
  169. uo_in.commit_transaction = sqlca
  170. uo_in.if_getid_ture = FALSE
  171. //负单
  172. IF uo_in.newbegin(arg_s_trans.scid,22,arg_msg) = 0 THEN
  173. rslt = 0
  174. GOTO ext
  175. END IF
  176. uo_in.relid = arg_s_trans.billid
  177. uo_in.indate = arg_s_trans.billdate
  178. uo_in.inrep = arg_s_trans.rep
  179. uo_in.part = arg_s_trans.billcode
  180. uo_in.dscrp = arg_s_trans.dscrp
  181. uo_in.relint_2 = 0 // 0 - 负 1 - 正
  182. uo_in.storageid = arg_s_trans.storageid
  183. uo_in.sptname = '库存配置调整单(负)'
  184. FOR ll_i = 1 TO ll_arr_cnt
  185. //转换
  186. ls_uunit = ''
  187. ld_rate = 0
  188. ld_uqty = 0
  189. ld_uprice = 0
  190. IF arg_s_trans.arg_s_mx[ll_i].ifunit = 0 THEN
  191. ls_uunit = arg_s_trans.arg_s_mx[ll_i].unit
  192. ld_rate = 1
  193. ld_uqty = arg_s_trans.arg_s_mx[ll_i].qty
  194. ld_uprice = arg_s_trans.arg_s_mx[ll_i].cost
  195. ELSE
  196. IF arg_s_trans.arg_s_mx[ll_i].rate = 0 THEN
  197. arg_msg = '调货产品资料设为双数量核算,但没有设置默认转换率,请检查'
  198. rslt = 0
  199. GOTO ext
  200. END IF
  201. ls_uunit = arg_s_trans.arg_s_mx[ll_i].uunit
  202. ld_rate = arg_s_trans.arg_s_mx[ll_i].rate
  203. ld_uqty = arg_s_trans.arg_s_mx[ll_i].qty / arg_s_trans.arg_s_mx[ll_i].rate
  204. ld_uprice = arg_s_trans.arg_s_mx[ll_i].cost * arg_s_trans.arg_s_mx[ll_i].rate
  205. END IF
  206. IF uo_in.acceptmx(ll_i,&
  207. arg_s_trans.arg_s_mx[ll_i].mtrlid,&
  208. arg_s_trans.arg_s_mx[ll_i].mtrlcode,&
  209. arg_s_trans.arg_s_mx[ll_i].plancode,&
  210. arg_s_trans.arg_s_mx[ll_i].status,&
  211. 0 - ld_uqty,&
  212. ld_uprice,&
  213. 1,&
  214. arg_s_trans.arg_s_mx[ll_i].mxdscrp,&
  215. arg_msg,&
  216. 0,0,0,arg_s_trans.arg_s_mx[ll_i].woodcode,&
  217. arg_s_trans.arg_s_mx[ll_i].pcode,&
  218. arg_s_trans.arg_s_mx[ll_i].sptid,&
  219. ls_uunit,ld_rate,0 - arg_s_trans.arg_s_mx[ll_i].qty,0,0,'','',0,0,&
  220. arg_s_trans.arg_s_mx[ll_i].mtrlcuscode,arg_s_trans.arg_s_mx[ll_i].Location,&
  221. 0 - ld_uqty,&
  222. 0) = 0 THEN
  223. rslt = 0
  224. GOTO ext
  225. END IF
  226. NEXT
  227. IF uo_in.Save(FALSE,arg_msg) = 0 THEN
  228. rslt = 0
  229. GOTO ext
  230. END IF
  231. ll_inwareid_out = uo_in.inwareid
  232. IF uo_in.getinfo(arg_s_trans.scid,ll_inwareid_out,arg_msg) = 0 THEN
  233. rslt = 0
  234. GOTO ext
  235. END IF
  236. IF uo_in.auditing(FALSE,arg_msg) = 0 THEN
  237. rslt = 0
  238. GOTO ext
  239. END IF
  240. //正
  241. IF uo_in.newbegin(arg_s_trans.scid,22,arg_msg) = 0 THEN
  242. rslt = 0
  243. GOTO ext
  244. END IF
  245. uo_in.relid = arg_s_trans.billid
  246. uo_in.indate = arg_s_trans.billdate
  247. uo_in.inrep = arg_s_trans.rep
  248. uo_in.part = arg_s_trans.billcode
  249. uo_in.dscrp = arg_s_trans.dscrp
  250. uo_in.relint_2 = 1 // 0 - 负 1 - 正
  251. uo_in.storageid = arg_s_trans.storageid
  252. uo_in.sptname = '库存配置调整单(正)'
  253. FOR ll_i = 1 TO ll_arr_cnt
  254. //转换
  255. ls_uunit = ''
  256. ld_rate = 0
  257. ld_uqty = 0
  258. ld_uprice = 0
  259. IF arg_s_trans.arg_s_mx[ll_i].ifunit = 0 THEN
  260. ls_uunit = arg_s_trans.arg_s_mx[ll_i].unit
  261. ld_rate = 1
  262. ld_uqty = arg_s_trans.arg_s_mx[ll_i].qty
  263. ld_uprice = arg_s_trans.arg_s_mx[ll_i].cost
  264. ELSE
  265. IF arg_s_trans.arg_s_mx[ll_i].rate = 0 THEN
  266. arg_msg = '调货产品资料设为双数量核算,但没有设置默认转换率,请检查'
  267. rslt = 0
  268. GOTO ext
  269. END IF
  270. ls_uunit = arg_s_trans.arg_s_mx[ll_i].uunit
  271. ld_rate = arg_s_trans.arg_s_mx[ll_i].rate
  272. ld_uqty = arg_s_trans.arg_s_mx[ll_i].qty / arg_s_trans.arg_s_mx[ll_i].rate
  273. ld_uprice = arg_s_trans.arg_s_mx[ll_i].cost * arg_s_trans.arg_s_mx[ll_i].rate
  274. END IF
  275. IF uo_in.acceptmx(ll_i,&
  276. arg_s_trans.arg_s_mx[ll_i].mtrlid,&
  277. arg_s_trans.arg_s_mx[ll_i].mtrlcode,&
  278. arg_s_trans.arg_s_mx[ll_i].plancode_new,&
  279. arg_s_trans.arg_s_mx[ll_i].status_new,&
  280. ld_uqty,&
  281. ld_uprice,&
  282. 1,&
  283. arg_s_trans.arg_s_mx[ll_i].mxdscrp,&
  284. arg_msg,&
  285. 0,0,0,arg_s_trans.arg_s_mx[ll_i].woodcode_new,&
  286. arg_s_trans.arg_s_mx[ll_i].pcode_new,&
  287. arg_s_trans.arg_s_mx[ll_i].sptid_new,&
  288. ls_uunit,ld_rate,arg_s_trans.arg_s_mx[ll_i].qty,0,0,'','',0,0,&
  289. arg_s_trans.arg_s_mx[ll_i].mtrlcuscode_new,arg_s_trans.arg_s_mx[ll_i].Location_new,&
  290. ld_uqty,&
  291. 0) = 0 THEN
  292. rslt = 0
  293. GOTO ext
  294. END IF
  295. NEXT
  296. IF uo_in.Save(FALSE,arg_msg) = 0 THEN
  297. rslt = 0
  298. GOTO ext
  299. END IF
  300. ll_inwareid_in = uo_in.inwareid
  301. IF uo_in.getinfo(arg_s_trans.scid,ll_inwareid_in,arg_msg) = 0 THEN
  302. rslt = 0
  303. GOTO ext
  304. END IF
  305. IF uo_in.auditing(FALSE,arg_msg) = 0 THEN
  306. rslt = 0
  307. GOTO ext
  308. END IF
  309. IF uof_update_waredate(arg_billid,FALSE,arg_msg) = 0 THEN
  310. rslt = 0
  311. GOTO ext
  312. END IF
  313. ext:
  314. IF rslt = 0 THEN
  315. ROLLBACK;
  316. ELSEIF rslt = 1 AND arg_ifcommit THEN
  317. COMMIT;
  318. END IF
  319. DESTROY uo_in
  320. RETURN rslt
  321. end function
  322. public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg);Int rslt = 1
  323. s_mtrlware_pzcode_trans arg_s_trans
  324. IF arg_billid <= 0 THEN
  325. rslt = 0
  326. arg_msg = '错误单据唯一码'
  327. GOTO ext
  328. END IF
  329. IF arg_newdescppart = '' THEN
  330. rslt = 0
  331. arg_msg = "要添加内容为空,操作取消"
  332. GOTO ext
  333. END IF
  334. IF p_getinfo(arg_billid,arg_s_trans,arg_msg) = 0 THEN
  335. rslt = 0
  336. GOTO ext
  337. END IF
  338. IF arg_s_trans.flag = 0 THEN
  339. rslt = 0
  340. arg_msg = '单据未审核,不可以增加备注'
  341. GOTO ext
  342. END IF
  343. UPDATE u_mtrlware_pzcode_trans
  344. SET DSCRP = DSCRP+' '+:arg_newdescppart
  345. WHERE billid = :arg_billid
  346. AND flag = 1;
  347. IF SQLCA.SQLCode <> 0 THEN
  348. rslt = 0
  349. arg_msg = "因网络或其它原因导致添加备注操作失败"+"~n"+SQLCA.SQLErrText
  350. GOTO ext
  351. END IF
  352. ext:
  353. IF rslt = 1 THEN
  354. COMMIT;
  355. ELSE
  356. ROLLBACK;
  357. END IF
  358. Return (rslt)
  359. end function
  360. public function integer del (long arg_billid, integer arg_chk_auto, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  361. s_mtrlware_pzcode_trans arg_s_trans
  362. IF arg_billid <= 0 THEN
  363. rslt = 0
  364. ARG_MSG = '错误单据唯一码'
  365. GOTO ext
  366. END IF
  367. IF p_getinfo(arg_billid,arg_s_trans,ARG_MSG) = 0 THEN
  368. rslt = 0
  369. GOTO ext
  370. END IF
  371. IF arg_s_trans.flag = 1 THEN
  372. rslt = 0
  373. ARG_MSG = '单据已经审核,不可以删除'
  374. GOTO ext
  375. END IF
  376. DELETE FROM u_mtrlware_pzcode_trans Where billid = :arg_billid;
  377. IF sqlca.SQLCode <> 0 THEN
  378. rslt = 0
  379. ARG_MSG = "删除单据操作失败"+"~n"+sqlca.SQLErrText
  380. GOTO ext
  381. END IF
  382. DELETE FROM u_mtrlware_pzcode_transmx Where billid = :arg_billid ;
  383. IF sqlca.SQLCode <> 0 THEN
  384. rslt = 0
  385. ARG_MSG = "删除单据明细操作失败"+"~n"+sqlca.SQLErrText
  386. GOTO ext
  387. END IF
  388. ext:
  389. IF rslt = 0 THEN
  390. ROLLBACK;
  391. ELSEIF rslt = 1 AND arg_ifcommit THEN
  392. COMMIT;
  393. END IF
  394. RETURN rslt
  395. end function
  396. public function integer p_getinfo (long arg_billid, ref s_mtrlware_pzcode_trans arg_s_trans, ref string arg_msg);Int rslt = 1
  397. IF arg_billid <= 0 THEN
  398. rslt = 0
  399. ARG_MSG = '错误单据唯一码'
  400. GOTO ext
  401. END IF
  402. SELECT
  403. billid,
  404. billcode,
  405. scid,
  406. billdate,
  407. rep,
  408. storageid,
  409. dscrp,
  410. relcode,
  411. flag
  412. INTO
  413. :arg_s_trans.billid,
  414. :arg_s_trans.billcode,
  415. :arg_s_trans.scid,
  416. :arg_s_trans.billdate,
  417. :arg_s_trans.rep,
  418. :arg_s_trans.storageid,
  419. :arg_s_trans.dscrp,
  420. :arg_s_trans.relcode,
  421. :arg_s_trans.flag
  422. FROM u_mtrlware_pzcode_trans
  423. Where billid = :arg_billid;
  424. IF sqlca.SQLCode <> 0 THEN
  425. rslt = 0
  426. ARG_MSG = '查询库存配置调整单内容失败(错误单据唯一码)'
  427. GOTO ext
  428. END IF
  429. ext:
  430. RETURN rslt
  431. end function
  432. public function integer save (s_mtrlware_pzcode_trans arg_s_trans, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1
  433. Long cnt = 0
  434. DateTime server_dt
  435. Long ll_billid,it_mxbt,ll_i,i
  436. String ls_unit
  437. String ls_sccode,ls_billcode,ls_reltaskcode
  438. IF IsNull(arg_s_trans.scid) THEN arg_s_trans.scid = 0
  439. IF IsNull(arg_s_trans.billid) THEN arg_s_trans.billid = 0
  440. IF IsNull(arg_s_trans.rep) THEN arg_s_trans.rep = ''
  441. IF IsNull(arg_s_trans.relcode) THEN arg_s_trans.relcode = ''
  442. IF IsNull(arg_s_trans.dscrp) THEN arg_s_trans.dscrp = ''
  443. IF IsNull(arg_s_trans.storageid) THEN arg_s_trans.storageid = 0
  444. IF IsNull(arg_s_trans.relcode) THEN arg_s_trans.relcode = ''
  445. IF arg_s_trans.rep = '' THEN
  446. rslt = 0
  447. arg_msg = "请输入经手人"
  448. GOTO ext
  449. END IF
  450. cnt = 0
  451. SELECT count(*) INTO :cnt
  452. FROM u_storage
  453. Where storageid = :arg_s_trans.storageid ;
  454. IF sqlca.SQLCode <> 0 THEN
  455. rslt = 0
  456. arg_msg = "查询操作失败,仓库资料"
  457. GOTO ext
  458. END IF
  459. IF cnt = 0 THEN
  460. rslt = 0
  461. arg_msg = "仓库未定义或错误"
  462. GOTO ext
  463. END IF
  464. SELECT Top 1 getdate() INTO :server_dt FROM u_user;
  465. IF sqlca.SQLCode <> 0 THEN
  466. rslt = 0
  467. arg_msg = "查询操作失败,日期 "
  468. GOTO ext
  469. END IF
  470. it_mxbt = UpperBound(arg_s_trans.arg_s_mx)
  471. IF it_mxbt <= 0 THEN
  472. rslt = 0
  473. arg_msg = "没有正确明细内容"
  474. GOTO ext
  475. END IF
  476. //
  477. //FOR ll_i = 1 TO it_mxbt
  478. //
  479. //NEXT
  480. IF arg_s_trans.billid = 0 THEN
  481. ll_billid = f_sys_scidentity(0,"u_mtrlware_pzcode_trans","billid",arg_msg,TRUE,id_sqlca)
  482. IF ll_billid <= 0 THEN
  483. rslt = 0
  484. GOTO ext
  485. END IF
  486. IF f_get_sccode(arg_s_trans.scid,sqlca,ls_sccode,arg_msg) = 0 THEN
  487. rslt = 0
  488. GOTO ext
  489. END IF
  490. ls_billcode = getid(arg_s_trans.scid,ls_sccode + 'MP',Date(server_dt),FALSE,sqlca)
  491. IF ls_billcode = "err" THEN
  492. rslt = 0
  493. arg_msg = "无法获取单据编号"+"~n"+sqlca.SQLErrText
  494. GOTO ext
  495. END IF
  496. INSERT INTO u_mtrlware_pzcode_trans
  497. (scid,
  498. billid,
  499. billcode,
  500. billdate,
  501. rep,
  502. storageid,
  503. relcode,
  504. dscrp,
  505. opemp,
  506. opdate)
  507. VALUES (
  508. :arg_s_trans.scid,
  509. :ll_billid,
  510. :ls_billcode,
  511. :arg_s_trans.billdate,
  512. :arg_s_trans.rep,
  513. :arg_s_trans.storageid,
  514. :arg_s_trans.relcode,
  515. :arg_s_trans.dscrp,
  516. :arg_opemp,
  517. getdate()) ;
  518. IF sqlca.SQLCode <> 0 THEN
  519. rslt = 0
  520. arg_msg = "因网络或其它原因导致建立单据操作失败"+"~n"+sqlca.SQLErrText
  521. GOTO ext
  522. END IF
  523. FOR i = 1 TO it_mxbt
  524. INSERT INTO u_mtrlware_pzcode_transmx
  525. (billid,
  526. printid,
  527. scid,
  528. mtrlwareid,
  529. mtrlid,
  530. status,
  531. woodcode,
  532. pcode,
  533. plancode,
  534. mtrlcuscode,
  535. location,
  536. sptid,
  537. qty,
  538. cost,
  539. status_new,
  540. woodcode_new,
  541. pcode_new,
  542. plancode_new,
  543. mtrlcuscode_new,
  544. location_new,
  545. sptid_new,
  546. mxdscrp)
  547. VALUES (:ll_billid,
  548. :arg_s_trans.arg_s_mx[i].printid,
  549. :arg_s_trans.arg_s_mx[i].scid,
  550. :arg_s_trans.arg_s_mx[i].mtrlwareid,
  551. :arg_s_trans.arg_s_mx[i].mtrlid,
  552. :arg_s_trans.arg_s_mx[i].status,
  553. :arg_s_trans.arg_s_mx[i].woodcode,
  554. :arg_s_trans.arg_s_mx[i].pcode,
  555. :arg_s_trans.arg_s_mx[i].plancode,
  556. :arg_s_trans.arg_s_mx[i].mtrlcuscode,
  557. :arg_s_trans.arg_s_mx[i].location,
  558. :arg_s_trans.arg_s_mx[i].sptid,
  559. :arg_s_trans.arg_s_mx[i].qty,
  560. :arg_s_trans.arg_s_mx[i].cost,
  561. :arg_s_trans.arg_s_mx[i].status_new,
  562. :arg_s_trans.arg_s_mx[i].woodcode_new,
  563. :arg_s_trans.arg_s_mx[i].pcode_new,
  564. :arg_s_trans.arg_s_mx[i].plancode_new,
  565. :arg_s_trans.arg_s_mx[i].mtrlcuscode_new,
  566. :arg_s_trans.arg_s_mx[i].location_new,
  567. :arg_s_trans.arg_s_mx[i].sptid_new,
  568. :arg_s_trans.arg_s_mx[i].mxdscrp);
  569. IF sqlca.SQLCode <> 0 THEN
  570. rslt = 0
  571. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+sqlca.SQLErrText
  572. GOTO ext
  573. END IF
  574. NEXT
  575. uo_billid = ll_billid
  576. ELSE
  577. UPDATE u_mtrlware_pzcode_trans
  578. SET rep = :arg_s_trans.rep,
  579. billdate = :arg_s_trans.billdate,
  580. storageid = :arg_s_trans.storageid,
  581. moddate = getdate(),
  582. modemp = :arg_opemp,
  583. relcode = :arg_s_trans.relcode,
  584. dscrp = :arg_s_trans.dscrp
  585. WHERE billid = :arg_s_trans.billid
  586. AND flag = 0;
  587. IF sqlca.SQLCode <> 0 OR sqlca.SQLNRows <= 0 THEN
  588. rslt = 0
  589. arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+sqlca.SQLErrText
  590. GOTO ext
  591. END IF
  592. DELETE FROM u_mtrlware_pzcode_transmx
  593. Where billid = :arg_s_trans.billid;
  594. IF sqlca.SQLCode <> 0 THEN
  595. rslt = 0
  596. arg_msg = "删除旧有明细操作失败"+"~n"+sqlca.SQLErrText
  597. GOTO ext
  598. END IF
  599. FOR i = 1 TO it_mxbt
  600. INSERT INTO u_mtrlware_pzcode_transmx
  601. (billid,
  602. printid,
  603. scid,
  604. mtrlwareid,
  605. mtrlid,
  606. status,
  607. woodcode,
  608. pcode,
  609. plancode,
  610. mtrlcuscode,
  611. location,
  612. sptid,
  613. qty,
  614. cost,
  615. status_new,
  616. woodcode_new,
  617. pcode_new,
  618. plancode_new,
  619. mtrlcuscode_new,
  620. location_new,
  621. sptid_new,
  622. mxdscrp)
  623. VALUES (:arg_s_trans.billid,
  624. :arg_s_trans.arg_s_mx[i].printid,
  625. :arg_s_trans.arg_s_mx[i].scid,
  626. :arg_s_trans.arg_s_mx[i].mtrlwareid,
  627. :arg_s_trans.arg_s_mx[i].mtrlid,
  628. :arg_s_trans.arg_s_mx[i].status,
  629. :arg_s_trans.arg_s_mx[i].woodcode,
  630. :arg_s_trans.arg_s_mx[i].pcode,
  631. :arg_s_trans.arg_s_mx[i].plancode,
  632. :arg_s_trans.arg_s_mx[i].mtrlcuscode,
  633. :arg_s_trans.arg_s_mx[i].location,
  634. :arg_s_trans.arg_s_mx[i].sptid,
  635. :arg_s_trans.arg_s_mx[i].qty,
  636. :arg_s_trans.arg_s_mx[i].cost,
  637. :arg_s_trans.arg_s_mx[i].status_new,
  638. :arg_s_trans.arg_s_mx[i].woodcode_new,
  639. :arg_s_trans.arg_s_mx[i].pcode_new,
  640. :arg_s_trans.arg_s_mx[i].plancode_new,
  641. :arg_s_trans.arg_s_mx[i].mtrlcuscode_new,
  642. :arg_s_trans.arg_s_mx[i].location_new,
  643. :arg_s_trans.arg_s_mx[i].sptid_new,
  644. :arg_s_trans.arg_s_mx[i].mxdscrp);
  645. IF sqlca.SQLCode <> 0 THEN
  646. rslt = 0
  647. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+sqlca.SQLErrText
  648. GOTO ext
  649. END IF
  650. NEXT
  651. uo_billid = arg_s_trans.billid
  652. END IF
  653. ext:
  654. IF rslt = 0 THEN
  655. ROLLBACK;
  656. ELSEIF arg_ifcommit AND rslt = 1 THEN
  657. COMMIT;
  658. END IF
  659. RETURN rslt
  660. end function
  661. public function integer getinfo (long arg_billid, ref s_mtrlware_pzcode_trans arg_ref_s_trans, ref long arg_arr_cnt, ref string arg_msg);Int rslt = 1
  662. Long i = 1,no_mxcheck = 0
  663. IF arg_billid <= 0 THEN
  664. rslt = 0
  665. arg_msg = '错误单据唯一码'
  666. GOTO ext
  667. END IF
  668. IF p_getinfo(arg_billid,arg_ref_s_trans,arg_msg) = 0 THEN
  669. rslt = 0
  670. GOTO ext
  671. END IF
  672. //用游标读取明细
  673. DECLARE cur_mx CURSOR FOR
  674. SELECT u_mtrlware_pzcode_transmx.billid,
  675. u_mtrlware_pzcode_transmx.printid,
  676. u_mtrlware_pzcode_transmx.scid,
  677. u_mtrlware_pzcode_transmx.mtrlwareid,
  678. u_mtrlware_pzcode_transmx.mtrlid,
  679. u_mtrlware_pzcode_transmx.status,
  680. u_mtrlware_pzcode_transmx.woodcode,
  681. u_mtrlware_pzcode_transmx.pcode,
  682. u_mtrlware_pzcode_transmx.plancode,
  683. u_mtrlware_pzcode_transmx.mtrlcuscode,
  684. u_mtrlware_pzcode_transmx.location,
  685. u_mtrlware_pzcode_transmx.sptid,
  686. u_mtrlware_pzcode_transmx.qty,
  687. u_mtrlware_pzcode_transmx.cost,
  688. u_mtrlware_pzcode_transmx.status_new,
  689. u_mtrlware_pzcode_transmx.woodcode_new,
  690. u_mtrlware_pzcode_transmx.pcode_new,
  691. u_mtrlware_pzcode_transmx.plancode_new,
  692. u_mtrlware_pzcode_transmx.mtrlcuscode_new,
  693. u_mtrlware_pzcode_transmx.location_new,
  694. u_mtrlware_pzcode_transmx.sptid_new,
  695. u_mtrlware_pzcode_transmx.mxdscrp,
  696. u_mtrldef.unit,
  697. u_mtrldef.ifunit,
  698. u_mtrldef.unit_buy,
  699. u_mtrldef.rate_buy
  700. FROM u_mtrlware_pzcode_transmx INNER JOIN
  701. u_mtrldef ON u_mtrlware_pzcode_transmx.mtrlid = u_mtrldef.mtrlid
  702. WHERE billid = :arg_billid
  703. Order By printid;
  704. OPEN cur_mx;
  705. FETCH cur_mx
  706. INTO
  707. :arg_ref_s_trans.arg_s_mx[i].billid,
  708. :arg_ref_s_trans.arg_s_mx[i].printid,
  709. :arg_ref_s_trans.arg_s_mx[i].scid,
  710. :arg_ref_s_trans.arg_s_mx[i].mtrlwareid,
  711. :arg_ref_s_trans.arg_s_mx[i].mtrlid,
  712. :arg_ref_s_trans.arg_s_mx[i].status,
  713. :arg_ref_s_trans.arg_s_mx[i].woodcode,
  714. :arg_ref_s_trans.arg_s_mx[i].pcode,
  715. :arg_ref_s_trans.arg_s_mx[i].plancode,
  716. :arg_ref_s_trans.arg_s_mx[i].mtrlcuscode,
  717. :arg_ref_s_trans.arg_s_mx[i].location,
  718. :arg_ref_s_trans.arg_s_mx[i].sptid,
  719. :arg_ref_s_trans.arg_s_mx[i].qty,
  720. :arg_ref_s_trans.arg_s_mx[i].cost,
  721. :arg_ref_s_trans.arg_s_mx[i].status_new,
  722. :arg_ref_s_trans.arg_s_mx[i].woodcode_new,
  723. :arg_ref_s_trans.arg_s_mx[i].pcode_new,
  724. :arg_ref_s_trans.arg_s_mx[i].plancode_new,
  725. :arg_ref_s_trans.arg_s_mx[i].mtrlcuscode_new,
  726. :arg_ref_s_trans.arg_s_mx[i].location_new,
  727. :arg_ref_s_trans.arg_s_mx[i].sptid_new,
  728. :arg_ref_s_trans.arg_s_mx[i].mxdscrp,
  729. :arg_ref_s_trans.arg_s_mx[i].unit,
  730. :arg_ref_s_trans.arg_s_mx[i].ifunit,
  731. :arg_ref_s_trans.arg_s_mx[i].uunit,
  732. :arg_ref_s_trans.arg_s_mx[i].rate;
  733. DO WHILE sqlca.SQLCode = 0
  734. i++
  735. FETCH cur_mx
  736. INTO
  737. :arg_ref_s_trans.arg_s_mx[i].billid,
  738. :arg_ref_s_trans.arg_s_mx[i].printid,
  739. :arg_ref_s_trans.arg_s_mx[i].scid,
  740. :arg_ref_s_trans.arg_s_mx[i].mtrlwareid,
  741. :arg_ref_s_trans.arg_s_mx[i].mtrlid,
  742. :arg_ref_s_trans.arg_s_mx[i].status,
  743. :arg_ref_s_trans.arg_s_mx[i].woodcode,
  744. :arg_ref_s_trans.arg_s_mx[i].pcode,
  745. :arg_ref_s_trans.arg_s_mx[i].plancode,
  746. :arg_ref_s_trans.arg_s_mx[i].mtrlcuscode,
  747. :arg_ref_s_trans.arg_s_mx[i].location,
  748. :arg_ref_s_trans.arg_s_mx[i].sptid,
  749. :arg_ref_s_trans.arg_s_mx[i].qty,
  750. :arg_ref_s_trans.arg_s_mx[i].cost,
  751. :arg_ref_s_trans.arg_s_mx[i].status_new,
  752. :arg_ref_s_trans.arg_s_mx[i].woodcode_new,
  753. :arg_ref_s_trans.arg_s_mx[i].pcode_new,
  754. :arg_ref_s_trans.arg_s_mx[i].plancode_new,
  755. :arg_ref_s_trans.arg_s_mx[i].mtrlcuscode_new,
  756. :arg_ref_s_trans.arg_s_mx[i].location_new,
  757. :arg_ref_s_trans.arg_s_mx[i].sptid_new,
  758. :arg_ref_s_trans.arg_s_mx[i].mxdscrp,
  759. :arg_ref_s_trans.arg_s_mx[i].unit,
  760. :arg_ref_s_trans.arg_s_mx[i].ifunit,
  761. :arg_ref_s_trans.arg_s_mx[i].uunit,
  762. :arg_ref_s_trans.arg_s_mx[i].rate;
  763. LOOP
  764. CLOSE cur_mx;
  765. //检验明细是否读入完整
  766. SELECT count(*) INTO :no_mxcheck
  767. FROM u_mtrlware_pzcode_transmx
  768. Where billid = :arg_billid;
  769. IF sqlca.SQLCode <> 0 THEN
  770. rslt = 0
  771. arg_msg = "查询库存配置调整单操作失败,单据明细数量"
  772. GOTO ext
  773. END IF
  774. IF i <> (no_mxcheck+1) THEN
  775. rslt = 0
  776. arg_msg = "查询库存配置调整单操作失败,单据明细"
  777. GOTO ext
  778. END IF
  779. arg_arr_cnt = i - 1
  780. ext:
  781. RETURN rslt
  782. end function
  783. public function integer uof_update_waredate (long arg_billid, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  784. Long ll_arr_cnt
  785. DateTime ld_waredate,ld_auditingdate,ld_waradate_mx
  786. String ls_auditdate,ls_waredate
  787. Long ll_mtrlid,ll_sptid,ll_mtrlwareid,ll_sptid_new
  788. String ls_status,ls_woodcode,ls_pcode,ls_plancode
  789. String ls_mtrlcuscode,ls_location
  790. String ls_status_new,ls_woodcode_new,ls_pcode_new,ls_plancode_new
  791. String ls_mtrlcuscode_new,ls_location_new
  792. Long i
  793. IF arg_billid <= 0 THEN
  794. rslt = 0
  795. arg_msg = '错误单据唯一码'
  796. GOTO ext
  797. END IF
  798. s_mtrlware_pzcode_trans arg_s_trans
  799. IF getinfo(arg_billid,arg_s_trans,ll_arr_cnt,arg_msg) = 0 THEN
  800. rslt = 0
  801. GOTO ext
  802. END IF
  803. SELECT auditdate INTO :ld_auditingdate
  804. FROM u_mtrlware_pzcode_trans
  805. Where billid = :arg_billid;
  806. IF sqlca.SQLCode <> 0 THEN
  807. rslt = 0
  808. arg_msg = "因网络或其它原因导致单据审核操作失败"+"~n"+sqlca.SQLErrText
  809. GOTO ext
  810. END IF
  811. ls_auditdate = String(ld_auditingdate,'yyyy-mm-dd hh:mm')
  812. FOR i = 1 TO ll_arr_cnt
  813. ll_mtrlid = arg_s_trans.arg_s_mx[i].mtrlid
  814. ll_sptid = arg_s_trans.arg_s_mx[i].sptid
  815. ls_status = arg_s_trans.arg_s_mx[i].status
  816. ls_woodcode = arg_s_trans.arg_s_mx[i].woodcode
  817. ls_pcode = arg_s_trans.arg_s_mx[i].pcode
  818. ls_plancode = arg_s_trans.arg_s_mx[i].plancode
  819. ls_mtrlcuscode = arg_s_trans.arg_s_mx[i].mtrlcuscode
  820. ls_location = arg_s_trans.arg_s_mx[i].Location
  821. ls_status_new = arg_s_trans.arg_s_mx[i].status_new
  822. ls_woodcode_new = arg_s_trans.arg_s_mx[i].woodcode_new
  823. ls_pcode_new = arg_s_trans.arg_s_mx[i].pcode_new
  824. ls_plancode_new = arg_s_trans.arg_s_mx[i].plancode_new
  825. ls_mtrlcuscode_new = arg_s_trans.arg_s_mx[i].mtrlcuscode_new
  826. ls_location_new = arg_s_trans.arg_s_mx[i].Location_new
  827. ll_sptid_new = arg_s_trans.arg_s_mx[i].sptid_new
  828. SELECT waredate INTO :ld_waredate
  829. FROM u_mtrlware
  830. WHERE scid = :arg_s_trans.scid
  831. AND storageid = :arg_s_trans.storageid
  832. AND mtrlid = :ll_mtrlid
  833. AND sptid = :ll_sptid
  834. AND status = :ls_status
  835. AND woodcode = :ls_woodcode
  836. AND pcode = :ls_pcode
  837. AND plancode = :ls_plancode
  838. AND mtrlcuscode = :ls_mtrlcuscode
  839. AND Location = :ls_location;
  840. IF sqlca.SQLCode <> 0 THEN
  841. rslt = 0
  842. arg_msg = '明细行:'+string(i)+',查询明细原库存最近进仓日期失败,'+sqlca.SQLErrText
  843. GOTO ext
  844. END IF
  845. SELECT waredate INTO :ld_waradate_mx
  846. FROM u_mtrlware
  847. WHERE scid = :arg_s_trans.scid
  848. AND storageid = :arg_s_trans.storageid
  849. AND mtrlid = :ll_mtrlid
  850. AND sptid = :ll_sptid_new
  851. AND status = :ls_status_new
  852. AND woodcode = :ls_woodcode_new
  853. AND pcode = :ls_pcode_new
  854. AND plancode = :ls_plancode_new
  855. AND mtrlcuscode = :ls_mtrlcuscode_new
  856. AND Location = :ls_location_new;
  857. IF sqlca.SQLCode <> 0 THEN
  858. rslt = 0
  859. arg_msg = '明细行:'+string(i)+',查询明细新库存最近进仓日期失败,错误:'+string(sqlca.SQLCode)+','+sqlca.SQLErrText
  860. GOTO ext
  861. END IF
  862. ls_waredate = String(ld_waradate_mx,'yyyy-mm-dd hh:mm')
  863. IF ls_auditdate = ls_waredate THEN
  864. UPDATE u_mtrlware
  865. SET waredate = :ld_waredate
  866. WHERE scid = :arg_s_trans.scid
  867. AND storageid = :arg_s_trans.storageid
  868. AND mtrlid = :ll_mtrlid
  869. AND sptid = :ll_sptid_new
  870. AND status = :ls_status_new
  871. AND woodcode = :ls_woodcode_new
  872. AND pcode = :ls_pcode_new
  873. AND plancode = :ls_plancode_new
  874. AND mtrlcuscode = :ls_mtrlcuscode_new
  875. AND Location = :ls_location_new;
  876. IF sqlca.SQLCode <> 0 THEN
  877. rslt = 0
  878. arg_msg = '明细行:'+string(i)+',更新明细新库存最近进仓日期失败,'+sqlca.SQLErrText
  879. GOTO ext
  880. END IF
  881. END IF
  882. NEXT
  883. ext:
  884. IF rslt = 0 THEN
  885. ROLLBACK;
  886. ELSEIF rslt = 1 AND arg_ifcommit THEN
  887. COMMIT;
  888. END IF
  889. RETURN rslt
  890. end function
  891. on uo_mtrlware_pzcode_trans.create
  892. call super::create
  893. TriggerEvent( this, "constructor" )
  894. end on
  895. on uo_mtrlware_pzcode_trans.destroy
  896. TriggerEvent( this, "destructor" )
  897. call super::destroy
  898. end on
  899. global type uo_incase from nonvisualobject
  900. end type