uo_quote.sru 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712
  1. $PBExportHeader$uo_quote.sru
  2. forward
  3. global type uo_quote from nonvisualobject
  4. end type
  5. type s_quotemx from structure within uo_quote
  6. end type
  7. end forward
  8. type s_quotemx from structure
  9. long mtrlid
  10. string mtrlcode
  11. string mtrlname
  12. string mtrlmode
  13. string unit
  14. long printid
  15. decimal { 10 } maxprice
  16. decimal { 10 } planprice
  17. string mxdscrp
  18. decimal { 10 } wfjgprice
  19. decimal { 10 } profit_margin
  20. decimal { 10 } sumprice
  21. decimal { 10 } sumprice_1
  22. decimal { 10 } outcost
  23. decimal { 10 } mancost
  24. decimal { 10 } mtrlcost
  25. string pfcode
  26. string status
  27. string woodcode
  28. string pcode
  29. decimal { 10 } qty
  30. decimal { 10 } qty1
  31. decimal { 5 } rebate
  32. decimal { 10 } addqty
  33. string formula
  34. decimal { 10 } lastprice
  35. string dscrp_text
  36. string mxdscrp2
  37. string mxdscrp3
  38. string mxdscrp4
  39. string newunit
  40. end type
  41. global type uo_quote from nonvisualobject
  42. end type
  43. global uo_quote uo_quote
  44. type variables
  45. PUBLIC PROTECTEDWRITE Long scid = 0
  46. PUBLIC PROTECTEDWRITE Long quoteID = 0
  47. PUBLIC PROTECTEDWRITE String quoteCode = ''
  48. PUBLIC PROTECTEDWRITE DateTime opdate
  49. PUBLIC PROTECTEDWRITE String operator = ''
  50. PUBLIC PROTECTEDWRITE String Permit_emp = ''//审核操作员
  51. public protectedwrite datetime moddate //修改时间,自动
  52. public protectedwrite string modemp //修改操作员
  53. public protectedwrite int flag=0 //审核标志
  54. public protectedwrite datetime auditingdate //审核时间
  55. Long custID = 0
  56. String Assign_emp
  57. DateTime quotedate
  58. String dscrp
  59. String dscrp2
  60. string relcode
  61. long moneyid
  62. int billtype
  63. datetime sendTime
  64. string sendUser,fiebrelcode
  65. Transaction commit_transaction
  66. PRIVATE:
  67. s_quotemx quotemx[] //明细结构数组
  68. Long it_MXBT = 0 //明细结构数组末指针
  69. Boolean IT_NEWBEGIN = FALSE //新建标志
  70. Boolean IT_UPDATEBEGIN = FALSE//修改标志
  71. end variables
  72. forward prototypes
  73. public function integer p_reset ()
  74. public function integer p_clearmx ()
  75. public function integer newbegin (long arg_scid, ref string arg_msg)
  76. public function integer save (string arg_operator, ref string arg_msg, boolean arg_ifcommit)
  77. public function integer add_dscrp (long arg_scid, long arg_quoteid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit)
  78. public function integer cancel (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit)
  79. public function integer p_getinfo (long arg_scid, long arg_quoteid, ref string arg_msg)
  80. public function integer updatebegin (long arg_scid, long arg_quoteid, ref string arg_msg)
  81. public function integer audit (long arg_scid, long arg_quoteid, string arg_emp, ref string arg_msg, boolean arg_ifcommit)
  82. public function integer cancelaudit (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit)
  83. public function integer uof_audit_mx (long arg_scid, long arg_quoteid, long arg_printid, integer arg_flag, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
  84. public function integer uof_update_mx (long arg_scid, long arg_quoteid, long arg_printid, decimal arg_sumprice, decimal arg_sumprice_1, decimal arg_profit_margin, decimal arg_mtrlcost, decimal arg_mancost, decimal arg_outcost, decimal arg_wfjgprice, string arg_pfcode, s_quote_rqmtrl arg_rqmtrl, s_quote_workprice arg_workprice, ref string arg_msg, boolean arg_ifcommit)
  85. public function integer acceptmx (long arg_mtrlid, string arg_mtrlcode, string arg_mtrlname, string arg_mtrlmode, string arg_unit, string arg_mxdscrp, ref string arg_msg, long arg_printid, decimal arg_sumprice, decimal arg_sumprice_1, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_maxprice, decimal arg_planprice, decimal arg_profit_margin, decimal arg_wfjgprice, decimal arg_outcost, decimal arg_mancost, decimal arg_mtrlcost, decimal arg_qty, decimal arg_qty1, decimal arg_rebate, decimal arg_addqty, string arg_formula, string arg_dscrp_text)
  86. public function integer sec_audit (long arg_scid, long arg_quoteid, string arg_emp, ref string arg_msg, boolean arg_ifcommit)
  87. public function integer getinfo (long arg_scid, long arg_quoteid, ref string arg_msg)
  88. public function integer cancelsecaudit (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit)
  89. public function integer uof_stop_mx (long arg_scid, long arg_quoteid, long arg_printid, integer arg_flag, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
  90. public function integer acceptmx (long arg_mtrlid, string arg_mtrlcode, string arg_mtrlname, string arg_mtrlmode, string arg_unit, string arg_mxdscrp, ref string arg_msg, long arg_printid, decimal arg_sumprice, decimal arg_sumprice_1, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_maxprice, decimal arg_planprice, decimal arg_profit_margin, decimal arg_wfjgprice, decimal arg_outcost, decimal arg_mancost, decimal arg_mtrlcost, decimal arg_qty, decimal arg_qty1, decimal arg_rebate, decimal arg_addqty, string arg_formula, string arg_dscrp_text, string arg_mxdscrp2, string arg_mxdscrp3, readonly string arg_mxdscrp4, string arg_newunit)
  91. end prototypes
  92. public function integer p_reset ();//INT p_RESET()
  93. //清除对象及其明细
  94. //taskid=0
  95. //taskcode=''
  96. //operator=''
  97. //relcode = ''
  98. //status=0
  99. it_newbegin=FALSE
  100. it_updatebegin=FALSE
  101. //清除明细
  102. P_CLEARMX()
  103. RETURN 1
  104. end function
  105. public function integer p_clearmx ();//INT p_clearmx()
  106. //清除明细
  107. it_mxbt=0
  108. RETURN 1
  109. end function
  110. public function integer newbegin (long arg_scid, ref string arg_msg);//重置对象,设定业务类型与关联ID,准备建立新单
  111. //0 fail 1 success
  112. long rslt=1,CNT=0
  113. if arg_scid < 0 then
  114. arg_msg = '请选择分部'
  115. rslt = 0
  116. goto ext
  117. end if
  118. p_reset()
  119. it_newbegin=TRUE
  120. it_updatebegin=FALSE
  121. scid=arg_scid
  122. quoteid = 0
  123. ext:
  124. if rslt = 0 then p_reset()
  125. return rslt
  126. end function
  127. public function integer save (string arg_operator, ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1,cnt = 0,i
  128. DateTime server_dt
  129. Long ll_quoteid
  130. String ls_sccode
  131. IF IsNull(dscrp) THEN dscrp = ''
  132. IF IsNull(dscrp2) THEN dscrp2 = ''
  133. IF IsNull(assign_emp) THEN assign_emp = ''
  134. IF IsNull(arg_operator) THEN arg_operator = ''
  135. IF IsNull(sendUser) THEN sendUser = ''
  136. IF IsNull(fiebrelcode) THEN fiebrelcode = ''
  137. operator = arg_operator
  138. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  139. rslt = 0
  140. arG_MSG = "非编辑状态不可以提交"
  141. GOTO ext
  142. END IF
  143. IF Trim(assign_emp) = '' THEN
  144. rslt = 0
  145. arG_MSG = "请输入报价单经手人"
  146. GOTO ext
  147. END IF
  148. cnt = 0
  149. SELECT count(*) INTO :cnt
  150. FROM u_cust
  151. Where cusid = :custID USING commit_transaction;
  152. IF commit_transaction.SQLCode <> 0 THEN
  153. rslt = 0
  154. arG_MSG = "查询操作失败,客户资料"
  155. GOTO ext
  156. END IF
  157. IF cnt = 0 THEN
  158. rslt = 0
  159. arG_MSG = "客户未定义或错误"
  160. GOTO ext
  161. END IF
  162. SELECT Top 1 getdate() INTO :server_dt FROM u_user USING commit_transaction;
  163. //取得系统时间,借用操作员表
  164. IF commit_transaction.SQLCode <> 0 THEN
  165. rslt = 0
  166. arG_MSG = "查询操作失败,日期 "
  167. GOTO ext
  168. END IF
  169. IF f_check_inoutdate(0,quotedate,true,arG_MSG) = 0 THEN
  170. rslt = 0
  171. GOTO ext
  172. END IF
  173. IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
  174. rslt = 0
  175. arG_MSG = "没有正确报价单明细内容"
  176. GOTO ext
  177. END IF
  178. cnt = 0
  179. SELECT count(*) INTO :cnt
  180. FROM u_user
  181. Where username = :arg_operator USING commit_transaction ;
  182. IF commit_transaction.SQLCode <> 0 THEN
  183. rslt = 0
  184. arG_MSG = "查询操作失败,操作员!"
  185. GOTO ext
  186. END IF
  187. IF cnt = 0 THEN
  188. rslt = 0
  189. arG_MSG = "操作员姓名未登记或已取消!"
  190. GOTO ext
  191. END IF
  192. opdate = server_dt //填写单据建立时间(最近修改时间)
  193. ////////////////////////////////////////////////// //开始区分:新建/更新 处理
  194. IF quoteID = 0 THEN //新建
  195. ll_quoteid = f_sys_scidentity(scid,"u_quote","quoteID",arG_MSG,TRUE,commit_transaction) //数据commit事务)
  196. IF ll_quoteid <= 0 THEN
  197. rslt = 0
  198. GOTO ext
  199. END IF
  200. IF f_get_sccode(scid,commit_transaction,ls_sccode,arG_MSG) = 0 THEN
  201. rslt = 0
  202. GOTO ext
  203. END IF
  204. quoteCode = getid(scid,ls_sccode + 'BJ',Date(server_dt),FALSE,commit_transaction)
  205. IF quoteCode = "err" THEN
  206. quoteCode = ''
  207. rslt = 0
  208. arG_MSG = "无法获取报价单编号"+"~n"+commit_transaction.SQLErrText
  209. GOTO ext
  210. END IF
  211. INSERT INTO u_quote
  212. ( scid,
  213. quoteid,
  214. quoteCode,
  215. cusID,
  216. quotedate,
  217. Assign_Emp,
  218. relcode,
  219. flag,
  220. Dscrp,
  221. Dscrp2,
  222. opemp,
  223. opdate,
  224. fiebrelcode,
  225. billtype,
  226. moneyid
  227. )
  228. VALUES ( :scid,
  229. :ll_quoteid,
  230. :quoteCode,
  231. :custID,
  232. :quotedate,
  233. :Assign_Emp,
  234. :relcode,
  235. 0,
  236. :Dscrp,
  237. :Dscrp2,
  238. :operator,
  239. :server_dt,
  240. :fiebrelcode,
  241. :billtype,
  242. :moneyid) USING commit_transaction ;
  243. IF commit_transaction.SQLCode <> 0 THEN
  244. rslt = 0
  245. arG_MSG = "插入报价单操作失败"+"~n"+commit_transaction.SQLErrText
  246. GOTO ext
  247. END IF
  248. //读取新quoteid
  249. quoteID = ll_quoteid
  250. ELSE //////////////////////////////////////////////// //更新
  251. UPDATE u_quote
  252. SET cusID = :custID,
  253. quotedate = :quotedate,
  254. Assign_Emp = :Assign_Emp,
  255. Dscrp = :Dscrp,
  256. Dscrp2 = :Dscrp2,
  257. moddate = getdate(),
  258. Modemp = :publ_operator,
  259. relcode = :relcode,
  260. fiebrelcode = :fiebrelcode,
  261. billtype = :billtype,
  262. moneyid = :moneyid
  263. WHERE u_quote.quoteid = :quoteID
  264. AND scid = :scid
  265. AND flag = 0 USING commit_transaction;
  266. IF commit_transaction.SQLCode <> 0 OR sqlca.SQLNRows <= 0 THEN
  267. rslt = 0
  268. arG_MSG = "更新报价单操作失败"+"~n"+commit_transaction.SQLErrText
  269. GOTO ext
  270. END IF
  271. //删除原有明细
  272. DELETE FROM u_quotemx
  273. WHERE quoteID = :quoteID
  274. AND scid = :scid USING commit_transaction;
  275. IF commit_transaction.SQLCode <> 0 THEN
  276. rslt = 0
  277. arG_MSG = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  278. GOTO ext
  279. END IF
  280. DELETE FROM u_quoteMx_dscrp
  281. WHERE quoteID = :quoteID
  282. AND scid = :scid USING commit_transaction;
  283. IF commit_transaction.SQLCode <> 0 THEN
  284. rslt = 0
  285. arG_MSG = "删除明细备注操作失败"+"~n"+commit_transaction.SQLErrText
  286. GOTO ext
  287. END IF
  288. DELETE FROM u_quoterqmtrl
  289. WHERE quoteID = :quoteID
  290. AND scid = :scid USING commit_transaction;
  291. IF commit_transaction.SQLCode <> 0 THEN
  292. rslt = 0
  293. arG_MSG = "删除明细成本操作失败"+"~n"+commit_transaction.SQLErrText
  294. GOTO ext
  295. END IF
  296. DELETE FROM u_quoteworkprice
  297. WHERE quoteID = :quoteID
  298. AND scid = :scid USING commit_transaction;
  299. IF commit_transaction.SQLCode <> 0 THEN
  300. rslt = 0
  301. arG_MSG = "删除明细成本操作失败"+"~n"+commit_transaction.SQLErrText
  302. GOTO ext
  303. END IF
  304. END IF
  305. FOR i = 1 TO it_mxbt
  306. INSERT INTO u_quotemx
  307. ( scid,
  308. quoteid,
  309. mtrlid,
  310. printid,
  311. maxprice,
  312. planprice,
  313. mxdscrp,
  314. sumprice,
  315. sumprice_1,
  316. pfcode,
  317. status,
  318. woodcode,
  319. pcode,
  320. profit_margin,
  321. wfjgprice,
  322. outcost,
  323. mancost,
  324. mtrlcost,
  325. qty,
  326. rebate,
  327. addqty,
  328. formula,
  329. lastprice,
  330. mtrlcode,
  331. mtrlname,
  332. mtrlmode,
  333. unit,
  334. qty1,
  335. mxdscrp2,
  336. mxdscrp3,
  337. mxdscrp4,
  338. newunit)
  339. VALUES (:scid,
  340. :quoteID,
  341. :quotemx[i].mtrlid,
  342. :quotemx[i].printid,
  343. :quotemx[i].maxprice ,
  344. :quotemx[i].planprice ,
  345. :quotemx[i].mxdscrp,
  346. :quotemx[i].sumprice,
  347. :quotemx[i].sumprice_1,
  348. :quotemx[i].pfcode,
  349. :quotemx[i].status,
  350. :quotemx[i].woodcode,
  351. :quotemx[i].pcode,
  352. :quotemx[i].profit_margin,
  353. :quotemx[i].wfjgprice,
  354. :quotemx[i].outcost,
  355. :quotemx[i].mancost,
  356. :quotemx[i].mtrlcost,
  357. :quotemx[i].qty,
  358. :quotemx[i].rebate,
  359. :quotemx[i].addqty,
  360. :quotemx[i].formula,
  361. :quotemx[i].lastprice,
  362. :quotemx[i].mtrlcode,
  363. :quotemx[i].mtrlname,
  364. :quotemx[i].mtrlmode,
  365. :quotemx[i].unit,
  366. :quotemx[i].qty1,
  367. :quotemx[i].mxdscrp2,
  368. :quotemx[i].mxdscrp3,
  369. :quotemx[i].mxdscrp4,
  370. :quotemx[i].newunit) USING commit_transaction;
  371. IF commit_transaction.SQLCode <> 0 THEN
  372. if it_newbegin then quoteID = 0
  373. rslt = 0
  374. arG_MSG = "插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  375. GOTO ext
  376. END IF
  377. IF Len(Trim(quotemx[i].dscrp_text)) > 0 THEN
  378. INSERT INTO u_quotemx_dscrp
  379. (scid,
  380. quoteid,
  381. printid,
  382. dscrp)
  383. VALUES
  384. (:scid,
  385. :quoteID,
  386. :quotemx[i].printid,
  387. :quotemx[i].dscrp_text) Using commit_transaction;
  388. IF commit_transaction.SQLCode <> 0 THEN
  389. if it_newbegin then quoteID = 0 //还原quoteID
  390. rslt = 0
  391. arG_MSG = "插入明细备注操作失败"+"~n"+commit_transaction.SQLErrText
  392. GOTO ext
  393. END IF
  394. END IF
  395. NEXT
  396. it_newbegin = FALSE
  397. it_updatebegin = FALSE
  398. ext:
  399. IF rslt = 0 THEN
  400. p_clearmx()
  401. ROLLBACK USING commit_transaction;
  402. ELSEIF arg_ifcommit AND rslt = 1 THEN
  403. COMMIT USING commit_transaction;
  404. END IF
  405. Return(rslt)
  406. end function
  407. public function integer add_dscrp (long arg_scid, long arg_quoteid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit);//add_dscrp(string arg_newdescppart)
  408. //0 fail 1 SUCCESS
  409. Int rslt = 1
  410. arg_newdescppart = Trim(arg_newdescppart)
  411. IF it_updatebegin OR it_newbegin THEN
  412. rslt = 0
  413. arG_MSG = "编辑状态下不可用"
  414. GOTO ext
  415. END IF
  416. IF arg_newdescppart = '' THEN
  417. rslt = 0
  418. arG_MSG = "要添加内容为空,操作取消"
  419. GOTO ext
  420. END IF
  421. IF p_getinfo(arg_scid,arg_quoteid,arG_MSG) = 0 THEN
  422. rslt = 0
  423. GOTO ext
  424. END IF
  425. IF flag = 0 THEN
  426. rslt = 0
  427. arG_MSG = "待审核状态下不可用"
  428. GOTO ext
  429. END IF
  430. UPDATE u_quote
  431. SET DSCRP = DSCRP+' '+:arg_newdescppart
  432. Where u_quote.quoteid = :arg_quoteid USING commit_transaction;
  433. IF commit_transaction.SQLCode <> 0 THEN
  434. rslt = 0
  435. arG_MSG = "因网络或其它原因导致添加报价单备注操作失败"+"~n"+commit_transaction.SQLErrText
  436. ROLLBACK USING commit_transaction;
  437. GOTO ext
  438. END IF
  439. DSCRP = DSCRP+' '+arg_newdescppart
  440. it_newbegin = FALSE
  441. it_updatebegin = FALSE
  442. ext:
  443. IF arg_ifcommit AND rslt = 1 THEN
  444. COMMIT USING commit_transaction;
  445. END IF
  446. p_reset()
  447. Return (rslt)
  448. end function
  449. public function integer cancel (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit);//删除未审核的报价单
  450. //0 FAIL, 1 SUCCESS
  451. Int rslt = 1
  452. IF arg_quoteid <= 0 THEN
  453. rslt = 0
  454. ARG_MSG = '错误报价单唯一码'
  455. GOTO ext
  456. END IF
  457. IF p_getinfo(arg_scid,arg_quoteid,ARG_MSG) = 0 THEN
  458. rslt = 0
  459. GOTO ext
  460. END IF
  461. IF flag = 1 THEN
  462. rslt = 0
  463. ARG_MSG = "报价单已经审核,不可以删除"
  464. GOTO ext
  465. END IF
  466. DELETE FROM u_quoterqmtrl
  467. Where u_quoterqmtrl.quoteid = :arg_quoteid
  468. AND u_quoterqmtrl.scid = :arg_scid USING commit_transaction;
  469. IF commit_transaction.SQLCode <> 0 THEN
  470. rslt = 0
  471. ARG_MSG = "删除报价单用料明细操作失败"+"~n"+SQLCA.SQLErrText
  472. ROLLBACK USING commit_transaction;
  473. GOTO ext
  474. END IF
  475. DELETE FROM u_quotemx
  476. Where u_quotemx.quoteid = :arg_quoteid
  477. AND u_quotemx.scid = :arg_scid USING commit_transaction;
  478. IF commit_transaction.SQLCode <> 0 THEN
  479. rslt = 0
  480. ARG_MSG = "删除报价单明细操作失败"+"~n"+SQLCA.SQLErrText
  481. ROLLBACK USING commit_transaction;
  482. GOTO ext
  483. END IF
  484. DELETE FROM u_quote
  485. Where u_quote.quoteid = :arg_quoteid
  486. AND u_quote.scid = :arg_scid USING commit_transaction;
  487. IF commit_transaction.SQLCode <> 0 THEN
  488. rslt = 0
  489. ARG_MSG = "删除报价单操作失败"+"~n"+commit_transaction.SQLErrText
  490. ROLLBACK USING commit_transaction;
  491. GOTO ext
  492. END IF
  493. it_newbegin = FALSE
  494. it_updatebegin = FALSE
  495. IF arg_ifcommit THEN
  496. COMMIT USING commit_transaction;
  497. END IF
  498. ext:
  499. p_reset()
  500. Return (rslt)
  501. end function
  502. public function integer p_getinfo (long arg_scid, long arg_quoteid, ref string arg_msg);Int rslt = 1
  503. SELECT
  504. quotecode,
  505. cusid,
  506. quotedate,
  507. assign_emp,
  508. relcode,
  509. dscrp,
  510. opemp,
  511. opdate,
  512. flag,
  513. billtype
  514. INTO
  515. :quotecode,
  516. :custid,
  517. :quotedate,
  518. :assign_emp,
  519. :relcode,
  520. :dscrp,
  521. :operator,
  522. :opdate,
  523. :flag,
  524. :billtype
  525. FROM u_quote
  526. Where u_quote.quoteid = :arg_quoteid AND
  527. u_quote.scid = :arg_scid USING commit_transaction;
  528. IF commit_transaction.SQLCode <> 0 THEN
  529. rslt = 0
  530. ARG_MSG = '查询报价单内容失败(错误订单唯一码)'+sqlca.SQLErrText
  531. GOTO ext
  532. END IF
  533. scid = arg_scid
  534. quoteid = arg_quoteid
  535. ext:
  536. RETURN rslt
  537. end function
  538. public function integer updatebegin (long arg_scid, long arg_quoteid, ref string arg_msg);//UPDATEbegin(long arg_taskid,ref string arg_msg)
  539. //从置对象,设定业务类型与关联ID,准备更新单
  540. //0 fail 1 success
  541. long rslt=1,CNT=0
  542. if arg_scid < 0 then
  543. arg_msg = '请选择分部'
  544. rslt = 0
  545. goto ext
  546. end if
  547. IF arg_quoteid<=0 THEN
  548. rslt=0
  549. ARG_MSG='错误报价单唯一码'
  550. goto ext
  551. end if
  552. if p_getinfo(arg_scid,arg_quoteid,arg_msg)=0 then
  553. rslt=0
  554. goto ext
  555. end if
  556. if flag=1 then
  557. rslt=0
  558. ARG_MSG='已经处于审核状态,不可以修改,要修改请先撤销审核'
  559. goto ext
  560. end if
  561. it_newbegin=FALSE
  562. it_updatebegin=TRUE
  563. p_clearmx() //清除明细
  564. scid=arg_scid
  565. quoteid=arg_quoteid
  566. ext:
  567. if rslt=0 then p_reset()
  568. return rslt
  569. end function
  570. public function integer audit (long arg_scid, long arg_quoteid, string arg_emp, ref string arg_msg, boolean arg_ifcommit);
  571. Int rslt = 1,cnt = 0
  572. IF arg_quoteid <= 0 THEN
  573. rslt = 0
  574. ARG_MSG = '错误报价单唯一码'
  575. GOTO ext
  576. END IF
  577. IF p_getinfo(arg_scid,arg_quoteid,ARG_MSG) = 0 THEN
  578. rslt = 0
  579. GOTO ext
  580. END IF
  581. IF flag = 1 THEN
  582. rslt = 0
  583. ARG_MSG = "报价单已经审核,操作取消"
  584. GOTO ext
  585. END IF
  586. cnt = 0
  587. SELECT count(*) INTO :cnt
  588. FROM u_user
  589. Where username = :arg_emp USING commit_transaction;
  590. IF commit_transaction.SQLCode <> 0 THEN
  591. rslt = 0
  592. ARG_MSG = "查询操作失败,操作员!"
  593. GOTO ext
  594. END IF
  595. IF cnt = 0 THEN
  596. rslt = 0
  597. ARG_MSG = "操作员姓名未登记或已取消!"
  598. GOTO ext
  599. END IF
  600. //更新审核标记
  601. UPDATE u_quote
  602. SET auditingrep = :arg_emp,
  603. auditingdate = getdate(),
  604. flag = 4
  605. Where u_quote.quoteid = :arg_quoteid AND u_quote.scid = :arg_scid AND u_quote.flag = 0 USING commit_transaction;
  606. IF commit_transaction.SQLCode <> 0 THEN
  607. rslt = 0
  608. ARG_MSG = "单据审核操作失败"+"~n"+commit_transaction.SQLErrText
  609. GOTO ext
  610. END IF
  611. flag = 4
  612. it_newbegin = FALSE
  613. it_updatebegin = FALSE
  614. ext:
  615. IF rslt = 0 THEN
  616. ROLLBACK USING commit_transaction;
  617. ELSEIF arg_ifcommit THEN
  618. COMMIT USING commit_transaction;
  619. END IF
  620. p_reset()
  621. Return (rslt)
  622. end function
  623. public function integer cancelaudit (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1,cnt = 0
  624. DateTime ls_auditingdate
  625. SetNull(ls_auditingdate)
  626. IF arg_quoteid <= 0 THEN
  627. rslt = 0
  628. ARG_MSG = '错误报价单唯一码'
  629. GOTO ext
  630. END IF
  631. IF p_getinfo(arg_scid,arg_quoteid,ARG_MSG) = 0 THEN
  632. rslt = 0
  633. GOTO ext
  634. END IF
  635. IF flag = 0 THEN
  636. rslt = 0
  637. ARG_MSG = "报价只有在已审核状态才可以执行撤消审核,请核对"
  638. GOTO ext
  639. END IF
  640. UPDATE u_quote
  641. SET flag = 0,auditingrep = '',auditingdate = :ls_auditingdate
  642. Where u_quote.quoteid = :arg_quoteid AND u_quote.scid = :arg_scid
  643. AND u_quote.flag = 4 USING commit_transaction ;
  644. IF commit_transaction.SQLCode <> 0 THEN
  645. rslt = 0
  646. ARG_MSG = "报价单撤消审核操作失败"+"~n"+commit_transaction.SQLErrText
  647. GOTO ext
  648. END IF
  649. //删除旧有物料需求记录
  650. DELETE FROM u_quoterqmtrl
  651. WHERE u_quoterqmtrl.quoteid = :arg_quoteid
  652. AND u_quoterqmtrl.scid = :arg_scid;
  653. IF sqlca.SQLCode <> 0 THEN
  654. ROLLBACK;
  655. ARG_MSG = '删除旧有物料需求记录失败 '+sqlca.SQLErrText
  656. rslt = 0
  657. GOTO ext
  658. END IF
  659. it_newbegin = FALSE
  660. it_updatebegin = FALSE
  661. ext:
  662. IF rslt = 0 THEN
  663. ROLLBACK USING commit_transaction;
  664. ELSEIF arg_ifcommit THEN
  665. COMMIT USING commit_transaction;
  666. END IF
  667. p_reset()
  668. Return (rslt)
  669. end function
  670. public function integer uof_audit_mx (long arg_scid, long arg_quoteid, long arg_printid, integer arg_flag, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  671. Int li_flag
  672. DateTime null_dt
  673. SetNull(null_dt)
  674. SELECT flag INTO :li_flag
  675. FROM u_quote
  676. WHERE scid = :arg_scid
  677. AND quoteid = :arg_quoteid USING commit_transaction;
  678. IF commit_transaction.SQLCode <> 0 THEN
  679. arg_msg = '查询报价单审核标记失败,'+commit_transaction.SQLErrText
  680. rslt = 0
  681. GOTO ext
  682. END IF
  683. IF li_flag = 0 THEN
  684. IF arg_flag = 1 THEN
  685. arg_msg = '报价单还未审核,不能明细审核'
  686. ELSE
  687. arg_msg = '报价单还未审核,不能明细撤审'
  688. END IF
  689. rslt = 0
  690. GOTO ext
  691. END IF
  692. SELECT flag INTO :li_flag
  693. FROM u_quotemx
  694. WHERE scid = :arg_scid
  695. AND quoteid = :arg_quoteid
  696. AND printid = :arg_printid USING commit_transaction;
  697. IF commit_transaction.SQLCode <> 0 THEN
  698. arg_msg = '查询明细审核标记失败,'+commit_transaction.SQLErrText
  699. rslt = 0
  700. GOTO ext
  701. END IF
  702. IF arg_flag = 1 THEN
  703. IF li_flag = 1 THEN
  704. arg_msg = '明细已审核不能再审核'
  705. rslt = 0
  706. GOTO ext
  707. END IF
  708. ELSE
  709. IF li_flag = 0 THEN
  710. arg_msg = '明细还未审核不能撤审'
  711. rslt = 0
  712. GOTO ext
  713. END IF
  714. END IF
  715. IF arg_flag = 1 THEN
  716. UPDATE u_quotemx SET
  717. flag = 1,
  718. auditemp = :arg_opemp,
  719. auditdate = getdate()
  720. WHERE scid = :arg_scid
  721. AND quoteid = :arg_quoteid
  722. AND printid = :arg_printid USING commit_transaction;
  723. IF commit_transaction.SQLCode <> 0 THEN
  724. arg_msg = '审核明细失败,'+commit_transaction.SQLErrText
  725. rslt = 0
  726. GOTO ext
  727. END IF
  728. ELSE
  729. UPDATE u_quotemx SET
  730. flag = 0,
  731. auditemp = '',
  732. auditdate = :null_dt
  733. WHERE scid = :arg_scid
  734. AND quoteid = :arg_quoteid
  735. AND printid = :arg_printid USING commit_transaction;
  736. IF commit_transaction.SQLCode <> 0 THEN
  737. arg_msg = '审核明细失败,'+commit_transaction.SQLErrText
  738. rslt = 0
  739. GOTO ext
  740. END IF
  741. END IF
  742. ext:
  743. IF rslt = 0 THEN
  744. ROLLBACK USING commit_transaction;
  745. ELSEIF rslt = 1 AND arg_ifcommit THEN
  746. COMMIT USING commit_transaction;
  747. END IF
  748. RETURN rslt
  749. end function
  750. public function integer uof_update_mx (long arg_scid, long arg_quoteid, long arg_printid, decimal arg_sumprice, decimal arg_sumprice_1, decimal arg_profit_margin, decimal arg_mtrlcost, decimal arg_mancost, decimal arg_outcost, decimal arg_wfjgprice, string arg_pfcode, s_quote_rqmtrl arg_rqmtrl, s_quote_workprice arg_workprice, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  751. Int li_flag
  752. Long cnt,ll_mtrlid,ll_i
  753. SELECT flag,mtrlid INTO :li_flag,:ll_mtrlid
  754. FROM u_quotemx
  755. WHERE scid = :arg_scid
  756. AND quoteid = :arg_quoteid
  757. AND printid = :arg_printid USING commit_transaction;
  758. IF commit_transaction.SQLCode <> 0 THEN
  759. arg_msg = '查询明细审核标记失败,'+commit_transaction.SQLErrText
  760. rslt = 0
  761. GOTO ext
  762. END IF
  763. IF li_flag = 1 THEN
  764. arg_msg = '明细已审核不能修改'
  765. rslt = 0
  766. GOTO ext
  767. END IF
  768. //SELECT count(*) INTO :cnt
  769. // FROM u_mtrl_pf
  770. // WHERE mtrlid = :ll_mtrlid
  771. // AND pfcode = :arg_pfcode USING commit_transaction;
  772. //IF commit_transaction.SQLCode <> 0 THEN
  773. // arg_msg = '查询明细物料清单资料失败,'+commit_transaction.SQLErrText
  774. // rslt = 0
  775. // GOTO ext
  776. //END IF
  777. //
  778. //IF cnt = 0 THEN
  779. // arg_msg = '明细物料不存在清单:'+arg_pfcode
  780. // rslt = 0
  781. // GOTO ext
  782. //END IF
  783. DELETE FROM u_quoterqmtrl
  784. WHERE scid = :arg_scid
  785. AND quoteid = :arg_quoteid
  786. and printid = :arg_printid USING commit_transaction;
  787. IF commit_transaction.SQLCode <> 0 THEN
  788. arg_msg = '删除报价明细物料成本明细失败,'+commit_transaction.SQLErrText
  789. rslt = 0
  790. GOTO ext
  791. END IF
  792. IF UpperBound(arg_rqmtrl.mtrlid) > 0 THEN
  793. FOR ll_i = 1 TO UpperBound(arg_rqmtrl.mtrlid)
  794. INSERT INTO u_quoterqmtrl
  795. (scid,
  796. quoteid,
  797. printid,
  798. pid,
  799. MtrlID,
  800. RqQty,
  801. newprice,
  802. planprice,
  803. lp,
  804. pmtrlid,
  805. costprice)
  806. VALUES
  807. (:arg_scid,
  808. :arg_quoteid,
  809. :arg_printid,
  810. :arg_rqmtrl.printid[ll_i],
  811. :arg_rqmtrl.mtrlid[ll_i],
  812. :arg_rqmtrl.RqQty[ll_i],
  813. :arg_rqmtrl.newprice[ll_i],
  814. :arg_rqmtrl.planprice[ll_i],
  815. :arg_rqmtrl.lp[ll_i],
  816. :arg_rqmtrl.pmtrlid[ll_i],
  817. :arg_rqmtrl.costprice[ll_i]) USING commit_transaction;
  818. IF commit_transaction.SQLCode <> 0 THEN
  819. arg_msg = '建立报价明细物料成本明细失败,'+commit_transaction.SQLErrText
  820. rslt = 0
  821. GOTO ext
  822. END IF
  823. NEXT
  824. END IF
  825. DELETE FROM u_quoteworkprice
  826. WHERE scid = :arg_scid
  827. AND quoteid = :arg_quoteid
  828. and printid = :arg_printid USING commit_transaction;
  829. IF commit_transaction.SQLCode <> 0 THEN
  830. arg_msg = '删除报价明细工价信息明细失败,'+commit_transaction.SQLErrText
  831. rslt = 0
  832. GOTO ext
  833. END IF
  834. IF UpperBound(arg_workprice.mtrlid) > 0 THEN
  835. FOR ll_i = 1 TO UpperBound(arg_workprice.mtrlid)
  836. INSERT INTO u_quoteworkprice
  837. (scid,
  838. quoteid,
  839. printid,
  840. pid,
  841. MtrlID,
  842. proid,
  843. proorder,
  844. procode,
  845. proname,
  846. wrkgrpid,
  847. workprice,
  848. workqty,
  849. dscrp,
  850. cost)
  851. VALUES
  852. (:arg_scid,
  853. :arg_quoteid,
  854. :arg_printid,
  855. :arg_workprice.pid[ll_i],
  856. :arg_workprice.mtrlid[ll_i],
  857. :arg_workprice.proid[ll_i],
  858. :arg_workprice.proorder[ll_i],
  859. :arg_workprice.procode[ll_i],
  860. :arg_workprice.proname[ll_i],
  861. :arg_workprice.wrkgrpid[ll_i],
  862. :arg_workprice.workprice[ll_i],
  863. :arg_workprice.workqty[ll_i],
  864. :arg_workprice.dscrp[ll_i],
  865. :arg_workprice.cost[ll_i]) USING commit_transaction;
  866. IF commit_transaction.SQLCode <> 0 THEN
  867. arg_msg = '建立报价明细工价信息明细失败,'+commit_transaction.SQLErrText
  868. rslt = 0
  869. GOTO ext
  870. END IF
  871. NEXT
  872. END IF
  873. UPDATE u_quotemx SET
  874. sumprice = :arg_sumprice,
  875. sumprice_1 = :arg_sumprice_1,
  876. profit_margin = :arg_profit_margin,
  877. mtrlcost = :arg_mtrlcost,
  878. mancost = :arg_mancost,
  879. outcost = :arg_outcost,
  880. wfjgprice = :arg_wfjgprice,
  881. pfcode = :arg_pfcode
  882. WHERE scid = :arg_scid
  883. AND quoteid = :arg_quoteid
  884. AND printid = :arg_printid USING commit_transaction;
  885. IF commit_transaction.SQLCode <> 0 THEN
  886. arg_msg = '更新明细资料失败,'+commit_transaction.SQLErrText
  887. rslt = 0
  888. GOTO ext
  889. END IF
  890. ext:
  891. IF rslt = 0 THEN
  892. ROLLBACK USING commit_transaction;
  893. ELSEIF rslt = 1 AND arg_ifcommit THEN
  894. COMMIT USING commit_transaction;
  895. END IF
  896. RETURN rslt
  897. end function
  898. public function integer acceptmx (long arg_mtrlid, string arg_mtrlcode, string arg_mtrlname, string arg_mtrlmode, string arg_unit, string arg_mxdscrp, ref string arg_msg, long arg_printid, decimal arg_sumprice, decimal arg_sumprice_1, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_maxprice, decimal arg_planprice, decimal arg_profit_margin, decimal arg_wfjgprice, decimal arg_outcost, decimal arg_mancost, decimal arg_mtrlcost, decimal arg_qty, decimal arg_qty1, decimal arg_rebate, decimal arg_addqty, string arg_formula, string arg_dscrp_text);Long rslt = 1,cnt = 0,i
  899. Decimal ld_newprice,ld_planprice
  900. String ls_pfcode
  901. Decimal ld_lastprice
  902. IF it_newbegin = False And it_updatebegin = False THEN
  903. rslt = 0
  904. arg_msg = "非编辑状态不可以使用,操作取消"
  905. GOTO ext
  906. END IF
  907. //清除空值
  908. IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
  909. IF IsNull(arg_mtrlcode) THEN arg_mtrlcode = ''
  910. IF IsNull(arg_mtrlname) THEN arg_mtrlname = ''
  911. IF IsNull(arg_mtrlmode) THEN arg_mtrlmode = ''
  912. IF IsNull(arg_unit) THEN arg_unit = ''
  913. IF IsNull(arg_sumprice) THEN arg_sumprice = 0
  914. IF IsNull(arg_sumprice_1) THEN arg_sumprice_1 = 0
  915. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  916. IF IsNull(arg_printid) THEN arg_printid = 0
  917. IF IsNull(arg_status) THEN arg_status = ''
  918. IF IsNull(arg_woodcode) THEN arg_woodcode = ''
  919. IF IsNull(arg_pcode) THEN arg_pcode = ''
  920. IF IsNull(arg_qty) THEN arg_qty = 0
  921. IF IsNull(arg_qty1) THEN arg_qty1 = 0
  922. IF IsNull(arg_rebate) THEN arg_rebate = 1
  923. IF IsNull(arg_addqty) THEN arg_addqty = 0
  924. IF IsNull(arg_formula) THEN arg_formula = ''
  925. IF IsNull(arg_dscrp_text) THEN arg_dscrp_text = ''
  926. IF billtype = 0 THEN
  927. IF arg_mtrlid = 0 THEN // 如果物料编号为空,则不作任何处理
  928. rslt = 1
  929. GOTO ext
  930. END IF
  931. END IF
  932. IF arg_printid = 0 THEN // 如果序号为空,则不作任何处理
  933. rslt = 1
  934. GOTO ext
  935. END IF
  936. IF billtype = 0 or arg_mtrlid > 0 THEN
  937. SELECT planprice
  938. INTO :ld_planprice
  939. FROM u_mtrldef
  940. Where u_mtrldef.mtrlid = :arg_mtrlid ;
  941. IF sqlca.SQLCode <> 0 THEN
  942. rslt = 0
  943. arg_msg = "查询物料:"+arg_mtrlcode+'计划价失败'
  944. GOTO ext
  945. END IF
  946. SELECT price
  947. INTO :ld_newprice
  948. FROM v_maxprice_cusprice
  949. Where mtrlid = :arg_mtrlid;
  950. IF sqlca.SQLCode <> 0 Or IsNull(ld_newprice) THEN ld_newprice = 0
  951. SELECT top 1 u_quotemx.sumprice_1
  952. INTO :ld_lastprice
  953. FROM u_quotemx,u_quote
  954. WHERE u_quotemx.quoteid = u_quote.quoteid AND
  955. u_quotemx.status = :arg_status AND
  956. u_quotemx.woodcode = :arg_woodcode AND
  957. u_quotemx.pcode = :arg_pcode AND
  958. u_quote.cusid = :custID AND
  959. u_quote.flag = 1
  960. Order By u_quote.quotedate Desc;
  961. IF sqlca.SQLCode <> 0 Or IsNull(ld_lastprice) THEN ld_lastprice = 0
  962. ls_pfcode = f_get_dft_pf(arg_mtrlid)
  963. END IF
  964. FOR i = 1 To it_mxbt //合并重复项(产品)
  965. IF quotemx[i].mtrlid = arg_mtrlid And &
  966. quotemx[i].mtrlcode = arg_mtrlcode And &
  967. quotemx[i].status = arg_status And &
  968. quotemx[i].woodcode = arg_woodcode And &
  969. quotemx[i].pcode = arg_pcode And &
  970. quotemx[i].qty = arg_qty And &
  971. quotemx[i].qty1 = arg_qty1 THEN
  972. rslt = 0
  973. arg_msg = "存在相同的产品,在"+quotemx[i].mtrlcode+",请自行手动合并"
  974. GOTO ext
  975. END IF
  976. NEXT
  977. //写入内容
  978. it_mxbt++
  979. quotemx[it_mxbt].mtrlid = arg_mtrlid
  980. quotemx[it_mxbt].mtrlcode = arg_mtrlcode
  981. quotemx[it_mxbt].mtrlname = arg_mtrlname
  982. quotemx[it_mxbt].mtrlmode = arg_mtrlmode
  983. quotemx[it_mxbt].unit = arg_unit
  984. quotemx[it_mxbt].maxprice = ld_newprice
  985. quotemx[it_mxbt].planprice = ld_planprice
  986. quotemx[it_mxbt].mxdscrp = arg_mxdscrp
  987. quotemx[it_mxbt].printid = arg_printid
  988. quotemx[it_mxbt].sumprice = arg_sumprice
  989. quotemx[it_mxbt].sumprice_1 = arg_sumprice_1
  990. quotemx[it_mxbt].pfcode = ls_pfcode
  991. quotemx[it_mxbt].status = arg_status
  992. quotemx[it_mxbt].woodcode = arg_woodcode
  993. quotemx[it_mxbt].pcode = arg_pcode
  994. quotemx[it_mxbt].maxprice = arg_maxprice
  995. quotemx[it_mxbt].planprice = arg_planprice
  996. quotemx[it_mxbt].profit_margin = arg_profit_margin
  997. quotemx[it_mxbt].wfjgprice = arg_wfjgprice
  998. quotemx[it_mxbt].outcost = arg_outcost
  999. quotemx[it_mxbt].mancost = arg_mancost
  1000. quotemx[it_mxbt].mtrlcost = arg_mtrlcost
  1001. quotemx[it_mxbt].qty = arg_qty
  1002. quotemx[it_mxbt].qty1 = arg_qty1
  1003. quotemx[it_mxbt].rebate = arg_rebate
  1004. quotemx[it_mxbt].addqty = arg_addqty
  1005. quotemx[it_mxbt].formula = arg_formula
  1006. quotemx[it_mxbt].lastprice = ld_lastprice
  1007. quotemx[it_mxbt].dscrp_text = arg_dscrp_text
  1008. ext:
  1009. IF rslt = 0 THEN p_clearmx()
  1010. Return(rslt)
  1011. end function
  1012. public function integer sec_audit (long arg_scid, long arg_quoteid, string arg_emp, ref string arg_msg, boolean arg_ifcommit);
  1013. Int rslt = 1,cnt = 0
  1014. Long i
  1015. uo_cusprice uo_update_cusprice
  1016. uo_update_cusprice = CREATE uo_cusprice
  1017. IF arg_quoteid <= 0 THEN
  1018. rslt = 0
  1019. ARG_MSG = '错误报价单唯一码'
  1020. GOTO ext
  1021. END IF
  1022. //IF uo_option_if_oa_quote = 1 And uo_option_quote_secaudit = 1 and audit_buildtype = 0 THEN
  1023. // IF f_check_if_oaflow(arg_scid,arg_quoteid,461,ARG_MSG ) = 0 THEN
  1024. // rslt = 0
  1025. // GOTO ext
  1026. // END IF
  1027. //END IF
  1028. IF getinfo(arg_scid,arg_quoteid,ARG_MSG) = 0 THEN
  1029. rslt = 0
  1030. GOTO ext
  1031. END IF
  1032. IF flag <> 4 THEN
  1033. rslt = 0
  1034. ARG_MSG = "销售报价单不是在待终审状态,不能执行终审"
  1035. GOTO ext
  1036. END IF
  1037. cnt = 0
  1038. SELECT count(*) INTO :cnt
  1039. FROM u_user
  1040. Where username = :arg_emp USING commit_transaction;
  1041. IF commit_transaction.SQLCode <> 0 THEN
  1042. rslt = 0
  1043. ARG_MSG = "查询操作失败,操作员!"
  1044. GOTO ext
  1045. END IF
  1046. IF cnt = 0 THEN
  1047. rslt = 0
  1048. ARG_MSG = "操作员姓名未登记或已取消!"
  1049. GOTO ext
  1050. END IF
  1051. //if billtype = 0 then
  1052. // FOR i = 1 TO it_mxbt
  1053. // IF quotemx[i].sumprice_1 <= 0 THEN
  1054. // rslt = 0
  1055. // ARG_MSG = '第'+String(i)+'行,请输入客户还价'
  1056. // GOTO ext
  1057. // END IF
  1058. //
  1059. // IF uo_update_cusprice.uof_update_custprice(0,0,custID,&
  1060. // quotemx[i].mtrlid,quotemx[i].mtrlcode,quotemx[i].status,&
  1061. // quotemx[i].woodcode,quotemx[i].pcode,&
  1062. // quoteID,quoteCode,quotedate,quotemx[i].sumprice_1,&
  1063. // quotemx[i].rebate,quotemx[i].sumprice_1 * quotemx[i].rebate * quotemx[i].qty,2,'',&
  1064. // quotemx[i].printid,2,moneyid,quotemx[i].qty,quotemx[i].qty1,FALSE,ARG_MSG) = 0 THEN
  1065. // rslt = 0
  1066. // GOTO ext
  1067. // END IF
  1068. // NEXT
  1069. //end if
  1070. //更新审核标记
  1071. UPDATE u_quote
  1072. SET sec_auditemp = :arg_emp,
  1073. sec_auditdate = getdate(),
  1074. flag = 1
  1075. Where u_quote.quoteID = :arg_quoteid
  1076. AND u_quote.scid = :arg_scid
  1077. AND u_quote.flag = 4
  1078. USING commit_transaction;
  1079. IF commit_transaction.SQLCode <> 0 THEN
  1080. rslt = 0
  1081. ARG_MSG = "因网络或其它原因导致单据审核操作失败"+"~n"+commit_transaction.SQLErrText
  1082. GOTO ext
  1083. END IF
  1084. it_newbegin = FALSE
  1085. it_updatebegin = FALSE
  1086. ext:
  1087. IF rslt = 0 THEN
  1088. ROLLBACK USING commit_transaction;
  1089. ELSEIF arg_ifcommit THEN
  1090. COMMIT USING commit_transaction;
  1091. END IF
  1092. p_reset()
  1093. Return (rslt)
  1094. end function
  1095. public function integer getinfo (long arg_scid, long arg_quoteid, ref string arg_msg);Int rslt = 1
  1096. Long i = 1
  1097. Long no_mxcheck
  1098. IF arg_quoteid <= 0 THEN
  1099. rslt = 0
  1100. arg_msg = "非法销售报价单唯一码"
  1101. GOTO ext
  1102. END IF
  1103. rslt = p_getinfo(arg_scid,arg_quoteid,arg_msg)
  1104. IF rslt = 0 THEN GOTO ext
  1105. DECLARE cur_quotemx CURSOR FOR
  1106. SELECT u_quotemx.printid,
  1107. u_quotemx.mtrlid,
  1108. u_quotemx.sumprice,
  1109. u_quotemx.sumprice_1,
  1110. u_quotemx.qty,
  1111. u_quotemx.qty1,
  1112. u_quotemx.mxDscrp,
  1113. u_quotemx.status,
  1114. u_quotemx.woodcode,
  1115. u_quotemx.pcode,
  1116. u_quotemx.rebate,
  1117. u_quotemx.mtrlcode,
  1118. u_quotemx.mtrlname,
  1119. u_quotemx.mtrlmode,
  1120. u_quotemx.unit
  1121. FROM u_quotemx
  1122. WHERE u_quotemx.scid = :arg_scid
  1123. AND u_quotemx.quoteid = :arg_quoteid USING commit_transaction;
  1124. OPEN cur_quotemx;
  1125. FETCH cur_quotemx INTO :quotemx[i].printid,:quotemx[i].mtrlid,
  1126. :quotemx[i].sumprice,:quotemx[i].sumprice_1,:quotemx[i].qty,:quotemx[i].qty1,:quotemx[i].mxdscrp,
  1127. :quotemx[i].status,:quotemx[i].woodcode,:quotemx[i].pcode,:quotemx[i].rebate,:quotemx[i].mtrlcode,
  1128. :quotemx[i].mtrlname,
  1129. :quotemx[i].mtrlmode,
  1130. :quotemx[i].unit;
  1131. DO WHILE commit_transaction.SQLCode = 0
  1132. i++
  1133. FETCH cur_quotemx INTO :quotemx[i].printid,:quotemx[i].mtrlid,
  1134. :quotemx[i].sumprice,:quotemx[i].sumprice_1,:quotemx[i].qty,:quotemx[i].qty1,:quotemx[i].mxdscrp,
  1135. :quotemx[i].status,:quotemx[i].woodcode,:quotemx[i].pcode,:quotemx[i].rebate,:quotemx[i].mtrlcode,
  1136. :quotemx[i].mtrlname,
  1137. :quotemx[i].mtrlmode,
  1138. :quotemx[i].unit;
  1139. LOOP
  1140. close cur_quotemx;
  1141. SELECT count(*) INTO :no_mxcheck
  1142. FROM u_quotemx
  1143. WHERE quoteid = :arg_quoteid
  1144. AND scid = :arg_scid USING commit_transaction;
  1145. IF commit_transaction.SQLCode <> 0 THEN
  1146. rslt = 0
  1147. arg_msg = "查询操作失败,报价单明细数量"
  1148. GOTO ext
  1149. END IF
  1150. IF i <> (no_mxcheck+1) THEN
  1151. rslt = 0
  1152. arg_msg = "查询操作失败,进仓单明细"
  1153. GOTO ext
  1154. END IF
  1155. it_mxbt = i - 1
  1156. it_newbegin = FALSE
  1157. it_updatebegin = FALSE
  1158. ext:
  1159. IF rslt = 0 THEN p_reset()
  1160. RETURN rslt
  1161. end function
  1162. public function integer cancelsecaudit (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1,cnt = 0
  1163. Long i
  1164. DateTime ls_auditingdate
  1165. SetNull(ls_auditingdate)
  1166. uo_cusprice uo_update_cusprice
  1167. uo_update_cusprice = Create uo_cusprice
  1168. IF arg_quoteid <= 0 THEN
  1169. rslt = 0
  1170. ARG_MSG = '错误报价单唯一码'
  1171. GOTO ext
  1172. END IF
  1173. IF getinfo(arg_scid,arg_quoteid,ARG_MSG) = 0 THEN
  1174. rslt = 0
  1175. GOTO ext
  1176. END IF
  1177. IF flag <> 1 THEN
  1178. rslt = 0
  1179. ARG_MSG = "报价只有在已审核状态才可以执行撤销终审,请核对"
  1180. GOTO ext
  1181. END IF
  1182. UPDATE u_quote
  1183. SET flag = 4,
  1184. sec_auditemp = '',
  1185. sec_auditdate = :ls_auditingdate
  1186. WHERE u_quote.quoteid = :arg_quoteid
  1187. AND u_quote.scid = :arg_scid
  1188. AND u_quote.flag = 1
  1189. Using commit_transaction ;
  1190. IF commit_transaction.SQLCode <> 0 THEN
  1191. rslt = 0
  1192. ARG_MSG = "因网络或其它原因导致报价单撤消审核操作失败"+"~n"+commit_transaction.SQLErrText
  1193. GOTO ext
  1194. END IF
  1195. //删除旧有物料需求记录
  1196. DELETE FROM u_quoterqmtrl
  1197. WHERE u_quoterqmtrl.quoteid = :arg_quoteid
  1198. And u_quoterqmtrl.scid = :arg_scid;
  1199. IF sqlca.SQLCode <> 0 THEN
  1200. ROLLBACK;
  1201. ARG_MSG = '删除旧有物料需求记录失败 '+sqlca.SQLErrText
  1202. rslt = 0
  1203. GOTO ext
  1204. END IF
  1205. //IF billtype = 0 THEN
  1206. // FOR i = 1 To it_mxbt
  1207. // IF uo_update_cusprice.uof_del_cusprice_auto(custid,quoteid,&
  1208. // quotemx[i].printid,quotemx[i].mtrlid,quotemx[i].status,&
  1209. // quotemx[i].woodcode,quotemx[i].pcode,&
  1210. // 2,moneyid,quotemx[i].qty,quotemx[i].qty1,False,ARG_MSG) = 0 THEN
  1211. // rslt = 0
  1212. // GOTO ext
  1213. // END IF
  1214. // NEXT
  1215. //END IF
  1216. it_newbegin = False
  1217. it_updatebegin = False
  1218. ext:
  1219. IF rslt = 0 THEN
  1220. ROLLBACK Using commit_transaction;
  1221. ELSEIF arg_ifcommit THEN
  1222. COMMIT Using commit_transaction;
  1223. END IF
  1224. Destroy uo_update_cusprice
  1225. p_reset()
  1226. Return (rslt)
  1227. end function
  1228. public function integer uof_stop_mx (long arg_scid, long arg_quoteid, long arg_printid, integer arg_flag, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  1229. Int li_bill_flag,li_mx_flag,li_mx_stopflag
  1230. DateTime null_dt
  1231. SetNull(null_dt)
  1232. SELECT flag INTO :li_bill_flag
  1233. FROM u_quote
  1234. WHERE scid = :arg_scid
  1235. And quoteid = :arg_quoteid Using commit_transaction;
  1236. IF commit_transaction.SQLCode <> 0 THEN
  1237. arg_msg = '查询报价单审核标记失败,'+commit_transaction.SQLErrText
  1238. rslt = 0
  1239. GOTO ext
  1240. END IF
  1241. IF li_bill_flag = 0 THEN
  1242. IF arg_flag = 1 THEN
  1243. arg_msg = '报价单还未审核,不能明细终止'
  1244. ELSE
  1245. arg_msg = '报价单还未审核,不能明细终止'
  1246. END IF
  1247. rslt = 0
  1248. GOTO ext
  1249. END IF
  1250. SELECT flag,stopflag INTO :li_mx_flag,:li_mx_stopflag
  1251. FROM u_quotemx
  1252. WHERE scid = :arg_scid
  1253. AND quoteid = :arg_quoteid
  1254. And printid = :arg_printid Using commit_transaction;
  1255. IF commit_transaction.SQLCode <> 0 THEN
  1256. arg_msg = '查询明细审核标记失败,'+commit_transaction.SQLErrText
  1257. rslt = 0
  1258. GOTO ext
  1259. END IF
  1260. IF li_mx_flag = 0 THEN
  1261. arg_msg = '明细未审核,不能终止操作'
  1262. rslt = 0
  1263. GOTO ext
  1264. END IF
  1265. IF arg_flag = 1 THEN
  1266. IF li_mx_stopflag = 1 THEN
  1267. arg_msg = '明细已终止不能再终止'
  1268. rslt = 0
  1269. GOTO ext
  1270. END IF
  1271. UPDATE u_quotemx SET
  1272. stopflag = 1,
  1273. stopemp = :arg_opemp,
  1274. stopdate = getdate()
  1275. WHERE scid = :arg_scid
  1276. AND quoteid = :arg_quoteid
  1277. And printid = :arg_printid Using commit_transaction;
  1278. IF commit_transaction.SQLCode <> 0 THEN
  1279. arg_msg = '终止明细失败,'+commit_transaction.SQLErrText
  1280. rslt = 0
  1281. GOTO ext
  1282. END IF
  1283. ELSE
  1284. IF li_mx_stopflag = 0 THEN
  1285. arg_msg = '明细还未终止不能取消终止操作'
  1286. rslt = 0
  1287. GOTO ext
  1288. END IF
  1289. UPDATE u_quotemx SET
  1290. stopflag = 0,
  1291. stopemp = '',
  1292. stopdate = :null_dt
  1293. WHERE scid = :arg_scid
  1294. AND quoteid = :arg_quoteid
  1295. And printid = :arg_printid Using commit_transaction;
  1296. IF commit_transaction.SQLCode <> 0 THEN
  1297. arg_msg = '取消终止明细失败,'+commit_transaction.SQLErrText
  1298. rslt = 0
  1299. GOTO ext
  1300. END IF
  1301. END IF
  1302. ext:
  1303. IF rslt = 0 THEN
  1304. ROLLBACK Using commit_transaction;
  1305. ELSEIF rslt = 1 And arg_ifcommit THEN
  1306. COMMIT Using commit_transaction;
  1307. END IF
  1308. RETURN rslt
  1309. end function
  1310. public function integer acceptmx (long arg_mtrlid, string arg_mtrlcode, string arg_mtrlname, string arg_mtrlmode, string arg_unit, string arg_mxdscrp, ref string arg_msg, long arg_printid, decimal arg_sumprice, decimal arg_sumprice_1, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_maxprice, decimal arg_planprice, decimal arg_profit_margin, decimal arg_wfjgprice, decimal arg_outcost, decimal arg_mancost, decimal arg_mtrlcost, decimal arg_qty, decimal arg_qty1, decimal arg_rebate, decimal arg_addqty, string arg_formula, string arg_dscrp_text, string arg_mxdscrp2, string arg_mxdscrp3, readonly string arg_mxdscrp4, string arg_newunit);Long rslt = 1,cnt = 0,i
  1311. Decimal ld_newprice,ld_planprice
  1312. String ls_pfcode
  1313. Decimal ld_lastprice
  1314. IF it_newbegin = False And it_updatebegin = False THEN
  1315. rslt = 0
  1316. arg_msg = "非编辑状态不可以使用,操作取消"
  1317. GOTO ext
  1318. END IF
  1319. //清除空值
  1320. IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
  1321. IF IsNull(arg_mtrlcode) THEN arg_mtrlcode = ''
  1322. IF IsNull(arg_mtrlname) THEN arg_mtrlname = ''
  1323. IF IsNull(arg_mtrlmode) THEN arg_mtrlmode = ''
  1324. IF IsNull(arg_unit) THEN arg_unit = ''
  1325. IF IsNull(arg_sumprice) THEN arg_sumprice = 0
  1326. IF IsNull(arg_sumprice_1) THEN arg_sumprice_1 = 0
  1327. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  1328. IF IsNull(arg_printid) THEN arg_printid = 0
  1329. IF IsNull(arg_status) THEN arg_status = ''
  1330. IF IsNull(arg_woodcode) THEN arg_woodcode = ''
  1331. IF IsNull(arg_pcode) THEN arg_pcode = ''
  1332. IF IsNull(arg_qty) THEN arg_qty = 0
  1333. IF IsNull(arg_qty1) THEN arg_qty1 = 0
  1334. IF IsNull(arg_rebate) THEN arg_rebate = 1
  1335. IF IsNull(arg_addqty) THEN arg_addqty = 0
  1336. IF IsNull(arg_formula) THEN arg_formula = ''
  1337. IF IsNull(arg_dscrp_text) THEN arg_dscrp_text = ''
  1338. IF IsNull(arg_newunit) THEN arg_newunit = ''
  1339. IF billtype = 0 THEN
  1340. IF arg_mtrlid = 0 THEN // 如果物料编号为空,则不作任何处理
  1341. rslt = 1
  1342. GOTO ext
  1343. END IF
  1344. END IF
  1345. IF arg_printid = 0 THEN // 如果序号为空,则不作任何处理
  1346. rslt = 1
  1347. GOTO ext
  1348. END IF
  1349. IF billtype = 0 or arg_mtrlid > 0 THEN
  1350. SELECT planprice
  1351. INTO :ld_planprice
  1352. FROM u_mtrldef
  1353. Where u_mtrldef.mtrlid = :arg_mtrlid ;
  1354. IF sqlca.SQLCode <> 0 THEN
  1355. rslt = 0
  1356. arg_msg = "查询物料:"+arg_mtrlcode+'计划价失败'
  1357. GOTO ext
  1358. END IF
  1359. SELECT price
  1360. INTO :ld_newprice
  1361. FROM v_maxprice_cusprice
  1362. Where mtrlid = :arg_mtrlid;
  1363. IF sqlca.SQLCode <> 0 Or IsNull(ld_newprice) THEN ld_newprice = 0
  1364. SELECT top 1 u_quotemx.sumprice_1
  1365. INTO :ld_lastprice
  1366. FROM u_quotemx,u_quote
  1367. WHERE u_quotemx.quoteid = u_quote.quoteid AND
  1368. u_quotemx.status = :arg_status AND
  1369. u_quotemx.woodcode = :arg_woodcode AND
  1370. u_quotemx.pcode = :arg_pcode AND
  1371. u_quote.cusid = :custID AND
  1372. u_quote.flag = 1
  1373. Order By u_quote.quotedate Desc;
  1374. IF sqlca.SQLCode <> 0 Or IsNull(ld_lastprice) THEN ld_lastprice = 0
  1375. ls_pfcode = f_get_dft_pf(arg_mtrlid)
  1376. END IF
  1377. FOR i = 1 To it_mxbt //合并重复项(产品)
  1378. IF quotemx[i].mtrlid = arg_mtrlid And &
  1379. quotemx[i].mtrlcode = arg_mtrlcode And &
  1380. quotemx[i].status = arg_status And &
  1381. quotemx[i].woodcode = arg_woodcode And &
  1382. quotemx[i].pcode = arg_pcode And &
  1383. quotemx[i].qty = arg_qty And &
  1384. quotemx[i].qty1 = arg_qty1 THEN
  1385. rslt = 0
  1386. arg_msg = "存在相同的产品,在"+quotemx[i].mtrlcode+",请自行手动合并"
  1387. GOTO ext
  1388. END IF
  1389. NEXT
  1390. //写入内容
  1391. it_mxbt++
  1392. quotemx[it_mxbt].mtrlid = arg_mtrlid
  1393. quotemx[it_mxbt].mtrlcode = arg_mtrlcode
  1394. quotemx[it_mxbt].mtrlname = arg_mtrlname
  1395. quotemx[it_mxbt].mtrlmode = arg_mtrlmode
  1396. quotemx[it_mxbt].unit = arg_unit
  1397. quotemx[it_mxbt].maxprice = ld_newprice
  1398. quotemx[it_mxbt].planprice = ld_planprice
  1399. quotemx[it_mxbt].mxdscrp = arg_mxdscrp
  1400. quotemx[it_mxbt].printid = arg_printid
  1401. quotemx[it_mxbt].sumprice = arg_sumprice
  1402. quotemx[it_mxbt].sumprice_1 = arg_sumprice_1
  1403. quotemx[it_mxbt].pfcode = ls_pfcode
  1404. quotemx[it_mxbt].status = arg_status
  1405. quotemx[it_mxbt].woodcode = arg_woodcode
  1406. quotemx[it_mxbt].pcode = arg_pcode
  1407. quotemx[it_mxbt].maxprice = arg_maxprice
  1408. quotemx[it_mxbt].planprice = arg_planprice
  1409. quotemx[it_mxbt].profit_margin = arg_profit_margin
  1410. quotemx[it_mxbt].wfjgprice = arg_wfjgprice
  1411. quotemx[it_mxbt].outcost = arg_outcost
  1412. quotemx[it_mxbt].mancost = arg_mancost
  1413. quotemx[it_mxbt].mtrlcost = arg_mtrlcost
  1414. quotemx[it_mxbt].qty = arg_qty
  1415. quotemx[it_mxbt].qty1 = arg_qty1
  1416. quotemx[it_mxbt].rebate = arg_rebate
  1417. quotemx[it_mxbt].addqty = arg_addqty
  1418. quotemx[it_mxbt].formula = arg_formula
  1419. quotemx[it_mxbt].lastprice = ld_lastprice
  1420. quotemx[it_mxbt].dscrp_text = arg_dscrp_text
  1421. quotemx[it_mxbt].mxdscrp2 = arg_mxdscrp2
  1422. quotemx[it_mxbt].mxdscrp3 = arg_mxdscrp3
  1423. quotemx[it_mxbt].mxdscrp4 = arg_mxdscrp4
  1424. quotemx[it_mxbt].newunit = arg_newunit
  1425. ext:
  1426. IF rslt = 0 THEN p_clearmx()
  1427. Return(rslt)
  1428. end function
  1429. on uo_quote.create
  1430. call super::create
  1431. TriggerEvent( this, "constructor" )
  1432. end on
  1433. on uo_quote.destroy
  1434. TriggerEvent( this, "destructor" )
  1435. call super::destroy
  1436. end on
  1437. global type uo_incase from nonvisualobject
  1438. end type