123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701 |
- $PBExportHeader$uo_spt_wfjg.sru
- forward
- global type uo_spt_wfjg from nonvisualobject
- end type
- end forward
- global type uo_spt_wfjg from nonvisualobject
- end type
- global uo_spt_wfjg uo_spt_wfjg
- type variables
- public protectedwrite long scid //罚款单scid
- 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 sptid
- long relid
- string inwarecode
- datetime billdate
- decimal amt
- string dscrp
- string relcode
- int payid
- int banktypeid
- string inrep
- private:
- boolean it_newbegin=false //新建标志
- boolean it_updatebegin=false//修改标志
- end variables
- forward prototypes
- public function integer p_reset ()
- public function integer save (ref string arg_msg, boolean arg_ifcommit)
- public function integer updatebegin (long arg_scid, long arg_billid, ref string arg_msg)
- public function integer newbegin (long arg_scid, ref string arg_msg)
- public function integer del (long arg_scid, long arg_billid, ref string arg_msg)
- public function integer getinfo (long arg_scid, long arg_billid, ref string arg_msg)
- public function integer auditing (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
- public function integer c_auditing (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
- public function integer add_dscrp (long arg_scid, 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
- sptid = 0
- amt = 0
- dscrp = ''
- relcode = ''
- inwarecode = ''
- relid = 0
- it_newbegin = FALSE
- it_updatebegin = FALSE
- RETURN 1
- 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
- string ls_sccode
- if isnull(sptid) then sptid = 0
- if isnull(relid) then relid = 0
- if isnull(amt) then amt = 0
- if isnull(banktypeid) then banktypeid = 0
- if isnull(dscrp) then dscrp = ''
- if isnull(relcode) then relcode = ''
- if isnull(inwarecode) then inwarecode = ''
- if isnull(inrep) then inrep = ''
- if it_newbegin = false and it_updatebegin = false then
- rslt = 0
- arg_msg = "非编辑状态不可以提交"
- goto ext
- end if
- select count(*) into :cnt
- from u_spt
- where sptid = :sptid;
- 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 amt = 0 then
- arg_msg = '请输入正确的金额'
- rslt = 0
- goto ext
- end if
- if inrep = '' then
- arg_msg = '请输入经手人'
- rslt = 0
- goto ext
- end if
- if banktypeid = 0 then
- arg_msg = '请请选择结算方式'
- rslt = 0
- goto ext
- end if
- select count(*) into :cnt
- from u_inware
- where scid = :scid
- and inwareid = :relid;
- 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
- 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(scid,"u_spt_wfjg","billid",arg_msg,TRUE,id_sqlca)
- if ls_newid <= 0 then
- rslt = 0
- goto ext
- end if
-
- //取分部代号
- if f_get_sccode(scid,sqlca,ls_sccode,arg_msg) = 0 then
- rslt = 0
- goto ext
- end if
-
-
- billcode = getid(scid,ls_sccode + "JG",date(server_dt),true,sqlca) //取得新单据编号
- if billcode = "err" then
- billcode = ''
- rslt = 0
- arg_msg = "无法获取加工单编号"
- goto ext
- end if
-
- insert into u_spt_wfjg (
- scid,
- billid,
- billcode,
- billdate,
- sptid,
- amt,
- banktypeid,
- inrep,
- dscrp,
- relcode,
- opdate,
- opemp,
- relid,
- inwarecode)
- values (
- :scid,
- :ls_newid,
- :billcode,
- :billdate,
- :sptid,
- :amt,
- :banktypeid,
- :inrep,
- :dscrp,
- :relcode,
- :server_dt,
- :publ_operator,
- :relid,
- :inwarecode);
- if sqlca.sqlcode <> 0 then
- rslt = 0
- arg_msg = "因网络或其它原因导致插入操作失败>>"+"~n"+sqlca.sqlerrtext
- goto ext
- end if
-
- insert into u_spt_wfjgMx
- (scid,billid,mtrlid,status,Qty,mxdscrp,printid)
- select :scid,:ls_newid,mtrlid,status,Qty,mxdscrp,printid
- from u_inwaremx
- where u_inwaremx.scid = :scid
- and u_inwaremx.inwareid =:relid;
- if sqlca.sqlcode <> 0 then
- arg_msg = '加入单据明细失败,'+sqlca.sqlerrtext
- rslt = 0
- goto ext
- end if
-
- billid = ls_newid
- else //////////////////////////////////////////////////更新
-
- update u_spt_wfjg
- set billdate = :billdate,
- sptid = :sptid,
- amt = :amt,
- dscrp = :dscrp,
- banktypeid = :banktypeid,
- inrep = :inrep,
- relcode = :relcode,
- moddate = :server_dt,
- modemp = :modemp,
- relid = :relid,
- inwarecode = :inwarecode
- where u_spt_wfjg.billid = :billid
- and u_spt_wfjg.scid = :scid
- and u_spt_wfjg.flag = 0;
- if sqlca.sqlcode <> 0 or sqlca.sqlnrows <= 0 then
- rslt = 0
- arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+sqlca.sqlerrtext
- goto ext
- end if
-
- delete from u_spt_wfjgMx
- where scid = :scid
- and billid = :billid;
- if sqlca.sqlcode <> 0 then
- arg_msg = '删除单据原明细内容失败,'+sqlca.sqlerrtext
- rslt = 0
- goto ext
- end if
-
- insert into u_spt_wfjgMx
- (scid,billid,mtrlid,status,Qty,mxdscrp,printid)
- select :scid,:billid,mtrlid,status,Qty,mxdscrp,printid
- from u_inwaremx
- where u_inwaremx.scid = :scid
- and u_inwaremx.inwareid =:relid;
- if sqlca.sqlcode <> 0 then
- arg_msg = '加入单据明细失败,'+sqlca.sqlerrtext
- rslt = 0
- 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 updatebegin (long arg_scid, 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 getinfo(arg_scid,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
- scid = arg_scid
- it_newbegin = false
- it_updatebegin = true
- ext:
- if rslt = 0 then p_reset()
- return rslt
- end function
- public function integer newbegin (long arg_scid, ref string arg_msg);int rslt = 1
- if arg_scid < 0 then
- arg_msg = '请选择分部'
- rslt = 0
- goto ext
- end if
- p_reset()
- scid=arg_scid
- it_newbegin=TRUE
- it_updatebegin=FALSE
- ext:
- if rslt = 0 then p_reset()
- return rslt
- end function
- public function integer del (long arg_scid, 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_spt_wfjg.flag
- into :flag
- from u_spt_wfjg
- where u_spt_wfjg.billid = :arg_billid;
- if sqlca.sqlcode <> 0 then
- rslt = 0
- arg_msg = '查询单据操作失败'
- goto ext
- end if
- if flag = 1 then
- rslt = 0
- arg_msg = "单据已经审核,不可以删除"
- goto ext
- end if
- delete from u_spt_wfjg
- where u_spt_wfjg.billid = :arg_billid
- and u_spt_wfjg.scid = :arg_scid;
- if sqlca.sqlcode <> 0 then
- rslt = 0
- arg_msg = "删除罚款单操作失败"+"~n"+sqlca.sqlerrtext
- goto ext
- end if
- commit;
- it_newbegin = false
- it_updatebegin = false
- if rslt = 0 then
- rollback;
- p_reset()
- end if
- ext:
- return (rslt)
- end function
- public function integer getinfo (long arg_scid, long arg_billid, ref string arg_msg);int rslt = 1
- if arg_billid <= 0 then
- billid = 0
- arg_msg = '错误的单据id'
- goto ext
- end if
- select
- u_spt_wfjg.billcode,
- u_spt_wfjg.billdate,
- u_spt_wfjg.sptid,
- u_spt_wfjg.amt,
- u_spt_wfjg.banktypeid,
- u_spt_wfjg.inrep,
- u_spt_wfjg.dscrp,
- u_spt_wfjg.payid,
- u_spt_wfjg.relcode,
- u_spt_wfjg.flag,
- u_spt_wfjg.relid,
- u_spt_wfjg.inwarecode
- into
- :billcode,
- :billdate,
- :sptid,
- :amt,
- :banktypeid,
- :inrep,
- :dscrp,
- :payid,
- :relcode,
- :flag,
- :relid,
- :inwarecode
- from u_spt_wfjg
- where u_spt_wfjg.billid = :arg_billid
- and u_spt_wfjg.scid = :arg_scid;
- if sqlca.sqlcode <> 0 then
- rslt = 0
- arg_msg = '查询数据操作失败,加工单'+sqlca.sqlerrtext
- goto ext
- end if
- scid = arg_scid
- billid = arg_billid
- ext:
- if rslt=0 then p_reset()
- return rslt
- end function
- public function integer auditing (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);//====================================================================
- // Function: auditing()
- //--------------------------------------------------------------------
- // Description:
- //--------------------------------------------------------------------
- // Arguments:
- // value long arg_scid
- // value long arg_billid
- // reference string arg_msg
- // value boolean arg_ifcommit
- //--------------------------------------------------------------------
- // Returns: integer
- //--------------------------------------------------------------------
- // Author: yyx Date: 2004.12.07
- //--------------------------------------------------------------------
- // Modify History:
- //
- //====================================================================
- Int rslt = 1
- String ls_dscrp
- uo_mustpay uo_pay
- uo_pay = CREATE uo_mustpay
- IF getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arg_msg = '单据已经审核,不可以再审核'
- GOTO ext
- END IF
- IF it_newbegin OR it_updatebegin THEN
- rslt = 0
- arg_msg = "编辑状态下不可以执行审核"
- GOTO ext
- END IF
- UPDATE u_spt_wfjg
- SET auditingrep = :publ_operator,
- auditingdate = getdate(),
- flag = 1
- WHERE u_spt_wfjg.billid = :arg_billid
- AND flag = 0 AND scid = :arg_scid;
-
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- ELSEIF sqlca.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在审核,请稍后查询。"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- IF amt <> 0 THEN
- ls_dscrp = billcode + "罚款"
-
- datetime plandate
- setnull(plandate)
- // if uo_pay.add_payrec (scid,sptid,billdate,inrep,amt,amt,0,ls_dscrp,&
- // billcode,banktypeid,1,publ_operator,billid,arg_msg,false,plandate,0,0)=0 then
- // rslt=0
- // goto ext
- // end if
- UPDATE u_spt_wfjg
- SET payid = :uo_pay.ref_payid
- WHERE u_spt_wfjg.billid = :arg_billid
- AND scid = :scid
- AND flag = 1 ;
-
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '更新罚款单相关应收帐ID失败'
- rslt = 0
- GOTO ext
- END IF
- END IF
- flag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- DESTROY uo_pay
- RETURN rslt
- end function
- public function integer c_auditing (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);int rslt=1
- string str_dscrp
- datetime null_dt
- setnull(null_dt)
- uo_mustpay uo_pay
- uo_pay = create uo_mustpay
- if getinfo(arg_scid,arg_billid,arg_msg) = 0 then
- rslt = 0
- goto ext
- end if
- if flag = 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
- update u_spt_wfjg
- set auditingrep = '',
- auditingdate = :null_dt,
- flag = 0
- where u_spt_wfjg.billid = :arg_billid
- and flag = 1 and scid = :arg_scid;
-
- if sqlca.sqlcode <> 0 then
- rslt = 0
- arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+sqlca.sqlerrtext
- goto ext
- elseif sqlca.sqlnrows = 0 then
- rslt = 0
- arg_msg = "单据正在撤消审核,请稍后查询。"+"~n"+sqlca.sqlerrtext
- goto ext
- end if
- if amt <> 0 then
- if uo_pay.del_payrec(scid,1,payid,sptid,arg_msg,false)=0 then
- rslt=0
- goto ext
- end if
- end if
- flag = 0
- ext:
- if rslt=0 then
- rollback;
- elseif rslt=1 and arg_ifcommit then
- commit;
- end if
- destroy uo_pay
- return rslt
- end function
- public function integer add_dscrp (long arg_scid, long arg_billid, string arg_newdescppart, ref string arg_msg);//add_dscrp(string arg_newdescppart)
- //0 fail 1 success
- int rslt=1
- arg_newdescppart=trim(arg_newdescppart)
- if it_updatebegin or it_newbegin then
- rslt=0
- arg_msg="编辑状态下不可用"
- goto ext
- end if
- if arg_newdescppart='' then
- rslt=0
- arg_msg="要添加内容为空,操作取消"
- goto ext
- end if
- rslt=getinfo(arg_scid,arg_billid,arg_msg)
- if rslt=0 then goto ext
- if flag=0 then
- rslt=0
- arg_msg="非审核状态下不可用"
- goto ext
- end if
- update u_spt_wfjg
- set dscrp = dscrp+' '+:arg_newdescppart
- where billid = :arg_billid
- and scid=:arg_scid;
- if sqlca.sqlcode<>0 then
- rollback ;
- rslt=0
- arg_msg="因网络或其它原因导致添加单据备注操作失败"+"~n"+sqlca.sqlerrtext
- goto ext
- end if
- commit ;
- dscrp = dscrp+' '+arg_newdescppart
- ext: return (rslt)
- end function
- on uo_spt_wfjg.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_spt_wfjg.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|