$PBExportHeader$uo_oa_emp_workplan.sru forward global type uo_oa_emp_workplan from nonvisualobject end type end forward global type uo_oa_emp_workplan from nonvisualobject end type global uo_oa_emp_workplan uo_oa_emp_workplan type variables Long uo_planid end variables forward prototypes public function integer uof_add_workplan (s_oa_emp_workplan arg_workplan, ref string arg_msg, boolean arg_ifcommit) public function integer uof_del_workplan (long arg_planid, ref string arg_msg, boolean arg_ifcommit) end prototypes public function integer uof_add_workplan (s_oa_emp_workplan arg_workplan, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Long ls_newid Long cnt Long ll_planrule_ori IF IsNull(arg_workplan.planid) THEN arg_workplan.planid = 0 IF IsNull(arg_workplan.empid) THEN arg_workplan.empid = 0 IF IsNull(arg_workplan.planrule) THEN arg_workplan.planrule = 0 IF IsNull(arg_workplan.relplanid) THEN arg_workplan.relplanid = 0 IF IsNull(arg_workplan.topic) THEN arg_workplan.topic = '' IF IsNull(arg_workplan.Address) THEN arg_workplan.Address = '' IF IsNull(arg_workplan.content) THEN arg_workplan.content = '' SELECT count(*) INTO :cnt FROM u_user Where empid = :arg_workplan.empid; IF sqlca.SQLCode <> 0 THEN arg_msg = '查询用户资料失败,原因:'+sqlca.SQLErrText rslt = 0 GOTO ext END IF IF cnt = 0 THEN arg_msg = '用户不存在,请检查' rslt = 0 GOTO ext END IF IF arg_workplan.topic = '' THEN arg_msg = '请输入主题' rslt = 0 GOTO ext END IF IF arg_workplan.stime > arg_workplan.etime THEN arg_msg = '开始时间不能大于结束时间,请检查' rslt = 0 GOTO ext END IF IF arg_workplan.planrule > 0 THEN IF DaysAfter ( Date(arg_workplan.stime), Date(arg_workplan.etime) ) > 0 THEN arg_msg = '规律出现的计划日期范围不能超过一天' rslt = 0 GOTO ext END IF END IF IF arg_workplan.planid = 0 THEN ls_newid = f_sys_scidentity(0,"oa_emp_workplan","planid",arg_msg,TRUE,id_sqlca) IF ls_newid <= 0 THEN rslt = 0 GOTO ext END IF INSERT INTO oa_emp_workplan (planid, empid, stime, etime, topic, address, content, opdate, planrule, kind, perdaynum) VALUES( :ls_newid, :arg_workplan.empid, :arg_workplan.stime, :arg_workplan.etime, :arg_workplan.topic, :arg_workplan.address, :arg_workplan.content, getdate(), :arg_workplan.planrule, 0, :arg_workplan.perdaynum); IF sqlca.SQLCode <> 0 THEN arg_msg = '增加工作计划失败,原因:'+sqlca.SQLErrText rslt = 0 GOTO ext END IF uo_planid = ls_newid ELSE SELECT planrule INTO :ll_planrule_ori FROM oa_emp_workplan Where planid = :arg_workplan.planid; IF sqlca.SQLCode <> 0 THEN arg_msg = '查询工作计划原出现规律失败,原因:'+sqlca.SQLErrText rslt = 0 GOTO ext END IF UPDATE oa_emp_workplan SET stime = :arg_workplan.stime, etime = :arg_workplan.etime, topic = :arg_workplan.topic, address = :arg_workplan.address, content = :arg_workplan.content, planrule = :arg_workplan.planrule, moddate = getdate(), perdaynum = :arg_workplan.perdaynum Where planid = :arg_workplan.planid and kind = 0; IF sqlca.SQLCode <> 0 THEN arg_msg = '更新工作计划失败,原因:'+sqlca.SQLErrText rslt = 0 GOTO ext END IF IF ll_planrule_ori > 0 THEN DELETE FROM oa_emp_workplan Where relplanid = :arg_workplan.planid and kind = 0 ; IF sqlca.SQLCode <> 0 THEN arg_msg = '删除相关生成工作计划失败,原因:'+sqlca.SQLErrText rslt = 0 GOTO ext END IF END IF uo_planid = arg_workplan.planid END IF ext: IF rslt = 0 THEN ROLLBACK; ELSEIF rslt = 1 AND arg_ifcommit THEN COMMIT; END IF RETURN rslt end function public function integer uof_del_workplan (long arg_planid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 IF IsNull(arg_planid) THEN arg_planid = 0 DELETE FROM oa_emp_workplan Where relplanid = :arg_planid and kind = 0 ; IF sqlca.SQLCode <> 0 THEN arg_msg = '删除相关生成工作计划失败,原因:'+sqlca.SQLErrText rslt = 0 GOTO ext END IF DELETE FROM oa_emp_workplan Where planid = :arg_planid and kind = 0; IF sqlca.SQLCode <> 0 THEN arg_msg = '删除工作计划失败,原因:'+sqlca.SQLErrText rslt = 0 GOTO ext END IF ext: IF rslt = 0 THEN ROLLBACK; ELSEIF rslt = 1 AND arg_ifcommit THEN COMMIT; END IF RETURN rslt end function on uo_oa_emp_workplan.create call super::create TriggerEvent( this, "constructor" ) end on on uo_oa_emp_workplan.destroy TriggerEvent( this, "destructor" ) call super::destroy end on