uo_addemp.sru 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. $PBExportHeader$uo_addemp.sru
  2. forward
  3. global type uo_addemp from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_addemp from nonvisualobject
  7. end type
  8. global uo_addemp uo_addemp
  9. type variables
  10. long addempid
  11. long departmentid
  12. string duty //申请职位
  13. datetime billdate //申请日期
  14. datetime arrivedate //希望到职日期
  15. decimal qty //增补人数
  16. string reason //申请理由
  17. string sex //性别
  18. string ifmarry //婚否
  19. long agepri //年龄-起
  20. long ageend //年龄-止
  21. string diploma //学历
  22. string specialty //专业
  23. string postname //职称
  24. string englevel //英语水平
  25. string experienece //经验
  26. string dscrp //补充内容
  27. string petition //申请人
  28. string administration //行政部
  29. string depmanager //部门经理
  30. string genmanager //总经理
  31. string addempcode //单据编码
  32. long flag //审核状态
  33. string opemp
  34. datetime opdate
  35. string modemp
  36. datetime moddate
  37. string auditrep
  38. datetime auditdate
  39. string dscrp2
  40. boolean it_newbegin=false //新建标志
  41. boolean it_updatebegin=false//修改标志
  42. end variables
  43. forward prototypes
  44. public function integer p_reset ()
  45. public function integer p_getinfo (long arg_addempid, ref string arg_msg)
  46. public function integer newbegin ()
  47. public function integer save (ref string arg_msg, boolean arg_ifcommit)
  48. public function integer del (long arg_addempid, ref string arg_msg)
  49. public function integer auditing (long arg_addempid, ref string arg_msg, boolean arg_ifcommit)
  50. public function integer c_auditing (long arg_addempid, ref string arg_msg, boolean arg_ifcommit)
  51. public function integer updatebegin (long arg_addempid, ref string arg_msg)
  52. end prototypes
  53. public function integer p_reset ();addempid = 0
  54. departmentid = 0
  55. duty = ''
  56. qty = 0
  57. reason = ''
  58. sex = ''
  59. ifmarry = ''
  60. agepri = 0
  61. ageend = 0
  62. diploma = ''
  63. specialty = ''
  64. postname = ''
  65. englevel = ''
  66. experienece = ''
  67. dscrp = ''
  68. petition = ''
  69. administration = ''
  70. depmanager = ''
  71. genmanager = ''
  72. addempcode = ''
  73. flag = 0
  74. dscrp2 = ''
  75. it_newbegin=false
  76. it_updatebegin=false
  77. return 1
  78. end function
  79. public function integer p_getinfo (long arg_addempid, ref string arg_msg);long rslt = 1
  80. SELECT u_addemp.departmentid,
  81. u_addemp.duty,
  82. u_addemp.arrivedate,
  83. u_addemp.qty,
  84. u_addemp.reason,
  85. u_addemp.sex,
  86. u_addemp.ifmarry,
  87. u_addemp.agepri,
  88. u_addemp.ageend,
  89. u_addemp.diploma,
  90. u_addemp.specialty,
  91. u_addemp.postname,
  92. u_addemp.englevel,
  93. u_addemp.experienece,
  94. u_addemp.dscrp,
  95. u_addemp.petition,
  96. u_addemp.administration,
  97. u_addemp.depmanager,
  98. u_addemp.genmanager,
  99. u_addemp.addempcode,
  100. u_addemp.flag,
  101. u_addemp.opemp,
  102. u_addemp.opdate,
  103. u_addemp.modemp,
  104. u_addemp.moddate,
  105. u_addemp.auditrep,
  106. u_addemp.auditdate ,
  107. u_addemp.dscrp2
  108. into :departmentid,
  109. :duty,
  110. :arrivedate,
  111. :qty,
  112. :reason,
  113. :sex,
  114. :ifmarry,
  115. :agepri,
  116. :ageend,
  117. :diploma,
  118. :specialty,
  119. :postname,
  120. :englevel,
  121. :experienece,
  122. :dscrp,
  123. :petition,
  124. :administration,
  125. :depmanager,
  126. :genmanager,
  127. :addempcode,
  128. :flag,
  129. :opemp,
  130. :opdate,
  131. :modemp,
  132. :moddate,
  133. :auditrep,
  134. :auditdate,
  135. :dscrp2
  136. from u_addemp
  137. where u_addemp.addempid = :arg_addempid ;
  138. if sqlca.sqlcode <> 0 then
  139. rslt = 0
  140. arg_msg = '查询人员增补申请单失败(错误单据唯一码)'+sqlca.sqlerrtext
  141. goto ext
  142. end if
  143. addempid = arg_addempid
  144. ext:
  145. return rslt
  146. end function
  147. public function integer newbegin ();p_reset()
  148. it_newbegin=TRUE
  149. it_updatebegin=FALSE
  150. return 1
  151. end function
  152. public function integer save (ref string arg_msg, boolean arg_ifcommit);Long rslt = 1
  153. DateTime server_dt
  154. Long ls_newid
  155. IF IsNull(departmentid) THEN departmentid = 0
  156. IF IsNull(duty) THEN duty = ''
  157. IF IsNull(qty) THEN qty = 0
  158. IF IsNull(reason) THEN reason = ''
  159. IF IsNull(sex) THEN sex = ''
  160. IF IsNull(ifmarry) THEN ifmarry = ''
  161. IF IsNull(agepri) THEN agepri = 0
  162. IF IsNull(ageend) THEN ageend = 0
  163. IF IsNull(diploma) THEN diploma = ''
  164. IF IsNull(specialty) THEN specialty = ''
  165. IF IsNull(postname) THEN postname = ''
  166. IF IsNull(englevel) THEN englevel = ''
  167. IF IsNull(experienece) THEN experienece = ''
  168. IF IsNull(dscrp) THEN dscrp = ''
  169. IF IsNull(petition) THEN petition = ''
  170. IF IsNull(administration) THEN administration = ''
  171. IF IsNull(depmanager) THEN depmanager = ''
  172. IF IsNull(genmanager) THEN genmanager = ''
  173. IF IsNull(flag) THEN flag = 0
  174. IF IsNull(dscrp2) THEN dscrp2 = ''
  175. IF it_newbegin = False And it_updatebegin = False THEN
  176. rslt = 0
  177. arg_msg = "非编辑状态不可以提交"
  178. GOTO ext
  179. END IF
  180. SELECT Top 1 getdate() Into :server_dt From u_user;
  181. //取得系统时间,借用操作员表
  182. IF sqlca.SQLCode <> 0 THEN
  183. rslt = 0
  184. arg_msg = "查询操作失败,日期 "
  185. GOTO ext
  186. END IF
  187. IF addempid = 0 THEN
  188. ls_newid = f_sys_scidentity(0,"u_addemp","addempid",arg_msg,False,sqlca)
  189. IF ls_newid < 0 THEN
  190. rslt = 0
  191. GOTO ext
  192. END IF
  193. addempcode = getid(0,"ZB",Date(server_dt),False,sqlca) //取得新单据编号
  194. IF addempcode = "err" THEN
  195. addempcode = ''
  196. rslt = 0
  197. arg_msg = "无法获取人员增补单编号"
  198. GOTO ext
  199. END IF
  200. INSERT INTO u_addemp(
  201. u_addemp.addempid,
  202. u_addemp.departmentid,
  203. u_addemp.duty,
  204. u_addemp.billdate,
  205. u_addemp.arrivedate,
  206. u_addemp.qty,
  207. u_addemp.reason,
  208. u_addemp.sex,
  209. u_addemp.ifmarry,
  210. u_addemp.agepri,
  211. u_addemp.ageend,
  212. u_addemp.diploma,
  213. u_addemp.specialty,
  214. u_addemp.postname,
  215. u_addemp.englevel,
  216. u_addemp.experienece,
  217. u_addemp.dscrp,
  218. u_addemp.petition,
  219. u_addemp.administration,
  220. u_addemp.depmanager,
  221. u_addemp.genmanager,
  222. u_addemp.addempcode,
  223. u_addemp.flag,
  224. u_addemp.opemp,
  225. u_addemp.opdate,
  226. u_addemp.dscrp2)
  227. VALUES ( :ls_newid,
  228. :departmentid,
  229. :duty,
  230. :billdate,
  231. :arrivedate,
  232. :qty,
  233. :reason,
  234. :sex,
  235. :ifmarry,
  236. :agepri,
  237. :ageend,
  238. :diploma,
  239. :specialty,
  240. :postname,
  241. :englevel,
  242. :experienece,
  243. :dscrp,
  244. :petition,
  245. :administration,
  246. :depmanager,
  247. :genmanager,
  248. :addempcode,
  249. 0,
  250. :publ_operator,
  251. :server_dt,
  252. :dscrp2);
  253. IF sqlca.SQLCode <> 0 THEN
  254. rslt = 0
  255. arg_msg = "因网络或其它原因导致插入操作失败>>"+"~n"+sqlca.SQLErrText
  256. GOTO ext
  257. END IF
  258. addempid = ls_newid
  259. ELSE
  260. UPDATE u_addemp
  261. SET departmentid = :departmentid,
  262. duty = :duty,
  263. billdate = :billdate,
  264. arrivedate = :arrivedate,
  265. qty = :qty,
  266. reason = :reason,
  267. sex = :sex,
  268. ifmarry = :ifmarry,
  269. agepri = :agepri,
  270. ageend = :ageend,
  271. diploma = :diploma,
  272. specialty = :specialty,
  273. postname = :postname,
  274. englevel = :englevel,
  275. experienece = :experienece,
  276. dscrp = :dscrp,
  277. petition = :petition,
  278. administration = :administration,
  279. depmanager = :depmanager,
  280. genmanager = :genmanager,
  281. addempcode = :addempcode,
  282. modemp = :publ_operator,
  283. moddate = :server_dt,
  284. dscrp2 = :dscrp2
  285. WHERE u_addemp.addempid = :addempid AND
  286. u_addemp.flag = 0;
  287. IF sqlca.SQLCode <> 0 Or sqlca.SQLNRows <= 0 THEN
  288. rslt = 0
  289. arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+sqlca.SQLErrText
  290. GOTO ext
  291. END IF
  292. END IF
  293. it_newbegin = False
  294. it_updatebegin = False
  295. ext:
  296. IF rslt = 0 THEN
  297. ROLLBACK;
  298. ELSEIF rslt = 1 And arg_ifcommit THEN
  299. COMMIT;
  300. END IF
  301. Return(rslt)
  302. end function
  303. public function integer del (long arg_addempid, ref string arg_msg);long rslt = 1
  304. if arg_addempid <= 0 then
  305. rslt = 0
  306. arg_msg = '没有删除对象,取消操作'
  307. goto ext
  308. end if
  309. if p_getinfo(arg_addempid,arg_msg) = 0 then
  310. rslt = 0
  311. goto ext
  312. end if
  313. if flag = 1 then
  314. rslt = 0
  315. arg_msg = "该人员增补单已经审核,不能删除"
  316. goto ext
  317. end if
  318. if it_newbegin or it_updatebegin then
  319. rslt=0
  320. arg_msg="编辑状态下不可以执行,操作取消"
  321. goto ext
  322. end if
  323. delete from u_addemp where u_addemp.addempid = :arg_addempid;
  324. if sqlca.sqlcode <> 0 then
  325. rslt = 0
  326. arg_msg = "删除人员增补单操作失败"+"~n"+sqlca.sqlerrtext
  327. goto ext
  328. end if
  329. commit;
  330. it_newbegin = false
  331. it_updatebegin = false
  332. if rslt = 0 then
  333. rollback;
  334. p_reset()
  335. end if
  336. ext:
  337. return (rslt)
  338. end function
  339. public function integer auditing (long arg_addempid, ref string arg_msg, boolean arg_ifcommit);long rslt = 1 ,cnt
  340. IF arg_addempid<=0 THEN
  341. rslt=0
  342. ARG_MSG='错误人员增补单唯一码'
  343. goto ext
  344. end if
  345. if p_getinfo(arg_addempid,arg_msg)=0 then
  346. rslt=0
  347. goto ext
  348. end if
  349. if flag = 1 then
  350. rslt=0
  351. arG_MSG="该人员增补单已经审核,操作取消"
  352. goto ext
  353. END IF
  354. cnt=0
  355. SELECT count(*) INTO :cnt
  356. FROM u_user
  357. WHERE username=:publ_operator using sqlca;
  358. if sqlca.sqlcode<>0 then
  359. rslt=0
  360. arG_MSG="查询操作失败,操作员!"
  361. goto ext
  362. end if
  363. if cnt=0 then
  364. rslt=0
  365. arG_MSG="操作员姓名未登记或已取消!"
  366. goto ext
  367. end if
  368. update u_addemp
  369. set flag = 1,
  370. auditrep = :publ_operator,
  371. auditdate = getdate()
  372. where u_addemp.addempid = :arg_addempid;
  373. if sqlca.sqlcode<>0 then
  374. ARG_msg='更新人员增补单审核状态失败,原因>>'+sqlca.sqlerrtext
  375. rslt=0
  376. goto ext
  377. end if
  378. ext:
  379. if rslt=0 then
  380. rollback;
  381. elseif rslt=1 and arg_ifcommit then
  382. commit;
  383. end if
  384. return rslt
  385. end function
  386. public function integer c_auditing (long arg_addempid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  387. Long cnt = 0
  388. DateTime null_server_dt
  389. SetNull(null_server_dt)
  390. IF arg_addempid <= 0 THEN
  391. rslt = 0
  392. ARG_MSG = '错误人员增补单唯一码'
  393. GOTO ext
  394. END IF
  395. IF p_getinfo(arg_addempid,ARG_MSG) = 0 THEN
  396. rslt = 0
  397. GOTO ext
  398. END IF
  399. IF flag = 0 THEN
  400. rslt = 0
  401. ARG_MSG = "该人员增补单还未审核,操作取消"
  402. GOTO ext
  403. END IF
  404. cnt = 0
  405. SELECT count(*) INTO :cnt
  406. From u_employ Where addempid = :arg_addempid;
  407. IF sqlca.SQLCode <> 0 THEN
  408. ARG_MSG = '查询单据是否已开初试单失败,'+sqlca.SQLErrText
  409. rslt = 0
  410. GOTO ext
  411. END IF
  412. IF cnt > 0 THEN
  413. ARG_MSG = '单据已开初试单失败,不能撤审'
  414. rslt = 0
  415. GOTO ext
  416. END IF
  417. cnt = 0
  418. SELECT count(*) INTO :cnt
  419. From u_reexam Where addempid = :arg_addempid;
  420. IF sqlca.SQLCode <> 0 THEN
  421. ARG_MSG = '查询单据是否已开复试单失败,'+sqlca.SQLErrText
  422. rslt = 0
  423. GOTO ext
  424. END IF
  425. IF cnt > 0 THEN
  426. ARG_MSG = '单据已开复试单失败,不能撤审'
  427. rslt = 0
  428. GOTO ext
  429. END IF
  430. UPDATE u_addemp
  431. SET flag = 0 ,
  432. auditrep = '',
  433. auditdate = :null_server_dt
  434. Where u_addemp.addempid = :arg_addempid And flag = 1 ;
  435. IF sqlca.SQLCode <> 0 THEN
  436. rslt = 0
  437. ARG_MSG = '更新人员增补单状态失败!原因:'+sqlca.SQLErrText
  438. GOTO ext
  439. END IF
  440. ext:
  441. IF rslt = 0 THEN
  442. ROLLBACK;
  443. ELSEIF rslt = 1 And arg_ifcommit THEN
  444. COMMIT;
  445. END IF
  446. RETURN rslt
  447. end function
  448. public function integer updatebegin (long arg_addempid, ref string arg_msg);int rslt = 1
  449. if arg_addempid <= 0 then
  450. rslt = 0
  451. arg_msg = '错误的规章制度唯一码'
  452. goto ext
  453. end if
  454. if p_getinfo(arg_addempid,arg_msg)=0 then
  455. rslt=0
  456. goto ext
  457. end if
  458. if flag = 1 then
  459. rslt = 0
  460. arg_msg = "规章制度已审核,不能修改"
  461. goto ext
  462. end if
  463. addempid = arg_addempid
  464. it_newbegin = false
  465. it_updatebegin = true
  466. ext:
  467. if rslt = 0 then p_reset()
  468. return rslt
  469. end function
  470. on uo_addemp.create
  471. call super::create
  472. TriggerEvent( this, "constructor" )
  473. end on
  474. on uo_addemp.destroy
  475. TriggerEvent( this, "destructor" )
  476. call super::destroy
  477. end on