123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646 |
- $PBExportHeader$uo_sptdef.sru
- forward
- global type uo_sptdef from nonvisualobject
- end type
- type s_spt_rep from structure within uo_sptdef
- end type
- end forward
- type s_spt_rep from structure
- long repid
- long sptid
- string repname
- string duty
- string sex
- string officetel
- string handtel
- string faxno
- string email
- string dscrp
- end type
- global type uo_sptdef from nonvisualobject
- end type
- global uo_sptdef uo_sptdef
- type variables
- public protectedwrite long sptid //进仓单表自动增量id
- public protectedwrite datetime opdate //建立时间,自动
- public protectedwrite string opemp //建立操作员
- s_spt s_sptdef
- boolean if_getid_ture=false
- transaction commit_transaction //数据commit事务
- PRIVATE:
- s_spt_rep sptmx[] //明细结构数组
- long it_mxbt=0 //明细结构数组末指针
- boolean it_newbegin=false //新建标志
- boolean it_updatebegin=false //修改标志
- end variables
- forward prototypes
- public function integer p_reset ()
- public function integer p_getinfo (long arg_sptid, ref string arg_msg)
- public function integer save (boolean arg_ifcommit, ref string arg_msg)
- public function integer newbegin (long arg_sptid)
- public function integer updatebegin (long arg_sptid, ref string arg_msg)
- public function integer del (long arg_sptid, string arg_sptcode, ref string arg_msg, boolean arg_ifcommit)
- public function integer acceptmx (long arg_repid, long arg_sptid, string arg_repname, string arg_duty, string arg_sex, string arg_officetel, string arg_handtel, string arg_faxno, string arg_email, string arg_dscrp, ref string arg_msg)
- public function integer p_clearmx ()
- public function integer getinfo (long arg_sptid, ref string arg_msg)
- end prototypes
- public function integer p_reset ();//int p_reset()
- s_sptdef.name = ''
- s_sptdef.spttype= ''
- s_sptdef.rep= ''
- s_sptdef.tele= ''
- s_sptdef.tele1= ''
- s_sptdef.bank= ''
- s_sptdef.cunt= ''
- s_sptdef.address= ''
- s_sptdef.code= ''
- s_sptdef.dscrp= ''
- s_sptdef.sptcode= ''
- s_sptdef.inuse= 0
- s_sptdef.faxno= ''
- s_sptdef.email= ''
- it_newbegin=false
- it_updatebegin=false
- //清除明细
- p_clearmx()
- return 1
- end function
- public function integer p_getinfo (long arg_sptid, ref string arg_msg);//p_getinfo(arg_scid,arg_inwareid,arg_msg)
- //0 失败 1成功
- INT rslt=1
- IF arg_sptid<=0 THEN
- rslt=0
- arG_MSG="非法供应商唯一码"
- goto ext
- end if
-
- SELECT name,
- spttype,
- rep,
- tele,
- tele1,
- bank,
- cunt,
- address,
- code,
- dscrp,
- sptcode,
- inuse,
- faxno,
- email
- into :s_sptdef.name,
- :s_sptdef.spttype,
- :s_sptdef.rep,
- :s_sptdef.tele,
- :s_sptdef.tele1,
- :s_sptdef.bank,
- :s_sptdef.cunt,
- :s_sptdef.address,
- :s_sptdef.code,
- :s_sptdef.dscrp,
- :s_sptdef.sptcode,
- :s_sptdef.inuse,
- :s_sptdef.faxno,
- :s_sptdef.email
- FROM u_spt
- WHERE sptid = :arg_sptid using commit_transaction;
- if commit_transaction.sqlcode<>0 then
- rslt=0
- if pos(lower(commit_transaction.SQLErrText),'more than') > 0 then
- arg_msg = '查询操作失败,查询数据返回值多于一个'
- else
- arG_MSG="查询操作失败(错误供应商唯一码)"
- end if
- goto ext
- end if
- sptid = arg_sptid
- ext:
- IF rslt=0 THEN p_reset()
- return rslt
- end function
- public function integer save (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i
- DateTime server_dt
- Long ls_newid
- Long ls_sptid
- IF IsNull(s_sptdef.Name) THEN s_sptdef.Name = ''
- IF IsNull(s_sptdef.spttype) THEN s_sptdef.spttype = ''
- IF IsNull(s_sptdef.rep) THEN s_sptdef.rep = ''
- IF IsNull(s_sptdef.tele) THEN s_sptdef.tele = ''
- IF IsNull(s_sptdef.bank) THEN s_sptdef.bank = ''
- IF IsNull(s_sptdef.tele1) THEN s_sptdef.tele1 = ''
- IF IsNull(s_sptdef.cunt) THEN s_sptdef.cunt = ''
- IF IsNull(s_sptdef.Address) THEN s_sptdef.Address = ''
- IF IsNull(s_sptdef.code) THEN s_sptdef.code = ''
- IF IsNull(s_sptdef.dscrp) THEN s_sptdef.dscrp = ''
- IF IsNull(s_sptdef.faxno) THEN s_sptdef.faxno = ''
- IF IsNull(s_sptdef.sptcode) THEN s_sptdef.sptcode = ''
- IF IsNull(s_sptdef.email) THEN s_sptdef.email = ''
- IF IsNull(s_sptdef.inuse) THEN s_sptdef.inuse = 1
- IF IsNull(s_sptdef.spttypeid) THEN s_sptdef.spttypeid = 11
- IF IsNull(s_sptdef.industry) THEN s_sptdef.industry = ''
- IF IsNull(s_sptdef.dftmoneyid) THEN s_sptdef.dftmoneyid = 0
- IF IsNull(s_sptdef.dftbanktypeid) THEN s_sptdef.dftbanktypeid = 0
- IF IsNull(s_sptdef.tax) THEN s_sptdef.tax = 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 Using commit_transaction ;
- //取得系统时间,借用操作员表
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,日期 "
- GOTO ext
- END IF
- //////////////////////////////////////////////// //开始区分:新建/更新 处理
- IF sptid = 0 THEN //新建
- ls_newid = f_sys_scidentity(0,"u_spt","sptid",arg_msg,if_getid_ture,commit_transaction)
- IF ls_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- INSERT INTO u_spt
- (sptid,
- name,
- spttype,
- rep,
- tele,
- tele1,
- bank,
- cunt,
- address,
- code,
- dscrp,
- sptcode,
- email,
- opdate,
- opemp,
- inuse,
- faxno,
- spttypeid,
- dftmoneyid,
- dftbanktypeid,
- industry,
- tax)
- VALUES
- (:ls_newid,
- :s_sptdef.name,
- :s_sptdef.spttype,
- :s_sptdef.rep,
- :s_sptdef.tele,
- :s_sptdef.tele1,
- :s_sptdef.bank,
- :s_sptdef.cunt,
- :s_sptdef.address,
- :s_sptdef.code,
- :s_sptdef.dscrp,
- :s_sptdef.sptcode,
- :s_sptdef.email,
- :server_dt,
- :publ_operator,
- :s_sptdef.inuse,
- :s_sptdef.faxno,
- :s_sptdef.spttypeid,
- :s_sptdef.dftmoneyid,
- :s_sptdef.dftbanktypeid,
- :s_sptdef.industry,
- :s_sptdef.tax) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- IF Pos(Lower(commit_transaction.SQLErrText),'pk_u_spt') > 0 THEN
- arg_msg = '插入操作供应商失败,关键字供应商ID重复'
- ELSEIF Pos(Lower(commit_transaction.SQLErrText),'ix_u_spt_1') > 0 THEN
- arg_msg = '插入操作供应商失败,供应商编号重复'
- ELSEIF Pos(Lower(commit_transaction.SQLErrText),'ix_u_spt') > 0 THEN
- arg_msg = '插入操作供应商失败,供应商名称、联系人重复'
- ELSE
- arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
-
- //读取新sptid
- sptid = ls_newid
- FOR i = 1 To it_mxbt
- INSERT INTO u_spt_rep
- (repid,
- sptid,
- repname,
- duty,
- sex,
- officetel,
- handtel,
- faxno,
- email,
- dscrp)
- VALUES (
- :sptmx[i].repid,
- :ls_newid,
- :sptmx[i].repname,
- :sptmx[i].duty,
- :sptmx[i].sex,
- :sptmx[i].officetel,
- :sptmx[i].handtel,
- :sptmx[i].faxno,
- :sptmx[i].email,
- :sptmx[i].dscrp
- ) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- sptid = 0 //sptid
- rslt = 0
- IF Pos(Lower(commit_transaction.SQLErrText),'pk_u_spt_rep') > 0 THEN
- arg_msg = '插入联系人资料操作失败,关键字联系人ID重复'
- ELSEIF Pos(Lower(commit_transaction.SQLErrText),'ix_u_spt_rep') > 0 THEN
- arg_msg = '插入联系人资料操作失败,联系人名称重复'
- ELSE
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
- NEXT
-
- ELSE //////////////////////////////////////////////// //更新
- UPDATE u_spt
- SET name = :s_sptdef.name,
- spttype = :s_sptdef.spttype,
- rep = :s_sptdef.rep,
- tele = :s_sptdef.tele,
- tele1 = :s_sptdef.tele1,
- bank = :s_sptdef.bank,
- cunt = :s_sptdef.cunt,
- address = :s_sptdef.address,
- code = :s_sptdef.code,
- dscrp = :s_sptdef.dscrp,
- sptcode = :s_sptdef.sptcode,
- email = :s_sptdef.email,
- inuse = :s_sptdef.inuse,
- faxno = :s_sptdef.faxno,
- spttypeid = :s_sptdef.spttypeid ,
- dftmoneyid = :s_sptdef.dftmoneyid,
- dftbanktypeid = :s_sptdef.dftbanktypeid,
- industry = :s_sptdef.industry,
- tax = :s_sptdef.tax,
- opdate=:server_dt,
- opemp=:publ_operator
- Where sptid = :sptid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN
- rslt = 0
- IF Pos(Lower(commit_transaction.SQLErrText),'pk_u_spt') > 0 THEN
- arg_msg = '更新操作供应商失败,关键字供应商ID重复'
- ELSEIF Pos(Lower(commit_transaction.SQLErrText),'ix_u_spt_1') > 0 THEN
- arg_msg = '更新操作供应商失败,供应商编号重复'
- ELSEIF Pos(Lower(commit_transaction.SQLErrText),'ix_u_spt') > 0 THEN
- arg_msg = '更新操作供应商失败,供应商名称、联系人重复'
- ELSE
- arg_msg = "因网络或其它原因导致更新操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
-
- //删除原有明细
- DELETE FROM u_spt_rep
- Where u_spt_rep.sptid = :sptid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除供应商联系人明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 To it_mxbt
- INSERT INTO u_spt_rep
- (repid,
- sptid,
- repname,
- duty,
- sex,
- officetel,
- handtel,
- faxno,
- email,
- dscrp)
- VALUES (
- :sptmx[i].repid,
- :sptid,
- :sptmx[i].repname,
- :sptmx[i].duty,
- :sptmx[i].sex,
- :sptmx[i].officetel,
- :sptmx[i].handtel,
- :sptmx[i].faxno,
- :sptmx[i].email,
- :sptmx[i].dscrp
- ) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- sptid = 0 //sptid
- rslt = 0
- IF Pos(Lower(commit_transaction.SQLErrText),'pk_u_spt_rep') > 0 THEN
- arg_msg = '插入联系人资料操作失败,关键字联系人ID重复'
- ELSEIF Pos(Lower(commit_transaction.SQLErrText),'ix_u_spt_rep') > 0 THEN
- arg_msg = '插入联系人资料操作失败,联系人名称重复'
- ELSE
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
- NEXT
-
- END IF
- it_newbegin = False
- it_updatebegin = False
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- p_clearmx()
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- arg_msg = '供应商资料,'+ arg_msg
- RETURN rslt
- end function
- public function integer newbegin (long arg_sptid);long rslt = 1
- it_newbegin =true
- it_updatebegin =false
- sptid = arg_sptid
- p_clearmx()
- return rslt
- end function
- public function integer updatebegin (long arg_sptid, ref string arg_msg);long rslt=1
- if arg_sptid<=0 then
- rslt=0
- arg_msg = '错误供应商唯一码'
- goto ext
- end if
- rslt=p_getinfo(arg_sptid,arg_msg)
- if rslt=0 then goto ext
- sptid=arg_sptid
- it_newbegin=false
- it_updatebegin=true
- p_clearmx() //清除明细
- ext:
- if rslt=0 then p_reset()
- arg_msg = '供应商资料,'+ arg_msg
- return rslt
- end function
- public function integer del (long arg_sptid, string arg_sptcode, ref string arg_msg, boolean arg_ifcommit);
- int rslt = 1
- long ls_long
- if arg_sptid = 0 then
- rslt = 0
- arg_msg = "没有删除对象,操作取消"
- goto ext
- end if
- ls_long = 0
- SELECT COUNT(*) INTO :LS_LONG FROM u_buytask Where u_buytask.sptid = :arg_sptid using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "数据查询操作失败!(请重试!)"
- goto ext
- END IF
- IF LS_LONG > 0 THEN
- rslt = 0
- arg_msg ="该资料已经使用于采购订单记录,不可以删除!"
- goto ext
- END IF
- LS_LONG = 0
- SELECT COUNT(*) INTO :LS_LONG FROM u_inware Where u_inware.sptid = :arg_sptid using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "数据查询操作失败!(请重试!)"
- goto ext
- END IF
- IF LS_LONG > 0 THEN
- rslt = 0
- arg_msg = "该资料已经使用于进仓记录,不可以删除!"
- goto ext
- END IF
- LS_LONG = 0
- SELECT COUNT(*) INTO :LS_LONG FROM u_bmstpay Where sptid = :arg_sptid using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "数据查询操作失败!(请重试!)"
- goto ext
- END IF
- IF LS_LONG > 0 THEN
- rslt = 0
- arg_msg = "该资料已经使用于应付帐,不可以删除!"
- goto ext
- END IF
- delete from u_spt_rep
- where sptid = :arg_sptid using commit_transaction;
- if commit_transaction.sqlcode <> 0 then
- rslt = 0
- arg_msg = "删除供应商联系人操作失败"+"~n"+commit_transaction.sqlerrtext
- goto ext
- end if
- delete from u_spt
- where sptid = :arg_sptid using commit_transaction;
- if commit_transaction.sqlcode <> 0 then
- rslt = 0
- arg_msg = "删除供应商操作失败"+"~n"+commit_transaction.sqlerrtext
- goto ext
- end if
- if f_setsysoplog('定义资料','供应商定义资料删除,id:'+string(arg_sptid)+',code:'+arg_sptcode,arg_msg,false) = 0 then
- rslt = 0
- goto ext
- end if
- it_newbegin = false
- it_updatebegin = false
- ext:
- if rslt=0 then
- rollback using commit_transaction;
- elseif rslt=1 and arg_ifcommit then
- commit using commit_transaction;
- end if
- p_reset()
- arg_msg = '供应商资料,'+ arg_msg
- return rslt
- end function
- public function integer acceptmx (long arg_repid, long arg_sptid, string arg_repname, string arg_duty, string arg_sex, string arg_officetel, string arg_handtel, string arg_faxno, string arg_email, string arg_dscrp, ref string arg_msg);Long rslt = 1,cnt = 0,ls_i
- IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
- rslt = 0
- arg_msg = "非编辑状态不可以使用,操作取消"
- GOTO ext
- END IF
- //清除空值
- IF IsNull(arg_repid) THEN arg_repid = 0
- IF IsNull(arg_sptid) THEN arg_sptid = 0
- IF IsNull(arg_repname) THEN arg_repname = ''
- IF IsNull(arg_duty) THEN arg_duty = ''
- IF IsNull(arg_sex) THEN arg_sex = ''
- IF IsNull(arg_officetel) THEN arg_officetel = ''
- IF IsNull(arg_handtel) THEN arg_handtel = ''
- IF IsNull(arg_faxno) THEN arg_faxno = ''
- IF IsNull(arg_email) THEN arg_email = ''
- IF IsNull(arg_dscrp) THEN arg_dscrp = ''
- IF arg_repid = 0 THEN
- rslt = 1
- GOTO ext
- END IF
- //检查sptid
- cnt = 0
- SELECT count(*)
- INTO :cnt
- FROM u_spt
- Where sptid = :arg_sptid USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,供应商:"+commit_transaction.sqlerrtext
- GOTO ext
- END IF
- //写入内容
- it_mxbt++
- sptmx[it_mxbt].repid = arg_repid
- sptmx[it_mxbt].sptid = arg_sptid
- sptmx[it_mxbt].repname = arg_repname
- sptmx[it_mxbt].duty = arg_duty
- sptmx[it_mxbt].sex = arg_sex
- sptmx[it_mxbt].officetel = arg_officetel
- sptmx[it_mxbt].handtel = arg_handtel
- sptmx[it_mxbt].faxno = arg_faxno
- sptmx[it_mxbt].email = arg_email
- sptmx[it_mxbt].dscrp = arg_dscrp
- ext:
- IF rslt = 0 THEN p_clearmx()
- arg_msg = '供应商资料,'+ arg_msg
- Return(rslt)
- end function
- public function integer p_clearmx ();//int p_clearmx()
- //清除明细
- it_mxbt=0
- return 1
- end function
- public function integer getinfo (long arg_sptid, ref string arg_msg);//getinfo(arg_scid,arg_sptid,arg_msg)
- //0 失败 1成功
- Int rslt = 1,i = 1,no_mxcheck = 0
- IF arg_sptid <= 0 THEN
- rslt = 0
- arg_msg = "非法供应商唯一码"
- GOTO ext
- END IF
- rslt = p_getinfo(arg_sptid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- //用游标读取明细
- DECLARE cur_inwaermx CURSOR FOR
- SELECT repid, sptid, repname, duty, sex, officetel, handtel, faxno, email, dscrp
- FROM u_spt_rep
- WHERE u_spt_rep.sptid = :arg_sptid USING commit_transaction;
-
- OPEN cur_inwaermx;
- FETCH cur_inwaermx INTO :sptmx[i].repid,:sptmx[i].sptid,
- :sptmx[i].repname,:sptmx[i].duty,:sptmx[i].sex,
- :sptmx[i].officetel,:sptmx[i].handtel,:sptmx[i].faxno,
- :sptmx[i].email,:sptmx[i].dscrp;
- DO WHILE commit_transaction.SQLCode = 0
- i++
- FETCH cur_inwaermx INTO :sptmx[i].repid,:sptmx[i].sptid,
- :sptmx[i].repname,:sptmx[i].duty,:sptmx[i].sex,
- :sptmx[i].officetel,:sptmx[i].handtel,:sptmx[i].faxno,
- :sptmx[i].email,:sptmx[i].dscrp;
- LOOP
- CLOSE cur_inwaermx;
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck
- FROM u_spt_rep
- WHERE u_spt_rep.sptid = :arg_sptid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,供应商表联系人明细"
- GOTO ext
- END IF
- IF i <> (no_mxcheck+1) THEN
- rslt = 0
- arg_msg = "查询操作失败,供应商表联系人明细"
- GOTO ext
- END IF
- sptid = arg_sptid
- it_mxbt = i - 1
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- on uo_sptdef.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_sptdef.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|