uo_spt_price_change.sru 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292
  1. $PBExportHeader$uo_spt_price_change.sru
  2. forward
  3. global type uo_spt_price_change from nonvisualobject
  4. end type
  5. type s_spt_price_changemx2 from structure within uo_spt_price_change
  6. end type
  7. end forward
  8. type s_spt_price_changemx2 from structure
  9. long mtrlid
  10. string status
  11. decimal { 10 } rate
  12. decimal { 10 } price
  13. decimal { 10 } wareprice
  14. decimal { 5 } lastprice
  15. decimal { 5 } qty
  16. decimal { 5 } qty1
  17. string dscrp
  18. long sptid
  19. long printid
  20. long printid1
  21. string mtrlcode
  22. string unit
  23. string sptmtrlname
  24. datetime lastdate
  25. datetime effdate
  26. string woodcode
  27. string pcode
  28. string jgdscrp
  29. integer hisflag
  30. integer taskflag
  31. integer wareflag
  32. datetime sdate
  33. datetime edate
  34. end type
  35. global type uo_spt_price_change from nonvisualobject
  36. end type
  37. global uo_spt_price_change uo_spt_price_change
  38. type variables
  39. public protectedwrite long billid
  40. public protectedwrite string billcode
  41. public protectedwrite datetime opdate
  42. public protectedwrite string opemp
  43. public protectedwrite datetime moddate
  44. public protectedwrite string modemp
  45. public protectedwrite int flag=0
  46. public protectedwrite datetime auditingdate
  47. public protectedwrite string auditingrep
  48. long mtrlid
  49. datetime billdate
  50. long sptid
  51. string dscrp
  52. string inrep
  53. int billtype
  54. long moneyid
  55. Transaction commit_transaction //数据commit事务
  56. long relbillid
  57. int ifauto
  58. int autobuild = 0 //是否自动操作
  59. private:
  60. boolean it_newbegin=false //新建标志
  61. boolean it_updatebegin=false//修改标志
  62. Boolean if_getid_ture = TRUE
  63. s_spt_price_changemx changemx[] //明细结构数组
  64. s_spt_price_changemx2 changemx2[] //明细结构数组
  65. Long it_mxbt = 0 //明细结构数组末指针
  66. Long it_mxbt2 = 0 //明细结构数组末指针
  67. s_mtrl_price_changemx changemx3[] //明细结构数组
  68. s_mtrl_price_changemx2 changemx4[] //明细结构数组
  69. Long it_mxbt3 = 0 //明细结构数组末指针
  70. Long it_mxbt4 = 0 //明细结构数组末指针
  71. uo_spt_price uo_price
  72. end variables
  73. forward prototypes
  74. public function integer p_reset ()
  75. public function integer updatebegin (long arg_billid, ref string arg_msg)
  76. public function integer save (ref string arg_msg, boolean arg_ifcommit)
  77. public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg)
  78. public function integer newbegin ()
  79. public function integer p_clearmx ()
  80. public function integer getinfo (long arg_billid, ref string arg_msg)
  81. public function integer p_getinfo (long arg_billid, ref string arg_msg)
  82. public function integer del (long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  83. public function integer auditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  84. public function integer c_auditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  85. public function integer first_audit (long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  86. public function integer first_caudit (long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  87. public function integer acceptmx2 (long arg_printid, long arg_printid1, long arg_mtrlid, string arg_mtrlcode, string arg_unit, decimal arg_price, decimal arg_rate, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, string arg_sptmtrlname, string arg_dscrp, datetime arg_effdate, decimal arg_qty, decimal arg_qty1, ref string arg_msg)
  88. public function integer uof_create_change (long arg_billid, ref string arg_msg)
  89. public function integer uof_destroy_change (long arg_billid, ref string arg_msg)
  90. public function integer acceptmx3 (s_mtrl_price_changemx arg_s_mx, ref string arg_msg)
  91. public function integer acceptmx4 (s_mtrl_price_changemx2 arg_s_mx, ref string arg_msg)
  92. public function integer uof_update_ware (ref string arg_msg, boolean arg_ifcommit)
  93. public function integer uof_update_task (ref string arg_msg, boolean arg_ifcommit)
  94. public function integer acceptmx (long arg_printid, long arg_mtrlid, string arg_mtrlcode, string arg_unit, decimal arg_enprice, decimal arg_rebate, decimal arg_rate, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, string arg_sptmtrlname, string arg_dscrp, datetime arg_effdate, datetime arg_effdate_end, decimal arg_qty, decimal arg_qty1, integer arg_hisflag, integer arg_taskflag, integer arg_wareflag, datetime arg_sdate, datetime arg_edate, ref string arg_msg)
  95. public function integer acceptmx (s_spt_price_changemx s_mx, ref string arg_msg)
  96. end prototypes
  97. public function integer p_reset ();//INT p_RESET()
  98. //清除对象及其明细
  99. billid = 0
  100. billcode = ''
  101. flag = 0
  102. inrep = ''
  103. sptid = 0
  104. billtype = 0
  105. dscrp = ''
  106. moneyid = 0
  107. it_newbegin = FALSE
  108. it_updatebegin = FALSE
  109. p_clearmx( )
  110. RETURN 1
  111. end function
  112. public function integer updatebegin (long arg_billid, ref string arg_msg);Int rslt = 1
  113. IF arg_billid <= 0 THEN
  114. billid = 0
  115. arg_msg = '错误的单据ID'
  116. GOTO ext
  117. END IF
  118. rslt = p_getinfo(arg_billid,arg_msg)
  119. IF rslt = 0 THEN GOTO ext
  120. IF flag = 1 THEN
  121. rslt = 0
  122. arg_msg = '单据已经审核,不可以修改'
  123. GOTO ext
  124. END IF
  125. billid = arg_billid
  126. it_newbegin = FALSE
  127. it_updatebegin = TRUE
  128. p_clearmx() //清除明细
  129. ext:
  130. IF rslt = 0 THEN p_reset()
  131. RETURN rslt
  132. end function
  133. public function integer save (ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1,cnt = 0,i
  134. DateTime server_dt
  135. Long ls_newid
  136. IF IsNull(sptid) THEN sptid = 0
  137. IF IsNull(dscrp) THEN dscrp = ''
  138. IF IsNull(inrep) THEN inrep = ''
  139. IF IsNull(moneyid) THEN moneyid = 0
  140. IF IsNull(relbillid) THEN relbillid = 0
  141. IF it_newbegin = False And it_updatebegin = False THEN
  142. rslt = 0
  143. arg_msg = "非编辑状态不可以提交"
  144. GOTO ext
  145. END IF
  146. IF billtype <> 1 And billtype <> 2 And billtype <> 3 THEN
  147. arg_msg = '错误的单据类型,1-调价单,2-报价单,3-纸板询价单'
  148. rslt = 0
  149. GOTO ext
  150. END IF
  151. cnt = 0
  152. SELECT count(*) INTO :cnt
  153. FROM cw_currency
  154. Where moneyid = :moneyid;
  155. IF sqlca.SQLCode <> 0 THEN
  156. arg_msg = '查询币种失败'
  157. rslt = 0
  158. GOTO ext
  159. END IF
  160. IF cnt = 0 THEN
  161. arg_msg = '币种资料不存在'
  162. rslt = 0
  163. GOTO ext
  164. END IF
  165. cnt = 0
  166. SELECT count(*) INTO :cnt
  167. FROM u_spt
  168. Where sptid = :sptid;
  169. IF sqlca.SQLCode <> 0 THEN
  170. arg_msg = '查询供应商资料失败'
  171. rslt = 0
  172. GOTO ext
  173. END IF
  174. IF cnt > 1 THEN
  175. arg_msg = '供应商资料重复'
  176. rslt = 0
  177. GOTO ext
  178. END IF
  179. IF inrep = '' THEN
  180. arg_msg = '请选择经手人'
  181. rslt = 0
  182. GOTO ext
  183. END IF
  184. IF it_mxbt = 0 THEN
  185. arg_msg = '没有正确的明细内容'
  186. rslt = 0
  187. GOTO ext
  188. END IF
  189. SELECT Top 1 getdate() Into :server_dt From u_user;
  190. //取得系统时间,借用操作员表
  191. IF sqlca.SQLCode <> 0 THEN
  192. rslt = 0
  193. arg_msg = "查询操作失败,日期 "
  194. GOTO ext
  195. END IF
  196. IF Year(Date(billdate)) < 2000 Or IsNull(billdate) THEN
  197. rslt = 0
  198. arg_msg = "时间不合理"
  199. GOTO ext
  200. END IF
  201. IF billid = 0 THEN //新建
  202. ls_newid = f_sys_scidentity(0,"u_spt_price_change","billid",arg_msg,True,id_sqlca)
  203. IF ls_newid <= 0 THEN
  204. rslt = 0
  205. GOTO ext
  206. END IF
  207. billcode = getid(0,"SP",Date(server_dt),False,sqlca) //取得新单据编号
  208. IF billcode = "err" THEN
  209. billcode = ''
  210. rslt = 0
  211. arg_msg = "无法获取单据编号"
  212. GOTO ext
  213. END IF
  214. INSERT INTO u_spt_price_change
  215. (billid,
  216. billcode,
  217. billdate,
  218. sptid,
  219. dscrp,
  220. opemp,
  221. opdate,
  222. inrep,
  223. billtype,
  224. moneyid,
  225. ifauto,
  226. relbillid)
  227. VALUES (
  228. :ls_newid,
  229. :billcode,
  230. :billdate,
  231. :sptid,
  232. :dscrp,
  233. :publ_operator,
  234. :server_dt,
  235. :inrep,
  236. :billtype,
  237. :moneyid,
  238. :ifauto,
  239. :relbillid) Using commit_transaction;
  240. IF commit_transaction.SQLCode <> 0 THEN
  241. rslt = 0
  242. arg_msg = "因网络或其它原因导致插入操作失败>>"+"~n"+sqlca.SQLErrText
  243. GOTO ext
  244. END IF
  245. billid = ls_newid
  246. ELSE //////////////////////////////////////////////// //更新
  247. UPDATE u_spt_price_change
  248. SET billdate = :billdate,
  249. sptid = :sptid,
  250. moddate = :server_dt,
  251. modemp = :publ_operator,
  252. dscrp = :dscrp,
  253. inrep = :inrep,
  254. billtype = :billtype,
  255. moneyid = :moneyid,
  256. relbillid = :relbillid
  257. WHERE billid = :billid
  258. And flag = 0 Using commit_transaction;
  259. IF sqlca.SQLCode <> 0 Or sqlca.SQLNRows <= 0 THEN
  260. rslt = 0
  261. arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+commit_transaction.SQLErrText
  262. GOTO ext
  263. END IF
  264. //删除原有明细
  265. DELETE FROM u_spt_price_changemx
  266. WHERE u_spt_price_changemx.billid = :billid
  267. Using commit_transaction;
  268. IF commit_transaction.SQLCode <> 0 THEN
  269. rslt = 0
  270. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  271. GOTO ext
  272. END IF
  273. //删除原有明细2
  274. DELETE FROM u_spt_price_changemx2
  275. WHERE u_spt_price_changemx2.billid = :billid
  276. Using commit_transaction;
  277. IF commit_transaction.SQLCode <> 0 THEN
  278. rslt = 0
  279. arg_msg = "删除旧有明细2操作失败"+"~n"+commit_transaction.SQLErrText
  280. GOTO ext
  281. END IF
  282. //删除原有明细3
  283. DELETE FROM u_mtrl_price_changemx
  284. WHERE billid = :billid
  285. Using commit_transaction;
  286. IF commit_transaction.SQLCode <> 0 THEN
  287. rslt = 0
  288. arg_msg = "删除旧有明细3操作失败"+"~n"+commit_transaction.SQLErrText
  289. GOTO ext
  290. END IF
  291. //删除原有明细4
  292. DELETE FROM u_mtrl_price_changemx2
  293. WHERE billid = :billid
  294. Using commit_transaction;
  295. IF commit_transaction.SQLCode <> 0 THEN
  296. rslt = 0
  297. arg_msg = "删除旧有明细4操作失败"+"~n"+commit_transaction.SQLErrText
  298. GOTO ext
  299. END IF
  300. END IF
  301. FOR i = 1 To it_mxbt
  302. INSERT INTO u_spt_price_changemx
  303. (
  304. billid,
  305. mtrlid,
  306. unit,
  307. enprice,
  308. price,
  309. rebate,
  310. status,
  311. woodcode,
  312. pcode,
  313. jgdscrp,
  314. lastprice,
  315. wareprice,
  316. rate,
  317. sptmtrlname,
  318. Dscrp,
  319. printid,
  320. lastdate,
  321. effdate,
  322. effdate_end,
  323. qty,
  324. qty1,
  325. hisflag,
  326. taskflag,
  327. wareflag,
  328. sdate,
  329. edate,
  330. buybargainid,
  331. buybargainprintid,
  332. buybargaincode)
  333. VALUES
  334. (
  335. :billid,
  336. :changemx[i].mtrlid,
  337. :changemx[i].unit,
  338. :changemx[i].enprice,
  339. :changemx[i].price,
  340. :changemx[i].rebate,
  341. :changemx[i].status,
  342. :changemx[i].woodcode,
  343. :changemx[i].pcode,
  344. :changemx[i].jgdscrp,
  345. :changemx[i].lastprice,
  346. :changemx[i].wareprice,
  347. :changemx[i].rate,
  348. :changemx[i].sptmtrlname,
  349. :changemx[i].Dscrp,
  350. :changemx[i].printid,
  351. :changemx[i].lastdate,
  352. :changemx[i].effdate,
  353. :changemx[i].effdate_end,
  354. :changemx[i].qty,
  355. :changemx[i].qty1,
  356. :changemx[i].hisflag,
  357. :changemx[i].taskflag,
  358. :changemx[i].wareflag,
  359. :changemx[i].sdate,
  360. :changemx[i].edate,
  361. :changemx[i].buybargainid,
  362. :changemx[i].buybargainprintid ,
  363. :changemx[i].buybargaincode
  364. ) Using commit_transaction ;
  365. IF commit_transaction.SQLCode <> 0 THEN
  366. IF it_newbegin THEN
  367. billid = 0
  368. END IF
  369. rslt = 0
  370. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  371. GOTO ext
  372. END IF
  373. NEXT
  374. FOR i = 1 To it_mxbt2
  375. INSERT INTO u_spt_price_changemx2
  376. (
  377. billid,
  378. mtrlid,
  379. unit,
  380. price,
  381. status,
  382. woodcode,
  383. pcode,
  384. jgdscrp,
  385. lastprice,
  386. wareprice,
  387. rate,
  388. sptmtrlname,
  389. Dscrp,
  390. printid,
  391. printid1,
  392. lastdate,
  393. effdate,
  394. qty,
  395. qty1)
  396. VALUES
  397. (
  398. :billid,
  399. :changemx2[i].mtrlid,
  400. :changemx2[i].unit,
  401. :changemx2[i].price,
  402. :changemx2[i].status,
  403. :changemx2[i].woodcode,
  404. :changemx2[i].pcode,
  405. :changemx2[i].jgdscrp,
  406. :changemx2[i].lastprice,
  407. :changemx2[i].wareprice,
  408. :changemx2[i].rate,
  409. :changemx2[i].sptmtrlname,
  410. :changemx2[i].Dscrp,
  411. :changemx2[i].printid,
  412. :changemx2[i].printid1,
  413. :changemx2[i].lastdate,
  414. :changemx2[i].effdate,
  415. :changemx2[i].qty,
  416. :changemx2[i].qty1
  417. ) Using commit_transaction ;
  418. IF commit_transaction.SQLCode <> 0 THEN
  419. IF it_newbegin THEN
  420. billid = 0
  421. END IF
  422. rslt = 0
  423. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  424. GOTO ext
  425. END IF
  426. NEXT
  427. FOR i = 1 To it_mxbt3
  428. INSERT INTO u_mtrl_price_changemx
  429. (billid,
  430. printid,
  431. relid,
  432. relprintid,
  433. relcode,
  434. price,
  435. rate,
  436. unit,
  437. mxtype,
  438. dscrp,
  439. scid,
  440. printid2)
  441. VALUES (
  442. :billid,
  443. :changemx3[i].printid,
  444. :changemx3[i].relid,
  445. :changemx3[i].relprintid,
  446. :changemx3[i].relcode,
  447. :changemx3[i].price,
  448. :changemx3[i].rate,
  449. :changemx3[i].unit,
  450. :changemx3[i].mxtype,
  451. :changemx3[i].dscrp,
  452. :changemx3[i].scid,
  453. :changemx3[i].printid2);
  454. IF sqlca.SQLCode <> 0 THEN
  455. if it_newbegin then billid = 0
  456. rslt = 0
  457. arg_msg = "因网络或其它原因导致插入明细3操作失败"+"~n"+sqlca.SQLErrText
  458. GOTO ext
  459. END IF
  460. NEXT
  461. FOR i = 1 To it_mxbt4
  462. INSERT INTO u_mtrl_price_changemx2
  463. (billid,
  464. printid,
  465. relid,
  466. relprintid,
  467. relcode,
  468. price,
  469. rate,
  470. unit,
  471. mxtype,
  472. dscrp,
  473. scid,
  474. printid2)
  475. VALUES (
  476. :billid,
  477. :changemx4[i].printid,
  478. :changemx4[i].relid,
  479. :changemx4[i].relprintid,
  480. :changemx4[i].relcode,
  481. :changemx4[i].price,
  482. :changemx4[i].rate,
  483. :changemx4[i].unit,
  484. :changemx4[i].mxtype,
  485. :changemx4[i].dscrp,
  486. :changemx4[i].scid,
  487. :changemx4[i].printid2);
  488. IF sqlca.SQLCode <> 0 THEN
  489. if it_newbegin then billid = 0
  490. rslt = 0
  491. arg_msg = "因网络或其它原因导致插入明细4操作失败"+"~n"+sqlca.SQLErrText
  492. GOTO ext
  493. END IF
  494. NEXT
  495. it_newbegin = False
  496. it_updatebegin = False
  497. ext:
  498. IF rslt = 0 THEN
  499. ROLLBACK Using commit_transaction ;
  500. p_clearmx()
  501. ELSEIF rslt = 1 And arg_ifcommit THEN
  502. COMMIT Using commit_transaction;
  503. END IF
  504. Return(rslt)
  505. end function
  506. public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg);Int rslt = 1
  507. arg_newdescppart = Trim(arg_newdescppart)
  508. IF arg_billid <= 0 THEN
  509. rslt = 0
  510. arg_msg = "没有删除对象,操作取消"
  511. GOTO ext
  512. END IF
  513. IF it_newbegin OR it_updatebegin THEN
  514. rslt = 0
  515. arg_msg = "编辑状态下不可以执行,操作取消"
  516. GOTO ext
  517. END IF
  518. rslt=p_getinfo(arg_billid,arg_msg)
  519. if rslt=0 then goto ext
  520. if flag=0 then
  521. rslt=0
  522. arg_msg="非审核状态下不可用"
  523. goto ext
  524. end if
  525. UPDATE u_spt_price_change
  526. SET dscrp = dscrp+' '+:arg_newdescppart
  527. Where u_spt_price_change.billid = :billid using commit_transaction;
  528. IF commit_transaction.SQLCode <> 0 THEN
  529. ROLLBACK ;
  530. rslt = 0
  531. arg_msg = "因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.SQLErrText
  532. GOTO ext
  533. END IF
  534. dscrp = dscrp+' '+arg_newdescppart
  535. ext:
  536. IF rslt = 0 THEN
  537. ROLLBACK USING commit_transaction ;
  538. ELSE
  539. COMMIT USING commit_transaction ;
  540. END IF
  541. Return(rslt)
  542. end function
  543. public function integer newbegin ();p_reset()
  544. it_newbegin=TRUE
  545. it_updatebegin=FALSE
  546. return 1
  547. end function
  548. public function integer p_clearmx ();//int p_clearmx()
  549. //清除明细
  550. it_mxbt=0
  551. it_mxbt2=0
  552. it_mxbt3 = 0
  553. it_mxbt4=0
  554. return 1
  555. end function
  556. public function integer getinfo (long arg_billid, ref string arg_msg);//getinfo(arg_scid,arg_billid,arg_msg)
  557. //0 失败 1成功
  558. Int rslt = 1,i = 1,no_mxcheck = 0
  559. IF arg_billid <= 0 THEN
  560. rslt = 0
  561. arg_msg = "非法调价单唯一码"
  562. GOTO ext
  563. END IF
  564. rslt = p_getinfo(arg_billid,arg_msg)
  565. IF rslt = 0 THEN GOTO ext
  566. //用游标读取明细
  567. DECLARE cur_changemx CURSOR FOR
  568. SELECT
  569. u_spt_price_changemx.printid,
  570. u_spt_price_changemx.mtrlid,
  571. u_mtrldef.mtrlcode,
  572. u_spt_price_changemx.unit,
  573. u_spt_price_changemx.enprice,
  574. u_spt_price_changemx.price,
  575. u_spt_price_changemx.rebate,
  576. u_spt_price_changemx.status,
  577. u_spt_price_changemx.woodcode,
  578. u_spt_price_changemx.pcode,
  579. u_spt_price_changemx.jgdscrp,
  580. u_spt_price_changemx.sptmtrlname,
  581. u_spt_price_changemx.Dscrp,
  582. u_spt_price_changemx.lastprice,
  583. u_spt_price_changemx.wareprice,
  584. u_spt_price_changemx.rate,
  585. u_spt_price_changemx.lastdate,
  586. u_spt_price_changemx.effdate,
  587. u_spt_price_changemx.effdate_end,
  588. u_spt_price_changemx.qty,
  589. u_spt_price_changemx.qty1,
  590. u_spt_price_changemx.hisflag,
  591. u_spt_price_changemx.taskflag,
  592. u_spt_price_changemx.wareflag,
  593. u_spt_price_changemx.sdate,
  594. u_spt_price_changemx.edate
  595. FROM u_spt_price_change
  596. INNER JOIN
  597. u_spt_price_changemx ON
  598. u_spt_price_change.billid = u_spt_price_changemx.billid
  599. INNER JOIN
  600. u_mtrldef ON u_spt_price_changemx.mtrlid = u_mtrldef.mtrlid
  601. WHERE u_spt_price_change.billid = :arg_billid
  602. Using commit_transaction;
  603. OPEN cur_changemx;
  604. FETCH cur_changemx INTO
  605. :changemx[i].printid,
  606. :changemx[i].mtrlid,
  607. :changemx[i].mtrlcode,
  608. :changemx[i].unit,
  609. :changemx[i].enprice,
  610. :changemx[i].price,
  611. :changemx[i].rebate,
  612. :changemx[i].status,
  613. :changemx[i].woodcode,
  614. :changemx[i].pcode,
  615. :changemx[i].jgdscrp,
  616. :changemx[i].sptmtrlname,
  617. :changemx[i].Dscrp,
  618. :changemx[i].lastprice,
  619. :changemx[i].wareprice,
  620. :changemx[i].rate,
  621. :changemx[i].lastdate,
  622. :changemx[i].effdate,
  623. :changemx[i].effdate_end,
  624. :changemx[i].qty,
  625. :changemx[i].qty1,
  626. :changemx[i].hisflag,
  627. :changemx[i].taskflag,
  628. :changemx[i].wareflag,
  629. :changemx[i].sdate,
  630. :changemx[i].edate;
  631. DO WHILE commit_transaction.SQLCode = 0
  632. i++
  633. FETCH cur_changemx INTO
  634. :changemx[i].printid,
  635. :changemx[i].mtrlid,
  636. :changemx[i].mtrlcode,
  637. :changemx[i].unit,
  638. :changemx[i].enprice,
  639. :changemx[i].price,
  640. :changemx[i].rebate,
  641. :changemx[i].status,
  642. :changemx[i].woodcode,
  643. :changemx[i].pcode,
  644. :changemx[i].jgdscrp,
  645. :changemx[i].sptmtrlname,
  646. :changemx[i].Dscrp,
  647. :changemx[i].lastprice,
  648. :changemx[i].wareprice,
  649. :changemx[i].rate,
  650. :changemx[i].lastdate,
  651. :changemx[i].effdate,
  652. :changemx[i].effdate_end,
  653. :changemx[i].qty,
  654. :changemx[i].qty1,
  655. :changemx[i].hisflag,
  656. :changemx[i].taskflag,
  657. :changemx[i].wareflag,
  658. :changemx[i].sdate,
  659. :changemx[i].edate;
  660. LOOP
  661. CLOSE cur_changemx;
  662. //检验明细是否读入完整
  663. SELECT count(*) INTO :no_mxcheck
  664. FROM u_spt_price_changemx
  665. WHERE u_spt_price_changemx.billid = :arg_billid
  666. Using commit_transaction;
  667. IF commit_transaction.SQLCode <> 0 THEN
  668. rslt = 0
  669. arg_msg = "查询操作失败,调价单明细数量"
  670. GOTO ext
  671. END IF
  672. IF i <> (no_mxcheck+1) THEN
  673. rslt = 0
  674. arg_msg = "查询操作失败,调价单明细"
  675. GOTO ext
  676. END IF
  677. it_mxbt = i - 1
  678. //用游标读取明细2
  679. i = 1
  680. DECLARE cur_changemx2 CURSOR FOR
  681. SELECT
  682. u_spt_price_changemx2.printid,
  683. u_spt_price_changemx2.printid1,
  684. u_spt_price_changemx2.mtrlid,
  685. u_mtrldef.mtrlcode,
  686. u_spt_price_changemx2.unit,
  687. u_spt_price_changemx2.price,
  688. u_spt_price_changemx2.status,
  689. u_spt_price_changemx2.woodcode,
  690. u_spt_price_changemx2.pcode,
  691. u_spt_price_changemx2.jgdscrp,
  692. u_spt_price_changemx2.sptmtrlname,
  693. u_spt_price_changemx2.Dscrp,
  694. u_spt_price_changemx2.lastprice,
  695. u_spt_price_changemx2.wareprice,
  696. u_spt_price_changemx2.rate,
  697. u_spt_price_changemx2.lastdate,
  698. u_spt_price_changemx2.effdate,
  699. u_spt_price_changemx2.qty,
  700. u_spt_price_changemx2.qty1
  701. FROM u_spt_price_change
  702. INNER JOIN
  703. u_spt_price_changemx2 ON
  704. u_spt_price_change.billid = u_spt_price_changemx2.billid
  705. INNER JOIN
  706. u_mtrldef ON u_spt_price_changemx2.mtrlid = u_mtrldef.mtrlid
  707. WHERE u_spt_price_change.billid = :arg_billid
  708. Using commit_transaction;
  709. OPEN cur_changemx2;
  710. FETCH cur_changemx2 INTO
  711. :changemx2[i].printid,
  712. :changemx2[i].printid1,
  713. :changemx2[i].mtrlid,
  714. :changemx2[i].mtrlcode,
  715. :changemx2[i].unit,
  716. :changemx2[i].price,
  717. :changemx2[i].status,
  718. :changemx2[i].woodcode,
  719. :changemx2[i].pcode,
  720. :changemx2[i].jgdscrp,
  721. :changemx2[i].sptmtrlname,
  722. :changemx2[i].Dscrp,
  723. :changemx2[i].lastprice,
  724. :changemx2[i].wareprice,
  725. :changemx2[i].rate,
  726. :changemx2[i].lastdate,
  727. :changemx2[i].effdate,
  728. :changemx2[i].qty,
  729. :changemx2[i].qty1;
  730. DO WHILE commit_transaction.SQLCode = 0
  731. i++
  732. FETCH cur_changemx2 INTO
  733. :changemx2[i].printid,
  734. :changemx2[i].printid1,
  735. :changemx2[i].mtrlid,
  736. :changemx2[i].mtrlcode,
  737. :changemx2[i].unit,
  738. :changemx2[i].price,
  739. :changemx2[i].status,
  740. :changemx2[i].woodcode,
  741. :changemx2[i].pcode,
  742. :changemx2[i].jgdscrp,
  743. :changemx2[i].sptmtrlname,
  744. :changemx2[i].Dscrp,
  745. :changemx2[i].lastprice,
  746. :changemx2[i].wareprice,
  747. :changemx2[i].rate,
  748. :changemx2[i].lastdate,
  749. :changemx2[i].effdate,
  750. :changemx2[i].qty,
  751. :changemx2[i].qty1;
  752. LOOP
  753. CLOSE cur_changemx2;
  754. //检验明细是否读入完整
  755. SELECT count(*) INTO :no_mxcheck
  756. FROM u_spt_price_changemx2
  757. WHERE u_spt_price_changemx2.billid = :arg_billid
  758. Using commit_transaction;
  759. IF commit_transaction.SQLCode <> 0 THEN
  760. rslt = 0
  761. arg_msg = "查询操作失败,调价单明细数量"
  762. GOTO ext
  763. END IF
  764. IF i <> (no_mxcheck+1) THEN
  765. rslt = 0
  766. arg_msg = "查询操作失败,调价单明细"
  767. GOTO ext
  768. END IF
  769. it_mxbt2 = i - 1
  770. //用游标读取明细3
  771. i = 1
  772. DECLARE cur_changemx3 CURSOR FOR
  773. SELECT u_mtrl_price_changemx.billid,
  774. u_mtrl_price_changemx.printid,
  775. u_mtrl_price_changemx.printid2,
  776. u_mtrl_price_changemx.relid,
  777. u_mtrl_price_changemx.price,
  778. u_mtrl_price_changemx.rate,
  779. u_mtrl_price_changemx.scid,
  780. u_mtrl_price_changemx.relprintid,
  781. u_mtrl_price_changemx.mxtype,
  782. u_mtrl_price_changemx.unit
  783. FROM u_mtrl_price_changemx
  784. WHERE u_mtrl_price_changemx.billid = :arg_billid
  785. Order By u_mtrl_price_changemx.printid;
  786. OPEN cur_changemx3;
  787. FETCH cur_changemx3 INTO :changemx3[i].billid,
  788. :changemx3[i].printid,:changemx3[i].printid2,:changemx3[i].relid,
  789. :changemx3[i].price,:changemx3[i].rate,
  790. :changemx3[i].scid,:changemx3[i].relprintid,
  791. :changemx3[i].mxtype,:changemx3[i].unit;
  792. DO WHILE sqlca.SQLCode = 0
  793. i++
  794. FETCH cur_changemx3 INTO :changemx3[i].billid,
  795. :changemx3[i].printid,:changemx3[i].printid2,:changemx3[i].relid,
  796. :changemx3[i].price,:changemx3[i].rate,
  797. :changemx3[i].scid,:changemx3[i].relprintid,
  798. :changemx3[i].mxtype,:changemx3[i].unit;
  799. LOOP
  800. CLOSE cur_changemx3;
  801. //检验明细是否读入完整
  802. SELECT count(*) INTO :no_mxcheck
  803. FROM u_mtrl_price_changemx
  804. Where billid = :arg_billid;
  805. IF sqlca.SQLCode <> 0 THEN
  806. rslt = 0
  807. arg_msg = "查询操作失败,单据明细数量"
  808. GOTO ext
  809. END IF
  810. IF i <> (no_mxcheck + 1) THEN
  811. rslt = 0
  812. arg_msg = "查询操作失败,单据明细"
  813. GOTO ext
  814. END IF
  815. it_mxbt3 = i - 1
  816. //用游标读取明细4
  817. i = 1
  818. DECLARE cur_changemx4 CURSOR FOR
  819. SELECT u_mtrl_price_changemx2.billid,
  820. u_mtrl_price_changemx2.printid,
  821. u_mtrl_price_changemx2.printid2,
  822. u_mtrl_price_changemx2.relid,
  823. u_mtrl_price_changemx2.price,
  824. u_mtrl_price_changemx2.rate,
  825. u_mtrl_price_changemx2.scid,
  826. u_mtrl_price_changemx2.relprintid,
  827. u_mtrl_price_changemx2.mxtype,
  828. u_mtrl_price_changemx2.unit
  829. FROM u_mtrl_price_changemx2
  830. where u_mtrl_price_changemx2.billid = :arg_billid
  831. Order By u_mtrl_price_changemx2.printid;
  832. OPEN cur_changemx4;
  833. FETCH cur_changemx4 INTO :changemx4[i].billid,
  834. :changemx4[i].printid,:changemx4[i].printid2,:changemx4[i].relid,
  835. :changemx4[i].price,:changemx4[i].rate,
  836. :changemx4[i].scid,:changemx4[i].relprintid,
  837. :changemx4[i].mxtype,:changemx4[i].unit;
  838. DO WHILE sqlca.SQLCode = 0
  839. i++
  840. FETCH cur_changemx4 INTO :changemx4[i].billid,
  841. :changemx4[i].printid,:changemx4[i].printid2,:changemx4[i].relid,
  842. :changemx4[i].price,:changemx4[i].rate,
  843. :changemx4[i].scid,:changemx4[i].relprintid,
  844. :changemx4[i].mxtype,:changemx4[i].unit;
  845. LOOP
  846. CLOSE cur_changemx4;
  847. //检验明细是否读入完整
  848. SELECT count(*) INTO :no_mxcheck
  849. FROM u_mtrl_price_changemx2
  850. Where billid = :arg_billid;
  851. IF sqlca.SQLCode <> 0 THEN
  852. rslt = 0
  853. arg_msg = "查询操作失败,单据明细数量"
  854. GOTO ext
  855. END IF
  856. IF i <> (no_mxcheck + 1) THEN
  857. rslt = 0
  858. arg_msg = "查询操作失败,单据明细"
  859. GOTO ext
  860. END IF
  861. it_mxbt4 = i - 1
  862. //////////////////
  863. billid = arg_billid
  864. it_newbegin = False
  865. it_updatebegin = False
  866. ext:
  867. IF rslt = 0 THEN p_reset()
  868. RETURN rslt
  869. end function
  870. public function integer p_getinfo (long arg_billid, ref string arg_msg);Int rslt = 1
  871. IF arg_billid <= 0 THEN
  872. rslt = 0
  873. arG_MSG = "非法调价单唯一码"
  874. GOTO ext
  875. END IF
  876. SELECT
  877. Billcode,
  878. billdate,
  879. sptid,
  880. flag,
  881. dscrp,
  882. inrep,
  883. billtype,
  884. moneyid,
  885. ifauto,
  886. relbillid
  887. INTO
  888. :Billcode,
  889. :billdate,
  890. :sptid,
  891. :flag,
  892. :dscrp,
  893. :Inrep,
  894. :billtype,
  895. :moneyid,
  896. :ifauto,
  897. :relbillid
  898. FROM u_spt_price_change
  899. Where billid = :arg_billid
  900. USING commit_transaction;
  901. IF commit_transaction.SQLCode <> 0 THEN
  902. rslt = 0
  903. arG_MSG = "查询操作失败(错误调价单唯一码),调价单"+commit_transaction.SQLErrText
  904. GOTO ext
  905. END IF
  906. billid = arg_billid
  907. ext:
  908. IF rslt = 0 THEN p_reset()
  909. RETURN rslt
  910. end function
  911. public function integer del (long arg_billid, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  912. IF arg_billid <= 0 THEN
  913. rslt = 0
  914. arg_msg = "没有删除对象,操作取消"
  915. GOTO ext
  916. END IF
  917. IF it_newbegin OR it_updatebegin THEN
  918. rslt = 0
  919. arg_msg = "编辑状态下不可以执行,操作取消"
  920. GOTO ext
  921. END IF
  922. rslt = p_getinfo(arg_billid,arg_msg)
  923. IF rslt = 0 THEN GOTO ext
  924. IF flag = 1 THEN
  925. rslt = 0
  926. arg_msg = "单据已经审核,不可以删除"
  927. GOTO ext
  928. END IF
  929. DELETE FROM u_spt_price_change WHERE u_spt_price_change.billid = :arg_billid
  930. USING commit_transaction;
  931. IF commit_transaction.SQLCode <> 0 THEN
  932. rslt = 0
  933. arg_msg = "删除单据操作失败"+"~n"+commit_transaction.SQLErrText
  934. GOTO ext
  935. END IF
  936. it_newbegin = FALSE
  937. it_updatebegin = FALSE
  938. ext:
  939. if rslt=0 then
  940. rollback using commit_transaction;
  941. elseif rslt=1 and arg_ifcommit then
  942. commit using commit_transaction;
  943. end if
  944. Return (rslt)
  945. end function
  946. public function integer auditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg);
  947. Long cnt = 0,i
  948. Int rslt
  949. rslt = 1
  950. IF arg_billid = 0 THEN
  951. rslt = 0
  952. arg_msg = "没有审核对象"
  953. GOTO ext
  954. END IF
  955. IF getinfo(arg_billid,arg_msg) = 0 THEN
  956. rslt = 0
  957. GOTO ext
  958. END IF
  959. IF flag <> 4 THEN
  960. rslt = 0
  961. arg_msg = '单据不是在待终审状态,不能执行终审,请检查!'
  962. GOTO ext
  963. END IF
  964. UPDATE u_spt_price_change SET
  965. flag = 1,
  966. auditemp = :publ_operator,
  967. Auditdate = getdate()
  968. WHERE billid = :billid
  969. And flag = 4 Using commit_transaction;
  970. IF commit_transaction.SQLCode <> 0 THEN
  971. arg_msg = '更新单价调整失败,原因>>'+commit_transaction.SQLErrText
  972. rslt = 0
  973. GOTO ext
  974. END IF
  975. FOR i = 1 To it_mxbt
  976. //更新价格历史
  977. IF changemx[i].hisflag = 1 THEN
  978. IF uo_price.uof_update_sptprice(0,sptid,changemx[i].mtrlid,changemx[i].unit,changemx[i].status,changemx[i].woodcode,changemx[i].pcode,changemx[i].jgdscrp,billid,changemx[i].enprice,changemx[i].rebate,&
  979. changemx[i].rate,changemx[i].wareprice,changemx[i].wareprice,billdate,billcode,1,changemx[i].Dscrp,i,2,moneyid,changemx[i].effdate,changemx[i].effdate_end,False,arg_msg) = 0 THEN
  980. rslt = 0
  981. GOTO ext
  982. END IF
  983. IF uo_price.uof_update_sptmtrlname(sptid,changemx[i].mtrlid,changemx[i].sptmtrlname,False,arg_msg) = 0 THEN
  984. rslt = 0
  985. GOTO ext
  986. END IF
  987. END IF
  988. NEXT
  989. IF it_mxbt2 > 0 THEN
  990. IF uof_create_change(arg_billid, arg_msg) = 0 THEN
  991. rslt = 0
  992. GOTO ext
  993. END IF
  994. END IF
  995. //更新采购订单
  996. IF it_mxbt3 > 0 THEN
  997. IF uof_update_task( arg_msg, false) = 0 THEN
  998. rslt = 0
  999. GOTO ext
  1000. END IF
  1001. END IF
  1002. //更新采购收货单
  1003. IF it_mxbt4 > 0 THEN
  1004. IF uof_update_ware( arg_msg, false) = 0 THEN
  1005. rslt = 0
  1006. GOTO ext
  1007. END IF
  1008. END IF
  1009. ext:
  1010. IF rslt = 0 THEN
  1011. ROLLBACK Using commit_transaction;
  1012. ELSEIF rslt = 1 And arg_ifcommit THEN
  1013. COMMIT Using commit_transaction;
  1014. END IF
  1015. RETURN rslt
  1016. end function
  1017. public function integer c_auditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg);
  1018. Long cnt = 0,i
  1019. Int rslt = 1
  1020. DateTime null_server_dt
  1021. SetNull(null_server_dt)
  1022. IF arg_billid = 0 THEN
  1023. rslt = 0
  1024. arg_msg = "没有审核对象"
  1025. GOTO ext
  1026. END IF
  1027. IF getinfo(arg_billid,arg_msg) = 0 THEN
  1028. rslt = 0
  1029. GOTO ext
  1030. END IF
  1031. IF flag <> 1 THEN
  1032. rslt = 0
  1033. arg_msg = '该单价调整未审核,不用撤审!'
  1034. GOTO ext
  1035. END IF
  1036. IF autobuild = 0 THEN
  1037. IF ifauto = 1 THEN
  1038. rslt = 0
  1039. arg_msg = '单据自动生成,不用手动撤审!'
  1040. GOTO ext
  1041. END IF
  1042. END IF
  1043. UPDATE u_spt_price_change SET
  1044. flag = 4,
  1045. Auditemp = '',
  1046. Auditdate = :null_server_dt
  1047. Where flag = 1 And billid = :billid Using commit_transaction;
  1048. IF commit_transaction.SQLCode <> 0 THEN
  1049. arg_msg = '更新单价调整失败,原因:'+commit_transaction.SQLErrText
  1050. rslt = 0
  1051. GOTO ext
  1052. END IF
  1053. ext:
  1054. IF rslt = 0 THEN
  1055. ROLLBACK Using commit_transaction;
  1056. ELSEIF rslt = 1 And arg_ifcommit THEN
  1057. COMMIT Using commit_transaction;
  1058. END IF
  1059. RETURN rslt
  1060. end function
  1061. public function integer first_audit (long arg_billid, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  1062. IF p_getinfo(arg_billid,arg_msg) = 0 THEN
  1063. rslt = 0
  1064. GOTO ext
  1065. END IF
  1066. IF flag <> 0 THEN
  1067. rslt = 0
  1068. arg_msg = '单据不是在待审核状态,不能执行初审'
  1069. GOTO ext
  1070. END IF
  1071. UPDATE u_spt_price_change
  1072. SET first_auditemp = :publ_operator,
  1073. first_auditdate = getdate(),
  1074. flag = 4
  1075. WHERE billid = :arg_billid
  1076. And flag = 0;
  1077. IF sqlca.SQLCode <> 0 THEN
  1078. rslt = 0
  1079. arg_msg = "因网络或其它原因导致单据审核操作失败"+"~n"+sqlca.SQLErrText
  1080. GOTO ext
  1081. END IF
  1082. ext:
  1083. IF rslt = 0 THEN
  1084. ROLLBACK;
  1085. ELSEIF rslt = 1 And arg_ifcommit THEN
  1086. COMMIT;
  1087. END IF
  1088. RETURN rslt
  1089. end function
  1090. public function integer first_caudit (long arg_billid, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  1091. DateTime null_dt
  1092. SetNull(null_dt)
  1093. IF p_getinfo(arg_billid,arg_msg) = 0 THEN
  1094. rslt = 0
  1095. GOTO ext
  1096. END IF
  1097. IF flag <> 4 THEN
  1098. rslt = 0
  1099. arg_msg = '单据不是审核状态,不能执行初撤'
  1100. GOTO ext
  1101. END IF
  1102. IF autobuild = 0 THEN
  1103. IF ifauto = 1 THEN
  1104. rslt = 0
  1105. arg_msg = '单据自动生成,不用手动撤审!'
  1106. GOTO ext
  1107. END IF
  1108. END IF
  1109. UPDATE u_spt_price_change
  1110. SET first_auditemp = '',
  1111. first_auditdate = :null_dt,
  1112. flag = 0
  1113. WHERE billid = :arg_billid
  1114. And flag = 4;
  1115. IF sqlca.SQLCode <> 0 THEN
  1116. rslt = 0
  1117. arg_msg = "因网络或其它原因导致单据审核操作失败"+"~n"+sqlca.SQLErrText
  1118. GOTO ext
  1119. END IF
  1120. ext:
  1121. IF rslt = 0 THEN
  1122. ROLLBACK;
  1123. ELSEIF rslt = 1 And arg_ifcommit THEN
  1124. COMMIT;
  1125. END IF
  1126. RETURN rslt
  1127. end function
  1128. public function integer acceptmx2 (long arg_printid, long arg_printid1, long arg_mtrlid, string arg_mtrlcode, string arg_unit, decimal arg_price, decimal arg_rate, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, string arg_sptmtrlname, string arg_dscrp, datetime arg_effdate, decimal arg_qty, decimal arg_qty1, ref string arg_msg);//已无用
  1129. Int rslt = 1
  1130. Decimal i_lastprice,i_lastrate,i_rate
  1131. DateTime ld_lastdate
  1132. String ls_unit
  1133. Long cnt
  1134. //IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  1135. // rslt = 0
  1136. // arg_msg = "非编辑状态不可以使用,操作取消"
  1137. // GOTO ext
  1138. //END IF
  1139. //
  1140. //
  1141. ////清除空值
  1142. //IF IsNull(arg_printid) THEN arg_printid = 0
  1143. //IF IsNull(arg_printid1) THEN arg_printid1 = 0
  1144. //IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
  1145. //IF IsNull(arg_mtrlcode) THEN arg_mtrlcode = ''
  1146. //IF IsNull(arg_status) THEN arg_status = ''
  1147. //IF IsNull(arg_dscrp) THEN arg_dscrp = ''
  1148. //IF IsNull(arg_price) THEN arg_price = 0
  1149. //IF IsNull(arg_unit) THEN arg_unit = ''
  1150. //IF IsNull(arg_rate) THEN arg_rate = 1
  1151. //IF arg_rate = 0 THEN arg_rate = 1
  1152. //IF IsNull(arg_qty) THEN arg_qty = 0
  1153. //IF IsNull(arg_qty1) THEN arg_qty1 = 0
  1154. //
  1155. //arg_effdate = datetime(date(arg_effdate),time(0))
  1156. //
  1157. //ls_unit = arg_unit
  1158. //
  1159. //IF arg_mtrlid = 0 and arg_price = 0 THEN
  1160. // rslt = 1
  1161. // GOTO ext
  1162. //END IF
  1163. //
  1164. //IF uo_price.uf_getmtrlsptprice_ch(sptid,arg_mtrlid,ls_unit,arg_status,arg_woodcode,arg_pcode,arg_jgdscrp,i_lastprice,i_rate,ld_lastdate,arg_msg) = 0 THEN
  1165. // rslt = 0
  1166. // GOTO ext
  1167. //END IF
  1168. //
  1169. //
  1170. //it_mxbt2++
  1171. //changemx2[it_mxbt2].mtrlid = arg_mtrlid
  1172. //changemx2[it_mxbt2].unit = arg_unit
  1173. //changemx2[it_mxbt2].price = arg_price
  1174. //changemx2[it_mxbt2].status = arg_status
  1175. //changemx2[it_mxbt2].lastprice = i_lastprice
  1176. //changemx2[it_mxbt2].wareprice = Round(arg_price/arg_rate,5)
  1177. //changemx2[it_mxbt2].rate = arg_rate
  1178. //changemx2[it_mxbt2].sptmtrlname = arg_sptmtrlname
  1179. //changemx2[it_mxbt2].Dscrp = arg_dscrp
  1180. //changemx2[it_mxbt2].lastdate = ld_lastdate
  1181. //changemx2[it_mxbt2].printid = it_mxbt2
  1182. //changemx2[it_mxbt2].printid1 = arg_printid1
  1183. //changemx2[it_mxbt2].effdate = arg_effdate
  1184. //changemx2[it_mxbt2].qty = arg_qty
  1185. //changemx2[it_mxbt2].qty1 = arg_qty1
  1186. //
  1187. //changemx2[it_mxbt2].woodcode = arg_woodcode
  1188. //changemx2[it_mxbt2].pcode = arg_pcode
  1189. //changemx2[it_mxbt2].jgdscrp = arg_jgdscrp
  1190. //
  1191. //
  1192. //ext:
  1193. //IF rslt = 0 THEN p_clearmx()
  1194. RETURN rslt
  1195. end function
  1196. public function integer uof_create_change (long arg_billid, ref string arg_msg);Int rslt = 1
  1197. Long i, mxcnt
  1198. datetime ldt_sdate, ldt_edate
  1199. uo_spt_price_change uo_price_chg
  1200. uo_price_chg = Create uo_spt_price_change
  1201. uo_price_chg.commit_transaction = commit_transaction
  1202. IF uo_price_chg.newbegin() = 0 THEN
  1203. rslt = 0
  1204. GOTO ext
  1205. END IF
  1206. uo_price_chg.billdate = DateTime(Today()) // 发生时间
  1207. uo_price_chg.sptid = sptid // 经手人
  1208. uo_price_chg.dscrp = dscrp //备注
  1209. uo_price_chg.billtype = 1 //询价单
  1210. uo_price_chg.inrep = inrep //备注
  1211. uo_price_chg.moneyid = moneyid //备注
  1212. uo_price_chg.relbillid = arg_billid //
  1213. uo_price_chg.ifauto = 1
  1214. FOR i = 1 To it_mxbt2
  1215. IF uo_price_chg.acceptmx(i,&
  1216. changemx2[i].mtrlid,&
  1217. changemx2[i].mtrlcode,&
  1218. changemx2[i].unit,&
  1219. changemx2[i].price,&
  1220. 1,&
  1221. changemx2[i].rate,&
  1222. changemx2[i].status,&
  1223. changemx2[i].woodcode,&
  1224. changemx2[i].pcode,&
  1225. changemx2[i].jgdscrp,&
  1226. changemx2[i].sptmtrlname,&
  1227. changemx2[i].dscrp,&
  1228. changemx2[i].effdate,&
  1229. datetime(9999-01-01, 23:59:59),&
  1230. changemx2[i].qty,&
  1231. changemx2[i].qty1,&
  1232. 1,0,0,ldt_sdate, ldt_edate,&
  1233. arg_msg) = 0 THEN
  1234. rslt = 0
  1235. GOTO ext
  1236. END IF
  1237. NEXT
  1238. IF uo_price_chg.Save(arg_msg,False) = 0 THEN
  1239. rslt = 0
  1240. GOTO ext
  1241. END IF
  1242. long ll_billid
  1243. ll_billid = uo_price_chg.billid
  1244. IF uo_price_chg.first_audit(ll_billid,False,arg_msg) = 0 THEN
  1245. rslt = 0
  1246. GOTO ext
  1247. END IF
  1248. IF uo_price_chg.auditing(ll_billid,False,arg_msg) = 0 THEN
  1249. rslt = 0
  1250. GOTO ext
  1251. END IF
  1252. ext:
  1253. //if rslt = 0 then
  1254. // rollback;
  1255. //else
  1256. //
  1257. //end if
  1258. Destroy uo_price_chg
  1259. RETURN rslt
  1260. end function
  1261. public function integer uof_destroy_change (long arg_billid, ref string arg_msg);Int rslt = 1
  1262. Long i, mxcnt
  1263. Long ll_billid
  1264. uo_spt_price_change uo_price_chg
  1265. uo_price_chg = Create uo_spt_price_change
  1266. uo_price_chg.commit_transaction = commit_transaction
  1267. IF uo_price_chg.newbegin() = 0 THEN
  1268. rslt = 0
  1269. GOTO ext
  1270. END IF
  1271. SELECT billid
  1272. INTO :ll_billid
  1273. FROM u_spt_price_change
  1274. WHERE relbillid = :arg_billid
  1275. And billtype = 1;
  1276. IF sqlca.sqlcode <> 0 THEN
  1277. arg_msg = "查询相关纸箱询价单失败,"+sqlca.SQLErrText
  1278. rslt = 0
  1279. GOTO ext
  1280. END IF
  1281. //uo_price_chg.ifauto = 1
  1282. uo_price_chg.autobuild = 1
  1283. IF uo_price_chg.first_caudit(ll_billid,False,arg_msg) = 0 THEN
  1284. rslt = 0
  1285. GOTO ext
  1286. END IF
  1287. IF uo_price_chg.del(ll_billid,False,arg_msg) = 0 THEN
  1288. rslt = 0
  1289. GOTO ext
  1290. END IF
  1291. ext:
  1292. //if rslt = 0 then
  1293. // rollback;
  1294. //else
  1295. //
  1296. //end if
  1297. Destroy uo_price_chg
  1298. RETURN rslt
  1299. end function
  1300. public function integer acceptmx3 (s_mtrl_price_changemx arg_s_mx, ref string arg_msg);
  1301. Int rslt = 1
  1302. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  1303. rslt = 0
  1304. arg_msg = "非编辑状态不可以使用,操作取消"
  1305. GOTO ext
  1306. END IF
  1307. //清除空值
  1308. //
  1309. //
  1310. IF arg_s_mx.relid = 0 and arg_s_mx.relprintid = 0 THEN
  1311. rslt = 1
  1312. GOTO ext
  1313. END IF
  1314. //插入明细
  1315. it_mxbt3++
  1316. changemx3[it_mxbt3] = arg_s_mx
  1317. ext:
  1318. IF rslt = 0 THEN p_clearmx()
  1319. RETURN rslt
  1320. end function
  1321. public function integer acceptmx4 (s_mtrl_price_changemx2 arg_s_mx, ref string arg_msg);
  1322. Int rslt = 1
  1323. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  1324. rslt = 0
  1325. arg_msg = "非编辑状态不可以使用,操作取消"
  1326. GOTO ext
  1327. END IF
  1328. //清除空值
  1329. //
  1330. //
  1331. IF arg_s_mx.relid = 0 and arg_s_mx.relprintid = 0 THEN
  1332. rslt = 1
  1333. GOTO ext
  1334. END IF
  1335. //插入明细
  1336. it_mxbt4++
  1337. changemx4[it_mxbt4] = arg_s_mx
  1338. ext:
  1339. IF rslt = 0 THEN p_clearmx()
  1340. RETURN rslt
  1341. end function
  1342. public function integer uof_update_ware (ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  1343. Decimal lde_newprice
  1344. //lde_newprice = arg_newprice
  1345. //s_mtrl_price_changemx2 changemx4[]
  1346. Long i, ll_printid2
  1347. long j
  1348. uo_inware uo_in_buy
  1349. uo_in_buy = Create uo_inware
  1350. uo_in_buy.commit_transaction = sqlca
  1351. uo_inware_wfjg uo_in_wfjg
  1352. uo_in_wfjg = Create uo_inware_wfjg
  1353. uo_in_wfjg.commit_transaction = sqlca
  1354. //IF getinfo2(arg_billid,changemx4,ll_arr_cnt2,arg_msg) = 0 THEN
  1355. // rslt = 0
  1356. // GOTO ext
  1357. //END IF
  1358. IF it_mxbt4 = 0 THEN RETURN 1 //没有的, 不提交事物, 成功返回
  1359. Int li_flag, li_secflag, li_balcflag
  1360. Decimal lde_fprice, lde_price, lde_uprice, lde_enprice, lde_jgprice, lde_enprice_tax, lde_enprice_notax, lde_cost
  1361. Decimal lde_uqty, lde_rate, lde_rebate, lde_mrate, lde_qty
  1362. Int li_thflag
  1363. FOR i = 1 To it_mxbt4 //收货明细
  1364. ll_printid2 = changemx4[i].printid2
  1365. IF ll_printid2 = 0 THEN
  1366. rslt = 0
  1367. arg_msg = "收货单明细行:["+String(i)+"],询价单明细对应行ID为0"
  1368. GOTO ext
  1369. END IF
  1370. IF ll_printid2 > it_mxbt THEN
  1371. rslt = 0
  1372. arg_msg = "收货单明细行:["+String(i)+"],询价单明细对应行ID错误,"+String(ll_printid2)
  1373. GOTO ext
  1374. END IF
  1375. //为防止对错printid,采用新写法 dyy 20141104
  1376. For j = 1 To it_mxbt
  1377. If changemx[j].printid = ll_printid2 Then
  1378. lde_newprice = changemx[j].price
  1379. Exit
  1380. End If
  1381. Next
  1382. // lde_newprice = changemx[ll_printid2].price
  1383. IF changemx4[i].mxtype = 2 THEN //采购
  1384. SELECT flag, secflag, balcflag
  1385. INTO :li_flag, :li_secflag, :li_balcflag
  1386. FROM u_inware
  1387. WHERE scid = :changemx4[i].scid
  1388. And inwareid = :changemx4[i].relid;
  1389. IF sqlca.SQLCode <> 0 THEN
  1390. rslt = 0
  1391. arg_msg = "收货单明细行:["+String(i)+"],查询采购收货单信息失败"+"~n"+sqlca.SQLErrText
  1392. GOTO ext
  1393. END IF
  1394. IF li_secflag = 1 THEN
  1395. rslt = 0
  1396. arg_msg = "收货单明细行:["+String(i)+"],对应采购收货单已经财审,不能更改单价"
  1397. GOTO ext
  1398. END IF
  1399. IF li_balcflag = 1 THEN
  1400. rslt = 0
  1401. arg_msg = "收货单明细行:["+String(i)+"],对应采购收货单已经结存,不能更改单价"
  1402. GOTO ext
  1403. END IF
  1404. IF li_flag = 1 THEN
  1405. IF uo_in_buy.mod_price(changemx4[i].scid,changemx4[i].relid,changemx4[i].relprintid,lde_newprice,0,-1,-1,arg_msg,False) = 0 THEN
  1406. rslt = 0
  1407. arg_msg = "收货单明细行:["+String(i)+"],"+arg_msg
  1408. GOTO ext
  1409. END IF
  1410. ELSE
  1411. SELECT u_inwaremx.uqty,
  1412. u_inwaremx.rate,
  1413. u_inwaremx.rebate,
  1414. u_inware.mrate,
  1415. u_inware.thflag
  1416. INTO :lde_uqty,
  1417. :lde_rate,
  1418. :lde_rebate,
  1419. :lde_mrate,
  1420. :li_thflag
  1421. FROM u_inwaremx INNER JOIN
  1422. u_inware ON u_inwaremx.scid = u_inware.scid
  1423. AND u_inwaremx.inwareid = u_inware.inwareid
  1424. WHERE u_inwaremx.scid = :changemx4[i].scid
  1425. AND u_inwaremx.inwareid = :changemx4[i].relid
  1426. And u_inwaremx.printid = :changemx4[i].relprintid Using sqlca;
  1427. IF sqlca.SQLCode <> 0 THEN
  1428. rslt = 0
  1429. arg_msg = '查询进仓单明细内容失败'+sqlca.SQLErrText
  1430. GOTO ext
  1431. END IF
  1432. lde_enprice = lde_newprice
  1433. lde_uprice = Round(lde_enprice * lde_mrate,10)
  1434. lde_fprice = Round((lde_uprice * lde_uqty)/(Round(lde_uqty * lde_rate,sys_option_unit_dec)),10)
  1435. lde_price = lde_fprice * lde_rebate
  1436. IF li_thflag = 0 THEN
  1437. lde_cost = lde_price * lde_rebate
  1438. END IF
  1439. UPDATE u_inwaremx
  1440. SET enprice = :lde_enprice,
  1441. uprice = :lde_uprice,
  1442. fprice = :lde_fprice,
  1443. price = :lde_price,
  1444. cost = :lde_cost,
  1445. deliprice_notax = :lde_enprice / (1 + tax)
  1446. WHERE scid = :changemx4[i].scid
  1447. AND inwareid = :changemx4[i].relid
  1448. And printid = :changemx4[i].relprintid Using sqlca;
  1449. IF sqlca.SQLCode <> 0 THEN
  1450. rslt = 0
  1451. arg_msg = "收货单明细行:["+String(i)+"],更新外协收货单价失败"+"~n"+sqlca.SQLErrText
  1452. GOTO ext
  1453. ELSEIF sqlca.SQLNRows = 0 THEN
  1454. rslt = 0
  1455. arg_msg = "收货单明细行:["+String(i)+"],外协收货单对应明细不存在或已财审/结存"+"~n"+sqlca.SQLErrText
  1456. GOTO ext
  1457. END IF
  1458. END IF
  1459. ELSEIF changemx4[i].mxtype = 3 THEN
  1460. SELECT flag, secflag, balcflag
  1461. INTO :li_flag, :li_secflag, :li_balcflag
  1462. FROM ow_wfjg_in
  1463. WHERE scid = :changemx4[i].scid
  1464. And inwareid = :changemx4[i].relid;
  1465. IF sqlca.SQLCode <> 0 THEN
  1466. rslt = 0
  1467. arg_msg = "收货单明细行:["+String(i)+"],查询外协收货单信息失败"+"~n"+sqlca.SQLErrText
  1468. GOTO ext
  1469. END IF
  1470. IF li_secflag = 1 THEN
  1471. rslt = 0
  1472. arg_msg = "收货单明细行:["+String(i)+"],对应外协收货单已经财审,不能更改单价"
  1473. GOTO ext
  1474. END IF
  1475. IF li_balcflag = 1 THEN
  1476. rslt = 0
  1477. arg_msg = "收货单明细行:["+String(i)+"],对应外协收货单已经结存,不能更改单价"
  1478. GOTO ext
  1479. END IF
  1480. IF li_flag = 1 THEN
  1481. IF uo_in_wfjg.mod_price(changemx4[i].scid,changemx4[i].relid,changemx4[i].relprintid,lde_fprice,lde_newprice,-1,-1,arg_msg,False) = 0 THEN
  1482. rslt = 0
  1483. arg_msg = "收货单明细行:["+String(i)+"],"+arg_msg
  1484. GOTO ext
  1485. END IF
  1486. ELSE
  1487. SELECT
  1488. fprice,
  1489. uqty,
  1490. qty,
  1491. rebate
  1492. INTO
  1493. :lde_fprice,
  1494. :lde_uqty,
  1495. :lde_qty,
  1496. :lde_rebate
  1497. FROM ow_wfjgmx_in_aft
  1498. WHERE scid = :changemx4[i].scid
  1499. AND inwareid = :changemx4[i].relid
  1500. AND printid = :changemx4[i].relprintid
  1501. Using sqlca;
  1502. IF sqlca.SQLCode <> 0 THEN
  1503. rslt = 0
  1504. arg_msg = '查询单据明细内容失败'+sqlca.SQLErrText
  1505. GOTO ext
  1506. END IF
  1507. lde_jgprice = lde_newprice
  1508. IF lde_qty <> 0 THEN
  1509. lde_uprice = Round(lde_newprice * lde_uqty/lde_qty,5)
  1510. ELSE
  1511. lde_uprice = 0
  1512. END IF
  1513. lde_cost = lde_uprice * lde_rebate + lde_fprice
  1514. lde_price = lde_uprice * lde_rebate + lde_fprice
  1515. UPDATE ow_wfjgmx_in_aft
  1516. SET jgprice = :lde_jgprice,
  1517. fprice = :lde_fprice,
  1518. uprice = :lde_uprice,
  1519. price = :lde_price,
  1520. cost = :lde_cost
  1521. WHERE scid = :changemx4[i].scid
  1522. AND inwareid = :changemx4[i].relid
  1523. And printid = :changemx4[i].relprintid Using sqlca;
  1524. IF sqlca.SQLCode <> 0 THEN
  1525. rslt = 0
  1526. arg_msg = "收货单明细行:["+String(i)+"],更新外协收货单价失败"+"~n"+sqlca.SQLErrText
  1527. GOTO ext
  1528. ELSEIF sqlca.SQLNRows = 0 THEN
  1529. rslt = 0
  1530. arg_msg = "收货单明细行:["+String(i)+"],外协收货单对应明细不存在或已财审/结存"+"~n"+sqlca.SQLErrText
  1531. GOTO ext
  1532. END IF
  1533. END IF
  1534. END IF
  1535. NEXT
  1536. ext:
  1537. destroy uo_in_buy
  1538. destroy uo_in_wfjg
  1539. IF rslt = 0 THEN
  1540. ROLLBACK;
  1541. ELSEIF arg_ifcommit THEN
  1542. COMMIT;
  1543. END IF
  1544. RETURN rslt
  1545. end function
  1546. public function integer uof_update_task (ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  1547. //s_mtrl_price_changemx changemx3[]
  1548. Decimal lde_newprice
  1549. //lde_newprice = arg_newprice
  1550. Long i, ll_printid2
  1551. Long j
  1552. If it_mxbt3 = 0 Then Return 1 //没有的, 不提交事物, 成功返回
  1553. Int li_status, li_secflag, li_balcflag
  1554. Decimal lde_fprice, lde_price, lde_uprice, lde_enprice, lde_jgprice, lde_enprice_tax, lde_enprice_notax, lde_cost
  1555. Decimal lde_uqty, lde_rate, lde_rebate, lde_mrate
  1556. For i = 1 To it_mxbt3 //订单明细
  1557. ll_printid2 = changemx3[i].printid2
  1558. If ll_printid2 = 0 Then
  1559. rslt = 0
  1560. arg_msg = "订单明细行:["+String(i)+"],询价单明细对应行ID为0"
  1561. Goto ext
  1562. End If
  1563. If ll_printid2 > it_mxbt Then
  1564. rslt = 0
  1565. arg_msg = "订单明细行:["+String(i)+"],询价单明细对应行ID错误,"+String(ll_printid2)
  1566. Goto ext
  1567. End If
  1568. //为防止对错printid,采用新写法 dyy 20141104
  1569. For j = 1 To it_mxbt
  1570. If changemx[j].printid = ll_printid2 Then
  1571. lde_newprice = changemx[j].price
  1572. Exit
  1573. End If
  1574. Next
  1575. // lde_newprice = changemx[ll_printid2].price
  1576. If changemx3[i].mxtype = 2 Then //采购
  1577. Select u_buytaskmx.uqty,
  1578. u_buytaskmx.rate,
  1579. u_buytaskmx.rebate,
  1580. u_buytask.mrate
  1581. Into
  1582. :lde_uqty,
  1583. :lde_rate,
  1584. :lde_rebate,
  1585. :lde_mrate
  1586. From u_buytaskmx Inner join u_buytask
  1587. On u_buytask.scid = u_buytaskmx.scid
  1588. And u_buytask.taskid = u_buytaskmx.taskid
  1589. Where u_buytaskmx.scid = :changemx3[i].scid
  1590. And u_buytaskmx.taskid = :changemx3[i].relid
  1591. And u_buytaskmx.printid = :changemx3[i].relprintid
  1592. Using sqlca;
  1593. If sqlca.SQLCode <> 0 Then
  1594. rslt = 0
  1595. arg_msg = "订单明细行:["+String(i)+"],查询采购订单明细内容失败"+sqlca.SQLErrText
  1596. Goto ext
  1597. End If
  1598. lde_enprice = lde_newprice
  1599. lde_uprice = Round(lde_enprice * lde_mrate,10)
  1600. lde_fprice = Round((lde_uprice * lde_uqty)/(Round(lde_uqty * lde_rate,sys_option_unit_dec)),10)
  1601. lde_price = lde_fprice * lde_rebate
  1602. Update u_buyTaskMx
  1603. Set fprice = :lde_fprice,
  1604. Price = :lde_price,
  1605. uprice = :lde_uprice,
  1606. enprice = :lde_enprice
  1607. Where scid = :changemx3[i].scid
  1608. And taskid = :changemx3[i].relid
  1609. And printid = :changemx3[i].relprintid;
  1610. If sqlca.SQLCode <> 0 Then
  1611. rslt = 0
  1612. arg_msg = "订单明细行:["+String(i)+"],更新采购订单单价失败"+"~n"+sqlca.SQLErrText
  1613. Goto ext
  1614. ElseIf sqlca.SQLNRows = 0 Then
  1615. rslt = 0
  1616. arg_msg = "订单明细行:["+String(i)+"],采购订单对应明细不存在"+"~n"+sqlca.SQLErrText
  1617. Goto ext
  1618. End If
  1619. ElseIf changemx3[i].mxtype = 3 Then
  1620. lde_price = lde_newprice
  1621. Update u_order_wfjgMx
  1622. Set price = :lde_price
  1623. Where scid = :changemx3[i].scid
  1624. And wfjgid = :changemx3[i].relid
  1625. And printid = :changemx3[i].relprintid;
  1626. If sqlca.SQLCode <> 0 Then
  1627. rslt = 0
  1628. arg_msg = "订单明细行:["+String(i)+"],更新外协订单单价失败"+"~n"+sqlca.SQLErrText
  1629. Goto ext
  1630. ElseIf sqlca.SQLNRows = 0 Then
  1631. rslt = 0
  1632. arg_msg = "订单明细行:["+String(i)+"],外协订单对应明细不存在"+"~n"+sqlca.SQLErrText
  1633. Goto ext
  1634. End If
  1635. End If
  1636. Next
  1637. ext:
  1638. If rslt = 0 Then
  1639. Rollback;
  1640. ElseIf arg_ifcommit Then
  1641. Commit;
  1642. End If
  1643. Return rslt
  1644. end function
  1645. public function integer acceptmx (long arg_printid, long arg_mtrlid, string arg_mtrlcode, string arg_unit, decimal arg_enprice, decimal arg_rebate, decimal arg_rate, string arg_status, string arg_woodcode, string arg_pcode, string arg_jgdscrp, string arg_sptmtrlname, string arg_dscrp, datetime arg_effdate, datetime arg_effdate_end, decimal arg_qty, decimal arg_qty1, integer arg_hisflag, integer arg_taskflag, integer arg_wareflag, datetime arg_sdate, datetime arg_edate, ref string arg_msg);s_spt_price_changemx s_mx
  1646. s_mx.printid = arg_printid
  1647. s_mx.mtrlid = arg_mtrlid
  1648. s_mx.mtrlcode = arg_mtrlcode
  1649. s_mx.unit = arg_unit
  1650. s_mx.enprice = arg_enprice
  1651. s_mx.rebate = arg_rebate
  1652. s_mx.rate = arg_rate
  1653. s_mx.status = arg_status
  1654. s_mx.woodcode = arg_woodcode
  1655. s_mx.pcode = arg_pcode
  1656. s_mx.jgdscrp = arg_jgdscrp
  1657. s_mx.sptmtrlname = arg_sptmtrlname
  1658. s_mx.dscrp = arg_dscrp
  1659. s_mx.effdate = arg_effdate
  1660. s_mx.effdate_end = arg_effdate_end
  1661. s_mx.qty = arg_qty
  1662. s_mx.qty1 = arg_qty1
  1663. s_mx.hisflag = arg_hisflag
  1664. s_mx.taskflag = arg_taskflag
  1665. s_mx.wareflag = arg_wareflag
  1666. s_mx.sdate = arg_sdate
  1667. s_mx.edate = arg_edate
  1668. s_mx.buybargainid = 0
  1669. s_mx.buybargainprintid = 0
  1670. s_mx.buybargaincode = ''
  1671. return acceptmx(s_mx, arg_msg)
  1672. /*
  1673. Int rslt = 1
  1674. Decimal i_lastprice,i_lastrate, i_lastzqrate
  1675. DateTime ld_lastdate
  1676. Long cnt
  1677. datetime ldt_effdate
  1678. ldt_effdate = datetime(today(),time(0))
  1679. IF it_newbegin = False And it_updatebegin = False THEN
  1680. rslt = 0
  1681. arg_msg = "非编辑状态不可以使用,操作取消"
  1682. GOTO ext
  1683. END IF
  1684. //清除空值
  1685. IF IsNull(arg_printid) THEN arg_printid = 0
  1686. IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
  1687. IF IsNull(arg_mtrlcode) THEN arg_mtrlcode = ''
  1688. IF IsNull(arg_status) THEN arg_status = ''
  1689. IF IsNull(arg_dscrp) THEN arg_dscrp = ''
  1690. IF IsNull(arg_enprice) THEN arg_enprice = 0
  1691. IF IsNull(arg_rebate) THEN arg_rebate = 1
  1692. IF IsNull(arg_unit) THEN arg_unit = ''
  1693. IF IsNull(arg_rate) THEN arg_rate = 1
  1694. IF arg_rate = 0 THEN arg_rate = 1
  1695. IF IsNull(arg_qty) THEN arg_qty = 0
  1696. IF IsNull(arg_qty1) THEN arg_qty1 = 0
  1697. IF IsNull(arg_hisflag) THEN arg_hisflag = 1
  1698. IF IsNull(arg_taskflag) THEN arg_taskflag = 0
  1699. IF IsNull(arg_wareflag) THEN arg_wareflag = 0
  1700. IF arg_mtrlid = 0 And arg_enprice = 0 THEN
  1701. rslt = 1
  1702. GOTO ext
  1703. END IF
  1704. IF arg_unit = '' THEN
  1705. arg_msg = "请选择单位"
  1706. rslt = 0
  1707. GOTO ext
  1708. END IF
  1709. arg_effdate = DateTime(Date(arg_effdate),Time(0))
  1710. arg_effdate_end = DateTime(Date(arg_effdate_end),Time(23:59:59))
  1711. IF arg_taskflag = 0 And arg_wareflag = 0 THEN
  1712. SetNull(arg_sdate)
  1713. SetNull(arg_edate)
  1714. ELSE
  1715. arg_sdate = DateTime(Date(arg_sdate),Time(0))
  1716. arg_edate = DateTime(Date(arg_edate),23:59:59)
  1717. IF Date(arg_sdate) < 2000-01-01 THEN
  1718. arg_msg = "请填写开始时间"
  1719. rslt = 0
  1720. GOTO ext
  1721. END IF
  1722. IF Date(arg_edate) < 2000-01-01 THEN
  1723. arg_msg = "请填写结束时间"
  1724. rslt = 0
  1725. GOTO ext
  1726. END IF
  1727. END IF
  1728. //IF uo_price.uf_getmtrlsptprice_ch(sptid,arg_mtrlid,arg_unit,arg_status,arg_woodcode,arg_pcode,arg_jgdscrp,i_lastprice,i_lastrate,ld_lastdate,arg_msg) = 0 THEN
  1729. //IF uo_price.uof_getnewprice(sptid,moneyid,arg_mtrlid,arg_unit,arg_status,arg_woodcode,arg_pcode,arg_jgdscrp,i_lastprice,i_lastzqrate,i_lastrate,ld_lastdate,arg_msg) = 0 THEN
  1730. IF uo_price.uof_sptmtrlprice_get(sptid,moneyid,arg_mtrlid,arg_unit,arg_status,arg_woodcode,arg_pcode,arg_jgdscrp,ldt_effdate,i_lastprice,i_lastzqrate,i_lastrate,ld_lastdate,arg_msg) = 0 THEN
  1731. rslt = 0
  1732. GOTO ext
  1733. END IF
  1734. //查询合同号
  1735. Long ll_buybargainid, ll_buybargainprintid
  1736. String ls_buybargaincode
  1737. IF uo_price.uof_getmtrlsptbuybargain(moneyid, sptid, arg_mtrlid,arg_unit,arg_status,arg_woodcode,arg_pcode,arg_jgdscrp,&
  1738. ll_buybargainid, ll_buybargainprintid, ls_buybargaincode,arg_msg) = 0 THEN
  1739. rslt = 0
  1740. GOTO ext
  1741. END IF
  1742. it_mxbt++
  1743. changemx[it_mxbt].printid = it_mxbt
  1744. changemx[it_mxbt].mtrlid = arg_mtrlid
  1745. changemx[it_mxbt].unit = arg_unit
  1746. changemx[it_mxbt].enprice = arg_enprice //原单价 - 采购单位
  1747. changemx[it_mxbt].rebate = arg_rebate //折扣
  1748. changemx[it_mxbt].price = Round(arg_enprice * arg_rebate,5) //折后单价 - 采购单位
  1749. changemx[it_mxbt].wareprice = Round(changemx[it_mxbt].price/arg_rate,5) //折后单价 - 库存单位
  1750. changemx[it_mxbt].rate = arg_rate
  1751. changemx[it_mxbt].status = arg_status
  1752. changemx[it_mxbt].woodcode = arg_woodcode
  1753. changemx[it_mxbt].pcode = arg_pcode
  1754. changemx[it_mxbt].jgdscrp = arg_jgdscrp
  1755. changemx[it_mxbt].lastprice = i_lastprice
  1756. changemx[it_mxbt].lastdate = ld_lastdate
  1757. changemx[it_mxbt].effdate = arg_effdate
  1758. changemx[it_mxbt].effdate_end = arg_effdate_end
  1759. changemx[it_mxbt].sptmtrlname = arg_sptmtrlname
  1760. changemx[it_mxbt].Dscrp = arg_dscrp
  1761. changemx[it_mxbt].qty = arg_qty
  1762. changemx[it_mxbt].qty1 = arg_qty1
  1763. changemx[it_mxbt].hisflag = arg_hisflag
  1764. changemx[it_mxbt].taskflag = arg_taskflag
  1765. changemx[it_mxbt].wareflag = arg_wareflag
  1766. changemx[it_mxbt].sdate = arg_sdate
  1767. changemx[it_mxbt].edate = arg_edate
  1768. changemx[it_mxbt].buybargainid = ll_buybargainid
  1769. changemx[it_mxbt].buybargainprintid = ll_buybargainprintid
  1770. changemx[it_mxbt].buybargaincode = ls_buybargaincode
  1771. ext:
  1772. IF rslt = 0 THEN p_clearmx()
  1773. RETURN rslt
  1774. */
  1775. end function
  1776. public function integer acceptmx (s_spt_price_changemx s_mx, ref string arg_msg);Int rslt = 1
  1777. Decimal i_lastprice,i_lastrate, i_lastzqrate
  1778. DateTime ld_lastdate
  1779. Long cnt
  1780. datetime ldt_effdate
  1781. ldt_effdate = datetime(today(),time(0))
  1782. IF it_newbegin = False And it_updatebegin = False THEN
  1783. rslt = 0
  1784. arg_msg = "非编辑状态不可以使用,操作取消"
  1785. GOTO ext
  1786. END IF
  1787. //清除空值
  1788. IF IsNull(s_mx.printid) THEN s_mx.printid = 0
  1789. IF IsNull(s_mx.mtrlid) THEN s_mx.mtrlid = 0
  1790. IF IsNull(s_mx.mtrlcode) THEN s_mx.mtrlcode = ''
  1791. IF IsNull(s_mx.status) THEN s_mx.status = ''
  1792. IF IsNull(s_mx.dscrp) THEN s_mx.dscrp = ''
  1793. IF IsNull(s_mx.enprice) THEN s_mx.enprice = 0
  1794. IF IsNull(s_mx.rebate) THEN s_mx.rebate = 1
  1795. IF IsNull(s_mx.unit) THEN s_mx.unit = ''
  1796. IF IsNull(s_mx.rate) THEN s_mx.rate = 1
  1797. IF s_mx.rate = 0 THEN s_mx.rate = 1
  1798. IF IsNull(s_mx.qty) THEN s_mx.qty = 0
  1799. IF IsNull(s_mx.qty1) THEN s_mx.qty1 = 0
  1800. IF IsNull(s_mx.hisflag) THEN s_mx.hisflag = 1
  1801. IF IsNull(s_mx.taskflag) THEN s_mx.taskflag = 0
  1802. IF IsNull(s_mx.wareflag) THEN s_mx.wareflag = 0
  1803. IF s_mx.mtrlid = 0 And s_mx.enprice = 0 THEN
  1804. rslt = 1
  1805. GOTO ext
  1806. END IF
  1807. IF s_mx.unit = '' THEN
  1808. arg_msg = "请选择单位"
  1809. rslt = 0
  1810. GOTO ext
  1811. END IF
  1812. s_mx.effdate = DateTime(Date(s_mx.effdate),Time(0))
  1813. s_mx.effdate_end = DateTime(Date(s_mx.effdate_end),Time(23:59:59))
  1814. IF s_mx.taskflag = 0 And s_mx.wareflag = 0 THEN
  1815. SetNull(s_mx.sdate)
  1816. SetNull(s_mx.edate)
  1817. ELSE
  1818. s_mx.sdate = DateTime(Date(s_mx.sdate),Time(0))
  1819. s_mx.edate = DateTime(Date(s_mx.edate),23:59:59)
  1820. IF Date(s_mx.sdate) < 2000-01-01 THEN
  1821. arg_msg = "请填写开始时间"
  1822. rslt = 0
  1823. GOTO ext
  1824. END IF
  1825. IF Date(s_mx.edate) < 2000-01-01 THEN
  1826. arg_msg = "请填写结束时间"
  1827. rslt = 0
  1828. GOTO ext
  1829. END IF
  1830. END IF
  1831. IF uo_price.uof_sptmtrlprice_get(sptid,moneyid,s_mx.mtrlid,s_mx.unit,s_mx.status,s_mx.woodcode,s_mx.pcode,s_mx.jgdscrp,ldt_effdate,i_lastprice,i_lastzqrate,i_lastrate,ld_lastdate,arg_msg) = 0 THEN
  1832. rslt = 0
  1833. GOTO ext
  1834. END IF
  1835. //改成传入 20131014
  1836. ////查询合同号
  1837. //Long ll_buybargainid, ll_buybargainprintid
  1838. //String ls_buybargaincode
  1839. //IF uo_price.uof_getmtrlsptbuybargain(moneyid, sptid, s_mx.mtrlid,s_mx.unit,s_mx.status,s_mx.woodcode,s_mx.pcode,s_mx.jgdscrp,&
  1840. // ll_buybargainid, ll_buybargainprintid, ls_buybargaincode,arg_msg) = 0 THEN
  1841. // rslt = 0
  1842. // GOTO ext
  1843. //END IF
  1844. it_mxbt++
  1845. changemx[it_mxbt].printid = it_mxbt
  1846. changemx[it_mxbt].mtrlid = s_mx.mtrlid
  1847. changemx[it_mxbt].unit = s_mx.unit
  1848. changemx[it_mxbt].enprice = s_mx.enprice //原单价 - 采购单位
  1849. changemx[it_mxbt].rebate = s_mx.rebate //折扣
  1850. changemx[it_mxbt].price = Round(s_mx.enprice * s_mx.rebate,5) //折后单价 - 采购单位
  1851. changemx[it_mxbt].wareprice = Round(changemx[it_mxbt].price/s_mx.rate,5) //折后单价 - 库存单位
  1852. changemx[it_mxbt].rate = s_mx.rate
  1853. changemx[it_mxbt].status = s_mx.status
  1854. changemx[it_mxbt].woodcode = s_mx.woodcode
  1855. changemx[it_mxbt].pcode = s_mx.pcode
  1856. changemx[it_mxbt].jgdscrp = s_mx.jgdscrp
  1857. changemx[it_mxbt].lastprice = i_lastprice
  1858. changemx[it_mxbt].lastdate = ld_lastdate
  1859. changemx[it_mxbt].effdate = s_mx.effdate
  1860. changemx[it_mxbt].effdate_end = s_mx.effdate_end
  1861. changemx[it_mxbt].sptmtrlname = s_mx.sptmtrlname
  1862. changemx[it_mxbt].Dscrp = s_mx.dscrp
  1863. changemx[it_mxbt].qty = s_mx.qty
  1864. changemx[it_mxbt].qty1 = s_mx.qty1
  1865. changemx[it_mxbt].hisflag = s_mx.hisflag
  1866. changemx[it_mxbt].taskflag = s_mx.taskflag
  1867. changemx[it_mxbt].wareflag = s_mx.wareflag
  1868. changemx[it_mxbt].sdate = s_mx.sdate
  1869. changemx[it_mxbt].edate = s_mx.edate
  1870. changemx[it_mxbt].buybargainid = s_mx.buybargainid
  1871. changemx[it_mxbt].buybargainprintid = s_mx.buybargainprintid
  1872. changemx[it_mxbt].buybargaincode = s_mx.buybargaincode
  1873. ext:
  1874. IF rslt = 0 THEN p_clearmx()
  1875. RETURN rslt
  1876. end function
  1877. on uo_spt_price_change.create
  1878. call super::create
  1879. TriggerEvent( this, "constructor" )
  1880. end on
  1881. on uo_spt_price_change.destroy
  1882. TriggerEvent( this, "destructor" )
  1883. call super::destroy
  1884. end on
  1885. event constructor;uo_price = CREATE uo_spt_price
  1886. end event
  1887. event destructor;destroy uo_price
  1888. end event