uo_quote.sru 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099
  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. long printid
  12. decimal { 10 } maxprice
  13. decimal { 10 } planprice
  14. string mxdscrp
  15. decimal { 10 } wfjgprice
  16. decimal { 10 } profit_margin
  17. decimal { 10 } sumprice
  18. decimal { 10 } sumprice_1
  19. decimal { 10 } outcost
  20. decimal { 10 } mancost
  21. decimal { 10 } mtrlcost
  22. string pfcode
  23. string status
  24. string woodcode
  25. string pcode
  26. decimal { 10 } qty
  27. decimal { 10 } qty1
  28. decimal { 5 } rebate
  29. string dscrp_text
  30. string mtrlname
  31. string mtrlmode
  32. string unit
  33. string mxdscrp2
  34. decimal { 10 } paintarea
  35. decimal { 10 } commonqty
  36. decimal { 10 } customqty
  37. decimal { 5 } taxrate
  38. decimal { 10 } fprice
  39. end type
  40. global type uo_quote from nonvisualobject
  41. end type
  42. global uo_quote uo_quote
  43. type variables
  44. PUBLIC PROTECTEDWRITE Long scid = 0
  45. PUBLIC PROTECTEDWRITE Long quoteID = 0
  46. PUBLIC PROTECTEDWRITE String quoteCode = ''
  47. PUBLIC PROTECTEDWRITE DateTime opdate
  48. PUBLIC PROTECTEDWRITE String operator = ''
  49. PUBLIC PROTECTEDWRITE String Permit_emp = ''//审核操作员
  50. public protectedwrite datetime moddate //修改时间,自动
  51. public protectedwrite string modemp //修改操作员
  52. public protectedwrite int flag=0 //审核标志
  53. public protectedwrite datetime auditingdate //审核时间
  54. Long custID = 0
  55. String Assign_emp
  56. DateTime quotedate
  57. String dscrp
  58. string relcode
  59. long moneyid
  60. int billtype
  61. datetime sendTime
  62. string sendUser,fiebrelcode
  63. decimal mrate
  64. Long audit_buildtype
  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. string uo_option_change_status,uo_option_change_woodcode,uo_option_change_pcode
  72. int uo_option_if_oa_quote,uo_option_quote_secaudit
  73. end variables
  74. forward prototypes
  75. public function integer p_reset ()
  76. public function integer p_clearmx ()
  77. public function integer newbegin (long arg_scid, ref string arg_msg)
  78. public function integer save (string arg_operator, ref string arg_msg, boolean arg_ifcommit)
  79. public function integer add_dscrp (long arg_scid, long arg_quoteid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit)
  80. public function integer cancel (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit)
  81. public function integer p_getinfo (long arg_scid, long arg_quoteid, ref string arg_msg)
  82. public function integer updatebegin (long arg_scid, long arg_quoteid, ref string arg_msg)
  83. public function integer audit (long arg_scid, long arg_quoteid, string arg_emp, ref string arg_msg, boolean arg_ifcommit)
  84. public function integer cancelaudit (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit)
  85. 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)
  86. public function integer getinfo (long arg_scid, long arg_quoteid, ref string arg_msg)
  87. public function integer uof_update_suliao (long arg_scid, long arg_quoteid, long arg_printid, s_quotesuliao arg_s_sl, ref string arg_msg, boolean arg_ifcommit)
  88. public function integer sec_audit (long arg_scid, long arg_quoteid, string arg_emp, ref string arg_msg, boolean arg_ifcommit)
  89. public function integer cancelsecaudit (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit)
  90. 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)
  91. 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, decimal arg_paintarea, decimal arg_commonqty, decimal arg_customqty, string arg_pfcode, s_quote_rqmtrl arg_rqmtrl, s_quote_workprice arg_workprice, ref string arg_msg, boolean arg_ifcommit)
  92. 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, string arg_dscrp_text, string arg_mxdscrp2, decimal arg_paintarea, decimal arg_commonqty, decimal arg_customqty, decimal arg_taxrate)
  93. end prototypes
  94. public function integer p_reset ();
  95. quoteID = 0
  96. quoteCode = ''
  97. operator = ''
  98. sendUser = ''
  99. fiebrelcode = ''
  100. mrate = 0
  101. flag = 0 //审核标志
  102. custID = 0
  103. Assign_emp = ''
  104. dscrp = ''
  105. relcode = ''
  106. it_newbegin = FALSE
  107. it_updatebegin = FALSE
  108. //清除明细
  109. P_CLEARMX()
  110. RETURN 1
  111. end function
  112. public function integer p_clearmx ();//INT p_clearmx()
  113. //清除明细
  114. it_mxbt=0
  115. RETURN 1
  116. end function
  117. public function integer newbegin (long arg_scid, ref string arg_msg);//重置对象,设定业务类型与关联ID,准备建立新单
  118. //0 fail 1 success
  119. long rslt=1,CNT=0
  120. if arg_scid < 0 then
  121. arg_msg = '请选择分部'
  122. rslt = 0
  123. goto ext
  124. end if
  125. p_reset()
  126. it_newbegin=TRUE
  127. it_updatebegin=FALSE
  128. scid=arg_scid
  129. ext:
  130. if rslt = 0 then p_reset()
  131. return rslt
  132. end function
  133. public function integer save (string arg_operator, ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1,cnt = 0,i
  134. DateTime server_dt
  135. Long ll_quoteid
  136. String ls_sccode
  137. IF IsNull(dscrp) THEN dscrp = ''
  138. IF IsNull(assign_emp) THEN assign_emp = ''
  139. IF IsNull(arg_operator) THEN arg_operator = ''
  140. IF IsNull(sendUser) THEN sendUser = ''
  141. IF IsNull(fiebrelcode) THEN fiebrelcode = ''
  142. IF IsNull(billtype) THEN billtype = 0
  143. IF IsNull(mrate) THEN mrate = 1
  144. //====================================================================
  145. // Script - save ( ref string arg_msg, boolean arg_ifcommit )
  146. // Reason:
  147. //--------------------------------------------------------------------
  148. // Modified By: yyx Date: 2004.02.20
  149. //--------------------------------------------------------------------
  150. //IF Len(dscrp) > 0 THEN dscrp = ' ' + dscrp
  151. //====================================================================
  152. operator = arg_operator
  153. IF it_newbegin = False And it_updatebegin = False THEN
  154. rslt = 0
  155. arG_MSG = "非编辑状态不可以提交"
  156. GOTO ext
  157. END IF
  158. IF Trim(assign_emp) = '' THEN
  159. rslt = 0
  160. arG_MSG = "请输入装箱单经手人"
  161. GOTO ext
  162. END IF
  163. cnt = 0
  164. SELECT count(*) INTO :cnt
  165. FROM u_cust
  166. Where cusid = :custID Using commit_transaction;
  167. IF commit_transaction.SQLCode <> 0 THEN
  168. rslt = 0
  169. arG_MSG = "查询操作失败,客户资料"
  170. GOTO ext
  171. END IF
  172. IF cnt = 0 THEN
  173. rslt = 0
  174. arG_MSG = "客户未定义或错误"
  175. GOTO ext
  176. END IF
  177. cnt = 0
  178. SELECT count(*) INTO :cnt
  179. FROM cw_currency
  180. Where moneyid = :moneyid;
  181. IF commit_transaction.SQLCode <> 0 THEN
  182. arG_MSG = '查询币种失败'
  183. rslt = 0
  184. GOTO ext
  185. END IF
  186. IF cnt = 0 THEN
  187. arG_MSG = '币种资料不存在'
  188. rslt = 0
  189. GOTO ext
  190. END IF
  191. IF mrate = 0 THEN
  192. arG_MSG = '币种汇率错误'
  193. rslt = 0
  194. GOTO ext
  195. END IF
  196. IF f_moneyid_rate_check(moneyid,mrate,arG_MSG) = 0 THEN
  197. rslt = 0
  198. GOTO ext
  199. END IF
  200. SELECT Top 1 getdate() Into :server_dt From u_user Using commit_transaction;
  201. //取得系统时间,借用操作员表
  202. IF commit_transaction.SQLCode <> 0 THEN
  203. rslt = 0
  204. arG_MSG = "查询操作失败,日期 "
  205. GOTO ext
  206. END IF
  207. IF f_check_inoutdate(0,quotedate,False,arG_MSG) = 0 THEN
  208. rslt = 0
  209. GOTO ext
  210. END IF
  211. IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
  212. rslt = 0
  213. arG_MSG = "没有正确报价单明细内容"
  214. GOTO ext
  215. END IF
  216. cnt = 0
  217. SELECT count(*) INTO :cnt
  218. FROM u_user
  219. Where username = :arg_operator Using commit_transaction ;
  220. IF commit_transaction.SQLCode <> 0 THEN
  221. rslt = 0
  222. arG_MSG = "查询操作失败,操作员!"
  223. GOTO ext
  224. END IF
  225. IF cnt = 0 THEN
  226. rslt = 0
  227. arG_MSG = "操作员姓名未登记或已取消!"
  228. GOTO ext
  229. END IF
  230. opdate = server_dt //填写单据建立时间(最近修改时间)
  231. ////////////////////////////////////////////////// //开始区分:新建/更新 处理
  232. IF quoteID = 0 THEN //新建
  233. ll_quoteid = f_sys_scidentity(scid,"u_quote","quoteID",arG_MSG,True,id_sqlca) //数据commit事务)
  234. IF ll_quoteid <= 0 THEN
  235. rslt = 0
  236. GOTO ext
  237. END IF
  238. IF f_get_sccode(scid,commit_transaction,ls_sccode,arG_MSG) = 0 THEN
  239. rslt = 0
  240. GOTO ext
  241. END IF
  242. IF billtype = 0 THEN
  243. quoteCode = getid(scid,ls_sccode + 'BJ',Date(server_dt),False,commit_transaction)
  244. IF quoteCode = "err" THEN
  245. quoteCode = ''
  246. rslt = 0
  247. arG_MSG = "无法获取报价单编号"+"~n"+commit_transaction.SQLErrText
  248. GOTO ext
  249. END IF
  250. ELSEIF billtype = 1 THEN
  251. quoteCode = getid(scid,ls_sccode + 'QR',Date(server_dt),False,commit_transaction)
  252. IF quoteCode = "err" THEN
  253. quoteCode = ''
  254. rslt = 0
  255. arG_MSG = "无法获取报价单编号"+"~n"+commit_transaction.SQLErrText
  256. GOTO ext
  257. END IF
  258. END IF
  259. INSERT INTO u_quote
  260. ( scid,
  261. quoteid,
  262. quoteCode,
  263. cusID,
  264. quotedate,
  265. Assign_Emp,
  266. relcode,
  267. flag,
  268. Dscrp,
  269. opemp,
  270. opdate,
  271. moneyid,
  272. fiebrelcode,
  273. billtype,
  274. mrate
  275. )
  276. VALUES ( :scid,
  277. :ll_quoteid,
  278. :quoteCode,
  279. :custID,
  280. :quotedate,
  281. :Assign_Emp,
  282. :relcode,
  283. 0,
  284. :Dscrp,
  285. :operator,
  286. :server_dt,
  287. :moneyid,
  288. :fiebrelcode,
  289. :billtype,
  290. :mrate) 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. //读取新quoteid
  297. quoteID = ll_quoteid
  298. FOR i = 1 To it_mxbt
  299. INSERT INTO u_quotemx
  300. ( scid,
  301. quoteid,
  302. mtrlid,
  303. printid,
  304. maxprice,
  305. planprice,
  306. mxdscrp,
  307. sumprice,
  308. sumprice_1,
  309. pfcode,
  310. status,
  311. woodcode,
  312. pcode,
  313. profit_margin,
  314. wfjgprice,
  315. outcost,
  316. mancost,
  317. mtrlcost,
  318. qty,
  319. qty1,
  320. rebate,
  321. mtrlcode,
  322. mtrlname,
  323. mtrlmode,
  324. unit,
  325. paintarea,
  326. commonqty,
  327. customqty,
  328. mxdscrp2,
  329. taxrate,
  330. fprice)
  331. VALUES (:scid,
  332. :ll_quoteid,
  333. :quotemx[i].mtrlid,
  334. :quotemx[i].printid,
  335. :quotemx[i].maxprice ,
  336. :quotemx[i].planprice ,
  337. :quotemx[i].mxdscrp,
  338. :quotemx[i].sumprice,
  339. :quotemx[i].sumprice_1,
  340. :quotemx[i].pfcode,
  341. :quotemx[i].status,
  342. :quotemx[i].woodcode,
  343. :quotemx[i].pcode,
  344. :quotemx[i].profit_margin,
  345. :quotemx[i].wfjgprice,
  346. :quotemx[i].outcost,
  347. :quotemx[i].mancost,
  348. :quotemx[i].mtrlcost,
  349. :quotemx[i].qty,
  350. :quotemx[i].qty1,
  351. :quotemx[i].rebate,
  352. :quotemx[i].mtrlcode,
  353. :quotemx[i].mtrlname,
  354. :quotemx[i].mtrlmode,
  355. :quotemx[i].unit,
  356. :quotemx[i].paintarea,
  357. :quotemx[i].commonqty,
  358. :quotemx[i].customqty,
  359. :quotemx[i].mxdscrp2,
  360. :quotemx[i].taxrate,
  361. :quotemx[i].fprice) Using commit_transaction;
  362. IF commit_transaction.SQLCode <> 0 THEN
  363. quoteID = 0 //还原quoteID
  364. rslt = 0
  365. arG_MSG = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  366. GOTO ext
  367. END IF
  368. IF Len(Trim(quotemx[i].dscrp_text)) > 0 THEN
  369. INSERT INTO u_quotemx_dscrp
  370. (scid,
  371. quoteid,
  372. printid,
  373. dscrp)
  374. VALUES
  375. (:scid,
  376. :ll_quoteid,
  377. :quotemx[i].printid,
  378. :quotemx[i].dscrp_text) Using commit_transaction;
  379. IF commit_transaction.SQLCode <> 0 THEN
  380. quoteID = 0 //还原quoteID
  381. rslt = 0
  382. arG_MSG = "因网络或其它原因导致插入明细备注操作失败"+"~n"+commit_transaction.SQLErrText
  383. GOTO ext
  384. END IF
  385. END IF
  386. NEXT
  387. ELSE //////////////////////////////////////////////// //更新
  388. UPDATE u_quote
  389. SET cusID = :custID,
  390. quotedate = :quotedate,
  391. Assign_Emp = :Assign_Emp,
  392. Dscrp = :Dscrp,
  393. moddate = getdate(),
  394. Modemp = :publ_operator,
  395. relcode = :relcode,
  396. moneyid = :moneyid,
  397. fiebrelcode = :fiebrelcode,
  398. mrate = :mrate
  399. WHERE u_quote.quoteid = :quoteID
  400. AND scid = :scid
  401. And flag = 0 Using commit_transaction;
  402. IF commit_transaction.SQLCode <> 0 Or sqlca.SQLNRows <= 0 THEN
  403. rslt = 0
  404. arG_MSG = "因网络或其它原因导致更新报价单操作失败"+"~n"+commit_transaction.SQLErrText
  405. GOTO ext
  406. END IF
  407. //删除原有明细
  408. DELETE FROM u_quotemx
  409. WHERE quoteID = :quoteID
  410. And scid = :scid Using commit_transaction;
  411. IF commit_transaction.SQLCode <> 0 THEN
  412. rslt = 0
  413. arG_MSG = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  414. GOTO ext
  415. END IF
  416. DELETE FROM u_quoterqmtrl
  417. WHERE quoteID = :quoteID
  418. And scid = :scid Using commit_transaction;
  419. IF commit_transaction.SQLCode <> 0 THEN
  420. rslt = 0
  421. arG_MSG = "删除明细成本操作失败"+"~n"+commit_transaction.SQLErrText
  422. GOTO ext
  423. END IF
  424. DELETE FROM u_quoteworkprice
  425. WHERE quoteID = :quoteID
  426. And scid = :scid Using commit_transaction;
  427. IF commit_transaction.SQLCode <> 0 THEN
  428. rslt = 0
  429. arG_MSG = "删除明细成本操作失败"+"~n"+commit_transaction.SQLErrText
  430. GOTO ext
  431. END IF
  432. //删除原有明细
  433. DELETE FROM u_quotemx_dscrp
  434. Where quoteID = :quoteID And scid = :scid Using commit_transaction;
  435. IF commit_transaction.SQLCode <> 0 THEN
  436. rslt = 0
  437. arG_MSG = "删除旧有明细备注操作失败"+"~n"+commit_transaction.SQLErrText
  438. GOTO ext
  439. END IF
  440. FOR i = 1 To it_mxbt
  441. INSERT INTO u_quotemx
  442. ( scid,
  443. quoteid,
  444. mtrlid,
  445. printid,
  446. maxprice,
  447. planprice,
  448. mxdscrp,
  449. sumprice,
  450. sumprice_1,
  451. pfcode,
  452. status,
  453. woodcode,
  454. pcode,
  455. profit_margin,
  456. wfjgprice,
  457. outcost,
  458. mancost,
  459. mtrlcost,
  460. qty,
  461. qty1,
  462. rebate,
  463. mtrlcode,
  464. mtrlname,
  465. mtrlmode,
  466. unit,
  467. paintarea,
  468. commonqty,
  469. customqty,
  470. mxdscrp2,
  471. taxrate,
  472. fprice)
  473. VALUES (:scid,
  474. :quoteID,
  475. :quotemx[i].mtrlid,
  476. :quotemx[i].printid,
  477. :quotemx[i].maxprice ,
  478. :quotemx[i].planprice ,
  479. :quotemx[i].mxdscrp,
  480. :quotemx[i].sumprice,
  481. :quotemx[i].sumprice_1,
  482. :quotemx[i].pfcode,
  483. :quotemx[i].status,
  484. :quotemx[i].woodcode,
  485. :quotemx[i].pcode,
  486. :quotemx[i].profit_margin,
  487. :quotemx[i].wfjgprice,
  488. :quotemx[i].outcost,
  489. :quotemx[i].mancost,
  490. :quotemx[i].mtrlcost,
  491. :quotemx[i].qty,
  492. :quotemx[i].qty1,
  493. :quotemx[i].rebate,
  494. :quotemx[i].mtrlcode,
  495. :quotemx[i].mtrlname,
  496. :quotemx[i].mtrlmode,
  497. :quotemx[i].unit,
  498. :quotemx[i].paintarea,
  499. :quotemx[i].commonqty,
  500. :quotemx[i].customqty,
  501. :quotemx[i].mxdscrp2,
  502. :quotemx[i].taxrate,
  503. :quotemx[i].fprice) Using commit_transaction;
  504. IF commit_transaction.SQLCode <> 0 THEN
  505. rslt = 0
  506. arG_MSG = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  507. GOTO ext
  508. END IF
  509. IF Len(Trim(quotemx[i].dscrp_text)) > 0 THEN
  510. INSERT INTO u_quotemx_dscrp
  511. (scid,
  512. quoteid,
  513. printid,
  514. dscrp)
  515. VALUES
  516. (:scid,
  517. :quoteID,
  518. :quotemx[i].printid,
  519. :quotemx[i].dscrp_text) Using commit_transaction;
  520. IF commit_transaction.SQLCode <> 0 THEN
  521. quoteID = 0 //还原quoteID
  522. rslt = 0
  523. arG_MSG = "因网络或其它原因导致插入明细备注操作失败"+"~n"+commit_transaction.SQLErrText
  524. GOTO ext
  525. END IF
  526. END IF
  527. NEXT
  528. END IF
  529. it_newbegin = False
  530. it_updatebegin = False
  531. ext:
  532. IF rslt = 0 THEN
  533. p_clearmx()
  534. ROLLBACK Using commit_transaction;
  535. ELSEIF arg_ifcommit And rslt = 1 THEN
  536. COMMIT Using commit_transaction;
  537. END IF
  538. Return(rslt)
  539. end function
  540. 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)
  541. //0 fail 1 SUCCESS
  542. Int rslt = 1
  543. arg_newdescppart = Trim(arg_newdescppart)
  544. IF it_updatebegin OR it_newbegin THEN
  545. rslt = 0
  546. arG_MSG = "编辑状态下不可用"
  547. GOTO ext
  548. END IF
  549. IF arg_newdescppart = '' THEN
  550. rslt = 0
  551. arG_MSG = "要添加内容为空,操作取消"
  552. GOTO ext
  553. END IF
  554. IF p_getinfo(arg_scid,arg_quoteid,arG_MSG) = 0 THEN
  555. rslt = 0
  556. GOTO ext
  557. END IF
  558. IF flag = 0 THEN
  559. rslt = 0
  560. arG_MSG = "待审核状态下不可用"
  561. GOTO ext
  562. END IF
  563. UPDATE u_quote
  564. SET DSCRP = DSCRP+' '+:arg_newdescppart
  565. Where u_quote.quoteid = :arg_quoteid USING commit_transaction;
  566. IF commit_transaction.SQLCode <> 0 THEN
  567. rslt = 0
  568. arG_MSG = "因网络或其它原因导致添加报价单备注操作失败"+"~n"+commit_transaction.SQLErrText
  569. ROLLBACK USING commit_transaction;
  570. GOTO ext
  571. END IF
  572. DSCRP = DSCRP+' '+arg_newdescppart
  573. it_newbegin = FALSE
  574. it_updatebegin = FALSE
  575. ext:
  576. IF arg_ifcommit AND rslt = 1 THEN
  577. COMMIT USING commit_transaction;
  578. END IF
  579. p_reset()
  580. Return (rslt)
  581. end function
  582. public function integer cancel (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit);//删除未审核的装箱单
  583. //0 FAIL, 1 SUCCESS
  584. Int rslt = 1
  585. IF arg_quoteid <= 0 THEN
  586. rslt = 0
  587. ARG_MSG = '错误装箱单唯一码'
  588. GOTO ext
  589. END IF
  590. IF p_getinfo(arg_scid,arg_quoteid,ARG_MSG) = 0 THEN
  591. rslt = 0
  592. GOTO ext
  593. END IF
  594. IF flag = 1 THEN
  595. rslt = 0
  596. ARG_MSG = "装箱单已经审核,不可以删除"
  597. GOTO ext
  598. END IF
  599. DELETE FROM u_quoterqmtrl
  600. WHERE u_quoterqmtrl.quoteid = :arg_quoteid
  601. And u_quoterqmtrl.scid = :arg_scid Using commit_transaction;
  602. IF commit_transaction.SQLCode <> 0 THEN
  603. rslt = 0
  604. ARG_MSG = "删除报价单用料明细操作失败"+"~n"+SQLCA.SQLErrText
  605. ROLLBACK Using commit_transaction;
  606. GOTO ext
  607. END IF
  608. DELETE FROM u_quotemx
  609. WHERE u_quotemx.quoteid = :arg_quoteid
  610. And u_quotemx.scid = :arg_scid Using commit_transaction;
  611. IF commit_transaction.SQLCode <> 0 THEN
  612. rslt = 0
  613. ARG_MSG = "删除报价单明细操作失败"+"~n"+SQLCA.SQLErrText
  614. ROLLBACK Using commit_transaction;
  615. GOTO ext
  616. END IF
  617. //删除原有明细
  618. DELETE FROM u_quotemx_dscrp
  619. Where quoteid = :arg_quoteid And scid = :arg_scid Using commit_transaction;
  620. IF commit_transaction.SQLCode <> 0 THEN
  621. rslt = 0
  622. ARG_MSG = "删除旧有明细备注操作失败"+"~n"+commit_transaction.SQLErrText
  623. GOTO ext
  624. END IF
  625. DELETE FROM u_quote
  626. WHERE u_quote.quoteid = :arg_quoteid
  627. And u_quote.scid = :arg_scid Using commit_transaction;
  628. IF commit_transaction.SQLCode <> 0 THEN
  629. rslt = 0
  630. ARG_MSG = "删除报价单操作失败"+"~n"+commit_transaction.SQLErrText
  631. ROLLBACK Using commit_transaction;
  632. GOTO ext
  633. END IF
  634. it_newbegin = False
  635. it_updatebegin = False
  636. IF arg_ifcommit THEN
  637. COMMIT Using commit_transaction;
  638. END IF
  639. ext:
  640. p_reset()
  641. Return (rslt)
  642. end function
  643. public function integer p_getinfo (long arg_scid, long arg_quoteid, ref string arg_msg);Int rslt = 1
  644. SELECT quotecode,
  645. cusid,
  646. quotedate,
  647. assign_emp,
  648. relcode,
  649. dscrp,
  650. opemp,
  651. opdate,
  652. flag,
  653. moneyid,
  654. billtype,
  655. mrate
  656. INTO :quotecode,
  657. :custid,
  658. :quotedate,
  659. :assign_emp,
  660. :relcode,
  661. :dscrp,
  662. :operator,
  663. :opdate,
  664. :flag,
  665. :moneyid,
  666. :billtype,
  667. :mrate
  668. FROM u_quote
  669. WHERE u_quote.quoteid = :arg_quoteid AND
  670. u_quote.scid = :arg_scid Using commit_transaction;
  671. IF commit_transaction.SQLCode <> 0 THEN
  672. rslt = 0
  673. ARG_MSG = '查询报价单内容失败(错误订单唯一码)'+sqlca.SQLErrText
  674. GOTO ext
  675. END IF
  676. scid = arg_scid
  677. quoteid = arg_quoteid
  678. ext:
  679. RETURN rslt
  680. end function
  681. public function integer updatebegin (long arg_scid, long arg_quoteid, ref string arg_msg);//UPDATEbegin(long arg_taskid,ref string arg_msg)
  682. //从置对象,设定业务类型与关联ID,准备更新单
  683. //0 fail 1 success
  684. long rslt=1,CNT=0
  685. if arg_scid < 0 then
  686. arg_msg = '请选择分部'
  687. rslt = 0
  688. goto ext
  689. end if
  690. IF arg_quoteid<=0 THEN
  691. rslt=0
  692. ARG_MSG='错误报价单唯一码'
  693. goto ext
  694. end if
  695. if p_getinfo(arg_scid,arg_quoteid,arg_msg)=0 then
  696. rslt=0
  697. goto ext
  698. end if
  699. if flag=1 then
  700. rslt=0
  701. ARG_MSG='已经处于审核状态,不可以修改,要修改请先撤销审核'
  702. goto ext
  703. end if
  704. it_newbegin=FALSE
  705. it_updatebegin=TRUE
  706. p_clearmx() //清除明细
  707. scid=arg_scid
  708. quoteid=arg_quoteid
  709. ext:
  710. if rslt=0 then p_reset()
  711. return rslt
  712. end function
  713. public function integer audit (long arg_scid, long arg_quoteid, string arg_emp, ref string arg_msg, boolean arg_ifcommit);
  714. Int rslt = 1,cnt = 0
  715. Long i
  716. uo_cusprice uo_update_cusprice
  717. uo_update_cusprice = Create uo_cusprice
  718. IF uo_option_if_oa_quote = -1000 THEN
  719. rslt = 0
  720. arg_msg = '选项:[235]销售报价单使用OA审批流程,读取初始默认值失败,操作取消!'
  721. GOTO ext
  722. END IF
  723. IF uo_option_quote_secaudit = -1000 THEN
  724. rslt = 0
  725. arg_msg = '选项:[236]销售报价单使用二级审核,读取初始默认值失败,操作取消!'
  726. GOTO ext
  727. END IF
  728. IF arg_quoteid <= 0 THEN
  729. rslt = 0
  730. arg_msg = '错误报价单唯一码'
  731. GOTO ext
  732. END IF
  733. IF getinfo(arg_scid,arg_quoteid,arg_msg) = 0 THEN
  734. rslt = 0
  735. GOTO ext
  736. END IF
  737. IF flag <> 0 THEN
  738. rslt = 0
  739. arg_msg = "销售报价单已经审核,操作取消"
  740. GOTO ext
  741. END IF
  742. cnt = 0
  743. SELECT count(*) INTO :cnt
  744. FROM u_user
  745. Where username = :arg_emp Using commit_transaction;
  746. IF commit_transaction.SQLCode <> 0 THEN
  747. rslt = 0
  748. arg_msg = "查询操作失败,操作员!"
  749. GOTO ext
  750. END IF
  751. IF cnt = 0 THEN
  752. rslt = 0
  753. arg_msg = "操作员姓名未登记或已取消!"
  754. GOTO ext
  755. END IF
  756. FOR i = 1 To it_mxbt
  757. IF quotemx[i].sumprice_1 <= 0 THEN
  758. rslt = 0
  759. arg_msg = '第'+String(i)+'行,请输入客户还价'
  760. GOTO ext
  761. END IF
  762. // IF uo_update_cusprice.uof_update_custprice(0,0,custID,&
  763. // quotemx[i].mtrlid,quotemx[i].mtrlcode,quotemx[i].status,&
  764. // quotemx[i].woodcode,quotemx[i].pcode,&
  765. // quoteID,quoteCode,quotedate,quotemx[i].sumprice_1,&
  766. // quotemx[i].rebate,quotemx[i].sumprice_1 * quotemx[i].rebate * quotemx[i].qty,2,'',&
  767. // quotemx[i].printid,2,moneyid,FALSE,ARG_MSG) = 0 THEN
  768. // rslt = 0
  769. // GOTO ext
  770. // END IF
  771. NEXT
  772. //更新审核标记
  773. UPDATE u_quote
  774. SET auditingrep = :arg_emp,
  775. auditingdate = getdate(),
  776. flag = 4
  777. WHERE u_quote.quoteID = :arg_quoteid
  778. AND u_quote.scid = :arg_scid
  779. AND u_quote.flag = 0
  780. Using commit_transaction;
  781. IF commit_transaction.SQLCode <> 0 THEN
  782. rslt = 0
  783. arg_msg = "因网络或其它原因导致单据审核操作失败"+"~n"+commit_transaction.SQLErrText
  784. GOTO ext
  785. END IF
  786. it_newbegin = False
  787. it_updatebegin = False
  788. IF uo_option_if_oa_quote = 1 And uo_option_quote_secaudit = 1 THEN
  789. IF f_oa(sqlca,False,arg_msg,461,arg_scid,arg_quoteid,quoteCode,relcode,dscrp) = 0 THEN
  790. rslt = 0
  791. GOTO ext
  792. END IF
  793. END IF
  794. ext:
  795. IF rslt = 0 THEN
  796. ROLLBACK Using commit_transaction;
  797. ELSEIF arg_ifcommit THEN
  798. COMMIT Using commit_transaction;
  799. END IF
  800. p_reset()
  801. Return (rslt)
  802. end function
  803. public function integer cancelaudit (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1,cnt = 0
  804. Long i
  805. DateTime ls_auditingdate
  806. SetNull(ls_auditingdate)
  807. IF uo_option_if_oa_quote = -1000 THEN
  808. rslt = 0
  809. arg_msg = '选项:[235]销售报价单使用OA审批流程,读取初始默认值失败,操作取消!'
  810. GOTO ext
  811. END IF
  812. IF uo_option_quote_secaudit = -1000 THEN
  813. rslt = 0
  814. arg_msg = '选项:[236]销售报价单使用二级审核,读取初始默认值失败,操作取消!'
  815. GOTO ext
  816. END IF
  817. uo_cusprice uo_update_cusprice
  818. uo_update_cusprice = Create uo_cusprice
  819. IF arg_quoteid <= 0 THEN
  820. rslt = 0
  821. ARG_MSG = '错误报价单唯一码'
  822. GOTO ext
  823. END IF
  824. IF uo_option_if_oa_quote = 1 And uo_option_quote_secaudit = 1 THEN
  825. IF f_check_if_oaflow_caudit(arg_scid,arg_quoteid,461,ARG_MSG ) = 0 THEN
  826. rslt = 0
  827. GOTO ext
  828. END IF
  829. END IF
  830. IF getinfo(arg_scid,arg_quoteid,ARG_MSG) = 0 THEN
  831. rslt = 0
  832. GOTO ext
  833. END IF
  834. IF flag <> 4 THEN
  835. rslt = 0
  836. ARG_MSG = "报价只有在待终审状态才可以执行撤销初审,请核对"
  837. GOTO ext
  838. END IF
  839. UPDATE u_quote
  840. SET flag = 0,
  841. auditingrep = '',
  842. auditingdate = :ls_auditingdate
  843. WHERE u_quote.quoteid = :arg_quoteid
  844. AND u_quote.scid = :arg_scid
  845. AND u_quote.flag = 4
  846. Using commit_transaction ;
  847. IF commit_transaction.SQLCode <> 0 THEN
  848. rslt = 0
  849. ARG_MSG = "因网络或其它原因导致报价单撤消审核操作失败"+"~n"+commit_transaction.SQLErrText
  850. GOTO ext
  851. END IF
  852. // //删除旧有物料需求记录
  853. //DELETE FROM u_quoterqmtrl
  854. // WHERE u_quoterqmtrl.quoteid = :arg_quoteid
  855. // AND u_quoterqmtrl.scid = :arg_scid;
  856. //IF sqlca.SQLCode <> 0 THEN
  857. // ROLLBACK;
  858. // ARG_MSG = '删除旧有物料需求记录失败 '+sqlca.SQLErrText
  859. // rslt = 0
  860. // GOTO ext
  861. //END IF
  862. //
  863. //FOR i = 1 TO it_mxbt
  864. // IF uo_update_cusprice.uof_del_cusprice_auto(custid,quoteid,&
  865. // quotemx[i].printid,quotemx[i].mtrlid,quotemx[i].status,&
  866. // quotemx[i].woodcode,quotemx[i].pcode,&
  867. // 2,moneyid,FALSE,ARG_MSG) = 0 THEN
  868. // rslt = 0
  869. // GOTO ext
  870. // END IF
  871. //NEXT
  872. it_newbegin = False
  873. it_updatebegin = False
  874. ext:
  875. IF rslt = 0 THEN
  876. ROLLBACK Using commit_transaction;
  877. ELSEIF arg_ifcommit THEN
  878. COMMIT Using commit_transaction;
  879. END IF
  880. Destroy uo_update_cusprice
  881. p_reset()
  882. Return (rslt)
  883. end function
  884. 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
  885. Int li_flag
  886. DateTime null_dt
  887. SetNull(null_dt)
  888. SELECT flag INTO :li_flag
  889. FROM u_quote
  890. WHERE scid = :arg_scid
  891. AND quoteid = :arg_quoteid USING commit_transaction;
  892. IF commit_transaction.SQLCode <> 0 THEN
  893. arg_msg = '查询报价单审核标记失败,'+commit_transaction.SQLErrText
  894. rslt = 0
  895. GOTO ext
  896. END IF
  897. IF li_flag = 0 THEN
  898. IF arg_flag = 1 THEN
  899. arg_msg = '报价单还未审核,不能明细审核'
  900. ELSE
  901. arg_msg = '报价单还未审核,不能明细撤审'
  902. END IF
  903. rslt = 0
  904. GOTO ext
  905. END IF
  906. SELECT flag INTO :li_flag
  907. FROM u_quotemx
  908. WHERE scid = :arg_scid
  909. AND quoteid = :arg_quoteid
  910. AND printid = :arg_printid USING commit_transaction;
  911. IF commit_transaction.SQLCode <> 0 THEN
  912. arg_msg = '查询明细审核标记失败,'+commit_transaction.SQLErrText
  913. rslt = 0
  914. GOTO ext
  915. END IF
  916. IF arg_flag = 1 THEN
  917. IF li_flag = 1 THEN
  918. arg_msg = '明细已审核不能再审核'
  919. rslt = 0
  920. GOTO ext
  921. END IF
  922. ELSE
  923. IF li_flag = 0 THEN
  924. arg_msg = '明细还未审核不能撤审'
  925. rslt = 0
  926. GOTO ext
  927. END IF
  928. END IF
  929. IF arg_flag = 1 THEN
  930. UPDATE u_quotemx SET
  931. flag = 1,
  932. auditemp = :arg_opemp,
  933. auditdate = getdate()
  934. WHERE scid = :arg_scid
  935. AND quoteid = :arg_quoteid
  936. AND printid = :arg_printid USING commit_transaction;
  937. IF commit_transaction.SQLCode <> 0 THEN
  938. arg_msg = '审核明细失败,'+commit_transaction.SQLErrText
  939. rslt = 0
  940. GOTO ext
  941. END IF
  942. ELSE
  943. UPDATE u_quotemx SET
  944. flag = 0,
  945. auditemp = '',
  946. auditdate = :null_dt
  947. WHERE scid = :arg_scid
  948. AND quoteid = :arg_quoteid
  949. AND printid = :arg_printid USING commit_transaction;
  950. IF commit_transaction.SQLCode <> 0 THEN
  951. arg_msg = '审核明细失败,'+commit_transaction.SQLErrText
  952. rslt = 0
  953. GOTO ext
  954. END IF
  955. END IF
  956. ext:
  957. IF rslt = 0 THEN
  958. ROLLBACK USING commit_transaction;
  959. ELSEIF rslt = 1 AND arg_ifcommit THEN
  960. COMMIT USING commit_transaction;
  961. END IF
  962. RETURN rslt
  963. end function
  964. public function integer getinfo (long arg_scid, long arg_quoteid, ref string arg_msg);Int rslt = 1
  965. Long i = 1
  966. Long no_mxcheck
  967. IF arg_quoteid <= 0 THEN
  968. rslt = 0
  969. arg_msg = "非法销售报价单唯一码"
  970. GOTO ext
  971. END IF
  972. rslt = p_getinfo(arg_scid,arg_quoteid,arg_msg)
  973. IF rslt = 0 THEN GOTO ext
  974. DECLARE cur_quotemx CURSOR FOR
  975. SELECT u_quotemx.printid,
  976. u_quotemx.mtrlid,
  977. u_quotemx.sumprice,
  978. u_quotemx.sumprice_1,
  979. u_quotemx.qty,
  980. u_quotemx.qty1,
  981. u_quotemx.mxDscrp,
  982. u_quotemx.status,
  983. u_quotemx.woodcode,
  984. u_quotemx.pcode,
  985. u_quotemx.rebate,
  986. u_quotemx.mtrlcode,
  987. u_quotemx.fprice
  988. FROM u_quotemx
  989. WHERE u_quotemx.scid = :arg_scid
  990. AND u_quotemx.quoteid = :arg_quoteid USING commit_transaction;
  991. OPEN cur_quotemx;
  992. FETCH cur_quotemx INTO :quotemx[i].printid,:quotemx[i].mtrlid,
  993. :quotemx[i].sumprice,:quotemx[i].sumprice_1,:quotemx[i].qty,:quotemx[i].qty1,:quotemx[i].mxdscrp,
  994. :quotemx[i].status,:quotemx[i].woodcode,:quotemx[i].pcode,:quotemx[i].rebate,:quotemx[i].mtrlcode,
  995. :quotemx[i].fprice;
  996. DO WHILE commit_transaction.SQLCode = 0
  997. i++
  998. FETCH cur_quotemx INTO :quotemx[i].printid,:quotemx[i].mtrlid,
  999. :quotemx[i].sumprice,:quotemx[i].sumprice_1,:quotemx[i].qty,:quotemx[i].qty1,:quotemx[i].mxdscrp,
  1000. :quotemx[i].status,:quotemx[i].woodcode,:quotemx[i].pcode,:quotemx[i].rebate,:quotemx[i].mtrlcode,
  1001. :quotemx[i].fprice;
  1002. LOOP
  1003. close cur_quotemx;
  1004. SELECT count(*) INTO :no_mxcheck
  1005. FROM u_quotemx
  1006. WHERE quoteid = :arg_quoteid
  1007. AND scid = :arg_scid USING commit_transaction;
  1008. IF commit_transaction.SQLCode <> 0 THEN
  1009. rslt = 0
  1010. arg_msg = "查询操作失败,报价单明细数量"
  1011. GOTO ext
  1012. END IF
  1013. IF i <> (no_mxcheck+1) THEN
  1014. rslt = 0
  1015. arg_msg = "查询操作失败,进仓单明细"
  1016. GOTO ext
  1017. END IF
  1018. it_mxbt = i - 1
  1019. it_newbegin = FALSE
  1020. it_updatebegin = FALSE
  1021. ext:
  1022. IF rslt = 0 THEN p_reset()
  1023. RETURN rslt
  1024. end function
  1025. public function integer uof_update_suliao (long arg_scid, long arg_quoteid, long arg_printid, s_quotesuliao arg_s_sl, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  1026. IF arg_quoteid <= 0 THEN
  1027. rslt = 0
  1028. arg_msg = '错误的单据唯一码'
  1029. GOTO ext
  1030. END IF
  1031. IF arg_printid <= 0 THEN
  1032. rslt = 0
  1033. arg_msg = '错误的单据明细唯一码'
  1034. GOTO ext
  1035. END IF
  1036. IF IsNull(arg_s_sl.mtrlid) THEN arg_s_sl.mtrlid = 0
  1037. IF IsNull(arg_s_sl.Pigment_price) THEN arg_s_sl.Pigment_price = 0
  1038. IF IsNull(arg_s_sl.Pigment_weight ) THEN arg_s_sl.Pigment_weight = 0
  1039. IF IsNull(arg_s_sl.Worktime ) THEN arg_s_sl.Worktime = 0
  1040. IF IsNull(arg_s_sl.Workprice ) THEN arg_s_sl.Workprice = 0
  1041. IF IsNull(arg_s_sl.Trans_price ) THEN arg_s_sl.Trans_price = 0
  1042. IF IsNull(arg_s_sl.Trans_qty ) THEN arg_s_sl.Trans_qty = 0
  1043. IF IsNull(arg_s_sl.Tax_rate ) THEN arg_s_sl.Tax_rate = 0
  1044. IF IsNull(arg_s_sl.Discount_rate ) THEN arg_s_sl.Discount_rate = 0
  1045. IF IsNull(arg_s_sl.Exprice ) THEN arg_s_sl.Exprice = 0
  1046. IF IsNull(arg_s_sl.Pack_price ) THEN arg_s_sl.Pack_price = 0
  1047. IF IsNull(arg_s_sl.Sumprice_cust ) THEN arg_s_sl.Sumprice_cust = 0
  1048. IF IsNull(arg_s_sl.profit_margin ) THEN arg_s_sl.profit_margin = 0
  1049. IF IsNull(arg_s_sl.sumprice ) THEN arg_s_sl.sumprice = 0
  1050. IF IsNull(arg_s_sl.consultqty ) THEN arg_s_sl.consultqty = 0
  1051. IF IsNull(arg_s_sl.materialprice ) THEN arg_s_sl.materialprice = 0
  1052. IF IsNull(arg_s_sl.Modelqty ) THEN arg_s_sl.Modelqty = 0
  1053. IF IsNull(arg_s_sl.Period ) THEN arg_s_sl.Period = 0
  1054. IF IsNull(arg_s_sl.EquipmentID ) THEN arg_s_sl.EquipmentID = 0
  1055. IF IsNull(arg_s_sl.Weight ) THEN arg_s_sl.Weight = 0
  1056. IF IsNull(arg_s_sl.Cost_Elec_Degree ) THEN arg_s_sl.Cost_Elec_Degree = 0
  1057. IF IsNull(arg_s_sl.Elec_Price ) THEN arg_s_sl.Elec_Price = 0
  1058. IF IsNull(arg_s_sl.Materialwaste ) THEN arg_s_sl.Materialwaste = 0
  1059. IF IsNull(arg_s_sl.discount_price ) THEN arg_s_sl.discount_price = 0
  1060. IF IsNull(arg_s_sl.EquipmentQty ) THEN arg_s_sl.EquipmentQty = 0
  1061. IF IsNull(arg_s_sl.management_cost ) THEN arg_s_sl.management_cost = 0
  1062. IF IsNull(arg_s_sl.depreciation_cost ) THEN arg_s_sl.depreciation_cost = 0
  1063. IF IsNull(arg_s_sl.suppose_price ) THEN arg_s_sl.suppose_price = 0
  1064. IF IsNull(arg_s_sl.suppose_ain ) THEN arg_s_sl.suppose_ain = 0
  1065. IF IsNull(arg_s_sl.suppose_tax_tate ) THEN arg_s_sl.suppose_tax_tate = 0
  1066. IF IsNull(arg_s_sl.net_profit ) THEN arg_s_sl.net_profit = 0
  1067. IF IsNull(arg_s_sl.vmtrlid ) THEN arg_s_sl.vmtrlid = 0
  1068. IF IsNull(arg_s_sl.material ) THEN arg_s_sl.material = ''
  1069. IF IsNull(arg_s_sl.total_cost ) THEN arg_s_sl.total_cost = 0
  1070. IF IsNull(arg_s_sl.equiment_totalqty) THEN arg_s_sl.equiment_totalqty = 0
  1071. DELETE FROM u_quotesuliao
  1072. WHERE scid = :arg_scid
  1073. AND quoteid = :arg_quoteid
  1074. AND printid = :arg_printid USING commit_transaction;
  1075. IF commit_transaction.SQLCode <> 0 THEN
  1076. arg_msg = '删除报价明细物料成本明细失败,'+commit_transaction.SQLErrText
  1077. rslt = 0
  1078. GOTO ext
  1079. END IF
  1080. INSERT INTO u_quotesuliao
  1081. (scid,
  1082. quoteid,
  1083. printid,
  1084. Pigment_price,
  1085. Pigment_weight,
  1086. Period,
  1087. Modelqty,
  1088. Worktime,
  1089. Workprice,
  1090. EquipmentID,
  1091. Trans_price,
  1092. Trans_qty,
  1093. Tax_rate,
  1094. Discount_rate,
  1095. Exprice,
  1096. Pack_price,
  1097. Sumprice_cust,
  1098. consultqty,
  1099. Materialprice,
  1100. Weight,
  1101. Cost_Elec_Degree,
  1102. Elec_Price,
  1103. Materialwaste,
  1104. discount_price,
  1105. EquipmentQty,
  1106. management_cost,
  1107. depreciation_cost,
  1108. suppose_price,
  1109. suppose_ain,
  1110. suppose_tax_tate,
  1111. net_profit,
  1112. vmtrlid,
  1113. Material,
  1114. equiment_totalqty,
  1115. total_cost,
  1116. mtrlid,
  1117. profit_margin,
  1118. sumprice)
  1119. VALUES
  1120. (:arg_scid,
  1121. :arg_quoteid,
  1122. :arg_printid,
  1123. :arg_s_sl.Pigment_price,
  1124. :arg_s_sl.Pigment_weight,
  1125. :arg_s_sl.Period,
  1126. :arg_s_sl.Modelqty,
  1127. :arg_s_sl.Worktime,
  1128. :arg_s_sl.Workprice,
  1129. :arg_s_sl.EquipmentID,
  1130. :arg_s_sl.Trans_price,
  1131. :arg_s_sl.Trans_qty,
  1132. :arg_s_sl.Tax_rate,
  1133. :arg_s_sl.Discount_rate,
  1134. :arg_s_sl.Exprice,
  1135. :arg_s_sl.Pack_price,
  1136. :arg_s_sl.Sumprice_cust,
  1137. :arg_s_sl.consultqty,
  1138. :arg_s_sl.Materialprice,
  1139. :arg_s_sl.Weight,
  1140. :arg_s_sl.Cost_Elec_Degree,
  1141. :arg_s_sl.Elec_Price,
  1142. :arg_s_sl.Materialwaste,
  1143. :arg_s_sl.discount_price,
  1144. :arg_s_sl.EquipmentQty,
  1145. :arg_s_sl.management_cost,
  1146. :arg_s_sl.depreciation_cost,
  1147. :arg_s_sl.suppose_price,
  1148. :arg_s_sl.suppose_ain,
  1149. :arg_s_sl.suppose_tax_tate,
  1150. :arg_s_sl.net_profit,
  1151. :arg_s_sl.vmtrlid,
  1152. :arg_s_sl.Material,
  1153. :arg_s_sl.equiment_totalqty,
  1154. :arg_s_sl.total_cost,
  1155. :arg_s_sl.mtrlid,
  1156. :arg_s_sl.profit_margin,
  1157. :arg_s_sl.sumprice) USING commit_transaction;
  1158. IF commit_transaction.SQLCode <> 0 THEN
  1159. arg_msg = '建立报价明细塑料计算信息明细失败,'+commit_transaction.SQLErrText
  1160. rslt = 0
  1161. GOTO ext
  1162. END IF
  1163. UPDATE u_quotemx SET
  1164. sumprice = :arg_s_sl.sumprice,
  1165. sumprice_1 = :arg_s_sl.Sumprice_cust,
  1166. profit_margin = :arg_s_sl.profit_margin
  1167. WHERE scid = :arg_scid
  1168. AND quoteid = :arg_quoteid
  1169. AND printid = :arg_printid USING commit_transaction;
  1170. IF commit_transaction.SQLCode <> 0 THEN
  1171. arg_msg = '更新明细资料失败,'+commit_transaction.SQLErrText
  1172. rslt = 0
  1173. GOTO ext
  1174. END IF
  1175. ext:
  1176. IF rslt = 0 THEN
  1177. ROLLBACK USING commit_transaction;
  1178. ELSEIF rslt = 1 AND arg_ifcommit THEN
  1179. COMMIT USING commit_transaction;
  1180. END IF
  1181. RETURN rslt
  1182. end function
  1183. public function integer sec_audit (long arg_scid, long arg_quoteid, string arg_emp, ref string arg_msg, boolean arg_ifcommit);
  1184. Int rslt = 1,cnt = 0
  1185. Long i
  1186. uo_cusprice uo_update_cusprice
  1187. uo_update_cusprice = Create uo_cusprice
  1188. IF arg_quoteid <= 0 THEN
  1189. rslt = 0
  1190. ARG_MSG = '错误报价单唯一码'
  1191. GOTO ext
  1192. END IF
  1193. IF uo_option_if_oa_quote = 1 And uo_option_quote_secaudit = 1 And audit_buildtype = 0 THEN
  1194. IF f_check_if_oaflow(arg_scid,arg_quoteid,461,ARG_MSG ) = 0 THEN
  1195. rslt = 0
  1196. GOTO ext
  1197. END IF
  1198. END IF
  1199. IF getinfo(arg_scid,arg_quoteid,ARG_MSG) = 0 THEN
  1200. rslt = 0
  1201. GOTO ext
  1202. END IF
  1203. IF flag <> 4 THEN
  1204. rslt = 0
  1205. ARG_MSG = "销售报价单不是在待终审状态,不能执行终审"
  1206. GOTO ext
  1207. END IF
  1208. cnt = 0
  1209. SELECT count(*) INTO :cnt
  1210. FROM u_user
  1211. Where username = :arg_emp Using commit_transaction;
  1212. IF commit_transaction.SQLCode <> 0 THEN
  1213. rslt = 0
  1214. ARG_MSG = "查询操作失败,操作员!"
  1215. GOTO ext
  1216. END IF
  1217. IF cnt = 0 THEN
  1218. rslt = 0
  1219. ARG_MSG = "操作员姓名未登记或已取消!"
  1220. GOTO ext
  1221. END IF
  1222. IF billtype = 0 THEN
  1223. FOR i = 1 To it_mxbt
  1224. IF quotemx[i].sumprice_1 <= 0 THEN
  1225. rslt = 0
  1226. ARG_MSG = '第'+String(i)+'行,请输入客户还价'
  1227. GOTO ext
  1228. END IF
  1229. IF uo_update_cusprice.uof_update_custprice(0,0,custID,&
  1230. quotemx[i].mtrlid,quotemx[i].mtrlcode,quotemx[i].status,&
  1231. quotemx[i].woodcode,quotemx[i].pcode,&
  1232. quoteID,quoteCode,quotedate,quotemx[i].sumprice_1,&
  1233. quotemx[i].rebate,quotemx[i].sumprice_1 * quotemx[i].rebate * quotemx[i].qty,2,'',&
  1234. quotemx[i].printid,2,moneyid,quotemx[i].qty,quotemx[i].qty1,False,ARG_MSG) = 0 THEN
  1235. rslt = 0
  1236. GOTO ext
  1237. END IF
  1238. NEXT
  1239. END IF
  1240. //更新审核标记
  1241. UPDATE u_quote
  1242. SET sec_auditemp = :arg_emp,
  1243. sec_auditdate = getdate(),
  1244. flag = 1
  1245. WHERE u_quote.quoteID = :arg_quoteid
  1246. AND u_quote.scid = :arg_scid
  1247. AND u_quote.flag = 4
  1248. Using commit_transaction;
  1249. IF commit_transaction.SQLCode <> 0 THEN
  1250. rslt = 0
  1251. ARG_MSG = "因网络或其它原因导致单据审核操作失败"+"~n"+commit_transaction.SQLErrText
  1252. GOTO ext
  1253. END IF
  1254. it_newbegin = False
  1255. it_updatebegin = False
  1256. ext:
  1257. IF rslt = 0 THEN
  1258. ROLLBACK Using commit_transaction;
  1259. ELSEIF arg_ifcommit THEN
  1260. COMMIT Using commit_transaction;
  1261. END IF
  1262. p_reset()
  1263. Return (rslt)
  1264. end function
  1265. public function integer cancelsecaudit (long arg_scid, long arg_quoteid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1,cnt = 0
  1266. Long i
  1267. DateTime ls_auditingdate
  1268. SetNull(ls_auditingdate)
  1269. uo_cusprice uo_update_cusprice
  1270. uo_update_cusprice = Create uo_cusprice
  1271. IF arg_quoteid <= 0 THEN
  1272. rslt = 0
  1273. ARG_MSG = '错误报价单唯一码'
  1274. GOTO ext
  1275. END IF
  1276. IF getinfo(arg_scid,arg_quoteid,ARG_MSG) = 0 THEN
  1277. rslt = 0
  1278. GOTO ext
  1279. END IF
  1280. IF flag <> 1 THEN
  1281. rslt = 0
  1282. ARG_MSG = "报价只有在已审核状态才可以执行撤销终审,请核对"
  1283. GOTO ext
  1284. END IF
  1285. UPDATE u_quote
  1286. SET flag = 4,
  1287. sec_auditemp = '',
  1288. sec_auditdate = :ls_auditingdate
  1289. WHERE u_quote.quoteid = :arg_quoteid
  1290. AND u_quote.scid = :arg_scid
  1291. AND u_quote.flag = 1
  1292. Using commit_transaction ;
  1293. IF commit_transaction.SQLCode <> 0 THEN
  1294. rslt = 0
  1295. ARG_MSG = "因网络或其它原因导致报价单撤消审核操作失败"+"~n"+commit_transaction.SQLErrText
  1296. GOTO ext
  1297. END IF
  1298. //删除旧有物料需求记录
  1299. DELETE FROM u_quoterqmtrl
  1300. WHERE u_quoterqmtrl.quoteid = :arg_quoteid
  1301. And u_quoterqmtrl.scid = :arg_scid;
  1302. IF sqlca.SQLCode <> 0 THEN
  1303. ROLLBACK;
  1304. ARG_MSG = '删除旧有物料需求记录失败 '+sqlca.SQLErrText
  1305. rslt = 0
  1306. GOTO ext
  1307. END IF
  1308. IF billtype = 0 THEN
  1309. FOR i = 1 To it_mxbt
  1310. IF uo_update_cusprice.uof_del_cusprice_auto(custid,quoteid,&
  1311. quotemx[i].printid,quotemx[i].mtrlid,quotemx[i].status,&
  1312. quotemx[i].woodcode,quotemx[i].pcode,&
  1313. 2,moneyid,quotemx[i].qty,quotemx[i].qty1,False,ARG_MSG) = 0 THEN
  1314. rslt = 0
  1315. GOTO ext
  1316. END IF
  1317. NEXT
  1318. END IF
  1319. it_newbegin = False
  1320. it_updatebegin = False
  1321. ext:
  1322. IF rslt = 0 THEN
  1323. ROLLBACK Using commit_transaction;
  1324. ELSEIF arg_ifcommit THEN
  1325. COMMIT Using commit_transaction;
  1326. END IF
  1327. Destroy uo_update_cusprice
  1328. p_reset()
  1329. Return (rslt)
  1330. end function
  1331. 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
  1332. Int li_bill_flag,li_mx_flag,li_mx_stopflag
  1333. DateTime null_dt
  1334. SetNull(null_dt)
  1335. SELECT flag INTO :li_bill_flag
  1336. FROM u_quote
  1337. WHERE scid = :arg_scid
  1338. And quoteid = :arg_quoteid Using commit_transaction;
  1339. IF commit_transaction.SQLCode <> 0 THEN
  1340. arg_msg = '查询报价单审核标记失败,'+commit_transaction.SQLErrText
  1341. rslt = 0
  1342. GOTO ext
  1343. END IF
  1344. IF li_bill_flag = 0 THEN
  1345. IF arg_flag = 1 THEN
  1346. arg_msg = '报价单还未审核,不能明细终止'
  1347. ELSE
  1348. arg_msg = '报价单还未审核,不能明细终止'
  1349. END IF
  1350. rslt = 0
  1351. GOTO ext
  1352. END IF
  1353. SELECT flag,stopflag INTO :li_mx_flag,:li_mx_stopflag
  1354. FROM u_quotemx
  1355. WHERE scid = :arg_scid
  1356. AND quoteid = :arg_quoteid
  1357. And printid = :arg_printid Using commit_transaction;
  1358. IF commit_transaction.SQLCode <> 0 THEN
  1359. arg_msg = '查询明细审核标记失败,'+commit_transaction.SQLErrText
  1360. rslt = 0
  1361. GOTO ext
  1362. END IF
  1363. IF li_mx_flag = 0 THEN
  1364. arg_msg = '明细未审核,不能终止操作'
  1365. rslt = 0
  1366. GOTO ext
  1367. END IF
  1368. IF arg_flag = 1 THEN
  1369. IF li_mx_stopflag = 1 THEN
  1370. arg_msg = '明细已终止不能再终止'
  1371. rslt = 0
  1372. GOTO ext
  1373. END IF
  1374. ELSE
  1375. IF li_mx_stopflag = 0 THEN
  1376. arg_msg = '明细还未终止不能取消终止操作'
  1377. rslt = 0
  1378. GOTO ext
  1379. END IF
  1380. END IF
  1381. IF arg_flag = 1 THEN
  1382. UPDATE u_quotemx SET
  1383. stopflag = 1,
  1384. stopemp = :arg_opemp,
  1385. stopdate = getdate()
  1386. WHERE scid = :arg_scid
  1387. AND quoteid = :arg_quoteid
  1388. And printid = :arg_printid Using commit_transaction;
  1389. IF commit_transaction.SQLCode <> 0 THEN
  1390. arg_msg = '终止明细失败,'+commit_transaction.SQLErrText
  1391. rslt = 0
  1392. GOTO ext
  1393. END IF
  1394. ELSE
  1395. UPDATE u_quotemx SET
  1396. stopflag = 0,
  1397. stopemp = '',
  1398. stopdate = :null_dt
  1399. WHERE scid = :arg_scid
  1400. AND quoteid = :arg_quoteid
  1401. And printid = :arg_printid Using commit_transaction;
  1402. IF commit_transaction.SQLCode <> 0 THEN
  1403. arg_msg = '取消终止明细失败,'+commit_transaction.SQLErrText
  1404. rslt = 0
  1405. GOTO ext
  1406. END IF
  1407. END IF
  1408. ext:
  1409. IF rslt = 0 THEN
  1410. ROLLBACK Using commit_transaction;
  1411. ELSEIF rslt = 1 And arg_ifcommit THEN
  1412. COMMIT Using commit_transaction;
  1413. END IF
  1414. RETURN rslt
  1415. end function
  1416. 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, decimal arg_paintarea, decimal arg_commonqty, decimal arg_customqty, string arg_pfcode, s_quote_rqmtrl arg_rqmtrl, s_quote_workprice arg_workprice, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  1417. Int li_flag
  1418. Long cnt,ll_mtrlid,ll_i
  1419. Int li_billtype
  1420. SELECT flag,mtrlid INTO :li_flag,:ll_mtrlid
  1421. FROM u_quotemx
  1422. WHERE scid = :arg_scid
  1423. AND quoteid = :arg_quoteid
  1424. And printid = :arg_printid Using commit_transaction;
  1425. IF commit_transaction.SQLCode <> 0 THEN
  1426. arg_msg = '查询明细审核标记失败,'+commit_transaction.SQLErrText
  1427. rslt = 0
  1428. GOTO ext
  1429. END IF
  1430. IF li_flag = 1 THEN
  1431. arg_msg = '明细已审核不能修改'
  1432. rslt = 0
  1433. GOTO ext
  1434. END IF
  1435. SELECT billtype INTO :li_billtype
  1436. FROM u_quote
  1437. WHERE scid = :arg_scid
  1438. And quoteid = :arg_quoteid Using commit_transaction;
  1439. IF commit_transaction.SQLCode <> 0 THEN
  1440. arg_msg = '查询单据类型失败,'+commit_transaction.SQLErrText
  1441. rslt = 0
  1442. GOTO ext
  1443. END IF
  1444. IF li_billtype = 0 THEN
  1445. SELECT count(*) INTO :cnt
  1446. FROM u_mtrl_pf
  1447. WHERE mtrlid = :ll_mtrlid
  1448. And pfcode = :arg_pfcode Using commit_transaction;
  1449. IF commit_transaction.SQLCode <> 0 THEN
  1450. arg_msg = '查询明细物料清单资料失败,'+commit_transaction.SQLErrText
  1451. rslt = 0
  1452. GOTO ext
  1453. END IF
  1454. IF cnt = 0 THEN
  1455. arg_msg = '明细物料不存在清单:'+arg_pfcode
  1456. rslt = 0
  1457. GOTO ext
  1458. END IF
  1459. END IF
  1460. DELETE FROM u_quoterqmtrl
  1461. WHERE scid = :arg_scid
  1462. AND quoteid = :arg_quoteid
  1463. And printid = :arg_printid Using commit_transaction;
  1464. IF commit_transaction.SQLCode <> 0 THEN
  1465. arg_msg = '删除报价明细物料成本明细失败,'+commit_transaction.SQLErrText
  1466. rslt = 0
  1467. GOTO ext
  1468. END IF
  1469. IF UpperBound(arg_rqmtrl.mtrlid) > 0 THEN
  1470. FOR ll_i = 1 To UpperBound(arg_rqmtrl.mtrlid)
  1471. INSERT INTO u_quoterqmtrl
  1472. (scid,
  1473. quoteid,
  1474. printid,
  1475. pid,
  1476. MtrlID,
  1477. RqQty,
  1478. newprice,
  1479. planprice,
  1480. lp,
  1481. pmtrlid,
  1482. status,
  1483. woodcode,
  1484. pcode,
  1485. pfgroup,
  1486. pfgroupqty,
  1487. pfgroupmode,
  1488. sonscale,
  1489. sonloss,
  1490. promode,
  1491. klmode,
  1492. klarea)
  1493. VALUES
  1494. (:arg_scid,
  1495. :arg_quoteid,
  1496. :arg_printid,
  1497. :arg_rqmtrl.printid[ll_i],
  1498. :arg_rqmtrl.mtrlid[ll_i],
  1499. :arg_rqmtrl.RqQty[ll_i],
  1500. :arg_rqmtrl.newprice[ll_i],
  1501. :arg_rqmtrl.planprice[ll_i],
  1502. :arg_rqmtrl.lp[ll_i],
  1503. :arg_rqmtrl.pmtrlid[ll_i],
  1504. :arg_rqmtrl.status[ll_i],
  1505. :arg_rqmtrl.woodcode[ll_i],
  1506. :arg_rqmtrl.pcode[ll_i],
  1507. :arg_rqmtrl.pfgroup[ll_i],
  1508. :arg_rqmtrl.pfgroupqty[ll_i],
  1509. :arg_rqmtrl.pfgroupmode[ll_i],
  1510. :arg_rqmtrl.sonscale[ll_i],
  1511. :arg_rqmtrl.sonloss[ll_i],
  1512. :arg_rqmtrl.promode[ll_i],
  1513. :arg_rqmtrl.klmode[ll_i],
  1514. :arg_rqmtrl.klarea[ll_i]) Using commit_transaction;
  1515. IF commit_transaction.SQLCode <> 0 THEN
  1516. arg_msg = '建立报价明细物料成本明细失败,'+commit_transaction.SQLErrText
  1517. rslt = 0
  1518. GOTO ext
  1519. END IF
  1520. NEXT
  1521. END IF
  1522. DELETE FROM u_quoteworkprice
  1523. WHERE scid = :arg_scid
  1524. AND quoteid = :arg_quoteid
  1525. And printid = :arg_printid Using commit_transaction;
  1526. IF commit_transaction.SQLCode <> 0 THEN
  1527. arg_msg = '删除报价明细工价信息明细失败,'+commit_transaction.SQLErrText
  1528. rslt = 0
  1529. GOTO ext
  1530. END IF
  1531. IF UpperBound(arg_workprice.mtrlid) > 0 THEN
  1532. FOR ll_i = 1 To UpperBound(arg_workprice.mtrlid)
  1533. INSERT INTO u_quoteworkprice
  1534. (scid,
  1535. quoteid,
  1536. printid,
  1537. pid,
  1538. MtrlID,
  1539. proid,
  1540. proorder,
  1541. procode,
  1542. proname,
  1543. wrkgrpid,
  1544. workprice,
  1545. workqty,
  1546. dscrp)
  1547. VALUES
  1548. (:arg_scid,
  1549. :arg_quoteid,
  1550. :arg_printid,
  1551. :arg_workprice.pid[ll_i],
  1552. :arg_workprice.mtrlid[ll_i],
  1553. :arg_workprice.proid[ll_i],
  1554. :arg_workprice.proorder[ll_i],
  1555. :arg_workprice.procode[ll_i],
  1556. :arg_workprice.proname[ll_i],
  1557. :arg_workprice.wrkgrpid[ll_i],
  1558. :arg_workprice.workprice[ll_i],
  1559. :arg_workprice.workqty[ll_i],
  1560. :arg_workprice.dscrp[ll_i]) Using commit_transaction;
  1561. IF commit_transaction.SQLCode <> 0 THEN
  1562. arg_msg = '建立报价明细工价信息明细失败,'+commit_transaction.SQLErrText
  1563. rslt = 0
  1564. GOTO ext
  1565. END IF
  1566. NEXT
  1567. END IF
  1568. UPDATE u_quotemx SET
  1569. sumprice = :arg_sumprice,
  1570. sumprice_1 = :arg_sumprice_1,
  1571. profit_margin = :arg_profit_margin,
  1572. mtrlcost = :arg_mtrlcost,
  1573. mancost = :arg_mancost,
  1574. outcost = :arg_outcost,
  1575. wfjgprice = :arg_wfjgprice,
  1576. pfcode = :arg_pfcode,
  1577. paintarea = :arg_paintarea,
  1578. commonqty = :arg_commonqty,
  1579. customqty = :arg_customqty
  1580. WHERE scid = :arg_scid
  1581. AND quoteid = :arg_quoteid
  1582. And printid = :arg_printid Using commit_transaction;
  1583. IF commit_transaction.SQLCode <> 0 THEN
  1584. arg_msg = '更新明细资料失败,'+commit_transaction.SQLErrText
  1585. rslt = 0
  1586. GOTO ext
  1587. END IF
  1588. ext:
  1589. IF rslt = 0 THEN
  1590. ROLLBACK Using commit_transaction;
  1591. ELSEIF rslt = 1 And arg_ifcommit THEN
  1592. COMMIT Using commit_transaction;
  1593. END IF
  1594. RETURN rslt
  1595. end function
  1596. 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, string arg_dscrp_text, string arg_mxdscrp2, decimal arg_paintarea, decimal arg_commonqty, decimal arg_customqty, decimal arg_taxrate);Long rslt = 1,cnt = 0,LS_i
  1597. Decimal ld_newprice,ld_planprice
  1598. Int li_statusflag,li_woodcodeflag,li_pcodeflag
  1599. String ls_pfcode
  1600. Int li_status_check,li_woodcode_check,li_pcode_check
  1601. IF uo_option_change_status = '-1000' THEN
  1602. rslt = 0
  1603. arg_msg = '选项:[029]配置标题文本,读取初始默认值失败,操作取消!'
  1604. GOTO ext
  1605. END IF
  1606. IF uo_option_change_woodcode = '-1000' THEN
  1607. rslt = 0
  1608. arg_msg = '选项:[027]配置1标题文本,读取初始默认值失败,操作取消!'
  1609. GOTO ext
  1610. END IF
  1611. IF uo_option_change_pcode = '-1000' THEN
  1612. rslt = 0
  1613. arg_msg = '选项:[028]配置2标题文本,读取初始默认值失败,操作取消!'
  1614. GOTO ext
  1615. END IF
  1616. IF it_newbegin = False And it_updatebegin = False THEN
  1617. rslt = 0
  1618. arg_msg = "非编辑状态不可以使用,操作取消"
  1619. GOTO ext
  1620. END IF
  1621. //清除空值
  1622. IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
  1623. IF IsNull(arg_sumprice) THEN arg_sumprice = 0
  1624. IF IsNull(arg_sumprice_1) THEN arg_sumprice_1 = 0
  1625. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  1626. IF IsNull(arg_printid) THEN arg_printid = 0
  1627. IF IsNull(arg_mtrlcode) THEN arg_mtrlcode = ''
  1628. IF IsNull(arg_status) THEN arg_status = ''
  1629. IF IsNull(arg_woodcode) THEN arg_woodcode = ''
  1630. IF IsNull(arg_pcode) THEN arg_pcode = ''
  1631. IF IsNull(arg_qty) THEN arg_qty = 0
  1632. IF IsNull(arg_qty1) THEN arg_qty1 = 0
  1633. IF IsNull(arg_rebate) THEN arg_rebate = 1
  1634. IF IsNull(arg_mxdscrp2) THEN arg_mxdscrp2 = ''
  1635. IF IsNull(arg_paintarea) THEN arg_paintarea = 0
  1636. IF IsNull(arg_commonqty) THEN arg_commonqty = 0
  1637. IF IsNull(arg_customqty) THEN arg_customqty = 0
  1638. IF IsNull(arg_taxrate) THEN arg_taxrate = 0
  1639. arg_status = Trim(arg_status)
  1640. arg_woodcode = Trim(arg_woodcode)
  1641. arg_pcode = Trim(arg_pcode)
  1642. IF billtype = 0 THEN
  1643. IF arg_mtrlid = 0 THEN // 如果物料编号为空,则不作任何处理
  1644. rslt = 1
  1645. GOTO ext
  1646. END IF
  1647. END IF
  1648. IF arg_printid = 0 THEN // 如果序号为空,则不作任何处理
  1649. rslt = 1
  1650. GOTO ext
  1651. END IF
  1652. IF billtype = 0 THEN
  1653. SELECT planprice,
  1654. statusflag,
  1655. woodcodeflag,
  1656. pcodeflag,
  1657. status_check,
  1658. woodcode_check,
  1659. pcode_check
  1660. INTO :ld_planprice,
  1661. :li_statusflag,
  1662. :li_woodcodeflag,
  1663. :li_pcodeflag,
  1664. :li_status_check,
  1665. :li_woodcode_check,
  1666. :li_pcode_check
  1667. FROM u_mtrldef
  1668. Where u_mtrldef.mtrlid = :arg_mtrlid ;
  1669. IF sqlca.SQLCode <> 0 THEN
  1670. rslt = 0
  1671. arg_msg = '行:'+String(arg_printid)+",查询物料:"+arg_mtrlcode+'计划价失败'
  1672. GOTO ext
  1673. END IF
  1674. IF li_statusflag = 2 THEN
  1675. IF arg_status = '' THEN
  1676. arg_msg = '行:'+String(arg_printid)+',物料'+uo_option_change_status + '字段使用组合配置,请输入'
  1677. rslt = 0
  1678. GOTO ext
  1679. END IF
  1680. ELSEIF li_statusflag = 4 And li_status_check = 1 THEN
  1681. IF arg_status = '' THEN
  1682. arg_msg = '行:'+String(arg_printid)+',物料'+uo_option_change_woodcode + '字段使用部件选配,请输入'
  1683. rslt = 0
  1684. GOTO ext
  1685. END IF
  1686. END IF
  1687. IF li_woodcodeflag = 4 And li_woodcode_check = 1 THEN
  1688. IF arg_woodcode = '' THEN
  1689. arg_msg = '行:'+String(arg_printid)+',物料'+uo_option_change_woodcode + '字段使用部件选配,请输入'
  1690. rslt = 0
  1691. GOTO ext
  1692. END IF
  1693. END IF
  1694. IF li_pcodeflag = 4 And li_pcode_check = 1 THEN
  1695. IF arg_pcode = '' THEN
  1696. arg_msg = '行:'+String(arg_printid)+',物料'+uo_option_change_pcode + '字段使用部件选配,请输入'
  1697. rslt = 0
  1698. GOTO ext
  1699. END IF
  1700. END IF
  1701. SELECT price
  1702. INTO :ld_newprice
  1703. FROM v_maxprice_cusprice
  1704. Where mtrlid = :arg_mtrlid;
  1705. IF sqlca.SQLCode <> 0 Or IsNull(ld_newprice) THEN ld_newprice = 0
  1706. ls_pfcode = f_get_dft_pf(arg_mtrlid)
  1707. END IF
  1708. FOR LS_i = 1 To it_mxbt //合并重复项(产品)
  1709. IF quotemx[LS_i].mtrlid = arg_mtrlid And &
  1710. quotemx[LS_i].mtrlcode = arg_mtrlcode And &
  1711. quotemx[LS_i].status = arg_status And &
  1712. quotemx[LS_i].woodcode = arg_woodcode And &
  1713. quotemx[LS_i].pcode = arg_pcode And &
  1714. quotemx[LS_i].qty = arg_qty And &
  1715. quotemx[LS_i].qty1 = arg_qty1 THEN
  1716. rslt = 0
  1717. arg_msg = "存在相同的产品,在"+quotemx[LS_i].mtrlcode+",请自行手动合并"
  1718. GOTO ext
  1719. END IF
  1720. NEXT
  1721. //写入内容
  1722. it_mxbt++
  1723. quotemx[it_mxbt].mtrlid = arg_mtrlid
  1724. quotemx[it_mxbt].mtrlcode = arg_mtrlcode
  1725. quotemx[it_mxbt].maxprice = ld_newprice
  1726. quotemx[it_mxbt].planprice = ld_planprice
  1727. quotemx[it_mxbt].mxdscrp = arg_mxdscrp
  1728. quotemx[it_mxbt].printid = arg_printid
  1729. quotemx[it_mxbt].sumprice = arg_sumprice
  1730. quotemx[it_mxbt].sumprice_1 = arg_sumprice_1
  1731. quotemx[it_mxbt].pfcode = ls_pfcode
  1732. quotemx[it_mxbt].status = arg_status
  1733. quotemx[it_mxbt].woodcode = arg_woodcode
  1734. quotemx[it_mxbt].pcode = arg_pcode
  1735. quotemx[it_mxbt].maxprice = arg_maxprice
  1736. quotemx[it_mxbt].planprice = arg_planprice
  1737. quotemx[it_mxbt].profit_margin = arg_profit_margin
  1738. quotemx[it_mxbt].wfjgprice = arg_wfjgprice
  1739. quotemx[it_mxbt].outcost = arg_outcost
  1740. quotemx[it_mxbt].mancost = arg_mancost
  1741. quotemx[it_mxbt].mtrlcost = arg_mtrlcost
  1742. quotemx[it_mxbt].qty = arg_qty
  1743. quotemx[it_mxbt].qty1 = arg_qty1
  1744. quotemx[it_mxbt].rebate = arg_rebate
  1745. quotemx[it_mxbt].dscrp_text = arg_dscrp_text
  1746. quotemx[it_mxbt].unit = arg_unit
  1747. quotemx[it_mxbt].mtrlname = arg_mtrlname
  1748. quotemx[it_mxbt].mtrlmode = arg_mtrlmode
  1749. quotemx[it_mxbt].mxdscrp2 = arg_mxdscrp2
  1750. quotemx[it_mxbt].paintarea = arg_paintarea
  1751. quotemx[it_mxbt].commonqty = arg_commonqty
  1752. quotemx[it_mxbt].customqty = arg_customqty
  1753. quotemx[it_mxbt].taxrate = arg_taxrate
  1754. quotemx[it_mxbt].fprice = arg_sumprice * mrate
  1755. ext:
  1756. IF rslt = 0 THEN p_clearmx()
  1757. Return(rslt)
  1758. end function
  1759. on uo_quote.create
  1760. call super::create
  1761. TriggerEvent( this, "constructor" )
  1762. end on
  1763. on uo_quote.destroy
  1764. TriggerEvent( this, "destructor" )
  1765. call super::destroy
  1766. end on
  1767. event constructor;String str_optionvalue,arg_msg
  1768. f_get_sys_option_value('029',str_optionvalue,arg_msg)
  1769. uo_option_change_status = str_optionvalue
  1770. f_get_sys_option_value('027',str_optionvalue,arg_msg)
  1771. uo_option_change_woodcode = str_optionvalue
  1772. f_get_sys_option_value('028',str_optionvalue,arg_msg)
  1773. uo_option_change_pcode = str_optionvalue
  1774. f_get_sys_option_value('235',str_optionvalue,arg_msg)
  1775. uo_option_if_oa_quote = long(str_optionvalue)
  1776. f_get_sys_option_value('236',str_optionvalue,arg_msg)
  1777. uo_option_quote_secaudit = long(str_optionvalue)
  1778. end event
  1779. global type uo_incase from nonvisualobject
  1780. end type