$PBExportHeader$uo_cwork.sru forward global type uo_cwork from nonvisualobject end type end forward global type uo_cwork from nonvisualobject end type global uo_cwork uo_cwork type variables public protectedwrite long billid //计件单自动增量id public protectedwrite string billcode //计件单的唯一编号 public protectedwrite datetime opdate //建立时间,自动 public protectedwrite string opemp //建立人 public protectedwrite datetime moddate //修改时间,自动 public protectedwrite string modemp //修改人 public protectedwrite int flag=0 //审核标志 public protectedwrite datetime auditingdate //审核时间 public protectedwrite string auditingrep //审核操作员 long empid datetime billdate decimal amt long wageid string reason string deptidea string idea datetime begindate datetime enddate long cworkid long wagemth uo_wage u_wage private: boolean it_newbegin=false //新建标志 boolean it_updatebegin=false//修改标志 end variables forward prototypes public function integer p_reset () public function integer newbegin (ref string arg_msg) public function integer updatebegin (long arg_billid, ref string arg_msg) public function integer c_auditing (long arg_wageid, long arg_wagemth, ref string arg_msg, boolean arg_ifcommit) public function integer save (ref string arg_msg, boolean arg_ifcommit) public function integer del (long arg_billid, ref string arg_msg) public function integer auditing (long arg_wageid, long arg_wagemth, ref string arg_msg, boolean arg_ifcommit) public function integer add_deptidea (long arg_billid, string arg_newdescppart, ref string arg_msg) public function integer add_idea (long arg_billid, string arg_newdescppart, ref string arg_msg) end prototypes public function integer p_reset ();//INT p_RESET() //清除对象及其明细 billid=0 billcode='' opemp='' auditingrep='' flag=0 empid=0 amt=0 reason='' wageid=0 cworkid=0 idea='' deptidea='' it_newbegin=FALSE it_updatebegin=FALSE RETURN 1 end function public function integer newbegin (ref string arg_msg);p_reset() it_newbegin=TRUE it_updatebegin=FALSE return 1 end function public function integer updatebegin (long arg_billid, ref string arg_msg);//==================================================================== // Function: updatebegin(arg_billid,arg_msg) //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value long arg_billid // reference string arg_msg //-------------------------------------------------------------------- // Returns: integer //-------------------------------------------------------------------- // Author: yyx Date: 2003.11.21 //-------------------------------------------------------------------- // Modify History: // //==================================================================== int rslt = 1 if arg_billid <= 0 then billid = 0 arg_msg = '错误的单据ID' goto ext end if select u_gz_cwork.billcode, u_gz_cwork.billdate, u_gz_cwork.wagemth, u_gz_cwork.wageid, u_gz_cwork.empid, u_gz_cwork.amt, u_gz_cwork.reason, u_gz_cwork.deptidea, u_gz_cwork.begindate, u_gz_cwork.enddate, u_gz_cwork.idea, u_gz_cwork.flag into :billcode, :billdate, :wagemth, :wageid, :empid, :amt, :reason, :deptidea, :begindate, :enddate, :idea, :flag from u_gz_cwork where u_gz_cwork.billid = :arg_billid; if sqlca.sqlcode <> 0 then rslt = 0 if pos(lower(sqlca.SQLErrText),'more than') > 0 then arg_msg = '查询操作失败,查询数据返回值多于一个' else arg_msg = '查询数据操作失败,考勤单(错误单据唯一码)' end if goto ext end if if flag = 1 then rslt = 0 arg_msg = '单据已经审核,不可以修改' goto ext end if billid = arg_billid it_newbegin = false it_updatebegin = true ext: if rslt = 0 then p_reset() arg_msg = '考勤单,'+ arg_msg return rslt end function public function integer c_auditing (long arg_wageid, long arg_wagemth, ref string arg_msg, boolean arg_ifcommit); long cnt=0,i int rslt=1 datetime null_server_dt setnull(null_server_dt) select count(*) into :cnt from u_gz_cwork where wagemth=:arg_wagemth and wageid = :arg_wageid and flag = 1; if sqlca.sqlcode<>0 then rslt=0 arg_msg='查询考勤单失败' goto ext end if if cnt=0 then rslt=0 arg_msg='该月的考勤单未审核,不用撤审!' goto ext end if select count(*) into :cnt from u_gz_wage where wagemth=:arg_wagemth and Auditingflag=1; if sqlca.sqlcode<>0 then rslt=0 arg_msg='查询工资表失败' goto ext end if if cnt>0 then rslt=0 arg_msg='该月的工资表已审核,不能撤审!' goto ext end if cnt=0 select count(*) into :cnt from u_gz_wageitem where useflag=1 and wageid=:arg_wageid; if sqlca.sqlcode<>0 then rslt=0 arg_msg='查询工资项目失败' goto ext end if if cnt=0 then rslt=0 arg_msg='不存在该工资项目' goto ext end if update u_gz_cwork set flag=0, Auditrep='', Auditdate=:null_server_dt where wagemth=:arg_wagemth and flag=1 and wageid=:arg_wageid; if sqlca.sqlcode<>0 then ARG_msg='更新考勤单失败,原因:'+sqlca.sqlerrtext rslt=0 goto ext end if update u_gz_wagemx set wageamt=0 where wageid=:arg_wageid and wagemth=:arg_wagemth; if sqlca.sqlcode<>0 then rslt=0 arg_Msg='更新工资表失败!原因:'+sqlca.sqlerrtext goto ext end if ext: if rslt=0 then rollback; elseif rslt=1 and arg_ifcommit then commit; end if arg_msg = '考勤单,'+ arg_msg return rslt end function public function integer save (ref string arg_msg, boolean arg_ifcommit);//==================================================================== // Function: save(arg_msg,arg_ifcommit) //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // reference string arg_msg // value boolean arg_ifcommit //-------------------------------------------------------------------- // Returns: integer //-------------------------------------------------------------------- // Author: yyx Date: 2003.11.21 //-------------------------------------------------------------------- // Modify History: // //==================================================================== integer rslt = 1,cnt = 0,i datetime server_dt long ls_newid if isnull(empid) then empid = 0 if isnull(amt) then amt = 0 if isnull(wageid) then wageid = 0 if isnull(wagemth) then wagemth = 0 if isnull(reason) then reason = '' if isnull(deptidea) then deptidea = '' if isnull(idea) then idea = '' if isnull(cworkid) then cworkid = 0 if it_newbegin = false and it_updatebegin = false then rslt = 0 arg_msg = "非编辑状态不可以提交" goto ext end if select count(*) into :cnt from u_rs_empinfo where empid = :empid; if sqlca.sqlcode <> 0 then arg_msg = '查询人员资料失败' rslt = 0 goto ext end if if cnt > 1 then arg_msg = '人员资料重复' rslt = 0 goto ext end if cnt = 0 select count(*) into :cnt from u_gz_cworkitem where cworkid = :cworkid; if sqlca.sqlcode <> 0 then arg_msg = '查询考勤项目资料失败' rslt = 0 goto ext end if if cnt > 1 then arg_msg = '考勤项目重复' rslt = 0 goto ext end if if wagemth = 0 then arg_msg = '错误的工资月份' rslt = 0 goto ext end if if amt < 0 then arg_msg = '请输入正确的金额' rslt = 0 goto ext end if select top 1 getdate() into :server_dt from u_user; //取得系统时间,借用操作员表 if sqlca.sqlcode <> 0 then rslt = 0 arg_msg = "查询操作失败,日期 " goto ext end if if year(date(billdate)) < 2000 or isnull(billdate) then rslt = 0 arg_msg = "时间不合理" goto ext end if ////////////////////////////////////////////////开始区分:新建/更新 处理 if billid = 0 then //新建 ls_newid = f_sys_scidentity(0,"u_gz_cwork","billid",arg_msg,true,sqlca) if ls_newid <= 0 then rslt = 0 goto ext end if billcode = getid(0,"KQ",date(server_dt),true,sqlca) //取得新单据编号 if billcode = "err" then billcode = '' rslt = 0 arg_msg = "无法获取考勤单编号" goto ext end if insert into u_gz_cwork ( billid, billcode, billdate, Wagemth, wageid, empid, amt, reason, deptidea, idea, begindate, enddate, cworkid, opdate, opemp) values ( :ls_newid, :billcode, :billdate, :Wagemth, :wageid, :empid, :amt, :reason, :deptidea, :idea, :begindate, :enddate, :cworkid, :server_dt, :publ_operator); if sqlca.sqlcode <> 0 then rslt = 0 if pos(lower(sqlca.SQLErrText),'pk_u_gz_cwork') > 0 then arg_msg = '插入操作失败,关键字单据ID重复' elseif pos(lower(sqlca.SQLErrText),'ix_u_gz_cwork') > 0 then arg_msg = '插入操作失败,单据编号重复' else arg_msg = "因网络或其它原因导致插入操作失败>>"+"~n"+sqlca.sqlerrtext end if goto ext end if billid = ls_newid else //////////////////////////////////////////////////更新 update u_gz_cwork set billdate = :billdate, wageid = :wageid, empid = :empid, amt = :amt, reason = :reason, deptidea = :deptidea, idea = :idea, moddate = :server_dt, modemp = :modemp, begindate = :begindate, enddate = :enddate, cworkid = :cworkid, Wagemth = :Wagemth where u_gz_cwork.billid = :billid and flag = 0; if sqlca.sqlcode <> 0 or sqlca.sqlnrows <= 0 then rslt = 0 if pos(lower(sqlca.SQLErrText),'pk_u_gz_cwork') > 0 then arg_msg = '插入操作失败,关键字单据ID重复' elseif pos(lower(sqlca.SQLErrText),'ix_u_gz_cwork') > 0 then arg_msg = '插入操作失败,单据编号重复' else arg_msg = "因网络或其它原因导致插入操作失败>>"+"~n"+sqlca.sqlerrtext end if goto ext end if end if it_newbegin = false it_updatebegin = false ext: if rslt = 0 then rollback; elseif rslt=1 and arg_ifcommit then commit; end if arg_msg = '考勤单,'+ arg_msg return(rslt) end function public function integer del (long arg_billid, ref string arg_msg);//==================================================================== // Function: del(arg_billid,arg_msg) //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value long arg_billid // reference string arg_msg //-------------------------------------------------------------------- // Returns: integer //-------------------------------------------------------------------- // Author: yyx Date: 2003.11.21 //-------------------------------------------------------------------- // Modify History: // //==================================================================== int rslt = 1 if arg_billid <= 0 then rslt = 0 arg_msg = "没有删除对象,操作取消" goto ext end if if it_newbegin or it_updatebegin then rslt=0 arg_msg="编辑状态下不可以执行,操作取消" goto ext end if select u_gz_cwork.flag into :flag from u_gz_cwork where u_gz_cwork.billid = :arg_billid; if sqlca.sqlcode <> 0 then rslt = 0 if pos(lower(sqlca.SQLErrText),'more than') > 0 then arg_msg = '查询操作失败,查询数据返回值多于一个' else arg_msg = '查询考勤单操作失败(错误单据唯一码)' end if goto ext end if if flag = 1 then rslt = 0 arg_msg = "单据已经审核,不可以删除" goto ext end if delete from u_gz_cwork where u_gz_cwork.billid = :arg_billid; if sqlca.sqlcode <> 0 then rslt = 0 arg_msg = "删除考勤单操作失败"+"~n"+sqlca.sqlerrtext goto ext end if commit; it_newbegin = false it_updatebegin = false ext: if rslt = 0 then rollback; p_reset() end if arg_msg = '考勤单,'+ arg_msg return (rslt) end function public function integer auditing (long arg_wageid, long arg_wagemth, ref string arg_msg, boolean arg_ifcommit);//==================================================================== // Function: auditing() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value long arg_wageid // value long arg_wagemth // value datetime arg_enddate // reference string arg_msg // value boolean arg_ifcommit //-------------------------------------------------------------------- // Returns: integer //-------------------------------------------------------------------- // Author: yyx Date: 2004.10.19 //-------------------------------------------------------------------- // Modify History: // //==================================================================== long cnt=0,i int rslt=1 decimal ls_emp_sumwage datastore ds_emp_sumwage cnt=0 select count(*) into :cnt from u_gz_cwork where wagemth=:arg_wagemth and wageid = :arg_wageid and flag=1; if sqlca.sqlcode<>0 then rslt=0 arg_msg='查询考勤单明细失败!' goto ext end if if cnt>0 then rslt=0 arg_msg='该月的考勤单已审核,审核前请先执行撤审!' goto ext end if cnt=0 select count(*) into :cnt from u_gz_wageitem where useflag=1 and wageid=:arg_wageid; if sqlca.sqlcode<>0 then rslt=0 arg_msg='查询工资项目失败!' goto ext end if if cnt=0 then rslt=0 arg_msg='不存在该工资项目!' goto ext end if ds_emp_sumwage=create datastore ds_emp_sumwage.dataobject='dw_emp_sumcworkwage' ds_emp_sumwage.settransobject(sqlca) if ds_emp_sumwage.retrieve(arg_wagemth,arg_wageid)<=0 then rslt=0 arg_msg='本月没有考勤单可审核或查询考勤单失败' goto ext end if for i= 1 to ds_emp_sumwage.rowcount() ls_emp_sumwage=0.00 ls_emp_sumwage=ds_emp_sumwage.object.sumwage[i] if u_wage.f_setwagemxdata(arg_wagemth,ds_emp_sumwage.object.empid[i],arg_wageid,ls_emp_sumwage,arg_msg,false)=0 then rslt=0 goto ext end if next update u_gz_cwork set flag=1, auditrep=:publ_operator, Auditdate=getdate() where wagemth = :arg_wagemth and wageid = :arg_wageid and flag = 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 arg_msg = '考勤单,'+ arg_msg return rslt end function public function integer add_deptidea (long arg_billid, string arg_newdescppart, ref string arg_msg);//==================================================================== // Function: add_dscrp(arg_billid,arg_newdescppart,arg_msg) //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value long arg_billid // value string arg_newdescppart // reference string arg_msg //-------------------------------------------------------------------- // Returns: integer //-------------------------------------------------------------------- // Author: yyx Date: 2003.11.21 //-------------------------------------------------------------------- // Modify History: // //==================================================================== int rslt = 1 arg_newdescppart = trim(arg_newdescppart) if arg_billid <= 0 then rslt = 0 arg_msg = "没有编辑对象,操作取消" goto ext end if //if it_newbegin or it_updatebegin then // rslt=0 // arg_msg="编辑状态下不可以执行,操作取消" // goto ext //end if select u_gz_cwork.flag into :flag from u_gz_cwork where u_gz_cwork.billid = :arg_billid; if sqlca.sqlcode <> 0 then rslt = 0 if pos(lower(sqlca.SQLErrText),'more than') > 0 then arg_msg = '查询操作失败,查询数据返回值多于一个' else arg_msg = '查询考勤单操作失败(错误单据唯一码)' end if goto ext end if if flag = 0 then rslt = 0 arg_msg = "非审核状态下不可用" goto ext end if update u_gz_cwork set deptidea = lTRIM(RTRIM(deptidea)) +' '+:arg_newdescppart where u_gz_cwork.billid = :arg_billid; if sqlca.sqlcode <> 0 then rollback ; rslt = 0 arg_msg = "因网络或其它原因导致添加主管部门意见操作失败"+"~n"+sqlca.sqlerrtext goto ext end if commit; deptidea = deptidea+' '+arg_newdescppart ext: arg_msg = '考勤单,'+ arg_msg return (rslt) end function public function integer add_idea (long arg_billid, string arg_newdescppart, ref string arg_msg); Int rslt = 1 arg_newdescppart = Trim(arg_newdescppart) IF arg_billid <= 0 THEN rslt = 0 arg_msg = "没有编辑对象,操作取消" GOTO ext END IF //if it_newbegin or it_updatebegin then // rslt=0 // arg_msg="编辑状态下不可以执行,操作取消" // goto ext //end if SELECT u_gz_cwork.flag INTO :flag FROM u_gz_cwork Where u_gz_cwork.billid = :arg_billid; IF sqlca.SQLCode <> 0 THEN rslt = 0 IF Pos(Lower(sqlca.SQLErrText),'more than') > 0 THEN arg_msg = '查询操作失败,查询数据返回值多于一个' ELSE arg_msg = '查询考勤单操作失败(错误单据唯一码)' END IF GOTO ext END IF IF flag = 0 THEN rslt = 0 arg_msg = "非审核状态下不可用" GOTO ext END IF UPDATE u_gz_cwork SET idea = lTRIM(RTRIM(idea)) +' '+:arg_newdescppart Where u_gz_cwork.billid = :arg_billid; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致添加批示操作失败"+"~n"+sqlca.SQLErrText GOTO ext END IF idea = idea+' '+arg_newdescppart ext: IF rslt = 0 THEN arg_msg = '考勤单,'+ arg_msg ROLLBACK; ELSE COMMIT; END IF RETURN rslt end function on uo_cwork.create call super::create TriggerEvent( this, "constructor" ) end on on uo_cwork.destroy TriggerEvent( this, "destructor" ) call super::destroy end on event constructor; u_wage=create uo_wage end event event destructor;DESTROY u_wage end event