$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