uo_reissue_sptcust.sru 33 KB

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