uo_income_expenses.sru 31 KB

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