uo_associat_sptcust.sru 31 KB

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