uo_saleplan.sru 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349
  1. $PBExportHeader$uo_saleplan.sru
  2. forward
  3. global type uo_saleplan from nonvisualobject
  4. end type
  5. type s_saleplanmx from structure within uo_saleplan
  6. end type
  7. type s_saleplanmx_mx from structure within uo_saleplan
  8. end type
  9. end forward
  10. type s_saleplanmx from structure
  11. long mtrlid
  12. string mtrlcode
  13. long printid
  14. decimal { 10 } planqty
  15. string mxdscrp
  16. decimal { 10 } price
  17. decimal { 2 } planamt
  18. string status
  19. string woodcode
  20. string pcode
  21. end type
  22. type s_saleplanmx_mx from structure
  23. long mtrlid
  24. string mtrlcode
  25. long printid
  26. decimal{10} planqty
  27. decimal{10} price
  28. decimal{2} planamt
  29. string mxdscrp
  30. end type
  31. global type uo_saleplan from nonvisualobject
  32. end type
  33. global uo_saleplan uo_saleplan
  34. type variables
  35. PUBLIC PROTECTEDWRITE Long scid = 0
  36. PUBLIC PROTECTEDWRITE Long billID = 0
  37. PUBLIC PROTECTEDWRITE String billCode = ''
  38. PUBLIC PROTECTEDWRITE DateTime opdate
  39. PUBLIC PROTECTEDWRITE String opemp = ''
  40. public protectedwrite datetime moddate //修改时间,自动
  41. public protectedwrite string modemp ='' //修改操作员
  42. public protectedwrite int flag=0 //审核标志
  43. public protectedwrite datetime auditingdate //审核时间
  44. PUBLIC PROTECTEDWRITE String auditingrep = ''//审核操作员
  45. public protectedwrite int secflag=0 //审核标志
  46. public protectedwrite datetime secauditingdate //审核时间
  47. PUBLIC PROTECTEDWRITE String secauditingrep = ''//审核操作员
  48. string outrep = ''
  49. decimal salemth = 0
  50. DateTime billdate
  51. String dscrp = ''
  52. string relcode = ''
  53. long cusid = 0
  54. Transaction commit_transaction
  55. PRIVATE:
  56. s_saleplanmx saleplanmx[] //明细结构数组
  57. s_saleplanmx_mx saleplanmx_mx[]
  58. Long it_MXBT = 0 //明细结构数组末指针
  59. long it_mxbt_mx = 0
  60. Boolean IT_NEWBEGIN = FALSE //新建标志
  61. Boolean IT_UPDATEBEGIN = FALSE//修改标志
  62. end variables
  63. forward prototypes
  64. public function integer p_reset ()
  65. public function integer p_clearmx ()
  66. public function integer newbegin (long arg_scid, ref string arg_msg)
  67. public function integer save (ref string arg_msg, boolean arg_ifcommit)
  68. public function integer p_getinfo (long arg_scid, long arg_billid, ref string arg_msg)
  69. public function integer getinfo (integer arg_scid, long arg_billid, ref string arg_msg)
  70. public function integer cancel (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  71. public function integer audit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  72. public function integer add_dscrp (long arg_scid, long arg_billid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit)
  73. public function integer updatebegin (long arg_scid, long arg_billid, ref string arg_msg)
  74. public function integer caudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  75. public function integer secaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  76. public function integer csecaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  77. public function integer updatesaleqty (long arg_salemth, string arg_outrep, ref string arg_msg, boolean arg_ifcommit)
  78. public function integer acceptmx (long arg_mtrlid, string arg_mtrlcode, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_planqty, decimal arg_price, string arg_mxdscrp, ref string arg_msg, long arg_printid)
  79. end prototypes
  80. public function integer p_reset ();//INT p_RESET()
  81. //清除对象及其明细
  82. billid=0
  83. billcode=''
  84. outrep = ''
  85. salemth = 0
  86. relcode = ''
  87. cusid = 0
  88. it_newbegin=FALSE
  89. it_updatebegin=FALSE
  90. //清除明细
  91. P_CLEARMX()
  92. RETURN 1
  93. end function
  94. public function integer p_clearmx ();//INT p_clearmx()
  95. //清除明细
  96. it_mxbt = 0
  97. it_mxbt_mx = 0
  98. RETURN 1
  99. end function
  100. public function integer newbegin (long arg_scid, ref string arg_msg);//重置对象,设定业务类型与关联ID,准备建立新单
  101. //0 fail 1 success
  102. long rslt=1,CNT=0
  103. if arg_scid < 0 then
  104. arg_msg = '请选择分部'
  105. rslt = 0
  106. goto ext
  107. end if
  108. p_reset()
  109. it_newbegin=TRUE
  110. it_updatebegin=FALSE
  111. scid=arg_scid
  112. ext:
  113. if rslt = 0 then p_reset()
  114. return rslt
  115. end function
  116. public function integer save (ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1,cnt = 0,i,j
  117. DateTime server_dt
  118. Long ll_billid
  119. String ls_sccode
  120. IF IsNull(dscrp) THEN dscrp = ''
  121. IF IsNull(relcode) THEN relcode = ''
  122. IF IsNull(salemth) THEN salemth = 0
  123. IF IsNull(outrep) THEN outrep = ''
  124. IF IsNull(cusid) THEN cusid = 0
  125. //IF Len(dscrp) > 0 THEN dscrp = ' ' + dscrp
  126. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  127. rslt = 0
  128. arG_MSG = "非编辑状态不可以提交"
  129. GOTO ext
  130. END IF
  131. IF Trim(outrep) = '' THEN
  132. rslt = 0
  133. arG_MSG = "请输入业务员"
  134. GOTO ext
  135. END IF
  136. cnt = 0
  137. SELECT count(*) INTO :cnt
  138. FROM u_saleplan
  139. WHERE outrep = :outrep
  140. AND salemth = :salemth
  141. AND billid <> :billid
  142. USING commit_transaction ;
  143. IF commit_transaction.SQLCode <> 0 THEN
  144. rslt = 0
  145. arG_MSG = '查询该业务当月是否已开销售计划失败'+"~n"+commit_transaction.SQLErrText
  146. GOTO ext
  147. END IF
  148. IF cnt > 0 THEN
  149. rslt = 0
  150. arG_MSG = '该业务员当月已开销售计划,不能重复开单'
  151. GOTO ext
  152. END IF
  153. IF cusid > 0 THEN
  154. cnt = 0
  155. SELECT count(*) INTO :cnt
  156. FROM u_cust
  157. Where cusid = :cusid;
  158. IF commit_transaction.SQLCode <> 0 THEN
  159. rslt = 0
  160. arG_MSG = "查询客户是否存在失败 "
  161. GOTO ext
  162. END IF
  163. IF cnt = 0 THEN
  164. rslt = 0
  165. arG_MSG = '客户资料不存在,请检查'
  166. GOTO ext
  167. END IF
  168. END IF
  169. SELECT Top 1 getdate() INTO :server_dt FROM u_user USING commit_transaction;
  170. IF commit_transaction.SQLCode <> 0 THEN
  171. rslt = 0
  172. arG_MSG = "查询操作失败,日期 "
  173. GOTO ext
  174. END IF
  175. IF f_check_inoutdate(0,billdate,FALSE,arG_MSG) = 0 THEN
  176. rslt = 0
  177. GOTO ext
  178. END IF
  179. IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
  180. rslt = 0
  181. arG_MSG = "没有正确单据明细内容"
  182. GOTO ext
  183. END IF
  184. //////////////////////////////////////////////// //开始区分:新建/更新 处理
  185. IF billid = 0 THEN //新建
  186. ll_billid = f_sys_scidentity(scid,"u_saleplan","billid",arG_MSG,TRUE,id_sqlca) //数据commit事务)
  187. IF ll_billid <= 0 THEN
  188. rslt = 0
  189. GOTO ext
  190. END IF
  191. IF f_get_sccode(scid,commit_transaction,ls_sccode,arG_MSG) = 0 THEN
  192. rslt = 0
  193. GOTO ext
  194. END IF
  195. billCode = getid(scid,ls_sccode + 'XP',Date(server_dt),FALSE,commit_transaction)
  196. IF billCode = "err" THEN
  197. billCode = ''
  198. rslt = 0
  199. arG_MSG = "无法获取单据编号"+"~n"+commit_transaction.SQLErrText
  200. GOTO ext
  201. END IF
  202. INSERT INTO u_saleplan
  203. ( scid,
  204. billid,
  205. billcode,
  206. outrep,
  207. billdate,
  208. salemth,
  209. relcode,
  210. Dscrp,
  211. opemp,
  212. opdate,
  213. cusid
  214. )
  215. VALUES (:scid,
  216. :ll_billid,
  217. :billCode,
  218. :outrep,
  219. :billdate,
  220. :salemth,
  221. :relcode,
  222. :Dscrp,
  223. :publ_operator,
  224. :server_dt,
  225. :cusid) USING commit_transaction ;
  226. IF commit_transaction.SQLCode <> 0 THEN
  227. rslt = 0
  228. arG_MSG = "因网络或其它原因导致插入单据操作失败"+"~n"+commit_transaction.SQLErrText
  229. ROLLBACK USING commit_transaction;
  230. GOTO ext
  231. END IF
  232. //读取新billid
  233. billid = ll_billid
  234. FOR i = 1 TO it_mxbt
  235. INSERT INTO u_saleplanmx
  236. ( scid,
  237. billid,
  238. mtrlid,
  239. planqty,
  240. mxdscrp,
  241. printid,
  242. price,
  243. planamt,
  244. status,
  245. woodcode,
  246. pcode,
  247. mxtype)
  248. VALUES (:scid,
  249. :ll_billid,
  250. :saleplanmx[i].mtrlid,
  251. :saleplanmx[i].planqty,
  252. :saleplanmx[i].mxdscrp,
  253. :saleplanmx[i].printid,
  254. :saleplanmx[i].price,
  255. :saleplanmx[i].planamt,
  256. :saleplanmx[i].status,
  257. :saleplanmx[i].woodcode,
  258. :saleplanmx[i].pcode,
  259. 0) USING commit_transaction;
  260. IF commit_transaction.SQLCode <> 0 THEN
  261. billid = 0 //还原billID
  262. rslt = 0
  263. arG_MSG = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  264. ROLLBACK USING commit_transaction;
  265. GOTO ext
  266. END IF
  267. NEXT
  268. FOR j = 1 TO it_mxbt_mx
  269. INSERT INTO u_saleplanmx
  270. ( scid,
  271. billid,
  272. mtrlid,
  273. planqty,
  274. mxdscrp,
  275. printid,
  276. price,
  277. planamt,
  278. mxtype)
  279. VALUES (:scid,
  280. :ll_billid,
  281. :saleplanmx_mx[j].mtrlid,
  282. :saleplanmx_mx[j].planqty,
  283. :saleplanmx_mx[j].mxdscrp,
  284. :saleplanmx_mx[j].printid,
  285. :saleplanmx_mx[j].price,
  286. :saleplanmx_mx[j].planamt,
  287. 1) USING commit_transaction;
  288. IF commit_transaction.SQLCode <> 0 THEN
  289. billid = 0 //还原billID
  290. rslt = 0
  291. arG_MSG = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  292. ROLLBACK USING commit_transaction;
  293. GOTO ext
  294. END IF
  295. NEXT
  296. ELSE //////////////////////////////////////////////// //更新
  297. UPDATE u_saleplan
  298. SET outrep = :outrep,
  299. salemth = :salemth,
  300. billdate = :billdate,
  301. relcode = :relcode,
  302. Dscrp = :Dscrp,
  303. moddate = getdate(),
  304. Modemp = :publ_operator,
  305. cusid = :cusid
  306. WHERE u_saleplan.billid = :billID
  307. AND scid = :scid
  308. AND flag = 0 USING commit_transaction;
  309. IF commit_transaction.SQLCode <> 0 OR sqlca.SQLNRows <= 0 THEN
  310. rslt = 0
  311. arG_MSG = "因网络或其它原因导致更新销售计划操作失败"+"~n"+commit_transaction.SQLErrText
  312. ROLLBACK USING commit_transaction;
  313. GOTO ext
  314. END IF
  315. //删除原有明细
  316. DELETE FROM u_saleplanmx
  317. Where u_saleplanmx.billid = :billid AND scid = :scid USING commit_transaction;
  318. IF commit_transaction.SQLCode <> 0 THEN
  319. rslt = 0
  320. arG_MSG = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  321. ROLLBACK USING commit_transaction;
  322. GOTO ext
  323. END IF
  324. FOR i = 1 TO it_mxbt
  325. INSERT INTO u_saleplanmx
  326. ( scid,
  327. billid,
  328. mtrlid,
  329. planqty,
  330. mxdscrp,
  331. printid,
  332. price,
  333. planamt,
  334. status,
  335. woodcode,
  336. pcode,
  337. mxtype)
  338. VALUES (:scid,
  339. :billid,
  340. :saleplanmx[i].mtrlid,
  341. :saleplanmx[i].planqty,
  342. :saleplanmx[i].mxdscrp,
  343. :saleplanmx[i].printid,
  344. :saleplanmx[i].price,
  345. :saleplanmx[i].planamt,
  346. :saleplanmx[i].status,
  347. :saleplanmx[i].woodcode,
  348. :saleplanmx[i].pcode,
  349. 0) USING commit_transaction;
  350. IF commit_transaction.SQLCode <> 0 THEN
  351. rslt = 0
  352. arG_MSG = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  353. ROLLBACK USING commit_transaction;
  354. GOTO ext
  355. END IF
  356. NEXT
  357. FOR j = 1 TO it_mxbt_mx
  358. INSERT INTO u_saleplanmx
  359. ( scid,
  360. billid,
  361. mtrlid,
  362. planqty,
  363. mxdscrp,
  364. printid,
  365. price,
  366. planamt,
  367. mxtype)
  368. VALUES (:scid,
  369. :billid,
  370. :saleplanmx_mx[j].mtrlid,
  371. :saleplanmx_mx[j].planqty,
  372. :saleplanmx_mx[j].mxdscrp,
  373. :saleplanmx_mx[j].printid,
  374. :saleplanmx_mx[j].price,
  375. :saleplanmx_mx[j].planamt,
  376. 1) USING commit_transaction;
  377. IF commit_transaction.SQLCode <> 0 THEN
  378. billid = 0 //还原billID
  379. rslt = 0
  380. arG_MSG = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  381. ROLLBACK USING commit_transaction;
  382. GOTO ext
  383. END IF
  384. NEXT
  385. END IF
  386. it_newbegin = FALSE
  387. it_updatebegin = FALSE
  388. ext:
  389. IF rslt = 0 THEN
  390. p_clearmx()
  391. ROLLBACK USING commit_transaction;
  392. ELSEIF arg_ifcommit AND rslt = 1 THEN
  393. COMMIT USING commit_transaction;
  394. END IF
  395. Return(rslt)
  396. end function
  397. public function integer p_getinfo (long arg_scid, long arg_billid, ref string arg_msg);Int rslt = 1
  398. SELECT
  399. billid,
  400. billcode,
  401. outrep,
  402. salemth,
  403. billdate,
  404. relcode,
  405. dscrp,
  406. opemp,
  407. opdate,
  408. flag,
  409. secflag
  410. INTO :billid,
  411. :billcode,
  412. :outrep,
  413. :salemth,
  414. :billdate,
  415. :relcode,
  416. :dscrp,
  417. :opemp,
  418. :opdate,
  419. :flag,
  420. :secflag
  421. FROM u_saleplan
  422. Where u_saleplan.billid = :arg_billid
  423. AND u_saleplan.scid = :arg_scid USING commit_transaction;
  424. IF commit_transaction.SQLCode <> 0 THEN
  425. rslt = 0
  426. ARG_MSG = '查询单据内容失败(错误单据唯一码)'+sqlca.SQLErrText
  427. GOTO ext
  428. END IF
  429. scid = arg_scid
  430. billid = arg_billid
  431. ext:
  432. RETURN rslt
  433. end function
  434. public function integer getinfo (integer arg_scid, long arg_billid, ref string arg_msg);
  435. Int rslt = 1,i = 1,no_mxcheck = 0
  436. Int j = 1
  437. IF arg_billid <= 0 THEN
  438. rslt = 0
  439. arg_msg = '错误单据唯一码'
  440. GOTO ext
  441. END IF
  442. IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
  443. rslt = 0
  444. GOTO ext
  445. END IF
  446. //用游标读取明细
  447. DECLARE cur_saleplanmx CURSOR FOR
  448. SELECT
  449. mtrlid,
  450. planqty,
  451. printid,
  452. mxdscrp,
  453. price,
  454. planamt,
  455. status,
  456. woodcode,
  457. pcode
  458. FROM u_saleplanmx
  459. WHERE u_saleplanmx.billid = :arg_billid AND
  460. u_saleplanmx.scid = :arg_scid AND
  461. u_saleplanmx.mxtype = 0
  462. Order By u_saleplanmx.printid USING commit_transaction;
  463. OPEN cur_saleplanmx;
  464. FETCH cur_saleplanmx INTO :saleplanmx[i].mtrlid,:saleplanmx[i].planqty,
  465. :saleplanmx[i].printid,:saleplanmx[i].mxdscrp,
  466. :saleplanmx[i].price,:saleplanmx[i].planamt,
  467. :saleplanmx[i].status,:saleplanmx[i].woodcode,:saleplanmx[i].pcode;
  468. DO WHILE commit_transaction.SQLCode = 0
  469. i++
  470. FETCH cur_saleplanmx INTO :saleplanmx[i].mtrlid,:saleplanmx[i].planqty,
  471. :saleplanmx[i].printid,:saleplanmx[i].mxdscrp,
  472. :saleplanmx[i].price,:saleplanmx[i].planamt,
  473. :saleplanmx[i].status,:saleplanmx[i].woodcode,:saleplanmx[i].pcode;
  474. LOOP
  475. CLOSE cur_saleplanmx;
  476. //检验明细是否读入完整
  477. SELECT count(*) INTO :no_mxcheck
  478. FROM u_saleplanmx
  479. WHERE u_saleplanmx.billid = :arg_billid AND
  480. u_saleplanmx.scid = :arg_scid AND
  481. u_saleplanmx.mxtype = 0 USING commit_transaction;
  482. IF commit_transaction.SQLCode <> 0 THEN
  483. rslt = 0
  484. arg_msg = "查询操作失败,单据明细数量"
  485. GOTO ext
  486. END IF
  487. IF i <> (no_mxcheck+1) THEN
  488. rslt = 0
  489. arg_msg = "查询操作失败,单据明细"
  490. GOTO ext
  491. END IF
  492. it_mxbt = i - 1
  493. //
  494. //用游标读取明细
  495. DECLARE cur_saleplanmx_mx CURSOR FOR
  496. SELECT
  497. mtrlid,
  498. planqty,
  499. printid,
  500. mxdscrp,
  501. price,
  502. planamt
  503. FROM u_saleplanmx
  504. WHERE u_saleplanmx.billid = :arg_billid AND
  505. u_saleplanmx.scid = :arg_scid AND
  506. u_saleplanmx.mxtype = 1
  507. Order By u_saleplanmx.printid USING commit_transaction;
  508. OPEN cur_saleplanmx_mx;
  509. FETCH cur_saleplanmx_mx INTO :saleplanmx[j].mtrlid,:saleplanmx[j].planqty,
  510. :saleplanmx[j].printid,:saleplanmx[j].mxdscrp,
  511. :saleplanmx[j].price,:saleplanmx[j].planamt;
  512. DO WHILE commit_transaction.SQLCode = 0
  513. j++
  514. FETCH cur_saleplanmx_mx INTO :saleplanmx[j].mtrlid,:saleplanmx[j].planqty,
  515. :saleplanmx[j].printid,:saleplanmx[j].mxdscrp,
  516. :saleplanmx[j].price,:saleplanmx[j].planamt;
  517. LOOP
  518. CLOSE cur_saleplanmx_mx;
  519. //检验明细是否读入完整
  520. SELECT count(*) INTO :no_mxcheck
  521. FROM u_saleplanmx
  522. WHERE u_saleplanmx.billid = :arg_billid AND
  523. u_saleplanmx.scid = :arg_scid AND
  524. u_saleplanmx.mxtype = 1 USING commit_transaction;
  525. IF commit_transaction.SQLCode <> 0 THEN
  526. rslt = 0
  527. arg_msg = "查询操作失败,单据明细数量"
  528. GOTO ext
  529. END IF
  530. IF j <> (no_mxcheck+1) THEN
  531. rslt = 0
  532. arg_msg = "查询操作失败,单据汇总明细"
  533. GOTO ext
  534. END IF
  535. it_mxbt_mx = j - 1
  536. it_newbegin = FALSE
  537. it_updatebegin = FALSE
  538. ext:
  539. IF rslt = 0 THEN p_reset()
  540. RETURN rslt
  541. end function
  542. public function integer cancel (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  543. IF arg_billid <= 0 THEN
  544. rslt = 0
  545. ARG_MSG = '错误单据唯一码'
  546. GOTO ext
  547. END IF
  548. IF p_getinfo(arg_scid,arg_billid,ARG_MSG) = 0 THEN
  549. rslt = 0
  550. GOTO ext
  551. END IF
  552. IF flag = 1 THEN
  553. rslt = 0
  554. ARG_MSG = "单据已经审核,不可以删除"
  555. GOTO ext
  556. END IF
  557. DELETE FROM u_saleplan
  558. WHERE u_saleplan.billid = :arg_billid
  559. AND u_saleplan.scid = :arg_scid USING commit_transaction;
  560. IF commit_transaction.SQLCode <> 0 THEN
  561. rslt = 0
  562. ARG_MSG = "删除销售计划操作失败"+"~n"+commit_transaction.SQLErrText
  563. ROLLBACK USING commit_transaction;
  564. GOTO ext
  565. END IF
  566. DELETE FROM u_saleplanmx
  567. Where u_saleplanmx.billid = :arg_billid AND u_saleplanmx.scid = :arg_scid USING commit_transaction;
  568. IF commit_transaction.SQLCode <> 0 THEN
  569. rslt = 0
  570. ARG_MSG = "删除单据明细操作失败"+"~n"+SQLCA.SQLErrText
  571. ROLLBACK USING commit_transaction;
  572. GOTO ext
  573. END IF
  574. it_newbegin = FALSE
  575. it_updatebegin = FALSE
  576. IF rslt = 0 THEN
  577. ROLLBACK USING commit_transaction;
  578. ELSEIF rslt = 1 AND arg_ifcommit THEN
  579. COMMIT USING commit_transaction;
  580. END IF
  581. ext:
  582. p_reset()
  583. Return (rslt)
  584. end function
  585. public function integer audit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);
  586. Int rslt = 1,cnt = 0
  587. IF arg_billid <= 0 THEN
  588. rslt = 0
  589. ARG_MSG = '错误单据唯一码'
  590. GOTO ext
  591. END IF
  592. IF getinfo(arg_scid,arg_billid,ARG_MSG) = 0 THEN
  593. rslt = 0
  594. GOTO ext
  595. END IF
  596. IF flag = 1 THEN
  597. rslt = 0
  598. ARG_MSG = "单据已经审核,操作取消"
  599. GOTO ext
  600. END IF
  601. IF it_MXBT <= 0 THEN
  602. rslt = 0
  603. ARG_MSG = "单据明细错误,操作取消"
  604. GOTO ext
  605. END IF
  606. //更新审核标记
  607. UPDATE u_saleplan
  608. SET auditingrep = :publ_operator,
  609. auditingdate = getdate(),
  610. flag = 1
  611. Where u_saleplan.billid = :arg_billid
  612. AND u_saleplan.scid = :arg_scid
  613. AND u_saleplan.flag = 0 USING commit_transaction;
  614. IF commit_transaction.SQLCode <> 0 THEN
  615. rslt = 0
  616. ARG_MSG = "因网络或其它原因导致单据审核操作失败"+"~n"+commit_transaction.SQLErrText
  617. GOTO ext
  618. END IF
  619. it_newbegin = FALSE
  620. it_updatebegin = FALSE
  621. ext:
  622. IF rslt = 0 THEN
  623. ROLLBACK USING commit_transaction;
  624. ELSEIF rslt = 1 and arg_ifcommit THEN
  625. COMMIT USING commit_transaction;
  626. END IF
  627. p_reset()
  628. Return (rslt)
  629. end function
  630. public function integer add_dscrp (long arg_scid, long arg_billid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  631. arg_newdescppart = Trim(arg_newdescppart)
  632. IF it_updatebegin OR it_newbegin THEN
  633. rslt = 0
  634. arG_MSG = "编辑状态下不可用"
  635. GOTO ext
  636. END IF
  637. IF arg_newdescppart = '' THEN
  638. rslt = 0
  639. arG_MSG = "要添加内容为空,操作取消"
  640. GOTO ext
  641. END IF
  642. IF p_getinfo(arg_scid,arg_billid,arG_MSG) = 0 THEN
  643. rslt = 0
  644. GOTO ext
  645. END IF
  646. IF flag = 0 THEN
  647. rslt = 0
  648. arG_MSG = "待审核状态下不可用"
  649. GOTO ext
  650. END IF
  651. UPDATE u_saleplan
  652. SET DSCRP = DSCRP+' '+:arg_newdescppart
  653. WHERE u_saleplan.billid = :arg_billid
  654. AND u_saleplan.scid = :arg_scid USING commit_transaction;
  655. IF commit_transaction.SQLCode <> 0 THEN
  656. rslt = 0
  657. arG_MSG = "因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.SQLErrText
  658. GOTO ext
  659. END IF
  660. DSCRP = DSCRP+' '+arg_newdescppart
  661. it_newbegin = FALSE
  662. it_updatebegin = FALSE
  663. ext:
  664. IF rslt = 0 THEN
  665. ROLLBACK USING commit_transaction;
  666. ELSEIF rslt = 1 AND arg_ifcommit THEN
  667. COMMIT USING commit_transaction;
  668. END IF
  669. p_reset()
  670. Return (rslt)
  671. end function
  672. public function integer updatebegin (long arg_scid, long arg_billid, ref string arg_msg);//UPDATEbegin(long arg_taskid,ref string arg_msg)
  673. //从置对象,设定业务类型与关联ID,准备更新进仓单
  674. //0 fail 1 success
  675. Long rslt = 1,CNT = 0
  676. IF arg_scid < 0 THEN
  677. arg_msg = '请选择分部'
  678. rslt = 0
  679. GOTO ext
  680. END IF
  681. IF arg_billid <= 0 THEN
  682. rslt = 0
  683. arg_msg = '错误销售计划唯一码'
  684. GOTO ext
  685. END IF
  686. IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
  687. rslt = 0
  688. GOTO ext
  689. END IF
  690. IF flag = 1 THEN
  691. rslt = 0
  692. arg_msg = '已经处于审核状态,不可以修改,要修改请先撤销审核'
  693. GOTO ext
  694. END IF
  695. it_newbegin = FALSE
  696. it_updatebegin = TRUE
  697. p_clearmx() //清除明细
  698. scid = arg_scid
  699. billid = arg_billid
  700. ext:
  701. IF rslt = 0 THEN p_reset()
  702. RETURN rslt
  703. end function
  704. public function integer caudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1,cnt = 0
  705. DateTime ls_auditingdate
  706. SetNull(ls_auditingdate)
  707. IF arg_billid <= 0 THEN
  708. rslt = 0
  709. ARG_MSG = '错误销售计划唯一码'
  710. GOTO ext
  711. END IF
  712. IF p_getinfo(arg_scid,arg_billid,ARG_MSG) = 0 THEN
  713. rslt = 0
  714. GOTO ext
  715. END IF
  716. IF flag = 0 THEN
  717. rslt = 0
  718. ARG_MSG = "单据只有在已审核状态才可以执行撤消审核,请核对"
  719. GOTO ext
  720. END IF
  721. IF secflag = 1 THEN
  722. rslt = 0
  723. ARG_MSG = "单据已经确认,不可以执行取消审核,请核对"
  724. GOTO ext
  725. END IF
  726. UPDATE u_saleplan
  727. SET flag = 0,auditingrep = '',auditingdate = :ls_auditingdate
  728. WHERE u_saleplan.billid = :arg_billid
  729. AND u_saleplan.scid = :arg_scid
  730. AND u_saleplan.flag = 1 USING commit_transaction ;
  731. IF commit_transaction.SQLCode <> 0 THEN
  732. rslt = 0
  733. ARG_MSG = "因网络或其它原因导致单据撤消审核操作失败"+"~n"+commit_transaction.SQLErrText
  734. GOTO ext
  735. END IF
  736. it_newbegin = FALSE
  737. it_updatebegin = FALSE
  738. ext:
  739. IF rslt = 0 THEN
  740. ROLLBACK USING commit_transaction;
  741. ELSEIF rslt = 1 AND arg_ifcommit THEN
  742. COMMIT USING commit_transaction;
  743. END IF
  744. p_reset()
  745. Return (rslt)
  746. end function
  747. public function integer secaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);
  748. Int rslt = 1,cnt = 0
  749. IF arg_billid <= 0 THEN
  750. rslt = 0
  751. ARG_MSG = '错误单据唯一码'
  752. GOTO ext
  753. END IF
  754. IF getinfo(arg_scid,arg_billid,ARG_MSG) = 0 THEN
  755. rslt = 0
  756. GOTO ext
  757. END IF
  758. IF flag = 0 then
  759. rslt = 0
  760. arg_msg = '单据未审核,操作取消'
  761. goto ext
  762. end if
  763. IF secflag = 1 THEN
  764. rslt = 0
  765. ARG_MSG = "单据已经二审,操作取消"
  766. GOTO ext
  767. END IF
  768. IF it_MXBT <= 0 THEN
  769. rslt = 0
  770. ARG_MSG = "单据明细错误,操作取消"
  771. GOTO ext
  772. END IF
  773. //更新审核标记
  774. UPDATE u_saleplan
  775. SET secauditingrep = :publ_operator, secauditingdate = getdate(),
  776. secflag = 1
  777. Where u_saleplan.billid = :arg_billid
  778. AND u_saleplan.scid = :arg_scid
  779. AND u_saleplan.secflag = 0 USING commit_transaction;
  780. IF commit_transaction.SQLCode <> 0 THEN
  781. rslt = 0
  782. ARG_MSG = "因网络或其它原因导致单据审核操作失败"+"~n"+commit_transaction.SQLErrText
  783. GOTO ext
  784. END IF
  785. it_newbegin = FALSE
  786. it_updatebegin = FALSE
  787. ext:
  788. IF rslt = 0 THEN
  789. ROLLBACK USING commit_transaction;
  790. ELSEIF rslt = 1 and arg_ifcommit THEN
  791. COMMIT USING commit_transaction;
  792. END IF
  793. p_reset()
  794. Return (rslt)
  795. end function
  796. public function integer csecaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1,cnt = 0
  797. datetime ls_secauditingdate
  798. setnull(ls_secauditingdate)
  799. IF arg_billid <= 0 THEN
  800. rslt = 0
  801. ARG_MSG = '错误单据唯一码'
  802. GOTO ext
  803. END IF
  804. IF getinfo(arg_scid,arg_billid,ARG_MSG) = 0 THEN
  805. rslt = 0
  806. GOTO ext
  807. END IF
  808. IF secflag = 0 THEN
  809. rslt = 0
  810. ARG_MSG = "单据未二审,操作取消"
  811. GOTO ext
  812. END IF
  813. IF it_MXBT <= 0 THEN
  814. rslt = 0
  815. ARG_MSG = "单据明细错误,操作取消"
  816. GOTO ext
  817. END IF
  818. //更新审核标记
  819. UPDATE u_saleplan
  820. SET secauditingrep = '', secauditingdate = :ls_secauditingdate,
  821. secflag = 0
  822. Where u_saleplan.billid = :arg_billid
  823. AND u_saleplan.scid = :arg_scid
  824. AND u_saleplan.secflag = 1 USING commit_transaction;
  825. IF commit_transaction.SQLCode <> 0 THEN
  826. rslt = 0
  827. ARG_MSG = "因网络或其它原因导致单据审核操作失败"+"~n"+commit_transaction.SQLErrText
  828. GOTO ext
  829. END IF
  830. it_newbegin = FALSE
  831. it_updatebegin = FALSE
  832. ext:
  833. IF rslt = 0 THEN
  834. ROLLBACK USING commit_transaction;
  835. ELSEIF rslt = 1 and arg_ifcommit THEN
  836. COMMIT USING commit_transaction;
  837. END IF
  838. p_reset()
  839. Return (rslt)
  840. end function
  841. public function integer updatesaleqty (long arg_salemth, string arg_outrep, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  842. Long cnt = 0
  843. cnt = 0
  844. SELECT count(*) INTO :cnt
  845. FROM u_saleplan
  846. WHERE salemth = :arg_salemth
  847. AND outrep = :arg_outrep
  848. AND flag = 0 USING commit_transaction;
  849. IF commit_transaction.SQLCode <> 0 THEN
  850. arg_msg = '查询业务员:'+arg_outrep+',本月是否有未审单据失败,'+commit_transaction.SQLErrText
  851. rslt = 0
  852. GOTO ext
  853. END IF
  854. IF cnt > 0 THEN
  855. arg_msg = '业务员:'+arg_outrep+',本月有未审单据,请检查'
  856. rslt = 0
  857. GOTO ext
  858. END IF
  859. cnt = 0
  860. SELECT count(*) INTO :cnt
  861. FROM u_saleplan
  862. WHERE salemth = :arg_salemth
  863. AND outrep = :arg_outrep
  864. AND secflag = 1 USING commit_transaction;
  865. IF commit_transaction.SQLCode <> 0 THEN
  866. arg_msg = '查询业务员:'+arg_outrep+',本月是否有终审单据失败,'+commit_transaction.SQLErrText
  867. rslt = 0
  868. GOTO ext
  869. END IF
  870. IF cnt > 0 THEN
  871. arg_msg = '业务员:'+arg_outrep+',本月有终审单据,请检查'
  872. rslt = 0
  873. GOTO ext
  874. END IF
  875. //计算当月实际销售数
  876. Int li_year,li_month
  877. li_year = Integer(Left(String(arg_salemth),4))
  878. IF Mid(String(arg_salemth),5,1) = '0' THEN
  879. li_month = Integer(Mid(String(arg_salemth),6,1))
  880. ELSE
  881. li_month = Integer(Mid(String(arg_salemth),5,2))
  882. END IF
  883. Long l,ll_ant_arr = 1
  884. Long ll_mtrlid_arr[],ll_scid_arr[]
  885. Decimal ld_saleqty_arr[],ld_saleamt_arr[]
  886. String ls_mtrlcode_arr[]
  887. Long ll_max_saleplanid
  888. DECLARE cur_sale CURSOR FOR
  889. SELECT isnull(sum(qty),0),
  890. isnull(sum(round(qty * price,2)),0),
  891. u_outwaremx.scid,
  892. u_outwaremx.mtrlid,
  893. u_mtrldef.mtrlcode
  894. FROM u_outwaremx,u_outware,u_mtrldef
  895. WHERE u_outwaremx.outwareid = u_outware.outwareid
  896. AND u_outwaremx.scid = u_outware.scid
  897. AND u_outwaremx.mtrlid = u_mtrldef.mtrlid
  898. AND u_outware.outrep = :arg_outrep
  899. AND datepart(yyyy,u_outware.outdate) = :li_year
  900. AND datepart(mm,u_outware.outdate) = :li_month
  901. AND u_outware.billtype = 1
  902. AND u_outware.flag = 1
  903. AND u_outware.secflag = 1
  904. AND u_outwaremx.outtypestr = ''
  905. GROUP BY u_outwaremx.scid,
  906. u_outwaremx.mtrlid,
  907. u_mtrldef.mtrlcode
  908. USING commit_transaction;
  909. OPEN cur_sale;
  910. FETCH cur_sale INTO :ld_saleqty_arr[ll_ant_arr],
  911. :ld_saleamt_arr[ll_ant_arr],
  912. :ll_scid_arr[ll_ant_arr],
  913. :ll_mtrlid_arr[ll_ant_arr],
  914. :ls_mtrlcode_arr[ll_ant_arr];
  915. DO WHILE commit_transaction.SQLCode = 0
  916. ll_ant_arr++
  917. FETCH cur_sale INTO :ld_saleqty_arr[ll_ant_arr],
  918. :ld_saleamt_arr[ll_ant_arr],
  919. :ll_scid_arr[ll_ant_arr],
  920. :ll_mtrlid_arr[ll_ant_arr],
  921. :ls_mtrlcode_arr[ll_ant_arr];
  922. LOOP
  923. CLOSE cur_sale;
  924. ll_ant_arr = ll_ant_arr - 1
  925. IF ll_ant_arr = 0 THEN
  926. arg_msg = '业务员:'+arg_outrep+',没有实际销售数,请检查'
  927. rslt = 0
  928. GOTO ext
  929. END IF
  930. DELETE u_saleplanmx
  931. FROM u_saleplan,u_saleplanmx
  932. WHERE u_saleplan.scid = u_saleplanmx.scid
  933. AND u_saleplan.billid = u_saleplanmx.billid
  934. AND u_saleplan.salemth = :arg_salemth
  935. AND u_saleplan.outrep = :arg_outrep
  936. AND u_saleplanmx.planqty = 0
  937. USING commit_transaction;
  938. IF commit_transaction.SQLCode <> 0 THEN
  939. rslt = 0
  940. arg_msg = '清除业务员:'+arg_outrep+'物料:'+ls_mtrlcode_arr[l]+',实际销售数量失败 ' + commit_transaction.SQLErrText
  941. GOTO ext
  942. END IF
  943. //Open(w_sys_wait_jdt) //初始化进度条
  944. //w_sys_wait_jdt.Show()
  945. //w_sys_wait_jdt.wf_accepttol(ll_ant_arr) //初始化进度条1
  946. //
  947. FOR l = 1 TO ll_ant_arr
  948. // w_sys_wait_jdt.wf_inc(l) //进度
  949. // w_sys_wait_jdt.st_msg.Text = "处理:"+ls_mtrlcode_arr[l] //进度信息
  950. UPDATE u_saleplanmx
  951. SET saleqty = :ld_saleqty_arr[l],
  952. saleamt = :ld_saleamt_arr[l]
  953. FROM u_saleplan,u_saleplanmx
  954. WHERE u_saleplan.scid = u_saleplanmx.scid
  955. AND u_saleplan.billid = u_saleplanmx.billid
  956. AND u_saleplan.salemth = :arg_salemth
  957. AND u_saleplan.outrep = :arg_outrep
  958. AND u_saleplanmx.scid = :ll_scid_arr[l]
  959. AND u_saleplanmx.mtrlid = :ll_mtrlid_arr[l]
  960. and u_saleplanmx.mxtype = 1
  961. USING commit_transaction;
  962. IF commit_transaction.SQLCode = 0 THEN
  963. IF commit_transaction.SQLNRows = 0 THEN
  964. SELECT max(billid) INTO :ll_max_saleplanid
  965. FROM u_saleplan
  966. WHERE u_saleplan.salemth = :arg_salemth
  967. AND u_saleplan.outrep = :arg_outrep
  968. AND u_saleplan.scid = :ll_scid_arr[l]
  969. USING commit_transaction;
  970. IF commit_transaction.SQLCode <> 0 THEN
  971. arg_msg = '查询业务员:'+arg_outrep+',单据ID失败,'+commit_transaction.SQLErrText
  972. rslt = 0
  973. GOTO ext
  974. END IF
  975. IF IsNull(ll_max_saleplanid) THEN ll_max_saleplanid = 0
  976. IF ll_max_saleplanid = 0 THEN
  977. arg_msg = '业务员:'+arg_outrep+',单据ID错误'
  978. rslt = 0
  979. GOTO ext
  980. END IF
  981. INSERT INTO u_saleplanmx
  982. (scid,
  983. billid,
  984. mtrlid,
  985. saleqty,
  986. saleamt,
  987. mxtype)
  988. VALUES
  989. (:ll_scid_arr[l],
  990. :ll_max_saleplanid,
  991. :ll_mtrlid_arr[l],
  992. :ld_saleqty_arr[l],
  993. :ld_saleamt_arr[l],
  994. 1)
  995. USING commit_transaction;
  996. IF commit_transaction.SQLCode <> 0 THEN
  997. arg_msg = '新增业务员:'+arg_outrep+'物料:'+ls_mtrlcode_arr[l]+',实际销售数量失败 ' + commit_transaction.SQLErrText
  998. rslt = 0
  999. GOTO ext
  1000. END IF
  1001. END IF
  1002. ELSE
  1003. rslt = 0
  1004. arg_msg = '更新业务员:'+arg_outrep+'物料:'+ls_mtrlcode_arr[l]+',实际销售数量失败 ' + commit_transaction.SQLErrText
  1005. GOTO ext
  1006. END IF
  1007. NEXT
  1008. ext:
  1009. //Close(w_sys_wait_jdt)
  1010. IF rslt = 0 THEN
  1011. ROLLBACK USING commit_transaction;
  1012. ELSEIF rslt = 1 AND arg_ifcommit THEN
  1013. COMMIT USING commit_transaction;
  1014. END IF
  1015. Return (rslt)
  1016. end function
  1017. public function integer acceptmx (long arg_mtrlid, string arg_mtrlcode, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_planqty, decimal arg_price, string arg_mxdscrp, ref string arg_msg, long arg_printid);Int rslt = 1
  1018. Long cnt = 0,LS_i,ls_j
  1019. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  1020. rslt = 0
  1021. arG_MSG = "非编辑状态不可以使用,操作取消"
  1022. GOTO ext
  1023. END IF
  1024. //清除空值
  1025. IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
  1026. IF IsNull(arg_mtrlcode) THEN arg_mtrlcode = ''
  1027. IF IsNull(arg_planqty) THEN arg_planqty = 0
  1028. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  1029. IF IsNull(arg_printid) THEN arg_printid = 0
  1030. IF IsNull(arg_price) THEN arg_price = 0
  1031. IF IsNull(arg_status) THEN arg_status = ''
  1032. IF IsNull(arg_woodcode) THEN arg_woodcode = ''
  1033. IF IsNull(arg_pcode) THEN arg_pcode = ''
  1034. IF arg_mtrlid = 0 OR arg_planqty = 0 THEN // 如果物料编号为空,则不作任何处理
  1035. rslt = 1
  1036. GOTO ext
  1037. END IF
  1038. //检查物料id
  1039. SELECT count(*)
  1040. INTO :cnt
  1041. FROM u_mtrldef
  1042. WHERE u_mtrldef.mtrlid = :arg_mtrlid
  1043. USING commit_transaction;
  1044. IF sqlca.SQLCode <> 0 THEN
  1045. rslt = 0
  1046. arG_MSG = "查询操作失败,产品编号,"+commit_transaction.SQLErrText
  1047. GOTO ext
  1048. END IF
  1049. IF cnt = 0 THEN
  1050. rslt = 0
  1051. arG_MSG = "错误的产品编号: "+String(arg_mtrlcode)
  1052. GOTO ext
  1053. END IF
  1054. cnt = 0
  1055. SELECT count(*) INTO :cnt
  1056. FROM u_saleplanmx,u_saleplan
  1057. WHERE u_saleplanmx.scid = u_saleplan.scid
  1058. AND u_saleplanmx.billid = u_saleplan.billid
  1059. AND u_saleplan.outrep = :outrep
  1060. AND u_saleplan.salemth = :salemth
  1061. AND u_saleplanmx.mtrlid = :arg_mtrlid
  1062. AND u_saleplanmx.status = :arg_status
  1063. AND u_saleplanmx.woodcode = :arg_woodcode
  1064. AND u_saleplanmx.pcode = :arg_pcode
  1065. AND u_saleplanmx.billid <> :billid
  1066. USING commit_transaction;
  1067. IF sqlca.SQLCode <> 0 THEN
  1068. arG_MSG = '查询业务员:'+outrep+',产品:'+arg_mtrlcode+',本月是否在其它计件单已做计划失败,'+commit_transaction.SQLErrText
  1069. rslt = 0
  1070. GOTO ext
  1071. END IF
  1072. IF cnt > 0 THEN
  1073. arG_MSG = '查询业务员:'+outrep+',产品:'+arg_mtrlcode+',本月在其它计件单已做计划失败'
  1074. rslt = 0
  1075. GOTO ext
  1076. END IF
  1077. FOR LS_i = 1 TO it_mxbt //合并重复项(产品,配置)
  1078. IF saleplanmx[LS_i].mtrlid = arg_mtrlid AND &
  1079. saleplanmx[LS_i].status = arg_status AND &
  1080. saleplanmx[LS_i].woodcode = arg_woodcode AND &
  1081. saleplanmx[LS_i].pcode = arg_pcode THEN
  1082. saleplanmx[LS_i].planqty = saleplanmx[LS_i].planqty + arg_planqty
  1083. rslt = 1
  1084. GOTO _next
  1085. END IF
  1086. NEXT
  1087. //写入内容
  1088. it_mxbt++
  1089. saleplanmx[it_mxbt].mtrlid = arg_mtrlid
  1090. saleplanmx[it_mxbt].mtrlcode = arg_mtrlcode
  1091. saleplanmx[it_mxbt].planqty = arg_planqty
  1092. saleplanmx[it_mxbt].price = arg_price
  1093. saleplanmx[it_mxbt].planamt = Round(arg_price * arg_planqty,2)
  1094. saleplanmx[it_mxbt].mxdscrp = arg_mxdscrp
  1095. saleplanmx[it_mxbt].printid = arg_printid
  1096. saleplanmx[it_mxbt].status = arg_status
  1097. saleplanmx[it_mxbt].woodcode = arg_woodcode
  1098. saleplanmx[it_mxbt].pcode = arg_pcode
  1099. _next:
  1100. FOR ls_j = 1 TO it_mxbt_mx //合并重复项(产品)
  1101. IF saleplanmx_mx[ls_j].mtrlid = arg_mtrlid THEN
  1102. saleplanmx_mx[ls_j].planqty = saleplanmx_mx[ls_j].planqty + arg_planqty
  1103. rslt = 1
  1104. GOTO ext
  1105. END IF
  1106. NEXT
  1107. it_mxbt_mx++
  1108. saleplanmx_mx[it_mxbt_mx].mtrlid = arg_mtrlid
  1109. saleplanmx_mx[it_mxbt_mx].mtrlcode = arg_mtrlcode
  1110. saleplanmx_mx[it_mxbt_mx].planqty = arg_planqty
  1111. saleplanmx_mx[it_mxbt_mx].price = arg_price
  1112. saleplanmx_mx[it_mxbt_mx].planamt = Round(arg_price * arg_planqty,2)
  1113. saleplanmx_mx[it_mxbt_mx].mxdscrp = arg_mxdscrp
  1114. saleplanmx_mx[it_mxbt_mx].printid = arg_printid
  1115. ext:
  1116. IF rslt = 0 THEN p_clearmx()
  1117. Return(rslt)
  1118. end function
  1119. on uo_saleplan.create
  1120. call super::create
  1121. TriggerEvent( this, "constructor" )
  1122. end on
  1123. on uo_saleplan.destroy
  1124. TriggerEvent( this, "destructor" )
  1125. call super::destroy
  1126. end on
  1127. global type uo_incase from nonvisualobject
  1128. end type