uo_cust_sample.sru 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  1. $PBExportHeader$uo_cust_sample.sru
  2. forward
  3. global type uo_cust_sample from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_cust_sample from nonvisualobject
  7. end type
  8. global uo_cust_sample uo_cust_sample
  9. type variables
  10. long sampleid
  11. int status
  12. Boolean IT_NEWBEGIN = TRUE //新建标志
  13. Boolean IT_UPDATEBEGIN = FALSE//修改标志
  14. int uo_option_cust_sample_secaudit
  15. end variables
  16. forward prototypes
  17. public function integer of_checkstatus (long arg_sampleid, ref string arg_msg)
  18. public function integer audit (long arg_sampleid, boolean arg_ifcommit, ref string arg_msg)
  19. public function integer caudit (long arg_sampleid, boolean arg_ifcommit, ref string arg_msg)
  20. public function integer csecaudit (long arg_sampleid, boolean arg_ifcommit, ref string arg_msg)
  21. public function integer secaudit (long arg_sampleid, boolean arg_ifcommit, ref string arg_msg)
  22. public function integer cancel (long arg_sampleid, boolean arg_ifcommit, ref string arg_msg)
  23. public function integer auditstatus (integer arg_type, long arg_sampleid, ref string arg_msg, boolean arg_ifcommit)
  24. public function integer updatebegin (long arg_sampleid[], ref string arg_msg)
  25. public function integer save (s_cust_sample arg_s_order, boolean arg_ifcommit, ref string arg_msg)
  26. public function integer p_reset ()
  27. public function integer trycmpl (long arg_sampleid, decimal arg_qty, ref string arg_msg, boolean arg_ifcommit)
  28. public function integer tmpstop (long arg_sampleid, ref string arg_msg, boolean arg_ifcommit)
  29. public function integer add_dscrp (long arg_sampleid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit)
  30. end prototypes
  31. public function integer of_checkstatus (long arg_sampleid, ref string arg_msg);Long rslt = 1
  32. IF arg_sampleid <= 0 THEN
  33. rslt = 0
  34. arg_msg = '错误的销售意向单唯一码!'
  35. GOTO ext
  36. END IF
  37. Long ls_status
  38. SELECT status
  39. INTO :ls_status
  40. FROM u_cust_sample
  41. Where sampleid = :arg_sampleid;
  42. IF sqlca.SQLCode <> 0 THEN
  43. rslt = 0
  44. arg_msg = '查询操作失败>'+sqlca.SQLErrText
  45. GOTO ext
  46. END IF
  47. status = ls_status
  48. ext:
  49. RETURN rslt
  50. end function
  51. public function integer audit (long arg_sampleid, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1
  52. IF uo_option_cust_sample_secaudit = -1000 THEN
  53. rslt = 0
  54. arg_msg = '选项:[372]销售意向单使用二级审核,读取初始默认值失败,操作取消!'
  55. GOTO ext
  56. END IF
  57. IF arg_sampleid <= 0 THEN
  58. rslt = 0
  59. arg_msg = '错误的销售意向单唯一码!'
  60. GOTO ext
  61. END IF
  62. IF of_checkstatus( arg_sampleid, arg_msg) = 0 THEN
  63. rslt = 0
  64. GOTO ext
  65. END IF
  66. UPDATE u_cust_sample
  67. SET status = 1,
  68. AuditingEmp = :publ_operator,
  69. AuditingDate = getdate()
  70. Where sampleid = :arg_sampleid Using sqlca;
  71. IF sqlca.SQLCode <> 0 THEN
  72. rslt = 0
  73. arg_msg = '更新操作失败》审核标记》'+sqlca.SQLErrText
  74. GOTO ext
  75. END IF
  76. IF uo_option_cust_sample_secaudit = 0 THEN
  77. IF secaudit( arg_sampleid,False, arg_msg) = 0 THEN
  78. rslt = 0
  79. arg_msg = '更新操作失败》审核标记》'+sqlca.SQLErrText
  80. GOTO ext
  81. END IF
  82. END IF
  83. ext:
  84. IF rslt = 0 THEN
  85. ROLLBACK;
  86. ELSEIF rslt = 1 And arg_ifcommit THEN
  87. COMMIT;
  88. END IF
  89. RETURN rslt
  90. end function
  91. public function integer caudit (long arg_sampleid, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1
  92. DateTime server_dt
  93. SetNull(server_dt)
  94. IF uo_option_cust_sample_secaudit = -1000 THEN
  95. rslt = 0
  96. arg_msg = '选项:[372]销售意向单使用二级审核,读取初始默认值失败,操作取消!'
  97. GOTO ext
  98. END IF
  99. IF arg_sampleid <= 0 THEN
  100. rslt = 0
  101. arg_msg = '错误的销售意向单唯一码!'
  102. GOTO ext
  103. END IF
  104. IF of_checkstatus( arg_sampleid, arg_msg) = 0 THEN
  105. rslt = 0
  106. GOTO ext
  107. END IF
  108. IF uo_option_cust_sample_secaudit = 0 THEN
  109. IF csecaudit( arg_sampleid,False, arg_msg) = 0 THEN
  110. rslt = 0
  111. arg_msg = '更新操作失败》审核标记》'+sqlca.SQLErrText
  112. GOTO ext
  113. END IF
  114. END IF
  115. UPDATE u_cust_sample
  116. SET status = 0,
  117. AuditingEmp = '',
  118. AuditingDate = :server_dt
  119. Where sampleid = :arg_sampleid Using sqlca;
  120. IF sqlca.SQLCode <> 0 THEN
  121. rslt = 0
  122. arg_msg = '更新操作失败》审核标记》'+sqlca.SQLErrText
  123. GOTO ext
  124. END IF
  125. ext:
  126. IF rslt = 0 THEN
  127. ROLLBACK;
  128. ELSEIF rslt = 1 And arg_ifcommit THEN
  129. COMMIT;
  130. END IF
  131. RETURN rslt
  132. end function
  133. public function integer csecaudit (long arg_sampleid, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1
  134. IF arg_sampleid <= 0 THEN
  135. rslt = 0
  136. arg_msg = '错误的销售意向单唯一码!'
  137. GOTO ext
  138. END IF
  139. IF of_checkstatus( arg_sampleid, arg_msg) = 0 THEN
  140. rslt = 0
  141. GOTO ext
  142. END IF
  143. DateTime server_dt
  144. SetNull(server_dt)
  145. UPDATE u_cust_sample
  146. SET status = 1,
  147. secAuditingEmp = '',
  148. secAuditingDate = :server_dt
  149. Where sampleid = :arg_sampleid Using sqlca;
  150. IF sqlca.SQLCode <> 0 THEN
  151. rslt = 0
  152. arg_msg = '更新操作失败》审核标记》'+sqlca.SQLErrText
  153. GOTO ext
  154. END IF
  155. ext:
  156. IF rslt = 0 THEN
  157. ROLLBACK;
  158. ELSEIF rslt = 1 And arg_ifcommit THEN
  159. COMMIT;
  160. END IF
  161. RETURN rslt
  162. end function
  163. public function integer secaudit (long arg_sampleid, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1
  164. IF arg_sampleid <= 0 THEN
  165. rslt = 0
  166. arg_msg = '错误的销售意向单唯一码!'
  167. GOTO ext
  168. END IF
  169. IF of_checkstatus( arg_sampleid, arg_msg) = 0 THEN
  170. rslt = 0
  171. GOTO ext
  172. END IF
  173. UPDATE u_cust_sample
  174. SET status = 2,
  175. secAuditingEmp = :publ_operator,
  176. secAuditingDate = getdate()
  177. Where sampleid = :arg_sampleid Using sqlca;
  178. IF sqlca.SQLCode <> 0 THEN
  179. rslt = 0
  180. arg_msg = '更新操作失败》审核标记》'+sqlca.SQLErrText
  181. GOTO ext
  182. END IF
  183. ext:
  184. IF rslt = 0 THEN
  185. ROLLBACK;
  186. ELSEIF rslt = 1 And arg_ifcommit THEN
  187. COMMIT;
  188. END IF
  189. RETURN rslt
  190. end function
  191. public function integer cancel (long arg_sampleid, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  192. IF arg_sampleid <= 0 THEN
  193. rslt = 0
  194. arg_msg = '错误单据唯一码'
  195. GOTO ext
  196. END IF
  197. Int li_status
  198. SELECT status INTO :li_status
  199. FROM u_cust_sample
  200. Where sampleid = :arg_sampleid;
  201. IF sqlca.SQLCode <> 0 THEN
  202. arg_msg = '查询单据审核标记失败'
  203. rslt = 0
  204. GOTO ext
  205. END IF
  206. IF li_status <> 0 THEN
  207. rslt = 0
  208. arg_msg = '单据已经审核,不可以删除'
  209. GOTO ext
  210. END IF
  211. DELETE FROM u_cust_sample Where sampleid = :arg_sampleid;
  212. IF sqlca.SQLCode <> 0 THEN
  213. rslt = 0
  214. arg_msg = "删除单据操作失败"+"~n"+sqlca.SQLErrText
  215. GOTO ext
  216. END IF
  217. ext:
  218. IF rslt = 0 THEN
  219. ROLLBACK;
  220. ELSEIF rslt = 1 AND arg_ifcommit THEN
  221. COMMIT;
  222. END IF
  223. RETURN rslt
  224. end function
  225. public function integer auditstatus (integer arg_type, long arg_sampleid, ref string arg_msg, boolean arg_ifcommit);
  226. Int rslt = 1
  227. Int li_status
  228. DateTime ls_null
  229. SetNull(ls_null)
  230. Decimal lde_orderqty, lde_acmpqty, lde_stopqty
  231. SELECT status
  232. INTO :li_status
  233. FROM u_cust_sample
  234. Where sampleid = :arg_sampleid;
  235. IF sqlca.SQLCode <> 0 THEN
  236. ARG_MSG = '查询单据审核标记失败,'+sqlca.SQLErrText
  237. rslt = 0
  238. GOTO ext
  239. END IF
  240. CHOOSE CASE arg_type
  241. CASE 1
  242. IF li_status <> 2 AND li_status <> 8 THEN
  243. rslt = 0
  244. ARG_MSG = "计划只有在进行状态才可以执行暂停,请核对"
  245. GOTO ext
  246. END IF
  247. IF li_status = 2 THEN
  248. UPDATE u_cust_sample
  249. SET status = 8,
  250. tmpstopemp = :publ_operator,
  251. tmpstopdate = getdate()
  252. Where sampleid = :arg_sampleid;
  253. IF sqlca.SQLCode <> 0 THEN
  254. rslt = 0
  255. ARG_MSG = "因网络或其它原因导致暂停计划操作失败"+"~n"+sqlca.SQLErrText
  256. GOTO ext
  257. END IF
  258. ELSE
  259. UPDATE u_cust_sample
  260. SET status = 2,
  261. tmpstopemp = '',
  262. tmpstopdate = :ls_null
  263. Where sampleid = :arg_sampleid ;
  264. IF sqlca.SQLCode <> 0 THEN
  265. rslt = 0
  266. ARG_MSG = "因网络或其它原因导致取消暂停计划操作失败"+"~n"+sqlca.SQLErrText
  267. GOTO ext
  268. END IF
  269. END IF
  270. CASE 2
  271. IF li_status <> 2 AND li_status <> 9 THEN
  272. rslt = 0
  273. ARG_MSG = "计划只有在进行状态才可以执行终止,请核对"
  274. GOTO ext
  275. END IF
  276. IF li_status = 2 THEN
  277. UPDATE u_cust_sample
  278. SET status = 9,
  279. stopemp = :publ_operator,
  280. stopdate = getdate()
  281. Where sampleid = :arg_sampleid;
  282. IF sqlca.SQLCode <> 0 THEN
  283. rslt = 0
  284. ARG_MSG = "因网络或其它原因导致终止计划操作失败"+"~n"+sqlca.SQLErrText
  285. GOTO ext
  286. END IF
  287. ELSE
  288. UPDATE u_cust_sample
  289. SET status = 2,
  290. stopemp = '',
  291. stopdate = :ls_null
  292. Where sampleid = :arg_sampleid ;
  293. IF sqlca.SQLCode <> 0 THEN
  294. rslt = 0
  295. ARG_MSG = "因网络或其它原因导致取消终止计划操作失败"+"~n"+sqlca.SQLErrText
  296. GOTO ext
  297. END IF
  298. END IF
  299. CASE 3
  300. IF li_status <> 2 AND li_status <> 6 THEN
  301. rslt = 0
  302. ARG_MSG = "计划只有在进行状态才可以执行完成,请核对"
  303. GOTO ext
  304. END IF
  305. IF li_status = 2 THEN
  306. UPDATE u_cust_sample
  307. SET status = 6,
  308. Accomplishemp = :publ_operator,
  309. Accomplishdate = getdate()
  310. Where sampleid = :arg_sampleid;
  311. IF sqlca.SQLCode <> 0 THEN
  312. rslt = 0
  313. ARG_MSG = "因网络或其它原因导致完成计划操作失败"+"~n"+sqlca.SQLErrText
  314. GOTO ext
  315. END IF
  316. ELSE
  317. UPDATE u_cust_sample
  318. SET status = 2,
  319. Accomplishemp = '',
  320. Accomplishdate = :ls_null
  321. Where sampleid = :arg_sampleid ;
  322. IF sqlca.SQLCode <> 0 THEN
  323. rslt = 0
  324. ARG_MSG = "因网络或其它原因导致取消完成计划操作失败"+"~n"+sqlca.SQLErrText
  325. GOTO ext
  326. END IF
  327. END IF
  328. END CHOOSE
  329. ext:
  330. IF rslt = 0 THEN
  331. ROLLBACK;
  332. ELSEIF arg_ifcommit AND rslt = 1 THEN
  333. COMMIT;
  334. END IF
  335. Return (rslt)
  336. end function
  337. public function integer updatebegin (long arg_sampleid[], ref string arg_msg);Int rslt = 1
  338. Int li_status,i
  339. string ls_samplecode
  340. FOR i = 1 TO UpperBound(arg_sampleid[])
  341. IF arg_sampleid[i] <= 0 THEN
  342. rslt = 0
  343. arg_msg = '错误单据唯一码'
  344. GOTO ext
  345. END IF
  346. SELECT status,samplecode INTO :li_status,:ls_samplecode
  347. FROM u_cust_sample
  348. Where sampleid = :arg_sampleid[i];
  349. IF sqlca.SQLCode <> 0 THEN
  350. arg_msg = '查询单据状态标记失败'
  351. rslt = 0
  352. GOTO ext
  353. END IF
  354. IF li_status <> 0 THEN
  355. rslt = 0
  356. arg_msg = ls_samplecode+"已经处于审核或完成等状态,不可以修改"
  357. GOTO ext
  358. END IF
  359. NEXT
  360. ext:
  361. RETURN rslt
  362. end function
  363. public function integer save (s_cust_sample arg_s_order, boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1,cnt = 0
  364. DateTime server_dt
  365. Long ll_sampleid,ll_i,i,ll_j
  366. String ls_sccode,ls_samplecode
  367. if isnull(arg_s_order.cusid) then arg_s_order.cusid = 0
  368. if isnull(arg_s_order.mtrlid) then arg_s_order.mtrlid = 0
  369. if isnull(arg_s_order.kind) then arg_s_order.kind = 0
  370. if isnull(arg_s_order.samplecontent) then arg_s_order.samplecontent = ''
  371. if isnull(arg_s_order.mtrlcode) then arg_s_order.mtrlcode = ''
  372. if isnull(arg_s_order.mtrlname) then arg_s_order.mtrlname = ''
  373. if isnull(arg_s_order.mtrlmode) then arg_s_order.mtrlmode = ''
  374. if isnull(arg_s_order.unit) then arg_s_order.unit = ''
  375. if isnull(arg_s_order.simplename) then arg_s_order.simplename = ''
  376. if isnull(arg_s_order.mtrlcolor) then arg_s_order.mtrlcolor = ''
  377. if isnull(arg_s_order.configname) then arg_s_order.configname = ''
  378. if isnull(arg_s_order.cusnarrate) then arg_s_order.cusnarrate = ''
  379. if isnull(arg_s_order.dscrp) then arg_s_order.dscrp = ''
  380. if isnull(arg_s_order.relcode) then arg_s_order.relcode = ''
  381. IF Year(Date(arg_s_order.sampledate)) < 2000 THEN
  382. rslt = 0
  383. arg_msg = "计划日期为空或不合理"
  384. GOTO ext
  385. END IF
  386. IF Date(arg_s_order.sampledate) > Date(arg_s_order.requiredate) THEN
  387. rslt = 0
  388. arg_msg = "计划日期大于交货日期"
  389. GOTO ext
  390. END IF
  391. IF Trim(arg_s_order.saler) = '' THEN
  392. rslt = 0
  393. arg_msg = "请输入业务员"
  394. GOTO ext
  395. END IF
  396. If (arg_s_order.CUSID) = 0 THEN
  397. rslt = 0
  398. arg_msg = "请输入客户资料"
  399. GOTO ext
  400. END IF
  401. If (arg_s_order.ifrel) = 0 THEN
  402. arg_s_order.mtrlid = 0
  403. END IF
  404. SELECT Top 1 getdate() Into :server_dt From u_user;
  405. IF sqlca.SQLCode <> 0 THEN
  406. rslt = 0
  407. arg_msg = "查询操作失败,日期 "
  408. GOTO ext
  409. END IF
  410. IF arg_s_order.sampleid = 0 THEN //新建
  411. ll_sampleid = f_sys_scidentity(0,"u_cust_sample","sampleid",arg_msg,False,sqlca)
  412. IF ll_sampleid <= 0 THEN
  413. rslt = 0
  414. GOTO ext
  415. END IF
  416. ls_samplecode = getid(0,ls_sccode + 'PD',Date(server_dt),False,sqlca)
  417. IF ls_samplecode = "err" THEN
  418. rslt = 0
  419. arg_msg = "无法获取单据编号"+"~n"+sqlca.SQLErrText
  420. GOTO ext
  421. END IF
  422. INSERT INTO u_cust_sample
  423. (sampleid,
  424. samplecode,
  425. status,
  426. cusid,
  427. mtrlid,
  428. saler,
  429. sampledate,
  430. requiredate,
  431. relcode,
  432. qty,
  433. dscrp,
  434. ifrel,
  435. mtrlcode,
  436. mtrlname,
  437. mtrlmode,
  438. unit,
  439. opemp,
  440. opdate,
  441. kind,
  442. samplecontent,
  443. simplename,
  444. mtrlcolor,
  445. configname,
  446. cusnarrate)
  447. VALUES (
  448. :ll_sampleid,
  449. :ls_samplecode,
  450. :arg_s_order.status,
  451. :arg_s_order.cusid,
  452. :arg_s_order.mtrlid,
  453. :arg_s_order.saler,
  454. :arg_s_order.sampledate,
  455. :arg_s_order.requiredate,
  456. :arg_s_order.relcode,
  457. :arg_s_order.qty,
  458. :arg_s_order.dscrp,
  459. :arg_s_order.ifrel,
  460. :arg_s_order.mtrlcode,
  461. :arg_s_order.mtrlname,
  462. :arg_s_order.mtrlmode,
  463. :arg_s_order.unit,
  464. :publ_operator,
  465. getdate(),
  466. :arg_s_order.kind,
  467. :arg_s_order.samplecontent,
  468. :arg_s_order.simplename,
  469. :arg_s_order.mtrlcolor,
  470. :arg_s_order.configname,
  471. :arg_s_order.cusnarrate
  472. );
  473. IF sqlca.SQLCode <> 0 THEN
  474. rslt = 0
  475. arg_msg = "因网络或其它原因导致建立单据操作失败"+"~n"+sqlca.SQLErrText
  476. GOTO ext
  477. END IF
  478. ELSE //更新
  479. UPDATE u_cust_sample SET
  480. cusid = :arg_s_order.cusid,
  481. requiredate = :arg_s_order.requiredate,
  482. qty = :arg_s_order.qty,
  483. ifdata = :arg_s_order.ifdata,
  484. status = :arg_s_order.status,
  485. sampledate = :arg_s_order.sampledate,
  486. relcode = :arg_s_order.relcode,
  487. saler = :arg_s_order.saler,
  488. mtrlid = :arg_s_order.mtrlid,
  489. dscrp = :arg_s_order.dscrp,
  490. ifrel = :arg_s_order.ifrel,
  491. mtrlcode = :arg_s_order.mtrlcode,
  492. mtrlname = :arg_s_order.mtrlname,
  493. mtrlmode = :arg_s_order.mtrlmode,
  494. unit = :arg_s_order.unit,
  495. moddate = getdate(),
  496. modemp = :publ_operator,
  497. kind = :arg_s_order.kind,
  498. samplecontent = :arg_s_order.samplecontent,
  499. simplename = :arg_s_order.simplename,
  500. mtrlcolor = :arg_s_order.mtrlcolor,
  501. configname = :arg_s_order.configname,
  502. cusnarrate = :arg_s_order.cusnarrate
  503. Where sampleid = :arg_s_order.sampleid;
  504. IF sqlca.SQLCode <> 0 THEN
  505. rslt = 0
  506. arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+sqlca.SQLErrText
  507. GOTO ext
  508. END IF
  509. END IF
  510. ext:
  511. IF rslt = 0 THEN
  512. ROLLBACK;
  513. ELSEIF arg_ifcommit And rslt = 1 THEN
  514. COMMIT;
  515. END IF
  516. RETURN rslt
  517. end function
  518. public function integer p_reset ();sampleid = 0
  519. status = 0
  520. it_newbegin = FALSE
  521. it_updatebegin = FALSE
  522. RETURN 1
  523. end function
  524. public function integer trycmpl (long arg_sampleid, decimal arg_qty, ref string arg_msg, boolean arg_ifcommit);//trycmplsaletask(arg_sampleid,arg_msg,arg_ifcommit)
  525. Int rslt = 1,cnt = 0,ll_status
  526. DateTime null_dt
  527. SetNull(null_dt)
  528. Decimal ls_zerook
  529. Boolean if_finish
  530. IF arg_sampleid <= 0 THEN
  531. rslt = 0
  532. arg_msg = '错误销售意向单唯一码'
  533. GOTO ext
  534. END IF
  535. SELECT status INTO :ll_status
  536. FROM u_cust_sample
  537. Where sampleid = :arg_sampleid;
  538. IF sqlca.SQLCode <> 0 THEN
  539. rslt = 0
  540. arg_msg = '错误销售意向单状态失败'
  541. GOTO ext
  542. END IF
  543. IF ll_status <> 2 AND ll_status <> 5 THEN
  544. rslt = 0
  545. IF ll_status <> 2 THEN
  546. arg_msg = "销售意向单只有在进行状态下才可以执行设完成状态"
  547. ELSEIF status <> 5 THEN
  548. arg_msg = "销售意向单只有在完成状态下才可以执行撤消完成状态"
  549. END IF
  550. GOTO ext
  551. END IF
  552. UPDATE u_cust_sample SET
  553. consignedqty = consignedqty+:Arg_qty
  554. Where sampleid = :arg_sampleid;
  555. IF sqlca.SQLCode <> 0 THEN
  556. rslt = 0
  557. arg_msg = '更新销售意向单已开单数量失败'
  558. GOTO ext
  559. END IF
  560. if_finish = TRUE
  561. SELECT u_cust_sample.qty - u_cust_sample.consignedqty INTO :ls_zerook
  562. FROM u_cust_sample
  563. Where ( u_cust_sample.sampleid = :arg_sampleid );
  564. IF ls_zerook > 0 THEN if_finish = FALSE
  565. IF ll_status = 2 AND if_finish THEN
  566. UPDATE u_cust_sample
  567. SET status = 5,
  568. accomplishdate = getdate(),
  569. Accomplishemp = :publ_operator
  570. Where ( u_cust_sample.sampleid = :arg_sampleid );
  571. IF sqlca.SQLCode <> 0 THEN
  572. rslt = 0
  573. arg_msg = "因网络或其他原因导致销售意向单完成状态设置操作失败"+"~n"+sqlca.SQLErrText
  574. GOTO ext
  575. END IF
  576. END IF
  577. IF ll_status = 5 AND NOT if_finish THEN
  578. UPDATE u_cust_sample
  579. SET status = 2,
  580. accomplishdate = :null_dt,
  581. Accomplishemp = ''
  582. Where ( u_cust_sample.sampleid = :arg_sampleid );
  583. IF sqlca.SQLCode <> 0 THEN
  584. rslt = 0
  585. arg_msg = "因网络或其他原因导致销售意向单撤消完成状态设置操作失败"+"~n"+sqlca.SQLErrText
  586. GOTO ext
  587. END IF
  588. END IF
  589. ext:
  590. IF rslt = 0 THEN
  591. ROLLBACK USING sqlca;
  592. ELSEIF arg_ifcommit AND rslt = 1 THEN
  593. COMMIT USING sqlca;
  594. END IF
  595. Return (rslt)
  596. end function
  597. public function integer tmpstop (long arg_sampleid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1,cnt = 0
  598. datetime ls_null
  599. setnull(ls_null)
  600. IF arg_sampleid <= 0 THEN
  601. rslt = 0
  602. ARG_MSG = '错误单据唯一码'
  603. GOTO ext
  604. END IF
  605. Int li_status
  606. SELECT status
  607. INTO :li_status
  608. FROM u_cust_sample
  609. Where sampleid = :arg_sampleid;
  610. IF sqlca.SQLCode <> 0 THEN
  611. ARG_MSG = '查询单据审核标记失败,'+sqlca.SQLErrText
  612. rslt = 0
  613. GOTO ext
  614. END IF
  615. IF li_status <> 1 AND li_status <> 2 AND li_status <> 8 THEN
  616. rslt = 0
  617. ARG_MSG = "计划只有在进行状态才可以执行暂停,请核对"
  618. GOTO ext
  619. END IF
  620. IF li_status = 2 THEN
  621. UPDATE u_cust_sample
  622. SET status = 8,
  623. tmpstopemp = :publ_operator,
  624. tmpstopdate=getdate()
  625. WHERE sampleid = :arg_sampleid;
  626. IF sqlca.SQLCode <> 0 THEN
  627. rslt = 0
  628. arg_msg = "因网络或其它原因导致暂停计划操作失败"+"~n"+sqlca.SQLErrText
  629. GOTO ext
  630. END IF
  631. ELSE
  632. UPDATE u_cust_sample
  633. SET status = 2,
  634. tmpstopemp = '',
  635. tmpstopdate=:ls_null
  636. WHERE sampleid = :arg_sampleid ;
  637. IF sqlca.SQLCode <> 0 THEN
  638. rslt = 0
  639. arg_msg = "因网络或其它原因导致取消暂停计划操作失败"+"~n"+sqlca.SQLErrText
  640. GOTO ext
  641. END IF
  642. END IF
  643. ext:
  644. IF rslt = 0 THEN
  645. ROLLBACK;
  646. ELSEIF arg_ifcommit AND rslt = 1 THEN
  647. COMMIT;
  648. END IF
  649. RETURN (rslt)
  650. end function
  651. public function integer add_dscrp (long arg_sampleid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit);//add_dscrp(string arg_newdescppart)
  652. //0 fail 1 SUCCESS
  653. Int rslt = 1
  654. arg_newdescppart = Trim(arg_newdescppart)
  655. IF arg_newdescppart = '' THEN
  656. rslt = 0
  657. arG_MSG = "要添加内容为空,操作取消"
  658. GOTO ext
  659. END IF
  660. IF status = 0 THEN
  661. rslt = 0
  662. arG_MSG = "未审核状态下不可用"
  663. GOTO ext
  664. END IF
  665. UPDATE u_cust_sample
  666. SET DSCRP = DSCRP+' '+:arg_newdescppart
  667. Where u_cust_sample.sampleid = :arg_sampleid USING sqlca ;
  668. IF sqlca.SQLCode <> 0 THEN
  669. rslt = 0
  670. arG_MSG = "因网络或其它原因导致添加单据备注操作失败"+"~n"+ sqlca.SQLErrText
  671. GOTO ext
  672. END IF
  673. //DSCRP = DSCRP+' '+arg_newdescppart
  674. it_newbegin = FALSE
  675. it_updatebegin = FALSE
  676. ext:
  677. IF rslt = 0 THEN
  678. ROLLBACK USING sqlca;
  679. ELSEIF arg_ifcommit THEN
  680. COMMIT USING sqlca;
  681. END IF
  682. p_reset()
  683. Return (rslt)
  684. end function
  685. on uo_cust_sample.create
  686. call super::create
  687. TriggerEvent( this, "constructor" )
  688. end on
  689. on uo_cust_sample.destroy
  690. TriggerEvent( this, "destructor" )
  691. call super::destroy
  692. end on
  693. event constructor;String str_optionvalue,arg_msg
  694. f_get_sys_option_value('372',str_optionvalue,arg_msg)
  695. uo_option_cust_sample_secaudit = Long(str_optionvalue)
  696. end event