uo_reissue.sru 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521
  1. $PBExportHeader$uo_reissue.sru
  2. forward
  3. global type uo_reissue from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_reissue from nonvisualobject
  7. end type
  8. global uo_reissue uo_reissue
  9. type variables
  10. PUBLIC PROTECTEDWRITE Long scid
  11. PUBLIC PROTECTEDWRITE Long reissueid
  12. PUBLIC PROTECTEDWRITE String reissuecode
  13. PUBLIC PROTECTEDWRITE DateTime opdate
  14. PUBLIC PROTECTEDWRITE String opemp
  15. PUBLIC PROTECTEDWRITE DateTime moddate
  16. PUBLIC PROTECTEDWRITE String modemp
  17. PUBLIC PROTECTEDWRITE Int flag
  18. PUBLIC PROTECTEDWRITE DateTime auditingdate
  19. PUBLIC PROTECTEDWRITE String auditingrep
  20. PUBLIC PROTECTEDWRITE Decimal sumamt = 0
  21. Long relid
  22. String relcode
  23. DateTime reissuedate
  24. String dscrp
  25. Long cusid
  26. String cuscode
  27. String reissueemp
  28. String cusname
  29. Long r_type
  30. Long relint_3
  31. Long moneyid
  32. Decimal mrate
  33. long itemid
  34. Int cwauditingflag = 0 //总账审核标记
  35. DateTime cwauditingdate //总账审核时间
  36. String cwauditingrep //总账审核操作员
  37. Transaction commit_transaction
  38. Boolean if_getid_ture = TRUE
  39. s_reissuemx reissuemx[]
  40. Long it_mxbt
  41. Boolean it_newbegin = FALSE
  42. Boolean it_updatebegin = FALSE
  43. end variables
  44. forward prototypes
  45. public function integer p_clearmx ()
  46. public function integer p_reset ()
  47. public function integer p_getinfo (long arg_scid, long arg_reissueid, ref string arg_msg)
  48. public function integer getinfo (long arg_scid, long arg_reissueid, ref string arg_msg)
  49. public function integer newbegin (long arg_scid, ref string arg_msg)
  50. public function integer updatebegin (long arg_scid, long arg_reissueid, ref string arg_msg)
  51. public function integer add_dscrp (long arg_scid, long arg_reissueid, string arg_newdescppart, ref string arg_msg)
  52. public function integer save (boolean arg_ifcommit, ref string arg_msg)
  53. public function integer del (long arg_scid, long arg_reissueid, ref string arg_msg, boolean arg_ifcommit)
  54. public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
  55. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
  56. public function integer acceptmx (decimal arg_qty, double arg_price, decimal arg_amt, string arg_mxdscrp, long arg_printid, ref string arg_msg, long arg_mtrlid, string arg_mtrlname)
  57. public function integer audit_subject (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  58. public function integer c_audit_subject (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  59. end prototypes
  60. public function integer p_clearmx ();//int p_clearmx()
  61. //清除明细
  62. it_mxbt=0
  63. sumamt = 0
  64. return 1
  65. end function
  66. public function integer p_reset ();//int p_reset()
  67. //清除对象及其明细
  68. scid = 0
  69. reissueid = 0
  70. reissuecode = ''
  71. opemp = ''
  72. modemp = ''
  73. auditingrep = ''
  74. flag = 0
  75. relid = 0
  76. relcode = ''
  77. dscrp = ''
  78. cusid = 0
  79. moneyid = 0
  80. cuscode = ''
  81. cusname = ''
  82. it_newbegin = FALSE
  83. it_updatebegin = FALSE
  84. //清除明细
  85. p_clearmx()
  86. RETURN 1
  87. end function
  88. public function integer p_getinfo (long arg_scid, long arg_reissueid, ref string arg_msg);//p_getinfo(arg_scid,arg_outwareid,arg_msg)
  89. //0 失败 1成功
  90. Int rslt = 1
  91. IF arg_reissueid <= 0 THEN
  92. rslt = 0
  93. arG_MSG = "非法补件单唯一码"
  94. GOTO ext
  95. END IF
  96. SELECT u_reissue.reissuecode,
  97. u_reissue.cusid,
  98. u_reissue.cuscode,
  99. u_reissue.cusname,
  100. u_reissue.reissuedate,
  101. u_reissue.relid,
  102. u_reissue.relcode,
  103. u_reissue.dscrp,
  104. u_reissue.flag,
  105. u_reissue.reissueemp,
  106. u_reissue.type,
  107. u_reissue.moneyid,
  108. u_reissue.mrate,
  109. u_reissue.relint_3,
  110. u_reissue.itemid,
  111. u_reissue.cwauditingflag,
  112. u_reissue.cwauditingrep,
  113. u_reissue.cwauditingdate
  114. INTO :reissuecode,
  115. :cusid,
  116. :cuscode,
  117. :cusname,
  118. :reissuedate,
  119. :relid,
  120. :relcode,
  121. :dscrp,
  122. :flag,
  123. :reissueemp,
  124. :r_type,
  125. :moneyid,
  126. :mrate,
  127. :relint_3,
  128. :itemid,
  129. :cwauditingflag,
  130. :cwauditingrep,
  131. :cwauditingdate
  132. FROM u_reissue
  133. WHERE u_reissue.reissueid = :arg_reissueid
  134. AND scid = :arg_scid
  135. USING commit_transaction;
  136. IF commit_transaction.SQLCode <> 0 THEN
  137. rslt = 0
  138. arG_MSG = "查询操作失败(错误补件单唯一码),补件单"+commit_transaction.SQLErrText
  139. GOTO ext
  140. END IF
  141. reissueid = arg_reissueid
  142. scid = arg_scid
  143. ext:
  144. IF rslt = 0 THEN p_reset()
  145. RETURN rslt
  146. end function
  147. public function integer getinfo (long arg_scid, long arg_reissueid, ref string arg_msg);//getinfo(arg_scid,arg_reissueid,arg_msg)
  148. //0 失败 1成功
  149. Int rslt = 1,i = 1,no_mxcheck = 0
  150. IF arg_reissueid <= 0 THEN
  151. rslt = 0
  152. arg_msg = "非法补件单唯一码"
  153. GOTO ext
  154. END IF
  155. sumamt = 0
  156. rslt = p_getinfo(arg_scid,arg_reissueid,arg_msg)
  157. IF rslt = 0 THEN GOTO ext
  158. //用游标读取明细
  159. IF r_type = 0 THEN
  160. DECLARE cur_inwaermx_0 CURSOR FOR
  161. SELECT u_reissuemx.printid,
  162. u_reissuemx.mtrlid,
  163. u_mtrldef.mtrlcode,
  164. u_mtrldef.mtrlname,
  165. u_reissuemx.qty,
  166. u_reissuemx.price,
  167. u_reissuemx.dscrp,
  168. u_reissuemx.amt,
  169. u_reissuemx.relid
  170. FROM u_reissuemx left OUTER join u_mtrldef on
  171. u_reissuemx.mtrlid = u_mtrldef.mtrlid
  172. WHERE u_reissuemx.reissueid = :arg_reissueid AND
  173. u_reissuemx.scid = :arg_scid USING commit_transaction;
  174. OPEN cur_inwaermx_0;
  175. FETCH cur_inwaermx_0 INTO :reissuemx[i].printid,
  176. :reissuemx[i].mtrlid,:reissuemx[i].mtrlcode,
  177. :reissuemx[i].mtrlname,:reissuemx[i].qty,
  178. :reissuemx[i].price,
  179. :reissuemx[i].mxdscrp,
  180. :reissuemx[i].amt,
  181. :reissuemx[i].relid;
  182. DO WHILE commit_transaction.SQLCode = 0
  183. sumamt += reissuemx[i].amt
  184. i++
  185. FETCH cur_inwaermx_0 INTO :reissuemx[i].printid,
  186. :reissuemx[i].mtrlid,:reissuemx[i].mtrlcode,
  187. :reissuemx[i].mtrlname,:reissuemx[i].qty,
  188. :reissuemx[i].price,
  189. :reissuemx[i].mxdscrp,
  190. :reissuemx[i].amt,
  191. :reissuemx[i].relid;
  192. LOOP
  193. CLOSE cur_inwaermx_0;
  194. ELSEIF r_type = 1 THEN
  195. DECLARE cur_inwaermx_1 CURSOR FOR
  196. SELECT u_reissuemx.printid,
  197. u_reissuemx.mtrlid,
  198. U_Expenses.Expensescode,
  199. U_Expenses.Expensesname,
  200. u_reissuemx.qty,
  201. u_reissuemx.price,
  202. u_reissuemx.dscrp,
  203. u_reissuemx.amt,
  204. u_reissuemx.relid
  205. FROM u_reissuemx left OUTER join U_Expenses on
  206. u_reissuemx.mtrlid = U_Expenses.Expensesid
  207. WHERE u_reissuemx.reissueid = :arg_reissueid AND
  208. u_reissuemx.scid = :arg_scid USING commit_transaction;
  209. OPEN cur_inwaermx_1;
  210. FETCH cur_inwaermx_1 INTO :reissuemx[i].printid,
  211. :reissuemx[i].mtrlid,:reissuemx[i].mtrlcode,
  212. :reissuemx[i].mtrlname,:reissuemx[i].qty,
  213. :reissuemx[i].price,
  214. :reissuemx[i].mxdscrp,
  215. :reissuemx[i].amt,
  216. :reissuemx[i].relid;
  217. DO WHILE commit_transaction.SQLCode = 0
  218. sumamt += reissuemx[i].amt
  219. i++
  220. FETCH cur_inwaermx_1 INTO :reissuemx[i].printid,
  221. :reissuemx[i].mtrlid,:reissuemx[i].mtrlcode,
  222. :reissuemx[i].mtrlname,:reissuemx[i].qty,
  223. :reissuemx[i].price,
  224. :reissuemx[i].mxdscrp,
  225. :reissuemx[i].amt,
  226. :reissuemx[i].relid;
  227. LOOP
  228. CLOSE cur_inwaermx_1;
  229. ELSEIF r_type = 2 THEN
  230. DECLARE cur_inwaermx_2 CURSOR FOR
  231. SELECT u_reissuemx.printid,
  232. u_reissuemx.mtrlid,
  233. U_Expenses.Expensescode,
  234. u_reissuemx.mtrlname,
  235. u_reissuemx.qty,
  236. u_reissuemx.price,
  237. u_reissuemx.dscrp,
  238. u_reissuemx.amt,
  239. u_reissuemx.relid
  240. FROM u_reissuemx left OUTER join U_Expenses on
  241. u_reissuemx.mtrlid = U_Expenses.Expensesid
  242. WHERE u_reissuemx.reissueid = :arg_reissueid AND
  243. u_reissuemx.scid = :arg_scid USING commit_transaction;
  244. OPEN cur_inwaermx_2;
  245. FETCH cur_inwaermx_2 INTO :reissuemx[i].printid,
  246. :reissuemx[i].mtrlid,:reissuemx[i].mtrlcode,
  247. :reissuemx[i].mtrlname,:reissuemx[i].qty,
  248. :reissuemx[i].price,
  249. :reissuemx[i].mxdscrp,
  250. :reissuemx[i].amt,
  251. :reissuemx[i].relid;
  252. DO WHILE commit_transaction.SQLCode = 0
  253. sumamt += reissuemx[i].amt
  254. i++
  255. FETCH cur_inwaermx_2 INTO :reissuemx[i].printid,
  256. :reissuemx[i].mtrlid,:reissuemx[i].mtrlcode,
  257. :reissuemx[i].mtrlname,:reissuemx[i].qty,
  258. :reissuemx[i].price,
  259. :reissuemx[i].mxdscrp,
  260. :reissuemx[i].amt,
  261. :reissuemx[i].relid;
  262. LOOP
  263. CLOSE cur_inwaermx_2;
  264. END IF
  265. //检验明细是否读入完整
  266. SELECT count(*) INTO :no_mxcheck
  267. FROM u_reissuemx
  268. WHERE u_reissuemx.reissueid = :arg_reissueid
  269. AND scid = :arg_scid USING commit_transaction;
  270. IF commit_transaction.SQLCode <> 0 THEN
  271. rslt = 0
  272. arg_msg = "查询操作失败,补件单明细数量"
  273. GOTO ext
  274. END IF
  275. IF i <> (no_mxcheck+1) THEN
  276. rslt = 0
  277. arg_msg = "查询操作失败,补件单明细"
  278. GOTO ext
  279. END IF
  280. reissueid = arg_reissueid
  281. scid = arg_scid
  282. it_mxbt = i - 1
  283. it_newbegin = FALSE
  284. it_updatebegin = FALSE
  285. ext:
  286. IF rslt = 0 THEN p_reset()
  287. RETURN rslt
  288. end function
  289. public function integer newbegin (long arg_scid, ref string arg_msg);//====================================================================
  290. // Function: newbegin(long arg_scid,int arg_billtype,ref string arg_msg)
  291. //--------------------------------------------------------------------
  292. // Description: 从置对象,设定业务类型,准备建立新进仓单
  293. //--------------------------------------------------------------------
  294. // Arguments:
  295. // value long arg_scid
  296. // value integer arg_billtype
  297. // reference string arg_msg
  298. //--------------------------------------------------------------------
  299. // Returns: integer
  300. //--------------------------------------------------------------------
  301. // Author: yyx Date: 2003.11.12
  302. //--------------------------------------------------------------------
  303. // Modify History:
  304. //
  305. //====================================================================
  306. int rslt=1
  307. if arg_scid < 0 then
  308. arg_msg = '请选择分部'
  309. rslt = 0
  310. goto ext
  311. end if
  312. p_reset()
  313. scid=arg_scid
  314. it_newbegin=true
  315. it_updatebegin=false
  316. ext:
  317. if rslt=0 then p_reset()
  318. return rslt
  319. end function
  320. public function integer updatebegin (long arg_scid, long arg_reissueid, ref string arg_msg);//====================================================================
  321. // Function: updatebegin(arg_scid,arg_inwareid,arg_billtype,arg_msg)
  322. //--------------------------------------------------------------------
  323. // Description: 从置对象,设定业务类型与关联ID,准备更新进仓单
  324. //--------------------------------------------------------------------
  325. // Arguments:
  326. // value long arg_scid
  327. // value long arg_inwareid
  328. // value integer arg_billtype
  329. // reference string arg_msg
  330. //--------------------------------------------------------------------
  331. // Returns: integer
  332. //--------------------------------------------------------------------
  333. // Author: yyx Date: 2003.11.12
  334. //--------------------------------------------------------------------
  335. // Modify History:
  336. //
  337. //====================================================================
  338. long rslt=1
  339. if arg_scid < 0 then
  340. arg_msg = '请选择分部'
  341. rslt = 0
  342. goto ext
  343. end if
  344. if arg_reissueid<=0 then
  345. rslt=0
  346. goto ext
  347. end if
  348. rslt=p_getinfo(arg_scid,arg_reissueid,arg_msg)
  349. if rslt=0 then goto ext
  350. if flag=1 then
  351. rslt=0
  352. arg_msg='单据已经审核,不可以修改'
  353. goto ext
  354. end if
  355. reissueid=arg_reissueid
  356. scid=arg_scid
  357. it_newbegin=false
  358. it_updatebegin=true
  359. p_clearmx() //清除明细
  360. ext:
  361. if rslt=0 then p_reset()
  362. return rslt
  363. end function
  364. public function integer add_dscrp (long arg_scid, long arg_reissueid, string arg_newdescppart, ref string arg_msg);//add_dscrp(string arg_newdescppart)
  365. //0 fail 1 success
  366. int rslt=1
  367. arg_newdescppart=trim(arg_newdescppart)
  368. if it_updatebegin or it_newbegin then
  369. rslt=0
  370. arg_msg="编辑状态下不可用"
  371. goto ext
  372. end if
  373. if arg_newdescppart='' then
  374. rslt=0
  375. arg_msg="要添加内容为空,操作取消"
  376. goto ext
  377. end if
  378. rslt=p_getinfo(arg_scid,arg_reissueid,arg_msg)
  379. if rslt=0 then goto ext
  380. if flag=0 then
  381. rslt=0
  382. arg_msg="非审核状态下不可用"
  383. goto ext
  384. end if
  385. update u_reissue
  386. set dscrp = dscrp+' '+:arg_newdescppart
  387. where u_reissue.reissueid = :reissueid
  388. and scid=:scid using commit_transaction;
  389. if commit_transaction.sqlcode<>0 then
  390. rollback ;
  391. rslt=0
  392. arg_msg="因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.sqlerrtext
  393. goto ext
  394. end if
  395. commit using commit_transaction;
  396. dscrp = dscrp+' '+arg_newdescppart
  397. ext: return (rslt)
  398. end function
  399. public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1,cnt = 0,i
  400. DateTime server_dt
  401. Long ls_newid
  402. String ls_sccode
  403. IF IsNull(relid) THEN relid = 0
  404. IF IsNull(cusid) THEN cusid = 0
  405. IF IsNull(moneyid) THEN moneyid = 0
  406. IF IsNull(relcode) THEN relcode = ''
  407. IF IsNull(reissueemp) THEN reissueemp = ''
  408. IF IsNull(dscrp) THEN dscrp = ''
  409. IF IsNull(itemid) THEN itemid = 0
  410. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  411. rslt = 0
  412. arg_msg = "非编辑状态不可以提交"
  413. GOTO ext
  414. END IF
  415. SELECT Top 1 getdate() INTO :server_dt FROM u_user USING commit_transaction ;
  416. IF commit_transaction.SQLCode <> 0 THEN
  417. rslt = 0
  418. arg_msg = "查询操作失败,日期 "
  419. GOTO ext
  420. END IF
  421. IF r_type = 2 THEN
  422. IF cusid = 0 THEN
  423. arg_msg = '请选择供应商'
  424. rslt = 0
  425. GOTO ext
  426. END IF
  427. SELECT count(*) INTO :cnt
  428. FROM u_spt
  429. WHERE sptid = :cusid
  430. USING commit_transaction;
  431. IF commit_transaction.SQLCode <> 0 THEN
  432. arg_msg = '查询供应商资料失败,'+sqlca.SQLErrText
  433. rslt = 0
  434. GOTO ext
  435. END IF
  436. IF cnt = 0 THEN
  437. rslt = 0
  438. arg_msg = '错误的供应商资料'
  439. GOTO ext
  440. END IF
  441. ELSE
  442. IF cusid = 0 THEN
  443. arg_msg = '请选择客户'
  444. rslt = 0
  445. GOTO ext
  446. END IF
  447. SELECT count(*) INTO :cnt
  448. FROM u_cust
  449. WHERE cusid = :cusid
  450. USING commit_transaction;
  451. IF commit_transaction.SQLCode <> 0 THEN
  452. arg_msg = '查询客户资料失败,'+sqlca.SQLErrText
  453. rslt = 0
  454. GOTO ext
  455. END IF
  456. IF cnt = 0 THEN
  457. rslt = 0
  458. arg_msg = '错误的客户资料'
  459. GOTO ext
  460. END IF
  461. END IF
  462. IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
  463. rslt = 0
  464. arg_msg = "没有正确进仓内容"
  465. GOTO ext
  466. END IF
  467. IF itemid = 0 THEN
  468. rslt = 0
  469. arg_msg = '请选择项目'
  470. GOTO ext
  471. END IF
  472. SELECT count(*) INTO :cnt
  473. FROM u_itemdef
  474. WHERE itemid = :itemid
  475. USING commit_transaction;
  476. IF commit_transaction.SQLCode <> 0 THEN
  477. arg_msg = '查询项目资料失败,'+sqlca.SQLErrText
  478. rslt = 0
  479. GOTO ext
  480. END IF
  481. IF cnt = 0 THEN
  482. rslt = 0
  483. arg_msg = '错误的项目资料'
  484. GOTO ext
  485. END IF
  486. IF f_check_inoutdate(0,reissuedate,true,arg_msg) = 0 THEN
  487. rslt = 0
  488. GOTO ext
  489. END IF
  490. ////////////////////////////////////////////// //开始区分:新建/更新 处理
  491. IF reissueid = 0 THEN //新建
  492. ls_newid = f_sys_scidentity(scid,"u_reissue","reissueid",arg_msg,if_getid_ture,commit_transaction)
  493. IF ls_newid <= 0 THEN
  494. rslt = 0
  495. GOTO ext
  496. END IF
  497. //取分部代号
  498. IF f_get_sccode(scid,commit_transaction,ls_sccode,arg_msg) = 0 THEN
  499. rslt = 0
  500. GOTO ext
  501. END IF
  502. //取得新单据编号
  503. IF r_type = 0 THEN
  504. reissuecode = getid(scid,ls_sccode + 'FJ',Date(server_dt),if_getid_ture,commit_transaction)
  505. ELSEIF r_type = 1 THEN
  506. reissuecode = getid(scid,ls_sccode + 'FY',Date(server_dt),if_getid_ture,commit_transaction)
  507. ELSE
  508. reissuecode = getid(scid,ls_sccode + 'FS',Date(server_dt),if_getid_ture,commit_transaction)
  509. END IF
  510. IF reissuecode = "err" THEN
  511. reissuecode = ''
  512. rslt = 0
  513. arg_msg = "无法获取单据编号"+"~n"+commit_transaction.SQLErrText
  514. GOTO ext
  515. END IF
  516. INSERT INTO u_reissue (
  517. scid,
  518. reissueid,
  519. reissuecode,
  520. cusid,
  521. reissuedate,
  522. relid,
  523. relcode,
  524. dscrp,
  525. opdate,
  526. opemp,
  527. flag,
  528. reissueemp,
  529. type,
  530. moneyid,
  531. mrate,
  532. itemid)
  533. VALUES (
  534. :scid,
  535. :ls_newid,
  536. :reissuecode,
  537. :cusid,
  538. :reissuedate,
  539. :relid,
  540. :relcode,
  541. :dscrp,
  542. :server_dt,
  543. :publ_operator,
  544. :flag,
  545. :reissueemp,
  546. :r_type,
  547. :moneyid,
  548. :mrate,
  549. :itemid) USING commit_transaction ;
  550. IF commit_transaction.SQLCode <> 0 THEN
  551. rslt = 0
  552. IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_reissue') > 0 THEN
  553. arg_msg = '插入操作失败,关键字单据ID重复'
  554. ELSEIF Pos(Lower(commit_transaction.SQLErrText),'IX_u_reissue') > 0 THEN
  555. arg_msg = '插入操作失败,关键字单据编号重复'
  556. ELSE
  557. arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
  558. END IF
  559. GOTO ext
  560. END IF
  561. //读取新reissueid
  562. reissueid = ls_newid
  563. FOR i = 1 TO it_mxbt
  564. INSERT INTO u_reissuemx
  565. (scid,
  566. reissueid,
  567. mtrlid,
  568. printid,
  569. qty,
  570. price,
  571. amt,
  572. dscrp,
  573. mtrlname)
  574. VALUES (
  575. :scid,
  576. :ls_newid,
  577. :reissuemx[i].mtrlid,
  578. :reissuemx[i].printid,
  579. :reissuemx[i].qty,
  580. :reissuemx[i].price,
  581. :reissuemx[i].amt,
  582. :reissuemx[i].mxdscrp,
  583. :reissuemx[i].mtrlname) USING commit_transaction;
  584. IF commit_transaction.SQLCode <> 0 THEN
  585. reissueid = 0 //还原reissueid
  586. rslt = 0
  587. IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_reissuemx') > 0 THEN
  588. arg_msg = '插入明细操作失败,关键字单据ID,序号重复'
  589. ELSE
  590. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  591. END IF
  592. GOTO ext
  593. END IF
  594. NEXT
  595. ELSE //////////////////////////////////////////////// //更新
  596. UPDATE u_reissue
  597. SET cusid = :cusid,
  598. reissuedate = :reissuedate,
  599. relid = :relid,
  600. relcode = :relcode,
  601. dscrp = :dscrp,
  602. moddate = : server_dt,
  603. modemp = :publ_operator,
  604. reissueemp = :reissueemp,
  605. type = :r_type,
  606. moneyid = :moneyid,
  607. mrate = :mrate,
  608. itemid = :itemid
  609. WHERE u_reissue.reissueid = :reissueid
  610. AND u_reissue.scid = :scid
  611. AND flag = 0 USING commit_transaction;
  612. IF commit_transaction.SQLCode <> 0 OR commit_transaction.SQLNRows <= 0 THEN
  613. rslt = 0
  614. arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+commit_transaction.SQLErrText
  615. GOTO ext
  616. END IF
  617. //删除原有明细
  618. DELETE FROM u_reissuemx
  619. WHERE u_reissuemx.reissueid = :reissueid
  620. AND u_reissuemx.scid = :scid USING commit_transaction;
  621. IF commit_transaction.SQLCode <> 0 THEN
  622. rslt = 0
  623. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  624. GOTO ext
  625. END IF
  626. FOR i = 1 TO it_mxbt
  627. INSERT INTO u_reissuemx
  628. (scid,
  629. reissueid,
  630. mtrlid,
  631. printid,
  632. qty,
  633. price,
  634. amt,
  635. dscrp,
  636. mtrlname)
  637. VALUES (
  638. :scid,
  639. :reissueid,
  640. :reissuemx[i].mtrlid,
  641. :reissuemx[i].printid,
  642. :reissuemx[i].qty,
  643. :reissuemx[i].price,
  644. :reissuemx[i].amt,
  645. :reissuemx[i].mxdscrp,
  646. :reissuemx[i].mtrlname) USING commit_transaction;
  647. IF commit_transaction.SQLCode <> 0 THEN
  648. rslt = 0
  649. IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_reissuemx') > 0 THEN
  650. arg_msg = '插入明细操作失败,关键字单据ID,序号重复'
  651. ELSE
  652. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  653. END IF
  654. GOTO ext
  655. END IF
  656. NEXT
  657. END IF
  658. it_newbegin = FALSE
  659. it_updatebegin = FALSE
  660. ext:
  661. IF rslt = 0 THEN
  662. ROLLBACK USING commit_transaction;
  663. p_clearmx()
  664. ELSEIF rslt = 1 AND arg_ifcommit THEN
  665. COMMIT USING commit_transaction;
  666. END IF
  667. RETURN rslt
  668. end function
  669. public function integer del (long arg_scid, long arg_reissueid, ref string arg_msg, boolean arg_ifcommit);//如果单据还没有审核删除单据极其明细
  670. //0 FAIL, 1 SUCCESS
  671. Int rslt = 1
  672. IF arg_reissueid <= 0 THEN
  673. rslt = 0
  674. arG_MSG = "没有删除对象,操作取消"
  675. GOTO ext
  676. END IF
  677. IF p_getinfo(arg_scid,arg_reissueid,arG_MSG) = 0 THEN
  678. rslt = 0
  679. GOTO ext
  680. END IF
  681. IF flag = 1 THEN
  682. rslt = 0
  683. arG_MSG = "单据已经审核,不可以删除"
  684. GOTO ext
  685. END IF
  686. DELETE FROM u_reissue
  687. WHERE u_reissue.reissueid = :arg_reissueid
  688. AND u_reissue.scid = :arg_scid USING commit_transaction;
  689. IF commit_transaction.SQLCode <> 0 THEN
  690. rslt = 0
  691. arG_MSG = "删除补件单操作失败"+"~n"+commit_transaction.SQLErrText
  692. GOTO ext
  693. END IF
  694. DELETE FROM u_reissuemx
  695. WHERE u_reissuemx.reissueid = :arg_reissueid
  696. AND u_reissuemx.scid = :arg_scid USING commit_transaction;
  697. IF commit_transaction.SQLCode <> 0 THEN
  698. rslt = 0
  699. arG_MSG = "删除补件单明细操作失败"+"~n"+commit_transaction.SQLErrText
  700. GOTO ext
  701. END IF
  702. it_newbegin = FALSE
  703. it_updatebegin = FALSE
  704. ext:
  705. IF rslt = 0 THEN
  706. ROLLBACK USING commit_transaction;
  707. p_reset()
  708. ELSEIF rslt = 1 AND arg_ifcommit THEN
  709. COMMIT USING commit_transaction;
  710. END IF
  711. RETURN (rslt)
  712. end function
  713. public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,ll_i
  714. //DateTime ld_viewdate
  715. //SetNull(ld_viewdate)
  716. uo_musttake uo_take
  717. uo_mustpay uo_pay
  718. uo_take = CREATE uo_musttake
  719. uo_pay = CREATE uo_mustpay
  720. String ls_about,ls_dscrp
  721. Decimal ld_takeamt = 0,ld_msttakeamt = 0
  722. Decimal ld_payamt = 0,ld_mstpayamt = 0
  723. long ll_moneyid_native,ll_moneyid
  724. Decimal ld_mrate
  725. IF reissueid = 0 THEN
  726. rslt = 0
  727. arg_msg = "没有审核对象"
  728. GOTO ext
  729. END IF
  730. IF it_newbegin OR it_updatebegin THEN
  731. rslt = 0
  732. arg_msg = "编辑状态下不可以执行审核"
  733. GOTO ext
  734. END IF
  735. IF flag = 1 THEN
  736. rslt = 0
  737. arg_msg = "单据已经审核"
  738. GOTO ext
  739. END IF
  740. Int li_btype
  741. Long ll_accountsid
  742. SELECT btype,accountsid INTO :li_btype,:ll_accountsid
  743. FROM cw_banktype
  744. Where banktypeid = :relid USING commit_transaction;
  745. IF commit_transaction.SQLCode <> 0 THEN
  746. rslt = 0
  747. arg_msg = '查询结算方式类型失败,'+ commit_transaction.SQLErrText
  748. GOTO ext
  749. END IF
  750. Select moneyid Into :ll_moneyid_native
  751. From cw_currency
  752. Where native = 1;
  753. If sqlca.SQLCode <> 0 Then
  754. arg_msg = '查询本位币资料失败'
  755. rslt = 0
  756. Goto ext
  757. End If
  758. SELECT count(*) INTO :cnt
  759. FROM u_user
  760. Where username = :publ_operator USING commit_transaction ;
  761. IF commit_transaction.SQLCode <> 0 THEN
  762. rslt = 0
  763. arg_msg = "查询操作失败,操作员"
  764. GOTO ext
  765. END IF
  766. IF cnt = 0 THEN
  767. rslt = 0
  768. arg_msg = "操作员姓名未登记或已取消"
  769. GOTO ext
  770. END IF
  771. UPDATE u_reissue
  772. SET auditingrep = :publ_operator,
  773. auditingdate = getdate(),
  774. flag = 1
  775. WHERE u_reissue.reissueid = :reissueid
  776. AND flag = 0
  777. AND scid = :scid USING commit_transaction;
  778. IF commit_transaction.SQLCode <> 0 THEN
  779. rslt = 0
  780. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  781. GOTO ext
  782. ELSEIF commit_transaction.SQLNRows = 0 THEN
  783. rslt = 0
  784. arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  785. GOTO ext
  786. END IF
  787. IF r_type = 0 THEN //补件单
  788. IF sumamt <> 0 THEN
  789. ls_about = reissuecode + "补件款"
  790. ls_dscrp = ls_about
  791. ld_msttakeamt = sumamt
  792. IF li_btype = 1 THEN
  793. ld_takeamt = ld_msttakeamt
  794. ELSE
  795. ld_takeamt = 0
  796. END IF
  797. s_bmsttake s_take
  798. s_take.scid = scid
  799. s_take.cusid = cusid
  800. s_take.takedate = reissuedate
  801. s_take.inrep = reissueemp
  802. s_take.oriamt = ld_msttakeamt
  803. s_take.msttakeamt = ld_msttakeamt
  804. s_take.takeamt = ld_takeamt
  805. s_take.dscrp = ls_dscrp
  806. s_take.billcode = reissuecode
  807. s_take.banktypeid = relid
  808. s_take.opemp = publ_operator
  809. s_take.buildtype = 1
  810. s_take.outwareid = reissueid
  811. s_take.accountsid = ll_accountsid
  812. s_take.itemid = itemid
  813. s_take.moneyid = moneyid
  814. s_take.viewdate = reissuedate
  815. s_take.relcode = relcode
  816. IF uo_take.add_takerec (s_take,arg_msg,FALSE) = 0 THEN
  817. rslt = 0
  818. GOTO ext
  819. END IF
  820. // IF uo_take.add_takerec(scid,cusid,reissuedate,reissueemp,ld_msttakeamt,Round(ld_msttakeamt,sys_saleamt_round),Round(ld_takeamt,sys_saleamt_round),ls_dscrp,&
  821. // reissuecode,relid,1,publ_operator,reissueid,0,arg_msg,FALSE,reissuedate,ll_accountsid,itemid,moneyid,relcode) = 0 THEN
  822. // rslt = 0
  823. // GOTO ext
  824. // END IF
  825. UPDATE u_reissue
  826. SET relint_3 = :uo_take.ref_takeid
  827. WHERE u_reissue.reissueid = :reissueid
  828. AND scid = :scid
  829. AND flag = 1 USING commit_transaction;
  830. IF commit_transaction.SQLCode <> 0 THEN
  831. arg_msg = '更新补件单相关应收帐ID失败'
  832. rslt = 0
  833. GOTO ext
  834. END IF
  835. END IF
  836. ELSEIF r_type = 1 THEN //费用单
  837. FOR ll_i = 1 TO it_mxbt
  838. IF reissuemx[ll_i].amt <> 0 THEN
  839. IF Trim(reissuemx[ll_i].mxdscrp) = '' THEN
  840. ls_about = reissuecode + ',' + reissuemx[ll_i].mtrlname
  841. ELSE
  842. ls_about = reissuecode + ',' + reissuemx[ll_i].mtrlname + ',' + reissuemx[ll_i].mxdscrp
  843. END IF
  844. ls_dscrp = ls_about
  845. ld_msttakeamt = 0 - reissuemx[ll_i].amt
  846. IF li_btype = 1 THEN
  847. ld_takeamt = ld_msttakeamt
  848. ELSE
  849. ld_takeamt = 0
  850. END IF
  851. IF sys_option_mst_multimoney = 0 THEN
  852. ld_msttakeamt = ld_msttakeamt * mrate
  853. ld_takeamt = ld_takeamt * mrate
  854. ld_mrate = 1
  855. ll_moneyid = ll_moneyid_native
  856. ELSE
  857. ld_msttakeamt = ld_msttakeamt
  858. ld_takeamt = ld_takeamt
  859. ld_mrate = mrate
  860. ll_moneyid = moneyid
  861. END IF
  862. s_bmsttake s_take2
  863. s_take2.scid = scid
  864. s_take2.cusid = cusid
  865. s_take2.takedate = reissuedate
  866. s_take2.inrep = reissueemp
  867. s_take2.oriamt = ld_msttakeamt
  868. s_take2.msttakeamt = ld_msttakeamt
  869. s_take2.takeamt = ld_takeamt
  870. s_take2.takeamt_cn = ld_takeamt
  871. s_take2.dscrp = ls_dscrp
  872. s_take2.billcode = reissuecode
  873. s_take2.banktypeid = relid
  874. s_take2.opemp = publ_operator
  875. s_take2.buildtype = 1
  876. s_take2.outwareid = reissueid
  877. s_take2.accountsid = ll_accountsid
  878. s_take2.itemid = itemid
  879. s_take2.moneyid = ll_moneyid
  880. s_take2.viewdate = reissuedate
  881. s_take2.relcode = relcode
  882. IF uo_take.add_takerec (s_take2,arg_msg,FALSE) = 0 THEN
  883. rslt = 0
  884. GOTO ext
  885. END IF
  886. // IF uo_take.add_takerec(scid,cusid,reissuedate,reissueemp,ld_msttakeamt,Round(ld_msttakeamt,sys_saleamt_round),Round(ld_takeamt,sys_saleamt_round),ls_dscrp,&
  887. // reissuecode,relid,1,publ_operator,reissueid,0,arg_msg,FALSE,reissuedate,ll_accountsid,itemid,moneyid,relcode) = 0 THEN
  888. // rslt = 0
  889. // GOTO ext
  890. // END IF
  891. UPDATE u_reissuemx
  892. SET relid = :uo_take.ref_takeid
  893. FROM u_reissuemx,u_reissue
  894. WHERE u_reissuemx.reissueid = :reissueid
  895. AND u_reissuemx.printid = :reissuemx[ll_i].printid
  896. AND u_reissuemx.scid = :scid
  897. AND u_reissuemx.scid = u_reissue.scid
  898. AND u_reissuemx.reissueid = u_reissue.reissueid
  899. AND u_reissue.flag = 1 USING commit_transaction;
  900. IF commit_transaction.SQLCode <> 0 THEN
  901. arg_msg = '更新费用单相关应收帐ID失败'
  902. rslt = 0
  903. GOTO ext
  904. END IF
  905. END IF
  906. NEXT
  907. ELSEIF r_type = 2 THEN //?
  908. FOR ll_i = 1 TO it_mxbt
  909. IF Trim(reissuemx[ll_i].mxdscrp) = '' THEN
  910. ls_about = reissuecode + ',' + reissuemx[ll_i].mtrlname
  911. ELSE
  912. ls_about = reissuecode + ',' + reissuemx[ll_i].mtrlname + ',' + reissuemx[ll_i].mxdscrp
  913. END IF
  914. ls_dscrp = ls_about
  915. ld_mstpayamt = reissuemx[ll_i].amt
  916. IF li_btype = 1 THEN
  917. ld_payamt = ld_mstpayamt
  918. ELSE
  919. ld_payamt = 0
  920. END IF
  921. IF sys_option_msp_multimoney = 0 THEN
  922. ld_mstpayamt = ld_mstpayamt * mrate
  923. ld_payamt = ld_payamt * mrate
  924. ld_mrate = 1
  925. ll_moneyid = ll_moneyid_native
  926. ELSE
  927. ld_mstpayamt = ld_mstpayamt
  928. ld_payamt = ld_payamt
  929. ld_mrate = mrate
  930. ll_moneyid = moneyid
  931. END IF
  932. DateTime plandate
  933. SetNull(plandate)
  934. s_bmstpay s_pay
  935. s_pay.scid = scid
  936. s_pay.sptid = cusid
  937. s_pay.paydate = reissuedate
  938. s_pay.inrep = reissueemp
  939. s_pay.oriamt = ld_mstpayamt
  940. s_pay.mstpayamt = ld_mstpayamt
  941. s_pay.payamt = ld_payamt
  942. s_pay.dscrp = ls_dscrp
  943. s_pay.billcode = reissuecode
  944. s_pay.banktypeid = relid
  945. s_pay.opemp = publ_operator
  946. s_pay.buildtype = 1
  947. s_pay.inwareid = reissueid
  948. s_pay.accountsid = ll_accountsid
  949. s_pay.itemid = itemid
  950. s_pay.moneyid = ll_moneyid
  951. s_pay.viewdate = plandate
  952. s_pay.relcode = relcode
  953. IF uo_pay.add_payrec (s_pay,arg_msg,FALSE) = 0 THEN
  954. rslt = 0
  955. GOTO ext
  956. END IF
  957. // IF uo_pay.add_payrec (scid,cusid,reissuedate,reissueemp,ld_mstpayamt,ld_mstpayamt,ld_payamt,ls_dscrp,&
  958. // reissuecode,relid,1,publ_operator,reissueid,0,arg_msg,FALSE,plandate,ll_accountsid,itemid,moneyid ,relcode) = 0 THEN
  959. // rslt = 0
  960. // GOTO ext
  961. // END IF
  962. UPDATE u_reissuemx
  963. SET relid = :uo_pay.ref_payid
  964. FROM u_reissuemx,u_reissue
  965. WHERE u_reissuemx.reissueid = :reissueid
  966. AND u_reissuemx.printid = :reissuemx[ll_i].printid
  967. AND u_reissuemx.scid = :scid
  968. AND u_reissuemx.scid = u_reissue.scid
  969. AND u_reissuemx.reissueid = u_reissue.reissueid
  970. AND u_reissue.flag = 1 USING commit_transaction;
  971. IF commit_transaction.SQLCode <> 0 THEN
  972. arg_msg = '更新相关应收帐ID失败'
  973. rslt = 0
  974. GOTO ext
  975. END IF
  976. NEXT
  977. END IF
  978. flag = 1
  979. ext:
  980. DESTROY uo_take
  981. DESTROY uo_pay
  982. IF rslt = 0 THEN
  983. ROLLBACK USING commit_transaction;
  984. ELSEIF rslt = 1 AND arg_ifcommit THEN
  985. COMMIT USING commit_transaction;
  986. END IF
  987. RETURN rslt
  988. end function
  989. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,ll_i
  990. uo_musttake uo_take
  991. uo_mustpay uo_pay
  992. uo_take = CREATE uo_musttake
  993. uo_pay = create uo_mustpay
  994. Long ll_takeid
  995. DateTime null_dt
  996. SetNull(null_dt)
  997. IF reissueid = 0 THEN
  998. rslt = 0
  999. arg_msg = "没有审核对象"
  1000. GOTO ext
  1001. END IF
  1002. IF it_newbegin OR it_updatebegin THEN
  1003. rslt = 0
  1004. arg_msg = "编辑状态下不可以执行审核"
  1005. GOTO ext
  1006. END IF
  1007. IF cwauditingflag = 1 THEN
  1008. rslt = 0
  1009. arG_MSG = "该单据已经总账审核,不能进行财务撤审"
  1010. GOTO ext
  1011. END IF
  1012. IF flag = 0 THEN
  1013. rslt = 0
  1014. arg_msg = "单据还未审核"
  1015. GOTO ext
  1016. END IF
  1017. SELECT count(*) INTO :cnt
  1018. FROM u_user
  1019. Where username = :publ_operator USING commit_transaction ;
  1020. IF commit_transaction.SQLCode <> 0 THEN
  1021. rslt = 0
  1022. arg_msg = "查询操作失败,操作员"
  1023. GOTO ext
  1024. END IF
  1025. IF cnt = 0 THEN
  1026. rslt = 0
  1027. arg_msg = "操作员姓名未登记或已取消"
  1028. GOTO ext
  1029. END IF
  1030. UPDATE u_reissue
  1031. SET Auditingrep = '',
  1032. Auditingdate = :null_dt,
  1033. flag = 0,
  1034. relint_3 = 0
  1035. WHERE u_reissue.reissueid = :reissueid
  1036. AND flag = 1
  1037. AND scid = :scid USING commit_transaction;
  1038. IF commit_transaction.SQLCode <> 0 THEN
  1039. rslt = 0
  1040. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  1041. GOTO ext
  1042. ELSEIF commit_transaction.SQLNRows = 0 THEN
  1043. rslt = 0
  1044. arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  1045. GOTO ext
  1046. END IF
  1047. IF r_type = 0 THEN
  1048. IF sumamt <> 0 THEN
  1049. IF uo_take.del_takerec(scid,1,relint_3,cusid,arg_msg,FALSE) = 0 THEN
  1050. rslt = 0
  1051. GOTO ext
  1052. END IF
  1053. END IF
  1054. ELSEIF r_type = 1 THEN
  1055. FOR ll_i = 1 TO it_mxbt
  1056. IF reissuemx[ll_i].amt <> 0 THEN
  1057. IF uo_take.del_takerec(scid,1,reissuemx[ll_i].relid,cusid,arg_msg,FALSE) = 0 THEN
  1058. rslt = 0
  1059. GOTO ext
  1060. END IF
  1061. UPDATE u_reissuemx
  1062. SET relid = 0
  1063. WHERE u_reissuemx.reissueid = :reissueid
  1064. AND u_reissuemx.printid = :reissuemx[ll_i].printid
  1065. AND u_reissuemx.scid = :scid USING commit_transaction;
  1066. IF commit_transaction.SQLCode <> 0 THEN
  1067. rslt = 0
  1068. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  1069. GOTO ext
  1070. END IF
  1071. END IF
  1072. NEXT
  1073. ELSEIF r_type = 2 THEN
  1074. FOR ll_i = 1 TO it_mxbt
  1075. IF reissuemx[ll_i].amt <> 0 THEN
  1076. IF uo_pay.del_payrec(scid,1,reissuemx[ll_i].relid,cusid,arg_msg,FALSE) = 0 THEN
  1077. rslt = 0
  1078. GOTO ext
  1079. END IF
  1080. UPDATE u_reissuemx
  1081. SET relid = 0
  1082. WHERE u_reissuemx.reissueid = :reissueid
  1083. AND u_reissuemx.printid = :reissuemx[ll_i].printid
  1084. AND u_reissuemx.scid = :scid USING commit_transaction;
  1085. IF commit_transaction.SQLCode <> 0 THEN
  1086. rslt = 0
  1087. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  1088. GOTO ext
  1089. END IF
  1090. END IF
  1091. NEXT
  1092. END IF
  1093. flag = 0
  1094. ext:
  1095. DESTROY uo_take
  1096. DESTROY uo_pay
  1097. IF rslt = 0 THEN
  1098. ROLLBACK USING commit_transaction;
  1099. ELSEIF rslt = 1 AND arg_ifcommit THEN
  1100. COMMIT USING commit_transaction;
  1101. END IF
  1102. RETURN rslt
  1103. end function
  1104. public function integer acceptmx (decimal arg_qty, double arg_price, decimal arg_amt, string arg_mxdscrp, long arg_printid, ref string arg_msg, long arg_mtrlid, string arg_mtrlname);Int rslt = 1
  1105. Long cnt = 0
  1106. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  1107. rslt = 0
  1108. arg_msg = "非编辑状态不可以使用,操作取消"
  1109. GOTO ext
  1110. END IF
  1111. //清除空值
  1112. IF IsNull(arg_qty) THEN arg_qty = 0
  1113. IF IsNull(arg_price) THEN arg_price = 0
  1114. IF IsNull(arg_printid) THEN arg_printid = 0
  1115. IF IsNull(arg_amt) THEN arg_amt = 0
  1116. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  1117. IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
  1118. IF IsNull(arg_mtrlname) THEN arg_mtrlname = ''
  1119. // 如果出仓数量为 0,或物料编号为空,则不作任何处理
  1120. IF r_type = 0 THEN
  1121. SELECT count(*) INTO :cnt
  1122. FROM u_mtrldef
  1123. Where mtrlid = :arg_mtrlid USING commit_transaction;
  1124. IF commit_transaction.SQLCode <> 0 THEN
  1125. arg_msg = "查询物料资料失败,"+commit_transaction.SQLErrText
  1126. rslt = 0
  1127. GOTO ext
  1128. END IF
  1129. IF arg_mtrlid = 0 THEN
  1130. rslt = 1
  1131. GOTO ext
  1132. END IF
  1133. ELSEIF r_type = 1 THEN
  1134. SELECT count(*) INTO :cnt
  1135. FROM U_Expenses
  1136. Where Expensesid = :arg_mtrlid USING commit_transaction;
  1137. IF commit_transaction.SQLCode <> 0 THEN
  1138. arg_msg = '查询项目资料失败,'+commit_transaction.SQLErrText
  1139. rslt = 0
  1140. GOTO ext
  1141. END IF
  1142. IF arg_mtrlid = 0 THEN
  1143. rslt = 1
  1144. GOTO ext
  1145. END IF
  1146. ELSEIF r_type = 2 AND arg_mtrlid > 0 THEN
  1147. SELECT count(*) INTO :cnt
  1148. FROM U_Expenses
  1149. Where Expensesid = :arg_mtrlid USING commit_transaction;
  1150. IF commit_transaction.SQLCode <> 0 THEN
  1151. arg_msg = '查询项目资料失败,'+commit_transaction.SQLErrText
  1152. rslt = 0
  1153. GOTO ext
  1154. END IF
  1155. END IF
  1156. IF arg_qty = 0 THEN
  1157. rslt = 1
  1158. GOTO ext
  1159. END IF
  1160. //写入内容
  1161. it_mxbt++
  1162. reissuemx[it_mxbt].mtrlid = arg_mtrlid
  1163. reissuemx[it_mxbt].qty = arg_qty
  1164. reissuemx[it_mxbt].amt = Round(arg_amt,2)
  1165. reissuemx[it_mxbt].price = arg_price
  1166. reissuemx[it_mxbt].mxdscrp = arg_mxdscrp
  1167. reissuemx[it_mxbt].printid = arg_printid
  1168. reissuemx[it_mxbt].mtrlname = arg_mtrlname
  1169. ext:
  1170. IF rslt = 0 THEN
  1171. p_clearmx()
  1172. arg_msg = "第" + String(arg_printid) + "行," + arg_msg
  1173. END IF
  1174. RETURN rslt
  1175. end function
  1176. public function integer audit_subject (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg);
  1177. Int rslt = 1,cnt = 0
  1178. IF arg_billid = 0 THEN
  1179. rslt = 0
  1180. arg_msg = "没有审核对象"
  1181. GOTO ext
  1182. END IF
  1183. IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
  1184. rslt = 0
  1185. GOTO ext
  1186. END IF
  1187. IF flag = 0 THEN
  1188. rslt = 0
  1189. arg_msg = "单据没有审核"
  1190. GOTO ext
  1191. END IF
  1192. IF cwauditingflag = 1 THEN
  1193. rslt = 0
  1194. arg_msg = "单据已经总账审核"
  1195. GOTO ext
  1196. END IF
  1197. UPDATE u_reissue
  1198. SET cwauditingflag = 1,
  1199. cwauditingdate = getdate(),
  1200. cwauditingrep = :publ_operator
  1201. WHERE ( u_reissue.reissueid = :arg_billid ) AND
  1202. ( u_reissue.scid = :arg_scid) Using commit_transaction;
  1203. IF commit_transaction.SQLCode <> 0 THEN
  1204. rslt = 0
  1205. arg_msg = "因网络或其它原因导致总账审核操作失败"+"~n"+commit_transaction.SQLErrText
  1206. ROLLBACK Using commit_transaction;
  1207. GOTO ext
  1208. END IF
  1209. ext:
  1210. IF arg_ifcommit And rslt = 1 THEN
  1211. COMMIT Using commit_transaction;
  1212. END IF
  1213. Return (rslt)
  1214. end function
  1215. public function integer c_audit_subject (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg);
  1216. Int rslt = 1,cnt = 0
  1217. IF arg_billid = 0 THEN
  1218. rslt = 0
  1219. arg_msg = "没有审核对象"
  1220. GOTO ext
  1221. END IF
  1222. IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
  1223. rslt = 0
  1224. GOTO ext
  1225. END IF
  1226. IF cwauditingflag = 0 THEN
  1227. rslt = 0
  1228. arg_msg = "单据没有总账审核"
  1229. GOTO ext
  1230. END IF
  1231. UPDATE u_reissue
  1232. SET cwauditingflag = 0,
  1233. cwauditingdate =null,
  1234. cwauditingrep = ''
  1235. WHERE ( u_reissue.reissueid = :arg_billid ) AND
  1236. ( u_reissue.scid = :arg_scid) Using commit_transaction;
  1237. IF commit_transaction.SQLCode <> 0 THEN
  1238. rslt = 0
  1239. arg_msg = "因网络或其它原因导致总账撤审操作失败"+"~n"+commit_transaction.SQLErrText
  1240. ROLLBACK Using commit_transaction;
  1241. GOTO ext
  1242. END IF
  1243. ext:
  1244. IF arg_ifcommit And rslt = 1 THEN
  1245. COMMIT Using commit_transaction;
  1246. END IF
  1247. Return (rslt)
  1248. end function
  1249. on uo_reissue.create
  1250. call super::create
  1251. TriggerEvent( this, "constructor" )
  1252. end on
  1253. on uo_reissue.destroy
  1254. TriggerEvent( this, "destructor" )
  1255. call super::destroy
  1256. end on