123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574 |
- $PBExportHeader$uo_abnormity_bill.sru
- forward
- global type uo_abnormity_bill from nonvisualobject
- end type
- end forward
- global type uo_abnormity_bill from nonvisualobject
- end type
- global uo_abnormity_bill uo_abnormity_bill
- 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 //审核操作员
- datetime billdate
- string dutydept
- string dutyrep
- string dutyreason
- decimal empwage
- decimal mtrlwage
- string workdept
- long itemid
- 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 save (ref string arg_msg, boolean arg_ifcommit)
- public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg)
- private function integer p_getinfo (long arg_billid, ref string arg_msg)
- public function integer auditing (long arg_billid, ref string arg_msg, boolean arg_ifcommit)
- public function integer c_auditing (long arg_billid, ref string arg_msg, boolean arg_ifcommit)
- public function integer del (long arg_billid, ref string arg_msg, boolean arg_ifcommit)
- end prototypes
- public function integer p_reset ();//INT p_RESET()
- //清除对象及其明细
- billid=0
- billcode=''
- opemp=''
- auditingrep=''
- flag=0
- dutydept=''
- dutyrep=''
- dutyreason=''
- empwage=0
- mtrlwage=0
- workdept=''
- itemid=0
- 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
- if p_getinfo(arg_billid,arg_msg) = 0 then
- rslt = 0
- 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()
- 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,i
- datetime server_dt
- long ls_newid,cnt
- if isnull(dutydept) then dutydept = ''
- if isnull(dutyrep) then dutyrep = ''
- if isnull(dutyreason) then dutyreason = ''
- if isnull(empwage) then empwage = 0.00
- if isnull(mtrlwage) then mtrlwage = 0.00
- if isnull(itemid) then itemid = 0
- if it_newbegin = false and it_updatebegin = false then
- rslt = 0
- arg_msg = "非编辑状态不可以提交"
- 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 f_check_inoutdate(0,billdate,FALSE,arG_MSG) = 0 THEN
- // rslt = 0
- // GOTO ext
- //END IF
- //
- select count(*) into :cnt
- from u_sc_abnormity_bill_item
- where itemid = :itemid;
- if sqlca.sqlcode <> 0 then
- arg_msg = '查询返工返修项目资料失败'
- rslt = 0
- goto ext
- end if
- if cnt = 0 then
- arg_msg = '系统不存在项目资料'
- rslt = 0
- goto ext
- end if
- ////////////////////////////////////////////////开始区分:新建/更新 处理
- if billid = 0 then //新建
- ls_newid = f_sys_scidentity(0,"u_sc_abnormity_bill","billid",arg_msg,TRUE,id_sqlca)
- if ls_newid <= 0 then
- rslt = 0
- goto ext
- end if
-
-
- billcode = getid(0,"FG",date(server_dt),true,sqlca) //取得新单据编号
- if billcode = "err" then
- billcode = ''
- rslt = 0
- arg_msg = "无法获取返工返修赔偿单编号"
- goto ext
- end if
-
- insert into u_sc_abnormity_bill (
- billid,
- billcode,
- billdate,
- dutydept,
- dutyrep,
- dutyreason,
- empwage,
- mtrlwage,
- workdept,
- opdate,
- opemp,
- itemid)
- values (
- :ls_newid,
- :billcode,
- :billdate,
- :dutydept,
- :dutyrep,
- :dutyreason,
- :empwage,
- :mtrlwage,
- :workdept,
- :server_dt,
- :publ_operator,
- :itemid);
- if sqlca.sqlcode <> 0 then
- rslt = 0
- arg_msg = "因网络或其它原因导致插入操作失败>>"+"~n"+sqlca.sqlerrtext
- goto ext
- end if
- billid = ls_newid
- else //////////////////////////////////////////////////更新
-
- update u_sc_abnormity_bill
- set billdate = :billdate,
- dutydept = :dutydept,
- dutyrep = :dutyrep,
- dutyreason = :dutyreason,
- empwage = :empwage,
- mtrlwage = :mtrlwage,
- workdept = :workdept,
- moddate = :server_dt,
- modemp = :modemp,
- itemid = :itemid
- where u_sc_abnormity_bill.billid = :billid
- and flag = 0;
- if sqlca.sqlcode <> 0 or sqlca.sqlnrows <= 0 then
- rslt = 0
- arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+sqlca.sqlerrtext
- 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
- return(rslt)
- end function
- public function integer add_dscrp (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
- if p_getinfo(arg_billid,arg_msg) = 0 then
- rslt = 0
- goto ext
- end if
- if flag = 0 then
- rslt = 0
- arg_msg = "非审核状态下不可用"
- goto ext
- end if
- update u_sc_abnormity_bill
- set dutyreason = dutyreason+' '+:arg_newdescppart
- where u_sc_abnormity_bill.billid = :billid;
- if sqlca.sqlcode <> 0 then
- rollback ;
- rslt = 0
- arg_msg = "因网络或其它原因导致添加单据备注操作失败"+"~n"+sqlca.sqlerrtext
- goto ext
- end if
- commit;
- dutyreason = dutyreason+' '+arg_newdescppart
- ext:
- return (rslt)
- end function
- private function integer p_getinfo (long arg_billid, ref string arg_msg);//====================================================================
- // Function: p_getinfo()
- //--------------------------------------------------------------------
- // Description:
- //--------------------------------------------------------------------
- // Arguments:
- // value long arg_billid
- // reference string arg_msg
- //--------------------------------------------------------------------
- // Returns: integer
- //--------------------------------------------------------------------
- // Author: yyx Date: 2004.11.22
- //--------------------------------------------------------------------
- // Modify History:
- //
- //====================================================================
- INT rslt=1
- IF arg_billid<=0 THEN
- rslt=0
- arG_MSG="非法单据唯一码"
- goto ext
- end if
- select
- u_sc_abnormity_bill.billcode,
- u_sc_abnormity_bill.billdate,
- u_sc_abnormity_bill.dutydept,
- u_sc_abnormity_bill.dutyrep,
- u_sc_abnormity_bill.dutyreason,
- u_sc_abnormity_bill.empwage,
- u_sc_abnormity_bill.mtrlwage,
- u_sc_abnormity_bill.flag,
- u_sc_abnormity_bill.workdept,
- u_sc_abnormity_bill.itemid
- into
- :billcode,
- :billdate,
- :dutydept,
- :dutyrep,
- :dutyreason,
- :empwage,
- :mtrlwage,
- :flag,
- :workdept,
- :itemid
- from u_sc_abnormity_bill
- where u_sc_abnormity_bill.billid = :arg_billid;
- if sqlca.sqlcode <> 0 then
- rslt = 0
- arg_msg = '查询数据操作失败,返工返修赔偿单'+sqlca.sqlerrtext
- goto ext
- end if
- billid = arg_billid
- ext:
- IF rslt=0 THEN p_reset()
- return rslt
- end function
- public function integer auditing (long arg_billid, ref string arg_msg, boolean arg_ifcommit);int rslt=1
- if arg_billid <= 0 then
- rslt = 0
- arg_msg = "没有删除对象,操作取消"
- goto ext
- end if
- if p_getinfo(arg_billid,arg_msg) = 0 then
- rslt = 0
- goto ext
- end if
- if flag = 1 then
- rslt = 0
- arg_msg = "单据已审核"
- goto ext
- end if
- update u_sc_abnormity_bill set
- flag=1,
- auditrep=:publ_operator,
- Auditdate=getdate()
- where billid = :arg_billid
- and flag = 0;
- if sqlca.sqlcode<>0 or sqlca.sqlnrows = 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
- public function integer c_auditing (long arg_billid, ref string arg_msg, boolean arg_ifcommit);
- int rslt=1
- long cnt = 0
- datetime null_dt
- setnull(null_dt)
- if arg_billid <= 0 then
- rslt = 0
- arg_msg = "没有删除对象,操作取消"
- goto ext
- end if
- if p_getinfo(arg_billid,arg_msg) = 0 then
- rslt = 0
- goto ext
- end if
- if flag = 0 then
- rslt = 0
- arg_msg = "单据还未审核"
- goto ext
- end if
- select count(*) into :cnt
- from u_sc_abnormity
- where relid = :arg_billid;
- if sqlca.sqlcode <> 0 then
- arg_msg = '查询返工返修单是否有异常计件单失败,不能撤审'
- rslt = 0
- goto ext
- end if
- if cnt > 0 then
- arg_msg = '返工返修单已有异常计件单,不能撤审'
- rslt = 0
- goto ext
- end if
- update u_sc_abnormity_bill set
- flag = 0,
- auditrep='',
- Auditdate=:null_dt
- where billid = :arg_billid
- and flag = 1;
- if sqlca.sqlcode<>0 or sqlca.sqlnrows = 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
- public function integer del (long arg_billid, ref string arg_msg, boolean arg_ifcommit);//====================================================================
- // 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
- long cnt = 0
- 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
- if p_getinfo(arg_billid,arg_msg) = 0 then
- rslt = 0
- goto ext
- end if
- if flag = 1 then
- rslt = 0
- arg_msg = "单据已经审核,不可以删除"
- goto ext
- end if
- //***检查异常工资单
- select count(*) into :cnt
- from u_sc_abnormity
- where relid = :arg_billid;
- if sqlca.sqlcode <> 0 then
- arg_msg = '查询返工返修赔偿单是否已存在异常计件单失败'
- rslt = 0
- goto ext
- end if
- if cnt > 0 then
- arg_msg = '单据已有异常计件单,不能删除'
- rslt = 0
- goto ext
- end if
- //***
- delete from u_sc_abnormity_bill
- where u_sc_abnormity_bill.billid = :arg_billid
- and u_sc_abnormity_bill.flag = 0;
- if sqlca.sqlcode <> 0 or sqlca.sqlnrows = 0 then
- rslt = 0
- arg_msg = "删除返工返修赔偿单操作失败"+"~n"+sqlca.sqlerrtext
- goto ext
- end if
- ext:
- IF rslt = 0 THEN
- ROLLBACK ;
- p_reset()
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT ;
- END IF
- Return (rslt)
- end function
- on uo_abnormity_bill.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_abnormity_bill.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|