uo_outware_move.sru 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386
  1. $PBExportHeader$uo_outware_move.sru
  2. forward
  3. global type uo_outware_move from nonvisualobject
  4. end type
  5. type s_outwaremx from structure within uo_outware_move
  6. end type
  7. end forward
  8. type s_outwaremx from structure
  9. long mtrlwareid
  10. long mtrlid
  11. long storageid
  12. decimal { 4 } qty
  13. string plancode
  14. decimal { 10 } cost
  15. string mtrlcode
  16. string mxdscrp
  17. long printid
  18. string status
  19. long scid
  20. integer dxflag
  21. long sptid
  22. string woodcode
  23. string pcode
  24. decimal { 10 } price
  25. decimal { 4 } addqty
  26. string unit
  27. string waredscrp
  28. datetime inworkdate
  29. string newplancode
  30. integer packqty
  31. decimal { 10 } cost_notax
  32. end type
  33. global type uo_outware_move from nonvisualobject
  34. end type
  35. global uo_outware_move uo_outware_move
  36. type variables
  37. public protectedwrite long outwareid //出仓单表自动增量id
  38. public protectedwrite string outwarecode //所有单据的唯一编号
  39. public protectedwrite datetime opdate //建立时间,自动
  40. public protectedwrite int flag=0 //仓库审核标志,默认0,审核时(变1)才减少库存
  41. public protectedwrite datetime auditingdate //审核时间
  42. public protectedwrite string auditingrep //审核操作员
  43. public protectedwrite string operator //建立操作员
  44. public protectedwrite datetime moddate //修改时间
  45. public protectedwrite string modrep //修改操作员
  46. long sstorageid //原仓库
  47. long dstorageid //目标仓库
  48. datetime outdate //进仓发生时间
  49. string outrep='' //经手人
  50. string dscrp='' //备注
  51. string relcode = ''
  52. string reason //调拨原因
  53. long d_auditflag = 0
  54. private:
  55. s_outwaremx outwaremx[] //明细结构数组
  56. long it_mxbt=0 //明细结构数组末指针
  57. boolean it_newbegin=true //新建标志
  58. boolean it_updatebegin=false//修改标志
  59. end variables
  60. forward prototypes
  61. public function integer add_dscrp (string arg_newdescppart, ref string arg_msg)
  62. public function integer p_clearmx ()
  63. public function integer p_reset ()
  64. public function integer p_getinfo (long arg_outwareid, ref string arg_msg)
  65. public function integer newbegin (ref string arg_msg)
  66. public function integer cancel (long arg_outwareid, ref string arg_msg)
  67. public function integer getinfo (long arg_outwareid, ref string arg_msg)
  68. public function integer updatebegin (long arg_outwareid, ref string arg_msg)
  69. public function integer ss_auditing (string arg_auditingrep, ref string arg_msg)
  70. public function integer c_ss_auditing (ref string arg_msg)
  71. public function integer ds_auditing (string arg_auditingrep, ref string arg_msg)
  72. public function integer c_ds_auditing (ref string arg_msg)
  73. public function integer mod_price (long arg_scid, long arg_outwareid, long arg_printid, decimal arg_price, ref string arg_msg)
  74. public function integer save (boolean arg_ifcommit, ref string arg_msg)
  75. public function integer acceptmx (long arg_mtrlwareid, decimal arg_qty, decimal arg_addqty, decimal arg_price, ref string arg_msg, long arg_printid, string arg_mxdscrp, string arg_newplancode, integer arg_packqty)
  76. end prototypes
  77. public function integer add_dscrp (string arg_newdescppart, ref string arg_msg);//add_dscrp(string arg_newdescppart)
  78. //0 fail 1 success
  79. int rslt=1
  80. arg_newdescppart=trim(arg_newdescppart)
  81. if it_updatebegin or it_newbegin then
  82. rslt=0
  83. arg_msg="编辑状态下不可用"
  84. goto ext
  85. end if
  86. update u_outware_move
  87. set dscrp = dscrp+' '+:arg_newdescppart
  88. where u_outware_move.outwareid = :outwareid;
  89. if sqlca.sqlcode<>0 then
  90. rollback ;
  91. rslt=0
  92. arg_msg="添加单据备注操作失败"+"~n"+sqlca.sqlerrtext
  93. goto ext
  94. end if
  95. commit;
  96. dscrp = dscrp+' '+arg_newdescppart
  97. ext: return (rslt)
  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 p_reset ();//int p_reset()
  105. //清除对象及其明细
  106. outwareid=0
  107. outwarecode = ''
  108. flag=0
  109. relcode = ''
  110. sstorageid = 0
  111. dstorageid = 0
  112. outrep=''
  113. dscrp=''
  114. it_newbegin=false
  115. it_updatebegin=false
  116. //清除明细
  117. p_clearmx()
  118. return 1
  119. end function
  120. public function integer p_getinfo (long arg_outwareid, ref string arg_msg);//getinfo(arg_outwareid,string arg_msg)
  121. //0 失败 1成功
  122. Int rslt = 1
  123. IF arg_outwareid <= 0 THEN
  124. rslt = 0
  125. arg_msg = "非法调拨单唯一码"
  126. GOTO ext
  127. END IF
  128. SELECT u_outware_move.outwarecode,
  129. u_outware_move.opdate,
  130. u_outware_move.operator,
  131. u_outware_move.flag,
  132. u_outware_move.auditingdate,
  133. u_outware_move.auditingrep,
  134. u_outware_move.moddate,
  135. u_outware_move.modrep,
  136. u_outware_move.outdate,
  137. u_outware_move.outrep,
  138. u_outware_move.dscrp,
  139. u_outware_move.sstorageid,
  140. u_outware_move.dstorageid,
  141. u_outware_move.relcode,
  142. u_outware_move.reason,
  143. u_outware_move.d_auditflag
  144. INTO :outwarecode,
  145. :opdate,
  146. :operator,
  147. :flag,
  148. :auditingdate,
  149. :auditingrep,
  150. :moddate,
  151. :modrep,
  152. :outdate,
  153. :outrep,
  154. :dscrp,
  155. :sstorageid,
  156. :dstorageid,
  157. :relcode,
  158. :reason,
  159. :d_auditflag
  160. FROM u_outware_move
  161. Where u_outware_move.outwareid = :arg_outwareid;
  162. IF sqlca.SQLCode <> 0 THEN
  163. rslt = 0
  164. arg_msg = "查询操作失败(错误出仓单唯一码),调拨单"
  165. GOTO ext
  166. END IF
  167. ext:
  168. IF rslt = 0 THEN p_reset()
  169. RETURN rslt
  170. end function
  171. public function integer newbegin (ref string arg_msg);//newbegin(INT arg_billtype,long arg_relid)
  172. //从置对象,设定业务类型与关联ID,准备建立新出仓单
  173. //0 fail 1 success
  174. LONG RSLT=1,CNT=0
  175. p_reset()
  176. it_newbegin=TRUE
  177. it_updatebegin=FALSE
  178. //EXT:
  179. IF RSLT=0 THEN p_reset()
  180. return RSLT
  181. end function
  182. public function integer cancel (long arg_outwareid, ref string arg_msg);//cancel()
  183. //如果单据还没有审核删除单据极其明细
  184. //0 FAIL, 1 SUCCESS
  185. INT rslt=1
  186. IF arg_outwareid<=0 THEN
  187. rslt=0
  188. arG_MSG="没有删除对象,操作取消"
  189. goto ext
  190. END IF
  191. rslt=p_getinfo(arg_outwareid,arg_msg)
  192. if rslt=0 then goto ext
  193. IF flag=1 THEN
  194. rslt=0
  195. arG_MSG="单据已经审核,不可以删除"
  196. goto ext
  197. END IF
  198. DELETE FROM u_outwaremovemx
  199. WHERE u_outwaremovemx.outwareid = :arg_outwareid;
  200. if sqlca.sqlcode<>0 then
  201. rslt=0
  202. arG_MSG="删除进仓单明细操作失败"+"~n"+SQLCA.SQLErrText
  203. ROLLBACK;
  204. goto ext
  205. end if
  206. DELETE FROM u_outware_move
  207. WHERE u_outware_move.outwareid = :arg_outwareid;
  208. if sqlca.sqlcode<>0 then
  209. rslt=0
  210. arG_MSG="删除进仓单操作失败"+"~n"+SQLCA.SQLErrText
  211. ROLLBACK;
  212. goto ext
  213. end if
  214. COMMIT;
  215. it_newbegin=FALSE
  216. it_updatebegin=FALSE
  217. EXT:
  218. p_reset()
  219. return (rslt)
  220. end function
  221. public function integer getinfo (long arg_outwareid, ref string arg_msg);//getinfo(long arg_outwareid,string arg_msg)
  222. //0 失败 1成功
  223. int rslt=1,i=1,no_mxcheck=0
  224. if arg_outwareid<=0 then
  225. rslt=0
  226. arg_msg="非法调拨仓单唯一码"
  227. goto ext
  228. end if
  229. if p_getinfo(arg_outwareid,arg_msg) = 0 then
  230. rslt = 0
  231. goto ext
  232. end if
  233. //用游标读取明细
  234. declare cur_outwaermx cursor for
  235. select u_outwaremovemx.mtrlwareid,
  236. u_outwaremovemx.mtrlid,
  237. u_outwaremovemx.storageid,
  238. u_outwaremovemx.qty,
  239. u_outwaremovemx.addqty,
  240. u_outwaremovemx.cost,
  241. u_outwaremovemx.price,
  242. u_mtrldef.mtrlcode,
  243. u_mtrldef.unit,
  244. u_outwaremovemx.printid,
  245. u_outwaremovemx.mxdscrp,
  246. u_outwaremovemx.status,
  247. u_outwaremovemx.plancode,
  248. u_outwaremovemx.scid,
  249. u_outwaremovemx.dxflag,
  250. u_outwaremovemx.sptid,
  251. u_outwaremovemx.woodcode,
  252. u_outwaremovemx.pcode,
  253. u_outwaremovemx.waredscrp,
  254. u_outwaremovemx.inworkdate,
  255. u_outwaremovemx.newplancode,
  256. u_outwaremovemx.cost_notax
  257. from u_outwaremovemx,u_mtrldef
  258. where u_outwaremovemx.outwareid = :arg_outwareid and
  259. u_outwaremovemx.mtrlid=u_mtrldef.mtrlid;
  260. open cur_outwaermx;
  261. fetch cur_outwaermx into :outwaremx[i].mtrlwareid,:outwaremx[i].mtrlid,
  262. :outwaremx[i].storageid,:outwaremx[i].qty,:outwaremx[i].addqty,
  263. :outwaremx[i].cost,:outwaremx[i].price,
  264. :outwaremx[i].mtrlcode,:outwaremx[i].unit,:outwaremx[i].printid,
  265. :outwaremx[i].mxdscrp,:outwaremx[i].status,
  266. :outwaremx[i].plancode,:outwaremx[i].scid,
  267. :outwaremx[i].dxflag,:outwaremx[i].sptid,
  268. :outwaremx[i].woodcode,:outwaremx[i].pcode,
  269. :outwaremx[i].waredscrp,
  270. :outwaremx[i].inworkdate,
  271. :outwaremx[i].newplancode,
  272. :outwaremx[i].cost_notax;
  273. do while sqlca.sqlcode=0
  274. i++
  275. fetch cur_outwaermx into :outwaremx[i].mtrlwareid,:outwaremx[i].mtrlid,
  276. :outwaremx[i].storageid,:outwaremx[i].qty,:outwaremx[i].addqty,
  277. :outwaremx[i].cost,:outwaremx[i].price,
  278. :outwaremx[i].mtrlcode,:outwaremx[i].unit,:outwaremx[i].printid,
  279. :outwaremx[i].mxdscrp,:outwaremx[i].status,
  280. :outwaremx[i].plancode,:outwaremx[i].scid,
  281. :outwaremx[i].dxflag,:outwaremx[i].sptid,
  282. :outwaremx[i].woodcode,:outwaremx[i].pcode,
  283. :outwaremx[i].waredscrp,
  284. :outwaremx[i].inworkdate,
  285. :outwaremx[i].newplancode,
  286. :outwaremx[i].cost_notax;
  287. loop
  288. close cur_outwaermx;
  289. //检验明细是否读入完整
  290. select count(*) into :no_mxcheck
  291. from u_outwaremovemx
  292. where u_outwaremovemx.outwareid = :arg_outwareid;
  293. if sqlca.sqlcode<>0 then
  294. rslt=0
  295. arg_msg="查询操作失败,调拨单明细数量"
  296. goto ext
  297. end if
  298. if i<>no_mxcheck+1 then
  299. rslt=0
  300. arg_msg="查询操作失败,调拨单明细"
  301. goto ext
  302. end if
  303. outwareid = arg_outwareid
  304. it_mxbt=i - 1
  305. it_newbegin=false
  306. it_updatebegin=false
  307. ext:
  308. if rslt=0 then p_reset()
  309. return rslt
  310. end function
  311. public function integer updatebegin (long arg_outwareid, ref string arg_msg);//updatebegin(long arg_outwareid,int arg_billtype,long arg_relid)
  312. //从置对象,设定业务类型与关联id,准备更新出仓单
  313. //0 fail 1 success
  314. Int rslt = 1,cnt = 0
  315. IF arg_outwareid <= 0 THEN
  316. rslt = 0
  317. outwareid = 0
  318. GOTO ext
  319. END IF
  320. rslt = p_getinfo(arg_outwareid,arg_msg)
  321. IF rslt = 0 THEN GOTO ext
  322. IF flag = 1 THEN
  323. rslt = 0
  324. arg_msg = '单据已经审核,不可以修改'
  325. GOTO ext
  326. END IF
  327. outwareid = arg_outwareid
  328. p_clearmx()
  329. it_newbegin = False
  330. it_updatebegin = True
  331. ext:
  332. IF rslt = 0 THEN p_reset()
  333. RETURN rslt
  334. end function
  335. public function integer ss_auditing (string arg_auditingrep, ref string arg_msg);//调仓单调出审核
  336. //auditing(arg_auditingrep,arg_msg)
  337. //单据审核后生成一张原仓库调拨出仓单,目标仓库调拨入仓单
  338. //0 fail 1 success
  339. Long rslt = 1,cnt = 0,i
  340. Long rst_outwareid //调拨出仓id
  341. Long s_scid
  342. Long o_scid
  343. uo_outware uo_out
  344. uo_out = Create uo_outware
  345. uo_out.commit_transaction = sqlca
  346. uo_out.if_getid_ture = False
  347. IF outwareid = 0 THEN
  348. rslt = 0
  349. arg_msg = "没有审核对象"
  350. GOTO ext
  351. END IF
  352. IF it_newbegin Or it_updatebegin THEN
  353. rslt = 0
  354. arg_msg = "编辑状态下不可以执行审核"
  355. GOTO ext
  356. END IF
  357. IF flag = 1 THEN
  358. rslt = 0
  359. arg_msg = "单据已经调出审核"
  360. GOTO ext
  361. END IF
  362. UPDATE u_outware_move
  363. SET auditingrep = :arg_auditingrep,
  364. auditingdate = getdate(),
  365. flag = 1
  366. Where u_outware_move.outwareid = :outwareid And flag = 0;
  367. IF sqlca.SQLCode <> 0 THEN
  368. rslt = 0
  369. arg_msg = "调出审核单据操作失败"+"~n"+sqlca.SQLErrText
  370. GOTO ext
  371. ELSEIF sqlca.SQLNRows = 0 THEN
  372. rslt = 0
  373. arg_msg = "调仓单据正在调出审核,请稍后查询。"+"~n"+sqlca.SQLErrText
  374. GOTO ext
  375. END IF
  376. SELECT scid INTO :s_scid
  377. FROM u_storage
  378. Where storageid = :sstorageid;
  379. IF sqlca.SQLCode <> 0 THEN
  380. arg_msg = '查询调出仓库所属分部资料失败'
  381. rslt = 0
  382. GOTO ext
  383. END IF
  384. //2.原事务生成出仓单
  385. IF uo_out.newbegin(s_scid,12,arg_msg) = 0 THEN
  386. rslt = 0
  387. GOTO ext
  388. END IF
  389. uo_out.relid = outwareid
  390. uo_out.outdate = outdate
  391. uo_out.outrep = outrep
  392. uo_out.part = outwarecode
  393. uo_out.dscrp = dscrp
  394. uo_out.cusname = '调拨出仓'
  395. uo_out.storageid = sstorageid
  396. FOR i = 1 To it_mxbt
  397. IF uo_out.acceptmx(outwaremx[i].mtrlwareid,&
  398. outwaremx[i].qty,outwaremx[i].addqty,outwaremx[i].cost,1,&
  399. outwaremx[i].mxdscrp,outwaremx[i].printid,arg_msg,0,0,0,0,0,0,0,outwaremx[i].unit,1,'','') = 0 THEN
  400. rslt = 0
  401. GOTO ext
  402. END IF
  403. NEXT
  404. IF uo_out.Save(False,arg_msg) = 0 THEN
  405. rslt = 0
  406. GOTO ext
  407. END IF
  408. rst_outwareid = uo_out.outwareid
  409. //4.原事务审核出仓单
  410. IF uo_out.getinfo(s_scid,rst_outwareid,arg_msg) = 0 THEN
  411. rslt = 0
  412. GOTO ext
  413. END IF
  414. IF uo_out.auditing(False,arg_msg) = 0 THEN
  415. rslt = 0
  416. GOTO ext
  417. END IF
  418. //更新出仓成本价
  419. IF sys_option_outwaremove = 0 THEN //按出仓成本价
  420. UPDATE u_outwaremovemx
  421. SET cost = u_outwaremx.cost,
  422. price = u_outwaremx.cost
  423. FROM u_OutWaremoveMx INNER JOIN
  424. u_outwaremx ON u_OutWaremoveMx.MtrlWareID = u_outwaremx.mtrlwareid
  425. WHERE (u_outwaremx.scid = :s_scid)
  426. And (u_outwaremx.outwareid = :rst_outwareid);
  427. ELSE
  428. UPDATE u_outwaremovemx
  429. SET cost = u_outwaremx.cost
  430. FROM u_OutWaremoveMx INNER JOIN
  431. u_outwaremx ON u_OutWaremoveMx.MtrlWareID = u_outwaremx.mtrlwareid
  432. WHERE (u_outwaremx.scid = :s_scid)
  433. And (u_outwaremx.outwareid = :rst_outwareid);
  434. END IF
  435. IF sqlca.SQLCode <> 0 THEN
  436. rslt = 0
  437. arg_msg = "更新调拨明细出仓成本价失败"+"~n"+sqlca.SQLErrText
  438. GOTO ext
  439. END IF
  440. flag = 1
  441. ext:
  442. IF rslt = 0 THEN
  443. ROLLBACK;
  444. ELSE
  445. COMMIT;
  446. END IF
  447. Destroy uo_out
  448. RETURN rslt
  449. end function
  450. public function integer c_ss_auditing (ref string arg_msg);//调仓单审核
  451. //auditing(arg_auditingrep,arg_msg)
  452. //单据审核后生成一张原仓库调拨出仓单,目标仓库调拨入仓单
  453. //0 fail 1 success
  454. Long rslt = 1,cnt = 0,i
  455. Long rst_outwareid //调拨出仓id
  456. Long rst_inwareid //调拨进仓id
  457. Long s_scid
  458. Long o_scid
  459. DateTime null_dt
  460. SetNull(null_dt)
  461. uo_outware uo_out
  462. uo_out = Create uo_outware
  463. uo_out.commit_transaction = sqlca
  464. uo_out.if_getid_ture = False
  465. IF outwareid = 0 THEN
  466. rslt = 0
  467. arg_msg = "没有撤审对象"
  468. GOTO ext
  469. END IF
  470. IF it_newbegin Or it_updatebegin THEN
  471. rslt = 0
  472. arg_msg = "编辑状态下不可以执行审核"
  473. GOTO ext
  474. END IF
  475. IF flag = 0 THEN
  476. rslt = 0
  477. arg_msg = "单据未调出审核"
  478. GOTO ext
  479. END IF
  480. UPDATE u_outware_move
  481. SET auditingrep = '',
  482. auditingdate = :null_dt,
  483. flag = 0
  484. Where u_outware_move.outwareid = :outwareid And flag = 1;
  485. IF sqlca.SQLCode <> 0 THEN
  486. rslt = 0
  487. arg_msg = "调出撤审单据操作失败"+"~n"+sqlca.SQLErrText
  488. GOTO ext
  489. ELSEIF sqlca.SQLNRows = 0 THEN
  490. rslt = 0
  491. arg_msg = "调仓单据正在调出撤审,请稍后查询。"+"~n"+sqlca.SQLErrText
  492. GOTO ext
  493. END IF
  494. SELECT scid INTO :s_scid
  495. FROM u_storage
  496. Where storageid = :sstorageid;
  497. IF sqlca.SQLCode <> 0 THEN
  498. arg_msg = '查询调出仓库所属分部资料失败'
  499. rslt = 0
  500. GOTO ext
  501. END IF
  502. //查询调仓单相关的出仓单
  503. SELECT outwareid INTO :rst_outwareid
  504. FROM u_outware
  505. WHERE scid = :s_scid
  506. AND relid = :outwareid
  507. And billtype = 12;
  508. IF sqlca.SQLCode <> 0 THEN
  509. arg_msg = '查询该调仓单相关出仓单失败,'+sqlca.SQLErrText
  510. rslt = 0
  511. GOTO ext
  512. END IF
  513. //撤审出仓单,再删除
  514. IF uo_out.getinfo(s_scid,rst_outwareid,arg_msg) = 0 THEN
  515. rslt = 0
  516. GOTO ext
  517. END IF
  518. IF uo_out.c_auditing(False,arg_msg) = 0 THEN
  519. rslt = 0
  520. GOTO ext
  521. END IF
  522. IF uo_out.del(s_scid,rst_outwareid,arg_msg,False) = 0 THEN
  523. rslt = 0
  524. GOTO ext
  525. END IF
  526. flag = 1
  527. ext:
  528. IF rslt = 0 THEN
  529. ROLLBACK;
  530. ELSE
  531. COMMIT;
  532. END IF
  533. Destroy uo_out
  534. RETURN rslt
  535. end function
  536. public function integer ds_auditing (string arg_auditingrep, ref string arg_msg);//调仓单调入审核
  537. //auditing(arg_auditingrep,arg_msg)
  538. //单据审核后生成一张原仓库调拨出仓单,目标仓库调拨入仓单
  539. //0 fail 1 success
  540. Long rslt = 1,cnt = 0,i
  541. Long rst_inwareid //调拨进仓id
  542. Long s_scid
  543. Long o_scid
  544. uo_inware uo_in
  545. uo_in = CREATE uo_inware
  546. uo_in.commit_transaction = sqlca
  547. uo_in.if_getid_ture = FALSE
  548. IF outwareid = 0 THEN
  549. rslt = 0
  550. arg_msg = "没有审核对象"
  551. GOTO ext
  552. END IF
  553. IF it_newbegin OR it_updatebegin THEN
  554. rslt = 0
  555. arg_msg = "编辑状态下不可以执行审核"
  556. GOTO ext
  557. END IF
  558. IF d_auditflag = 1 THEN
  559. rslt = 0
  560. arg_msg = "单据已经调入审核"
  561. GOTO ext
  562. END IF
  563. UPDATE u_outware_move
  564. SET d_auditingrep = :arg_auditingrep,
  565. d_auditingdate = getdate(),
  566. d_auditflag = 1
  567. Where u_outware_move.outwareid = :outwareid AND d_auditflag = 0;
  568. IF sqlca.SQLCode <> 0 THEN
  569. rslt = 0
  570. arg_msg = "调入审核单据操作失败"+"~n"+sqlca.SQLErrText
  571. GOTO ext
  572. ELSEIF sqlca.SQLNRows = 0 THEN
  573. rslt = 0
  574. arg_msg = "调仓单据正在调入审核,请稍后查询。"+"~n"+sqlca.SQLErrText
  575. GOTO ext
  576. END IF
  577. SELECT scid INTO :o_scid
  578. FROM u_storage
  579. Where storageid = :dstorageid;
  580. IF sqlca.SQLCode <> 0 THEN
  581. arg_msg = '查询调入仓库所属分部资料失败'
  582. rslt = 0
  583. GOTO ext
  584. END IF
  585. //3.目标事务建立进仓单
  586. DateTime server_datetime
  587. SELECT Top 1 getdate() INTO :server_datetime FROM u_user;
  588. //取得系统时间,借用操作员表
  589. IF sqlca.SQLCode <> 0 THEN
  590. rslt = 0
  591. arg_msg = "查询目标仓库日期失败"
  592. GOTO ext
  593. END IF
  594. IF uo_in.newbegin(o_scid,12,arg_msg) = 0 THEN
  595. rslt = 0
  596. GOTO ext
  597. END IF
  598. uo_in.relid = outwareid
  599. uo_in.indate = outdate
  600. uo_in.inrep = outrep
  601. uo_in.part = outwarecode
  602. uo_in.dscrp = dscrp
  603. uo_in.storageid = dstorageid
  604. uo_in.sptname = '调拨进仓'
  605. FOR i = 1 TO it_mxbt
  606. Decimal ld_price
  607. IF sys_option_outwaremove = 0 THEN
  608. ld_price = outwaremx[i].cost
  609. ELSE
  610. ld_price = outwaremx[i].price
  611. END IF
  612. IF uo_in.acceptmx(outwaremx[i].printid,&
  613. outwaremx[i].mtrlid,&
  614. outwaremx[i].mtrlcode,&
  615. outwaremx[i].newplancode,&
  616. outwaremx[i].status,&
  617. outwaremx[i].qty,&
  618. outwaremx[i].addqty,&
  619. ld_price,&
  620. 1,&
  621. outwaremx[i].mxdscrp,&
  622. arg_msg,&
  623. 0,0,0,0,outwaremx[i].woodcode,&
  624. outwaremx[i].pcode,&
  625. '',&
  626. outwaremx[i].sptid,outwaremx[i].unit,1,'',outwaremx[i].waredscrp,outwaremx[i].inworkdate,outwaremx[i].cost_notax) = 0 THEN
  627. rslt = 0
  628. GOTO ext
  629. END IF
  630. NEXT
  631. IF uo_in.Save(FALSE,arg_msg) = 0 THEN
  632. rslt = 0
  633. GOTO ext
  634. END IF
  635. rst_inwareid = uo_in.inwareid
  636. //4.原事务审核进仓单
  637. IF uo_in.getinfo(o_scid,rst_inwareid,arg_msg) = 0 THEN
  638. rslt = 0
  639. GOTO ext
  640. END IF
  641. IF uo_in.auditing(FALSE,arg_msg) = 0 THEN
  642. rslt = 0
  643. GOTO ext
  644. END IF
  645. d_auditflag = 1
  646. ext:
  647. IF rslt = 0 THEN
  648. ROLLBACK;
  649. ELSE
  650. COMMIT;
  651. END IF
  652. DESTROY uo_in
  653. RETURN rslt
  654. end function
  655. public function integer c_ds_auditing (ref string arg_msg);//调仓单调入撤审
  656. //auditing(arg_auditingrep,arg_msg)
  657. //单据审核后生成一张原仓库调拨出仓单,目标仓库调拨入仓单
  658. //0 fail 1 success
  659. Long rslt = 1,cnt = 0,i
  660. Long rst_inwareid //调拨进仓id
  661. Long s_scid
  662. Long o_scid
  663. DateTime null_dt
  664. SetNull(null_dt)
  665. uo_inware uo_in
  666. uo_in = Create uo_inware
  667. uo_in.commit_transaction = sqlca
  668. uo_in.if_getid_ture = False
  669. IF outwareid = 0 THEN
  670. rslt = 0
  671. arg_msg = "没有撤审对象"
  672. GOTO ext
  673. END IF
  674. IF it_newbegin Or it_updatebegin THEN
  675. rslt = 0
  676. arg_msg = "编辑状态下不可以执行审核"
  677. GOTO ext
  678. END IF
  679. IF d_auditflag = 0 THEN
  680. rslt = 0
  681. arg_msg = "单据未调入审核"
  682. GOTO ext
  683. END IF
  684. UPDATE u_outware_move
  685. SET d_auditingrep = '',
  686. d_auditingdate = :null_dt,
  687. d_auditflag = 0
  688. Where u_outware_move.outwareid = :outwareid And d_auditflag = 1;
  689. IF sqlca.SQLCode <> 0 THEN
  690. rslt = 0
  691. arg_msg = "调入撤审单据操作失败"+"~n"+sqlca.SQLErrText
  692. GOTO ext
  693. ELSEIF sqlca.SQLNRows = 0 THEN
  694. rslt = 0
  695. arg_msg = "调仓单据正在调入撤审,请稍后查询。"+"~n"+sqlca.SQLErrText
  696. GOTO ext
  697. END IF
  698. SELECT scid INTO :o_scid
  699. FROM u_storage
  700. Where storageid = :dstorageid;
  701. IF sqlca.SQLCode <> 0 THEN
  702. arg_msg = '查询调入仓库所属分部资料失败'
  703. rslt = 0
  704. GOTO ext
  705. END IF
  706. //查询调仓单相关的入仓单
  707. SELECT top 1 inwareid INTO :rst_inwareid
  708. FROM u_inware
  709. WHERE scid = :o_scid
  710. AND relid = :outwareid
  711. And billtype = 12;
  712. IF sqlca.SQLCode <> 0 THEN
  713. arg_msg = '查询该调仓单相关入仓单失败,'+sqlca.SQLErrText
  714. rslt = 0
  715. GOTO ext
  716. END IF
  717. //撤审入仓单,再删除
  718. IF uo_in.getinfo(o_scid,rst_inwareid,arg_msg) = 0 THEN
  719. rslt = 0
  720. GOTO ext
  721. END IF
  722. IF uo_in.c_auditing(False,arg_msg) = 0 THEN
  723. rslt = 0
  724. GOTO ext
  725. END IF
  726. IF uo_in.del(o_scid,rst_inwareid,arg_msg,False) = 0 THEN
  727. rslt = 0
  728. GOTO ext
  729. END IF
  730. d_auditflag = 1
  731. ext:
  732. IF rslt = 0 THEN
  733. ROLLBACK;
  734. ELSE
  735. COMMIT;
  736. END IF
  737. Destroy uo_in
  738. RETURN rslt
  739. end function
  740. public function integer mod_price (long arg_scid, long arg_outwareid, long arg_printid, decimal arg_price, ref string arg_msg);Long rslt = 1
  741. UPDATE u_OutWaremoveMx
  742. SET price = :arg_price
  743. WHERE outWareID = :arg_outwareid AND
  744. scid = :arg_scid AND
  745. Printid = :arg_printid ;
  746. IF sqlca.SQLCode <> 0 THEN
  747. rslt = 0
  748. arg_msg = "更新单价操作失败"+"~n"+sqlca.SQLErrText
  749. GOTO ext
  750. END IF
  751. ext:
  752. IF rslt = 0 THEN
  753. ROLLBACK;
  754. ELSE
  755. COMMIT;
  756. END IF
  757. RETURN rslt
  758. end function
  759. public function integer save (boolean arg_ifcommit, ref string arg_msg);//submit(string arg_msg)
  760. // 新建(outwareid=0)\更新(outwareid>0)
  761. //0 fail 1 success
  762. //
  763. // 函数执行出仓操作
  764. // 函数在表 u_outware_move、u_outwaremovemx 记帐
  765. // 1 检查单据信息合法性
  766. // 2 新建-取得单据编号\新建出仓单\读取出仓单唯一码\插入明细
  767. // 2 修改-更新出仓单\删除旧明细\插入明细
  768. // 3 提交,修改状态标志
  769. Integer rslt = 1,cnt = 0,i
  770. DateTime server_datetime
  771. Long ls_newid
  772. IF IsNull(dscrp) THEN dscrp = ''
  773. IF IsNull(outrep) THEN outrep = ''
  774. IF IsNull(relcode) THEN relcode = ''
  775. IF IsNull(reason) THEN reason = ''
  776. IF it_newbegin = False And it_updatebegin = False THEN
  777. rslt = 0
  778. arg_msg = "非编辑状态不可以提交"
  779. GOTO ext
  780. END IF
  781. SELECT Top 1 getdate() Into :server_datetime From u_user ;
  782. //取得系统时间,借用操作员表
  783. IF sqlca.SQLCode <> 0 THEN
  784. rslt = 0
  785. arg_msg = "查询操作失败,日期 "
  786. GOTO ext
  787. END IF
  788. IF it_mxbt = 0 THEN //如果输入库存物料资料错则已经清空
  789. rslt = 0
  790. arg_msg = "没有正确出仓内容"
  791. GOTO ext
  792. END IF
  793. IF outrep = '' THEN
  794. rslt = 0
  795. arg_msg = '请输入经手人'
  796. GOTO ext
  797. END IF
  798. IF Year(Date(outdate)) < 2000 Or IsNull(outdate) THEN
  799. rslt = 0
  800. arg_msg = "缺少出仓发生时间或不合理"
  801. GOTO ext
  802. END IF
  803. //检查仓库
  804. cnt = 0
  805. SELECT count(*) Into :cnt From u_storage Where storageid = :sstorageid;
  806. IF sqlca.SQLCode <> 0 THEN
  807. rslt = 0
  808. arg_msg = "查询操作失败,调出仓库"
  809. GOTO ext
  810. END IF
  811. IF cnt = 0 THEN
  812. rslt = 0
  813. arg_msg = "调出仓库未登记或已取消"
  814. GOTO ext
  815. END IF
  816. cnt = 0
  817. SELECT count(*) Into :cnt From u_storage Where storageid = :dstorageid;
  818. IF sqlca.SQLCode <> 0 THEN
  819. rslt = 0
  820. arg_msg = "查询操作失败,调入仓库"
  821. GOTO ext
  822. END IF
  823. IF cnt = 0 THEN
  824. rslt = 0
  825. arg_msg = "调入仓库未登记或已取消"
  826. GOTO ext
  827. END IF
  828. opdate = server_datetime //填写单据建立时间(最近修改时间)
  829. ////////////////////////////////////////////// //开始区分:新建/更新 处理
  830. IF outwareid = 0 THEN //新建
  831. ls_newid = f_sys_scidentity(sys_scid,"u_outware_move","outwareid",arg_msg,True,sqlca)
  832. IF ls_newid <= 0 THEN
  833. rslt = 0
  834. ROLLBACK;
  835. GOTO ext
  836. END IF
  837. outwarecode = getid(sys_scid,"MV",Date(server_datetime),True,sqlca) //取得新单据编号
  838. IF outwarecode = "err" THEN
  839. outwarecode = ''
  840. rslt = 0
  841. arg_msg = "无法获取出仓单编号"
  842. GOTO ext
  843. END IF
  844. INSERT INTO u_outware_move (
  845. outwareid,
  846. outwarecode,
  847. sstorageid,
  848. dstorageid,
  849. opdate,
  850. operator,
  851. flag,
  852. outdate,
  853. outrep,
  854. dscrp,
  855. relcode,
  856. reason)
  857. VALUES ( :ls_newid,
  858. :outwarecode,
  859. :sstorageid,
  860. :dstorageid,
  861. :server_datetime,
  862. :publ_operator,
  863. :flag,
  864. :outdate,
  865. :outrep,
  866. :dscrp,
  867. :relcode,
  868. :reason) ;
  869. IF sqlca.SQLCode <> 0 THEN
  870. rslt = 0
  871. arg_msg = '插入单据失败,'+sqlca.SQLErrText
  872. GOTO ext
  873. END IF
  874. outwareid = ls_newid
  875. ELSE //////////////////////////////////////////////// //更新
  876. UPDATE u_outware_move
  877. SET
  878. outdate = :outdate,
  879. outrep = :outrep,
  880. dscrp = :dscrp,
  881. sstorageid = :sstorageid,
  882. dstorageid = :dstorageid,
  883. relcode = :relcode,
  884. modrep = :publ_operator,
  885. moddate = getdate(),
  886. reason = :reason
  887. Where u_outware_move.outwareid = :outwareid And flag = 0;
  888. IF sqlca.SQLCode <> 0 Or sqlca.SQLNRows <= 0 THEN
  889. rslt = 0
  890. arg_msg = "更新单据操作失败"+"~n"+sqlca.SQLErrText
  891. GOTO ext
  892. END IF
  893. //删除原有明细
  894. DELETE FROM u_outwaremovemx
  895. Where u_outwaremovemx.outwareid = :outwareid;
  896. IF sqlca.SQLCode <> 0 THEN
  897. rslt = 0
  898. arg_msg = "删除旧有明细操作失败"+"~n"+sqlca.SQLErrText
  899. GOTO ext
  900. END IF
  901. // FOR i = 1 To it_mxbt
  902. // INSERT INTO u_outwaremovemx
  903. // ( outwareid,
  904. // mtrlwareid,
  905. // mtrlid,
  906. // storageid,
  907. // qty,
  908. // addqty,
  909. // cost,
  910. // price,
  911. // printid,
  912. // mxdscrp,
  913. // scid,
  914. // status,
  915. // plancode,
  916. // dxflag,
  917. // sptid,
  918. // woodcode,
  919. // pcode,
  920. // waredscrp,
  921. // inworkdate,
  922. // newplancode)
  923. // VALUES (:outwareid,
  924. // :outwaremx[i].mtrlwareid,
  925. // :outwaremx[i].mtrlid,
  926. // :outwaremx[i].storageid,
  927. // :outwaremx[i].qty,
  928. // :outwaremx[i].addqty,
  929. // :outwaremx[i].cost,
  930. // :outwaremx[i].price,
  931. // :outwaremx[i].printid,
  932. // :outwaremx[i].mxdscrp,
  933. // :outwaremx[i].scid,
  934. // :outwaremx[i].status,
  935. // :outwaremx[i].plancode,
  936. // :outwaremx[i].dxflag,
  937. // :outwaremx[i].sptid,
  938. // :outwaremx[i].woodcode,
  939. // :outwaremx[i].pcode,
  940. // :outwaremx[i].waredscrp,
  941. // :outwaremx[i].inworkdate,
  942. // :outwaremx[i].newplancode);
  943. //
  944. // IF sqlca.SQLCode <> 0 THEN
  945. // rslt = 0
  946. // IF Pos(Lower(sqlca.SQLErrText),'PK_u_outwaremovemx') > 0 THEN
  947. // arg_msg = '插入单据明细资料失败,关键字ID,序号重复'
  948. // ELSE
  949. // arg_msg = '因网络或其他原因导致插入单据明细资料失败,'+sqlca.SQLErrText
  950. // END IF
  951. // GOTO ext
  952. // END IF
  953. // NEXT
  954. END IF
  955. FOR i = 1 To it_mxbt
  956. INSERT INTO u_outwaremovemx
  957. (outwareid,
  958. mtrlwareid,
  959. mtrlid,
  960. storageid,
  961. qty,
  962. addqty,
  963. cost,
  964. price,
  965. printid,
  966. mxdscrp,
  967. scid,
  968. status,
  969. plancode,
  970. dxflag,
  971. sptid,
  972. woodcode,
  973. pcode,
  974. waredscrp,
  975. inworkdate,
  976. newplancode,
  977. packqty,
  978. cost_notax)
  979. VALUES (:outwareid,
  980. :outwaremx[i].mtrlwareid,
  981. :outwaremx[i].mtrlid,
  982. :outwaremx[i].storageid,
  983. :outwaremx[i].qty,
  984. :outwaremx[i].addqty,
  985. :outwaremx[i].cost,
  986. :outwaremx[i].price,
  987. :outwaremx[i].printid,
  988. :outwaremx[i].mxdscrp,
  989. :outwaremx[i].scid,
  990. :outwaremx[i].status,
  991. :outwaremx[i].plancode,
  992. :outwaremx[i].dxflag,
  993. :outwaremx[i].sptid,
  994. :outwaremx[i].woodcode,
  995. :outwaremx[i].pcode,
  996. :outwaremx[i].waredscrp,
  997. :outwaremx[i].inworkdate,
  998. :outwaremx[i].newplancode,
  999. :outwaremx[i].packqty,
  1000. :outwaremx[i].cost_notax);
  1001. IF sqlca.SQLCode <> 0 THEN
  1002. IF it_newbegin THEN outwareid = 0 //还原outwareid
  1003. rslt = 0
  1004. arg_msg = '插入单据明细失败,'+sqlca.SQLErrText
  1005. GOTO ext
  1006. END IF
  1007. NEXT
  1008. it_newbegin = False
  1009. it_updatebegin = False
  1010. ext:
  1011. IF rslt = 0 THEN
  1012. ROLLBACK;
  1013. p_clearmx()
  1014. ELSEIF arg_ifcommit THEN
  1015. COMMIT;
  1016. END IF
  1017. Return(rslt)
  1018. end function
  1019. public function integer acceptmx (long arg_mtrlwareid, decimal arg_qty, decimal arg_addqty, decimal arg_price, ref string arg_msg, long arg_printid, string arg_mxdscrp, string arg_newplancode, integer arg_packqty);//acceptmx(arg_mtrlwareid,arg_qty,arg_msg,arg_printid,arg_mxdscrp)
  1020. //return 0 fail 1 success
  1021. // 函数增加出仓单的一个出仓明细项
  1022. Long rslt = 1,cnt = 0,ls_i
  1023. Long i_mtrlid,i_storageid,i_scid
  1024. String i_mtrlcode,i_status,i_plancode,i_woodcode,i_pcode
  1025. Decimal i_cost,i_cost_notax
  1026. Int i_dxflag
  1027. Long i_sptid
  1028. Decimal i_notauditqty,i_allouseqty
  1029. String i_waredscrp
  1030. DateTime i_inworkdate
  1031. IF it_newbegin = False And it_updatebegin = False THEN
  1032. rslt = 0
  1033. arg_msg = "非编辑状态不可以使用,操作取消"
  1034. GOTO ext
  1035. END IF
  1036. //清除空值
  1037. IF IsNull(arg_mtrlwareid) THEN arg_mtrlwareid = 0
  1038. IF IsNull(arg_qty) THEN arg_qty = 0
  1039. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  1040. IF IsNull(arg_printid) THEN arg_printid = 0
  1041. IF IsNull(arg_price) THEN arg_price = 0
  1042. IF isnull(arg_packqty) then arg_packqty = 0
  1043. IF arg_mtrlwareid = 0 Or arg_qty = 0 THEN // 如果出仓数量为 0,或物料编号为空,则不作任何处理
  1044. rslt = 1
  1045. GOTO ext
  1046. END IF
  1047. //检查物料库存id
  1048. SELECT u_mtrlware.mtrlid,
  1049. u_mtrlware.storageid,
  1050. u_mtrlware.cost,
  1051. u_mtrldef.mtrlcode,
  1052. u_mtrlware.plancode,
  1053. u_mtrlware.status,
  1054. u_mtrlware.scid,
  1055. u_mtrlware.dxflag,
  1056. u_mtrlware.sptid,
  1057. u_mtrlware.woodcode,
  1058. u_mtrlware.pcode,
  1059. isnull(uv_mtrlware_noauditingqty.noauditingqty,0),
  1060. u_mtrlware.noallocqty,
  1061. u_mtrlware.waredscrp,
  1062. u_mtrlware.inworkdate,
  1063. u_mtrlware.cost_notax
  1064. INTO :i_mtrlid,
  1065. :i_storageid,
  1066. :i_cost,
  1067. :i_mtrlcode,
  1068. :i_plancode,
  1069. :i_status,
  1070. :i_scid,
  1071. :i_dxflag,
  1072. :i_sptid,
  1073. :i_woodcode,
  1074. :i_pcode,
  1075. :i_notauditqty,
  1076. :i_allouseqty,
  1077. :i_waredscrp,
  1078. :i_inworkdate,
  1079. :i_cost_notax
  1080. FROM u_mtrlware left OUTER join uv_mtrlware_noauditingqty
  1081. on ( u_mtrlware.mtrlwareid = uv_mtrlware_noauditingqty.mtrlwareid)
  1082. AND ( u_mtrlware.scid = uv_mtrlware_noauditingqty.scid),u_mtrldef
  1083. WHERE ( u_mtrlware.mtrlwareid = :arg_mtrlwareid )
  1084. AND ( u_mtrlware.mtrlid = u_mtrldef.mtrlid )
  1085. And ( u_mtrlware.storageid = :sstorageid );
  1086. IF sqlca.SQLCode <> 0 THEN
  1087. rslt = 0
  1088. arg_msg = "查询操作失败,库存编号错误"
  1089. GOTO ext
  1090. END IF
  1091. //检查成本价调整单
  1092. cnt = 0
  1093. SELECT count(*)
  1094. INTO :cnt
  1095. FROM u_updatecost,u_updatecostmx
  1096. WHERE u_updatecost.wareid = u_updatecostmx.wareid AND
  1097. u_updatecost.flag = 0 AND
  1098. u_updatecostmx.mtrlwareid = :arg_mtrlwareid Using sqlca;
  1099. IF sqlca.SQLCode <> 0 THEN
  1100. rslt = 0
  1101. arg_msg = "第" + String(arg_printid) + "行,查询成本价调整单操作失败"
  1102. GOTO ext
  1103. END IF
  1104. IF cnt > 0 THEN
  1105. rslt = 0
  1106. arg_msg = "第" + String(arg_printid) + "行," + i_mtrlcode + "已开成本价调整单,请先审核"
  1107. GOTO ext
  1108. END IF
  1109. IF IsNull(i_cost) THEN i_cost = 0
  1110. IF IsNull(i_cost_notax) THEN i_cost_notax = 0
  1111. IF IsNull(i_mtrlid) THEN i_mtrlid = 0
  1112. IF IsNull(i_storageid) THEN i_storageid = 0
  1113. IF IsNull(i_status) THEN i_status = ''
  1114. IF IsNull(i_plancode) THEN i_plancode = ''
  1115. IF IsNull(i_scid) THEN i_scid = 0
  1116. IF IsNull(i_dxflag) THEN i_dxflag = 0
  1117. IF IsNull(i_sptid) THEN i_sptid = 0
  1118. IF IsNull(i_pcode) THEN i_pcode = ''
  1119. //*****检查大于未开数不可以开单
  1120. IF flag = 0 THEN
  1121. Int ls_noallocflag
  1122. Decimal ol_mtrl_qty = 0
  1123. SELECT noallocflag INTO :ls_noallocflag
  1124. FROM u_storage
  1125. Where storageid = :sstorageid;
  1126. IF sqlca.SQLCode <> 0 THEN
  1127. rslt = 0
  1128. arg_msg = '查询仓库允许使用未开单库存属性失败'+sqlca.SQLErrText
  1129. GOTO ext
  1130. END IF
  1131. IF ls_noallocflag = 1 THEN
  1132. IF it_updatebegin THEN
  1133. SELECT u_outwaremovemx.qty
  1134. INTO :ol_mtrl_qty
  1135. FROM u_outwaremovemx
  1136. WHERE u_outwaremovemx.outwareid = :outwareid
  1137. And u_outwaremovemx.mtrlwareid = :arg_mtrlwareid;
  1138. IF sqlca.SQLCode = -1 THEN
  1139. rslt = 0
  1140. arg_msg = '查询原开单数量失败'
  1141. GOTO ext
  1142. END IF
  1143. END IF
  1144. IF arg_qty > ( i_allouseqty - i_notauditqty + ol_mtrl_qty ) THEN
  1145. rslt = 0
  1146. arg_msg = String(i_mtrlcode)+"库存未开单数不够,不能开单.未开单数{"+String(i_allouseqty - i_notauditqty + ol_mtrl_qty,'#####,0.00##')+"}"
  1147. GOTO ext
  1148. END IF
  1149. END IF
  1150. END IF
  1151. //***********************************************
  1152. //写入内容
  1153. it_mxbt++
  1154. outwaremx[it_mxbt].scid = i_scid
  1155. outwaremx[it_mxbt].mtrlwareid = arg_mtrlwareid
  1156. outwaremx[it_mxbt].mtrlid = i_mtrlid
  1157. outwaremx[it_mxbt].qty = arg_qty
  1158. outwaremx[it_mxbt].addqty = arg_addqty
  1159. outwaremx[it_mxbt].storageid = i_storageid
  1160. outwaremx[it_mxbt].cost = i_cost
  1161. outwaremx[it_mxbt].cost_notax = i_cost_notax
  1162. outwaremx[it_mxbt].mtrlcode = i_mtrlcode
  1163. outwaremx[it_mxbt].printid = arg_printid
  1164. outwaremx[it_mxbt].mxdscrp = arg_mxdscrp
  1165. outwaremx[it_mxbt].status = i_status
  1166. outwaremx[it_mxbt].plancode = i_plancode
  1167. outwaremx[it_mxbt].dxflag = i_dxflag
  1168. outwaremx[it_mxbt].sptid = i_sptid
  1169. outwaremx[it_mxbt].woodcode = i_woodcode
  1170. outwaremx[it_mxbt].pcode = i_pcode
  1171. outwaremx[it_mxbt].price = arg_price
  1172. outwaremx[it_mxbt].waredscrp = i_waredscrp
  1173. outwaremx[it_mxbt].inworkdate = i_inworkdate
  1174. outwaremx[it_mxbt].newplancode = arg_newplancode
  1175. outwaremx[it_mxbt].packqty = arg_packqty
  1176. ext:
  1177. IF rslt = 0 THEN
  1178. p_clearmx()
  1179. arg_msg = "第" + String(arg_printid) + "行," + arg_msg
  1180. END IF
  1181. Return(rslt)
  1182. end function
  1183. on uo_outware_move.create
  1184. call super::create
  1185. TriggerEvent( this, "constructor" )
  1186. end on
  1187. on uo_outware_move.destroy
  1188. TriggerEvent( this, "destructor" )
  1189. call super::destroy
  1190. end on