uo_oppose.sru 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201
  1. $PBExportHeader$uo_oppose.sru
  2. forward
  3. global type uo_oppose from nonvisualobject
  4. end type
  5. type s_opposemx_mtrl from structure within uo_oppose
  6. end type
  7. type s_opposemx_dept from structure within uo_oppose
  8. end type
  9. end forward
  10. type s_opposemx_mtrl from structure
  11. long mtrlid
  12. string status
  13. decimal { 5 } qty
  14. string mxdscrp
  15. long relid
  16. long relprintid
  17. long scid
  18. long mxtype
  19. end type
  20. type s_opposemx_dept from structure
  21. long deptid
  22. string wkpname
  23. end type
  24. global type uo_oppose from nonvisualobject
  25. end type
  26. global uo_oppose uo_oppose
  27. type variables
  28. public protectedwrite long billid
  29. public protectedwrite string billcode
  30. public protectedwrite int billtype
  31. public protectedwrite datetime opdate
  32. public protectedwrite string opemp
  33. public protectedwrite datetime moddate
  34. public protectedwrite string modemp
  35. public protectedwrite int flag
  36. public protectedwrite datetime auditingdate
  37. public protectedwrite string auditingrep
  38. long relid
  39. datetime billdate
  40. string opposedept
  41. datetime thdate
  42. datetime fhdate
  43. string threason
  44. string custdscrp
  45. string saleidea
  46. string productieda
  47. string qualityidea
  48. string manageridea
  49. string improveidea
  50. string wkpdscrp
  51. decimal opposeamt
  52. long itemid
  53. String responsibler
  54. boolean if_getid_ture=true
  55. transaction commit_transaction
  56. private:
  57. long it_mxbt=0
  58. s_opposemx_mtrl opposemx_mtrl[]
  59. long it_depmxbt=0
  60. s_opposemx_dept opposemx_dept[]
  61. boolean it_newbegin=false
  62. boolean it_updatebegin=false
  63. end variables
  64. forward prototypes
  65. public function integer save (boolean arg_ifcommit, ref string arg_msg)
  66. public function integer p_clearmx ()
  67. public function integer p_reset ()
  68. public function integer getinfo (long arg_scid, long arg_billid, ref string arg_msg)
  69. public function integer updatebegin (long arg_billid, ref string arg_msg)
  70. public function integer p_getinfo (long arg_billid, ref string arg_msg)
  71. public function integer del (long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  72. public function integer auditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  73. public function integer c_auditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  74. public function integer newbegin (integer arg_billtype, ref string arg_msg)
  75. public function long acceptdeptid (long arg_deptid, ref string arg_msg)
  76. public function integer add_qualityidea (long arg_billid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit)
  77. public function integer add_manageridea (long arg_billid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit)
  78. public function integer add_improveidea (long arg_billid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit)
  79. public function integer add_productieda (long arg_billid, long arg_deptid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit)
  80. public function integer acceptmx (long arg_mtrlid, string arg_status, decimal arg_qty, string arg_mxdscrp, long arg_mxtype, long arg_scid, long arg_relid, long arg_relprintid, ref string arg_msg)
  81. end prototypes
  82. public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1
  83. Long cnt = 0,i,ll_i
  84. DateTime server_dt
  85. Long ls_newid
  86. String ls_wkpdscrp
  87. IF IsNull(opposedept) THEN opposedept = ""
  88. IF IsNull(threason) THEN threason = ""
  89. IF IsNull(custdscrp) THEN custdscrp = ""
  90. IF IsNull(saleidea) THEN saleidea = ""
  91. IF IsNull(productieda) THEN productieda = ""
  92. IF IsNull(manageridea) THEN manageridea = ""
  93. IF IsNull(qualityidea) THEN qualityidea = ""
  94. IF IsNull(relid) THEN relid = 0
  95. IF IsNull(opposeamt) THEN opposeamt = 0
  96. IF IsNull(itemid) THEN itemid = 0
  97. IF it_newbegin = False And it_updatebegin = False THEN
  98. rslt = 0
  99. arg_msg = "非编辑状态不可以提交"
  100. GOTO ext
  101. END IF
  102. SELECT Top 1 getdate() Into :server_dt From u_user Using commit_transaction ;
  103. IF commit_transaction.SQLCode <> 0 THEN
  104. rslt = 0
  105. arg_msg = "查询操作失败,日期 "
  106. GOTO ext
  107. END IF
  108. SELECT count(*) INTO :cnt
  109. FROM u_oppose_item
  110. Where itemid = :itemid;
  111. IF sqlca.SQLCode <> 0 THEN
  112. arg_msg = '查询投拆项目资料失败'
  113. rslt = 0
  114. GOTO ext
  115. END IF
  116. IF cnt = 0 THEN
  117. arg_msg = '系统不存在项目资料'
  118. rslt = 0
  119. GOTO ext
  120. END IF
  121. IF billtype = 0 THEN
  122. IF opposedept = '' THEN
  123. arg_msg = '请输入投诉部门'
  124. rslt = 0
  125. GOTO ext
  126. END IF
  127. IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
  128. rslt = 0
  129. arg_msg = "没有正确产品明细内容"
  130. GOTO ext
  131. END IF
  132. IF it_depmxbt = 0 THEN //如果输入物料资料错则已经清空
  133. rslt = 0
  134. arg_msg = "没有正确部门明细内容"
  135. GOTO ext
  136. END IF
  137. //***************************
  138. FOR ll_i = 1 To it_depmxbt
  139. ls_wkpdscrp = ls_wkpdscrp + opposemx_dept[ll_i].wkpname +','
  140. NEXT
  141. IF Len(ls_wkpdscrp) > 0 THEN
  142. ls_wkpdscrp = Left(ls_wkpdscrp,Len(ls_wkpdscrp) - 1)
  143. END IF
  144. //****************************
  145. ELSE
  146. cnt = 0
  147. SELECT count(*) INTO :cnt
  148. FROM u_spt
  149. Where sptid = :relid ;
  150. IF sqlca.SQLCode <> 0 Or cnt = 0 THEN
  151. arg_msg = '查询供应商资料失败,可能供应商资料不存在'
  152. rslt = 0
  153. GOTO ext
  154. END IF
  155. END IF
  156. IF Year(Date(billdate)) < 2000 Or IsNull(billdate) THEN
  157. rslt = 0
  158. arg_msg = "缺少发生时间或不合理"
  159. GOTO ext
  160. END IF
  161. //====================================================================
  162. // script - save ( boolean arg_ifcommit, ref string arg_msg )
  163. // reason:
  164. //--------------------------------------------------------------------
  165. // modified by: yyx date: 2004.01.02
  166. //--------------------------------------------------------------------
  167. IF DaysAfter(Date(String(server_dt,'yyyy-mm-dd')),Date(String(billdate,'yyyy-mm-dd'))) > sys_option_input_days THEN
  168. rslt = 0
  169. arg_msg = '日期错误,日期不能超前系统日期'
  170. GOTO ext
  171. END IF
  172. IF DaysAfter(Date(String(billdate,'yyyy-mm-dd')),Date(String(server_dt,'yyyy-mm-dd'))) > sys_option_input_days THEN
  173. rslt = 0
  174. arg_msg = '日期错误,日期不能落后系统日期'
  175. GOTO ext
  176. END IF
  177. ////////////////////////////////////////////// //开始区分:新建/更新 处理
  178. IF billid = 0 THEN //新建
  179. ls_newid = f_sys_scidentity(0,"u_oppose","billid",arg_msg,if_getid_ture,commit_transaction)
  180. IF ls_newid <= 0 THEN
  181. rslt = 0
  182. GOTO ext
  183. END IF
  184. //取得新单据编号
  185. IF billtype = 0 THEN
  186. billcode = getid(0,'TS',Date(server_dt),if_getid_ture,commit_transaction)
  187. ELSE
  188. billcode = getid(0,'SS',Date(server_dt),if_getid_ture,commit_transaction)
  189. END IF
  190. IF billcode = "err" THEN
  191. billcode = ''
  192. rslt = 0
  193. arg_msg = "无法获取单据编号"+"~n"+commit_transaction.SQLErrText
  194. GOTO ext
  195. END IF
  196. INSERT INTO u_oppose(billid,
  197. billdate,
  198. opposedept,
  199. thdate,
  200. fhdate,
  201. threason,
  202. custdscrp,
  203. saleidea,
  204. productieda,
  205. qualityidea,
  206. manageridea,
  207. improveidea,
  208. billcode,
  209. opdate,
  210. opemp,
  211. billtype,
  212. relid,
  213. wkpdscrp,
  214. opposeamt,
  215. itemid,
  216. responsibler
  217. )
  218. VALUES(:ls_newid,
  219. :billdate,
  220. :opposedept,
  221. :thdate,
  222. :fhdate,
  223. :threason,
  224. :custdscrp,
  225. :saleidea,
  226. :productieda,
  227. :qualityidea,
  228. :manageridea,
  229. :improveidea,
  230. :billcode,
  231. getdate(),
  232. :publ_operator,
  233. :billtype,
  234. :relid,
  235. :ls_wkpdscrp,
  236. :opposeamt,
  237. :itemid,
  238. :responsibler
  239. ) Using commit_transaction ;
  240. IF commit_transaction.SQLCode <> 0 THEN
  241. rslt = 0
  242. IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_oppose') > 0 THEN
  243. arg_msg = '插入操作失败,关键字单据ID重复'
  244. ELSEIF Pos(Lower(commit_transaction.SQLErrText),'IX_u_oppose') > 0 THEN
  245. arg_msg = '插入操作失败,单据编号重复'
  246. ELSE
  247. arg_msg = "插入操作失败"+"~n"+commit_transaction.SQLErrText
  248. END IF
  249. GOTO ext
  250. END IF
  251. // FOR i = 1 TO it_depmxbt
  252. // INSERT INTO u_opposemx_dept(deptid,
  253. // billid,
  254. // opemp,
  255. // opdate)
  256. // Values (:opposemx_dept[i].deptid,:ls_newid,:publ_operator,getdate()) USING commit_transaction ;
  257. // IF commit_transaction.SQLCode <> 0 THEN
  258. // billid = 0
  259. // rslt = 0
  260. //
  261. // IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_opposemx_dept') > 0 THEN
  262. // arg_msg = '插入明细操作失败,关键字单据ID,序号重复'
  263. // ELSE
  264. // arg_msg = "插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  265. // END IF
  266. //
  267. // GOTO ext
  268. // END IF
  269. // NEXT
  270. //读取新inwareid
  271. billid = ls_newid
  272. // FOR i = 1 TO it_mxbt
  273. // INSERT INTO u_opposemx_mtrl(
  274. // mtrlid,
  275. // status,
  276. // qty,
  277. // mxdscrp ,
  278. // billid)
  279. // VALUES ( :opposemx_mtrl[i].mtrlid,
  280. // :opposemx_mtrl[i].status,
  281. // :opposemx_mtrl[i].qty,
  282. // :opposemx_mtrl[i].mxdscrp,
  283. // :ls_newid
  284. // ) USING commit_transaction;
  285. // IF commit_transaction.SQLCode <> 0 THEN
  286. // billid = 0 //还原inwareid
  287. // rslt = 0
  288. //
  289. // IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_opposemx_mtrl') > 0 THEN
  290. // arg_msg = '插入明细操作失败,关键字单据ID,序号重复'
  291. // ELSE
  292. // arg_msg = "插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  293. // END IF
  294. // GOTO ext
  295. // END IF
  296. // NEXT
  297. ELSE //////////////////////////////////////////////////更新
  298. UPDATE u_oppose
  299. SET billid = :billid,
  300. billdate = :billdate,
  301. opposedept = :opposedept,
  302. thdate = :thdate,
  303. fhdate = :fhdate,
  304. threason = :threason,
  305. custdscrp = :custdscrp,
  306. saleidea = :saleidea,
  307. productieda = :productieda,
  308. qualityidea = :qualityidea,
  309. manageridea = :manageridea,
  310. improveidea = :improveidea,
  311. billcode = :billcode,
  312. moddate = getdate(),
  313. modemp = :publ_operator,
  314. relid = :relid,
  315. wkpdscrp = :ls_wkpdscrp,
  316. opposeamt = :opposeamt,
  317. itemid = :itemid,
  318. responsibler = :responsibler
  319. WHERE u_oppose.billid = :billid
  320. And flag = 0 Using commit_transaction;
  321. IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN
  322. rslt = 0
  323. arg_msg = "更新单据操作失败"+"~n"+commit_transaction.SQLErrText
  324. GOTO ext
  325. END IF
  326. //删除原有明细
  327. DELETE FROM u_opposemx_dept
  328. Where u_opposemx_dept.billid = :billid Using commit_transaction;
  329. IF commit_transaction.SQLCode <> 0 THEN
  330. rslt = 0
  331. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  332. GOTO ext
  333. END IF
  334. //删除原有明细
  335. DELETE FROM u_opposemx_mtrl
  336. Where u_opposemx_mtrl.billid = :billid Using commit_transaction;
  337. IF commit_transaction.SQLCode <> 0 THEN
  338. rslt = 0
  339. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  340. GOTO ext
  341. END IF
  342. END IF
  343. FOR i = 1 To it_depmxbt
  344. INSERT INTO u_opposemx_dept(deptid,
  345. billid,
  346. opemp,
  347. opdate)
  348. Values (:opposemx_dept[i].deptid,:billid,:publ_operator,getdate()) Using commit_transaction ;
  349. IF commit_transaction.SQLCode <> 0 THEN
  350. IF it_newbegin THEN billid = 0
  351. rslt = 0
  352. IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_opposemx_dept') > 0 THEN
  353. arg_msg = '插入投诉部门明细操作失败,关键字单据ID,序号重复'
  354. ELSE
  355. arg_msg = "插入投诉部门明细操作失败"+"~n"+commit_transaction.SQLErrText
  356. END IF
  357. GOTO ext
  358. END IF
  359. NEXT
  360. FOR i = 1 To it_mxbt
  361. INSERT INTO u_opposemx_mtrl(
  362. mtrlid,
  363. status,
  364. qty,
  365. mxdscrp ,
  366. billid,
  367. mxtype,
  368. scid,
  369. relid,
  370. relprintid)
  371. VALUES ( :opposemx_mtrl[i].mtrlid,
  372. :opposemx_mtrl[i].status,
  373. :opposemx_mtrl[i].qty,
  374. :opposemx_mtrl[i].mxdscrp,
  375. :billid,
  376. :opposemx_mtrl[i].mxtype,
  377. :opposemx_mtrl[i].scid,
  378. :opposemx_mtrl[i].relid,
  379. :opposemx_mtrl[i].relprintid
  380. ) Using commit_transaction;
  381. IF commit_transaction.SQLCode <> 0 THEN
  382. IF it_newbegin THEN billid = 0
  383. rslt = 0
  384. IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_opposemx_mtrl') > 0 THEN
  385. arg_msg = '插入投诉产品明细操作失败,关键字单据ID,序号重复'
  386. ELSE
  387. arg_msg = "插入投诉产品明细操作失败"+"~n"+commit_transaction.SQLErrText
  388. END IF
  389. GOTO ext
  390. END IF
  391. NEXT
  392. it_newbegin = False
  393. it_updatebegin = False
  394. ext:
  395. IF rslt = 0 THEN
  396. ROLLBACK Using commit_transaction;
  397. p_clearmx()
  398. ELSEIF rslt = 1 And arg_ifcommit THEN
  399. COMMIT Using commit_transaction;
  400. END IF
  401. RETURN rslt
  402. end function
  403. public function integer p_clearmx ();//int p_clearmx()
  404. //清除明细
  405. it_mxbt=0
  406. it_depmxbt=0
  407. return 1
  408. end function
  409. public function integer p_reset ();//int p_reset()
  410. //清除对象及其明细
  411. billid = 0
  412. billcode = ''
  413. opemp = ''
  414. modemp = ''
  415. auditingrep = ''
  416. flag = 0
  417. opposedept = ''
  418. threason = ''
  419. custdscrp = ''
  420. saleidea = ''
  421. productieda = ''
  422. qualityidea = ''
  423. manageridea = ''
  424. improveidea = ''
  425. opposeamt = 0
  426. itemid = 0
  427. it_newbegin = false
  428. it_updatebegin = false
  429. //清除明细
  430. p_clearmx()
  431. return 1
  432. end function
  433. public function integer getinfo (long arg_scid, long arg_billid, ref string arg_msg);Int rslt = 1
  434. Long i = 1,no_mxcheck = 0,j = 1
  435. IF arg_billid <= 0 THEN
  436. rslt = 0
  437. arg_msg = "非法单据唯一码"
  438. GOTO ext
  439. END IF
  440. rslt = p_getinfo(arg_billid,arg_msg)
  441. IF rslt = 0 THEN GOTO ext
  442. //用游标读取明细
  443. DECLARE cur_inwaermx CURSOR FOR
  444. SELECT u_opposemx_mtrl.mtrlid,
  445. u_opposemx_mtrl.status,
  446. u_opposemx_mtrl.qty,
  447. u_opposemx_mtrl.mxdscrp,
  448. u_opposemx_mtrl.scid,
  449. u_opposemx_mtrl.relid,
  450. u_opposemx_mtrl.relprintid
  451. FROM u_opposemx_mtrl
  452. Where u_opposemx_mtrl.billid = :arg_billid Using commit_transaction;
  453. OPEN cur_inwaermx;
  454. FETCH cur_inwaermx INTO :opposemx_mtrl[i].mtrlid,
  455. :opposemx_mtrl[i].status,:opposemx_mtrl[i].qty ,
  456. :opposemx_mtrl[i].mxdscrp,
  457. :opposemx_mtrl[i].scid,
  458. :opposemx_mtrl[i].relid,
  459. :opposemx_mtrl[i].relprintid ;
  460. DO WHILE commit_transaction.SQLCode = 0
  461. i++
  462. FETCH cur_inwaermx INTO :opposemx_mtrl[i].mtrlid,
  463. :opposemx_mtrl[i].status,:opposemx_mtrl[i].qty ,
  464. :opposemx_mtrl[i].mxdscrp ,
  465. :opposemx_mtrl[i].scid,
  466. :opposemx_mtrl[i].relid,
  467. :opposemx_mtrl[i].relprintid ;
  468. LOOP
  469. CLOSE cur_inwaermx;
  470. //检验明细是否读入完整
  471. SELECT count(*) INTO :no_mxcheck
  472. FROM u_opposemx_mtrl
  473. WHERE u_opposemx_mtrl.billid = :arg_billid
  474. Using commit_transaction;
  475. IF commit_transaction.SQLCode <> 0 THEN
  476. rslt = 0
  477. arg_msg = "查询操作失败,进仓单明细数量"
  478. GOTO ext
  479. END IF
  480. IF i <> (no_mxcheck+1) THEN
  481. rslt = 0
  482. arg_msg = "查询操作失败,投诉单产品明细"
  483. GOTO ext
  484. END IF
  485. //用游标读取明细
  486. DECLARE cur_depmx CURSOR FOR
  487. SELECT u_opposemx_dept.deptid
  488. FROM u_opposemx_dept
  489. Where u_opposemx_dept.billid = :arg_billid Using commit_transaction;
  490. OPEN cur_depmx;
  491. FETCH cur_depmx Into :opposemx_dept[i].deptid ;
  492. DO WHILE commit_transaction.SQLCode = 0
  493. j++
  494. FETCH cur_depmx Into :opposemx_dept[i].deptid ;
  495. LOOP
  496. CLOSE cur_depmx;
  497. //检验明细是否读入完整
  498. SELECT count(*) INTO :no_mxcheck
  499. FROM u_opposemx_dept
  500. WHERE u_opposemx_dept.billid = :arg_billid
  501. Using commit_transaction;
  502. IF commit_transaction.SQLCode <> 0 THEN
  503. rslt = 0
  504. arg_msg = "查询操作失败,投诉单部门明细"
  505. GOTO ext
  506. END IF
  507. IF j <> (no_mxcheck+1) THEN
  508. rslt = 0
  509. arg_msg = "查询操作失败,进仓单明细"
  510. GOTO ext
  511. END IF
  512. billid = arg_billid
  513. it_mxbt = i - 1
  514. it_depmxbt = j - 1
  515. it_newbegin = False
  516. it_updatebegin = False
  517. ext:
  518. IF rslt = 0 THEN p_reset()
  519. RETURN rslt
  520. end function
  521. public function integer updatebegin (long arg_billid, ref string arg_msg);Long rslt = 1
  522. IF arg_billid <= 0 THEN
  523. rslt = 0
  524. GOTO ext
  525. END IF
  526. rslt = p_getinfo(arg_billid,arg_msg)
  527. IF rslt = 0 THEN GOTO ext
  528. IF flag = 1 THEN
  529. rslt = 0
  530. arg_msg = '单据已经审核,不可以修改'
  531. GOTO ext
  532. END IF
  533. billid = arg_billid
  534. it_newbegin = False
  535. it_updatebegin = True
  536. p_clearmx() //清除明细
  537. ext:
  538. IF rslt = 0 THEN p_reset()
  539. RETURN rslt
  540. end function
  541. public function integer p_getinfo (long arg_billid, ref string arg_msg);//p_getinfo(arg_scid,arg_inwareid,arg_msg)
  542. //0 失败 1成功
  543. Int rslt = 1
  544. IF arg_billid <= 0 THEN
  545. rslt = 0
  546. arG_MSG = "非法单据唯一码"
  547. GOTO ext
  548. END IF
  549. SELECT u_oppose.billid,
  550. u_oppose.billdate,
  551. u_oppose.billtype,
  552. u_oppose.relid,
  553. u_oppose.opposedept,
  554. u_oppose.thdate,
  555. u_oppose.fhdate,
  556. u_oppose.threason,
  557. u_oppose.custdscrp,
  558. u_oppose.saleidea,
  559. u_oppose.productieda,
  560. u_oppose.qualityidea,
  561. u_oppose.manageridea,
  562. u_oppose.improveidea,
  563. u_oppose.billcode,
  564. u_oppose.opdate,
  565. u_oppose.opemp,
  566. u_oppose.moddate,
  567. u_oppose.modemp,
  568. u_oppose.flag,
  569. u_oppose.auditdate,
  570. u_oppose.auditemp ,
  571. u_oppose.wkpdscrp,
  572. u_oppose.opposeamt,
  573. u_oppose.itemid
  574. INTO :billid,
  575. :billdate,
  576. :billtype,
  577. :relid,
  578. :opposedept,
  579. :thdate,
  580. :fhdate,
  581. :threason,
  582. :custdscrp,
  583. :saleidea,
  584. :productieda,
  585. :qualityidea,
  586. :manageridea,
  587. :improveidea,
  588. :billcode,
  589. :opdate,
  590. :opemp,
  591. :moddate,
  592. :modemp,
  593. :flag,
  594. :auditingdate,
  595. :auditingrep,
  596. :wkpdscrp,
  597. :opposeamt,
  598. :itemid
  599. FROM u_oppose
  600. Where u_oppose.billid = :arg_billid Using commit_transaction;
  601. IF commit_transaction.SQLCode <> 0 THEN
  602. rslt = 0
  603. arG_MSG = "查询操作失败(错误单据唯一码)"+commit_transaction.SQLErrText
  604. GOTO ext
  605. END IF
  606. billid = arg_billid
  607. ext:
  608. IF rslt = 0 THEN p_reset()
  609. RETURN rslt
  610. end function
  611. public function integer del (long arg_billid, ref string arg_msg, boolean arg_ifcommit);
  612. Int rslt = 1
  613. IF arg_billid = 0 THEN
  614. rslt = 0
  615. arg_msg = "没有删除对象,操作取消"
  616. GOTO ext
  617. END IF
  618. rslt = p_getinfo(arg_billid,arg_msg)
  619. IF rslt = 0 THEN GOTO ext
  620. IF flag = 1 THEN
  621. rslt = 0
  622. arg_msg = "单据已经审核,不可以删除"
  623. GOTO ext
  624. END IF
  625. DELETE FROM u_opposemx_mtrl
  626. Where u_opposemx_mtrl.billid = :arg_billid Using commit_transaction;
  627. IF commit_transaction.SQLCode <> 0 THEN
  628. rslt = 0
  629. arg_msg = "删除客户投诉单明细操作失败"+"~n"+commit_transaction.SQLErrText
  630. GOTO ext
  631. END IF
  632. DELETE FROM u_opposemx_dept
  633. Where u_opposemx_dept.billid = :arg_billid Using commit_transaction;
  634. IF commit_transaction.SQLCode <> 0 THEN
  635. rslt = 0
  636. arg_msg = "删除客户投诉单部门明细操作失败"+"~n"+commit_transaction.SQLErrText
  637. GOTO ext
  638. END IF
  639. DELETE FROM u_oppose
  640. Where u_oppose.billid = :arg_billid Using commit_transaction;
  641. IF commit_transaction.SQLCode <> 0 THEN
  642. rslt = 0
  643. arg_msg = "删除客户投诉单操作失败"+"~n"+commit_transaction.SQLErrText
  644. GOTO ext
  645. END IF
  646. it_newbegin = False
  647. it_updatebegin = False
  648. ext:
  649. IF rslt = 0 THEN
  650. ROLLBACK Using commit_transaction;
  651. ELSEIF rslt = 1 And arg_ifcommit THEN
  652. COMMIT Using commit_transaction;
  653. END IF
  654. p_reset()
  655. RETURN rslt
  656. end function
  657. public function integer auditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1
  658. IF arg_billid = 0 THEN
  659. rslt = 0
  660. arg_msg = "没有审核对象"
  661. GOTO ext
  662. END IF
  663. IF p_getinfo(arg_billid,arg_msg) = 0 THEN
  664. rslt = 0
  665. GOTO ext
  666. END IF
  667. IF flag = 1 THEN
  668. rslt = 0
  669. arg_msg = "单据已经审核"
  670. GOTO ext
  671. END IF
  672. UPDATE u_oppose
  673. SET auditemp = :publ_operator,
  674. auditdate = getdate(),
  675. flag = 1
  676. Where u_oppose.billid = :billid And flag = 0 Using commit_transaction;
  677. IF commit_transaction.SQLCode <> 0 THEN
  678. rslt = 0
  679. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  680. GOTO ext
  681. ELSEIF commit_transaction.SQLNRows = 0 THEN
  682. rslt = 0
  683. arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  684. GOTO ext
  685. END IF
  686. flag = 1
  687. ext:
  688. IF rslt = 0 THEN
  689. ROLLBACK Using commit_transaction;
  690. ELSEIF rslt = 1 And arg_ifcommit THEN
  691. COMMIT Using commit_transaction;
  692. END IF
  693. RETURN rslt
  694. end function
  695. public function integer c_auditing (long arg_billid, boolean arg_ifcommit, ref string arg_msg);
  696. Long rslt = 1
  697. DateTime null_dt
  698. SetNull(null_dt)
  699. IF arg_billid = 0 THEN
  700. rslt = 0
  701. arg_msg = "没有审核对象"
  702. GOTO ext
  703. END IF
  704. IF it_newbegin Or it_updatebegin THEN
  705. rslt = 0
  706. arg_msg = "编辑状态下不可以执行审核"
  707. GOTO ext
  708. END IF
  709. IF p_getinfo(arg_billid,arg_msg) = 0 THEN
  710. rslt = 0
  711. GOTO ext
  712. END IF
  713. IF flag = 0 THEN
  714. rslt = 0
  715. arg_msg = "单据还未审核"
  716. GOTO ext
  717. END IF
  718. UPDATE u_oppose
  719. SET auditemp = '',
  720. auditdate = :null_dt,
  721. flag = 0
  722. WHERE u_oppose.billid = :billid
  723. And flag = 1 Using commit_transaction;
  724. IF commit_transaction.SQLCode <> 0 THEN
  725. rslt = 0
  726. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  727. GOTO ext
  728. ELSEIF commit_transaction.SQLNRows = 0 THEN
  729. rslt = 0
  730. arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  731. GOTO ext
  732. END IF
  733. flag = 0
  734. ext:
  735. IF rslt = 0 THEN
  736. ROLLBACK Using commit_transaction;
  737. ELSEIF rslt = 1 And arg_ifcommit THEN
  738. COMMIT Using commit_transaction;
  739. END IF
  740. RETURN rslt
  741. end function
  742. public function integer newbegin (integer arg_billtype, ref string arg_msg);Int rslt = 1
  743. IF arg_billtype <> 0 And arg_billtype <> 1 THEN
  744. arg_msg = '错误的单据类型:0-客户/部门投诉单,1-供应商投诉单'
  745. rslt = 0
  746. GOTO ext
  747. END IF
  748. p_reset()
  749. it_newbegin = True
  750. it_updatebegin = False
  751. billtype = arg_billtype
  752. ext :
  753. IF rslt = 0 THEN p_reset()
  754. RETURN rslt
  755. end function
  756. public function long acceptdeptid (long arg_deptid, ref string arg_msg);Int rslt = 1
  757. Long i
  758. String ls_wrkGrpName
  759. IF IsNull(arg_deptid) THEN arg_deptid = 0
  760. IF arg_deptid = 0 THEN
  761. rslt = 1
  762. GOTO ext
  763. END IF
  764. SELECT workgroupname INTO :ls_wrkGrpName
  765. FROM u_workgroup
  766. Where workgroupid = :arg_deptid;
  767. IF sqlca.SQLCode <> 0 THEN
  768. arg_msg = '查询责任部门资料失败'
  769. rslt = 0
  770. GOTO ext
  771. END IF
  772. FOR i = 1 To it_depmxbt
  773. IF opposemx_dept[i].deptid = arg_deptid THEN
  774. rslt = 1
  775. GOTO ext
  776. END IF
  777. NEXT
  778. it_depmxbt++
  779. opposemx_dept[it_depmxbt].deptid = arg_deptid
  780. opposemx_dept[it_depmxbt].wkpname = ls_wrkGrpName
  781. ext:
  782. IF rslt = 0 THEN p_clearmx()
  783. RETURN rslt
  784. end function
  785. public function integer add_qualityidea (long arg_billid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  786. arg_newdescppart = Trim(arg_newdescppart)
  787. IF it_updatebegin OR it_newbegin THEN
  788. rslt = 0
  789. arG_MSG = "编辑状态下不可用"
  790. GOTO ext
  791. END IF
  792. IF arg_newdescppart = '' THEN
  793. rslt = 0
  794. arG_MSG = "要添加内容为空,操作取消"
  795. GOTO ext
  796. END IF
  797. IF p_getinfo(arg_billid,arG_MSG) = 0 THEN
  798. rslt = 0
  799. GOTO ext
  800. END IF
  801. IF flag = 1 THEN
  802. rslt = 0
  803. arG_MSG = "审核状态下不可用"
  804. GOTO ext
  805. END IF
  806. UPDATE u_oppose
  807. SET qualityidea = qualityidea+' '+:arg_newdescppart
  808. Where u_oppose.billid = :arg_billid USING commit_transaction ;
  809. IF commit_transaction.SQLCode <> 0 THEN
  810. rslt = 0
  811. arG_MSG = "因网络或其它原因导致添加操作失败"+"~n"+ commit_transaction.SQLErrText
  812. GOTO ext
  813. END IF
  814. qualityidea = qualityidea+' '+arg_newdescppart
  815. it_newbegin = FALSE
  816. it_updatebegin = FALSE
  817. ext:
  818. IF rslt = 0 THEN
  819. ROLLBACK USING commit_transaction;
  820. ELSEIF arg_ifcommit THEN
  821. COMMIT USING commit_transaction;
  822. END IF
  823. p_reset()
  824. Return (rslt)
  825. end function
  826. public function integer add_manageridea (long arg_billid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  827. arg_newdescppart = Trim(arg_newdescppart)
  828. IF it_updatebegin OR it_newbegin THEN
  829. rslt = 0
  830. arG_MSG = "编辑状态下不可用"
  831. GOTO ext
  832. END IF
  833. IF arg_newdescppart = '' THEN
  834. rslt = 0
  835. arG_MSG = "要添加内容为空,操作取消"
  836. GOTO ext
  837. END IF
  838. IF p_getinfo(arg_billid,arG_MSG) = 0 THEN
  839. rslt = 0
  840. GOTO ext
  841. END IF
  842. IF flag = 1 THEN
  843. rslt = 0
  844. arG_MSG = "审核状态下不可用"
  845. GOTO ext
  846. END IF
  847. UPDATE u_oppose
  848. SET manageridea = manageridea+' '+:arg_newdescppart
  849. Where u_oppose.billid = :arg_billid USING commit_transaction ;
  850. IF commit_transaction.SQLCode <> 0 THEN
  851. rslt = 0
  852. arG_MSG = "因网络或其它原因导致添加操作失败"+"~n"+ commit_transaction.SQLErrText
  853. GOTO ext
  854. END IF
  855. manageridea = manageridea+' '+arg_newdescppart
  856. it_newbegin = FALSE
  857. it_updatebegin = FALSE
  858. ext:
  859. IF rslt = 0 THEN
  860. ROLLBACK USING commit_transaction;
  861. ELSEIF arg_ifcommit THEN
  862. COMMIT USING commit_transaction;
  863. END IF
  864. p_reset()
  865. Return (rslt)
  866. end function
  867. public function integer add_improveidea (long arg_billid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  868. arg_newdescppart = Trim(arg_newdescppart)
  869. IF it_updatebegin OR it_newbegin THEN
  870. rslt = 0
  871. arG_MSG = "编辑状态下不可用"
  872. GOTO ext
  873. END IF
  874. IF arg_newdescppart = '' THEN
  875. rslt = 0
  876. arG_MSG = "要添加内容为空,操作取消"
  877. GOTO ext
  878. END IF
  879. IF p_getinfo(arg_billid,arG_MSG) = 0 THEN
  880. rslt = 0
  881. GOTO ext
  882. END IF
  883. IF flag = 1 THEN
  884. rslt = 0
  885. arG_MSG = "审核状态下不可用"
  886. GOTO ext
  887. END IF
  888. UPDATE u_oppose
  889. SET improveidea = improveidea+' '+:arg_newdescppart
  890. Where u_oppose.billid = :arg_billid USING commit_transaction ;
  891. IF commit_transaction.SQLCode <> 0 THEN
  892. rslt = 0
  893. arG_MSG = "因网络或其它原因导致添加操作失败"+"~n"+ commit_transaction.SQLErrText
  894. GOTO ext
  895. END IF
  896. improveidea = improveidea+' '+arg_newdescppart
  897. it_newbegin = FALSE
  898. it_updatebegin = FALSE
  899. ext:
  900. IF rslt = 0 THEN
  901. ROLLBACK USING commit_transaction;
  902. ELSEIF arg_ifcommit THEN
  903. COMMIT USING commit_transaction;
  904. END IF
  905. p_reset()
  906. Return (rslt)
  907. end function
  908. public function integer add_productieda (long arg_billid, long arg_deptid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  909. arg_newdescppart = Trim(arg_newdescppart)
  910. IF it_updatebegin OR it_newbegin THEN
  911. rslt = 0
  912. arG_MSG = "编辑状态下不可用"
  913. GOTO ext
  914. END IF
  915. IF arg_newdescppart = '' THEN
  916. rslt = 0
  917. arG_MSG = "要添加内容为空,操作取消"
  918. GOTO ext
  919. END IF
  920. IF p_getinfo(arg_billid,arG_MSG) = 0 THEN
  921. rslt = 0
  922. GOTO ext
  923. END IF
  924. IF flag = 1 THEN
  925. rslt = 0
  926. arG_MSG = "审核状态下不可用"
  927. GOTO ext
  928. END IF
  929. UPDATE u_opposemx_dept
  930. SET productieda = productieda+' '+:arg_newdescppart,
  931. opemp = :publ_operator,
  932. opdate = getdate()
  933. WHERE u_opposemx_dept.billid = :arg_billid
  934. AND u_opposemx_dept.deptid = :arg_deptid USING commit_transaction ;
  935. IF commit_transaction.SQLCode <> 0 THEN
  936. rslt = 0
  937. arG_MSG = "因网络或其它原因导致添加操作失败"+"~n"+ commit_transaction.SQLErrText
  938. GOTO ext
  939. END IF
  940. it_newbegin = FALSE
  941. it_updatebegin = FALSE
  942. ext:
  943. IF rslt = 0 THEN
  944. ROLLBACK USING commit_transaction;
  945. ELSEIF arg_ifcommit THEN
  946. COMMIT USING commit_transaction;
  947. END IF
  948. p_reset()
  949. Return (rslt)
  950. end function
  951. public function integer acceptmx (long arg_mtrlid, string arg_status, decimal arg_qty, string arg_mxdscrp, long arg_mxtype, long arg_scid, long arg_relid, long arg_relprintid, ref string arg_msg);Int rslt = 1
  952. Long cnt = 0,ls_i
  953. IF it_newbegin = False And it_updatebegin = False THEN
  954. rslt = 0
  955. arg_msg = "非编辑状态不可以使用,操作取消"
  956. GOTO ext
  957. END IF
  958. //清除空值
  959. IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
  960. IF IsNull(arg_status) THEN arg_status = ''
  961. IF IsNull(arg_qty) THEN arg_qty = 0
  962. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  963. IF IsNull(arg_scid) THEN arg_scid = 0
  964. IF IsNull(arg_relid) THEN arg_relid = 0
  965. IF IsNull(arg_relprintid) THEN arg_relprintid = 0
  966. IF IsNull(arg_mxtype) THEN arg_mxtype = 0
  967. // 如果进仓数量为 0,或物料编号为空,则不作任何处理
  968. IF arg_mtrlid = 0 Or arg_qty = 0 THEN
  969. rslt = 1
  970. GOTO ext
  971. END IF
  972. FOR ls_i = 1 To it_mxbt
  973. IF opposemx_mtrl[ls_i].mtrlid = arg_mtrlid And opposemx_mtrl[ls_i].status = arg_status THEN
  974. rslt = 1
  975. GOTO ext
  976. END IF
  977. NEXT
  978. //写入内容
  979. it_mxbt++
  980. opposemx_mtrl[it_mxbt].mtrlid = arg_mtrlid
  981. opposemx_mtrl[it_mxbt].status = arg_status
  982. opposemx_mtrl[it_mxbt].qty = arg_qty
  983. opposemx_mtrl[it_mxbt].mxdscrp = arg_mxdscrp
  984. opposemx_mtrl[it_mxbt].mxtype = arg_mxtype //0:销售订单; 1:销售发货单
  985. opposemx_mtrl[it_mxbt].scid = arg_scid
  986. opposemx_mtrl[it_mxbt].relid = arg_relid
  987. opposemx_mtrl[it_mxbt].relprintid = arg_relprintid
  988. ext:
  989. IF rslt = 0 THEN p_clearmx()
  990. Return(rslt)
  991. end function
  992. on uo_oppose.create
  993. call super::create
  994. TriggerEvent( this, "constructor" )
  995. end on
  996. on uo_oppose.destroy
  997. TriggerEvent( this, "destructor" )
  998. call super::destroy
  999. end on