123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771 |
- $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
|