12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424 |
- $PBExportHeader$uo_associat_sptcust.sru
- forward
- global type uo_associat_sptcust from nonvisualobject
- end type
- type s_bmsttakemx from structure within uo_associat_sptcust
- end type
- end forward
- type s_bmsttakemx from structure
- long scid
- long takeid
- string billcode
- datetime takedate
- string taketype
- decimal { 2 } msttakeamt
- decimal { 2 } takeamt
- decimal { 2 } oriamt
- decimal { 2 } mainmsttakeamt
- decimal { 2 } maintakeamt
- string opemp
- string dscrp
- string inrep
- integer buildtype
- long banktypeid
- string relbillcode
- end type
- global type uo_associat_sptcust from nonvisualobject
- end type
- global uo_associat_sptcust uo_associat_sptcust
- type variables
- PUBLIC PROTECTEDWRITE Long scid=0
- PUBLIC PROTECTEDWRITE Long salebillid //销售收入单表自动增量ID
- PUBLIC PROTECTEDWRITE String salebillcode //所有单据的唯一编号
- PUBLIC PROTECTEDWRITE DateTime opdate //建立时间,自动
- PUBLIC PROTECTEDWRITE Int flag = 0 //审核标志
- PUBLIC PROTECTEDWRITE DateTime Auditdate //审核时间
- PUBLIC PROTECTEDWRITE String auditREP //审核操作员
- PUBLIC PROTECTEDWRITE Long reissueid
- PUBLIC PROTECTEDWRITE String reissuecode
- PUBLIC PROTECTEDWRITE Decimal sumamt = 0
- String relcode = '' //交易单号
- String opemp //建立操作员
- DateTime takedate //发生时间
- String taketype = '' //付款方式
- String dscrp = '' //备注
- Long cusid = 0 //客户id
- Long sptid =0 //供应商ID
- Decimal msttakeamt //收入金额
- Decimal takeamt //收入金额
- String inrep
- Long ywrepid //业务员ID
- Long banktypeid //结算方式
- Long rapmoneyid //出纳帐ID
- Long accountsid //帐号ID
- Long itemid //收支项目ID
- long buildtype //建立类型
- int billtype
- long moneyid=0
- PRIVATE:
- S_BmsttakeMX mx[] //明细结构数组
- Long it_MXBT = 0 //明细结构数组末指针
- Boolean IT_NEWBEGIN = FALSE //新建标志
- Boolean IT_UPDATEBEGIN = FALSE//修改标志
- Long relid
- DateTime reissuedate
- String cuscode
- String reissueemp
- String cusname
- Long r_type
- Long relint_3
- Int cwauditingflag = 0 //总账审核标记
- DateTime cwauditingdate //总账审核时间
- String cwauditingrep //总账审核操作员
-
- Boolean if_getid_ture = TRUE
- s_reissuemx reissuemx[]
- Transaction commit_transaction
- end variables
- forward prototypes
- public function integer p_clearmx ()
- public function integer p_reset ()
- public function integer newbegin ()
- public function integer save_ds (ref string arg_msg, boolean arg_ifcommt)
- public function integer save_sptcust (ref string arg_msg, boolean arg_ifcommt, ref long oldsptid, ref long oldcustid)
- public function integer del (long al_spt, long al_cusid, ref string as_msg)
- public function integer save (ref string arg_msg, boolean arg_ifcommit)
- public function integer getinfo (long arg_scid, long arg_reissueid, ref string arg_msg)
- public function integer p_getinfo (long arg_scid, long arg_reissueid, ref string arg_msg)
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
- end prototypes
- public function integer p_clearmx ();//INT p_clearmx()
- //清除明细
- it_mxbt=0
- RETURN 1
- end function
- public function integer p_reset ();//INT p_RESET()
- //清除对象及其明细
- salebillid=0
- salebillcode=''
- opemp=''
- flag=0
- it_newbegin=FALSE
- it_updatebegin=FALSE
- //清除明细
- P_CLEARMX()
- RETURN 1
- end function
- public function integer newbegin ();//newbegin()
- //从置对象,设定业务类型,准备建立新单
- //0 fail 1 success
- LONG RSLT=1
- p_reset()
- it_newbegin=TRUE
- it_updatebegin=FALSE
- return RSLT
- end function
- public function integer save_ds (ref string arg_msg, boolean arg_ifcommt);//save(arg_msg,arg_ifcommt)
- // 新建(salebillid=0)\更新(salebillid>0)
- //0 fail 1 success
- uo_musttake uo_take
- uo_take = CREATE uo_musttake
- Integer rslt = 1,cnt = 0,i
- Decimal LS_KTSL
- Long LS_NEWoutWAREID
- DateTime server_datetime
- Long ls_newid
- Long ref_dateint
- String ls_cusname
- Decimal ls_msttakeamt
- Decimal ls_takeamt
- Long ll_itemid
- Long ll_dateint
- DateTime ld_takedate
- IF IsNull(dscrp) THEN dscrp = ''
- IF IsNull(relcode) THEN relcode = ''
- IF IsNull(inrep) THEN inrep = ''
- IF IsNull(taketype) THEN taketype = ''
- IF IsNull(accountsid) THEN accountsid = 0
- IF IsNull(itemid) THEN itemid = 0
- IF moneyid <= 0 THEN
- rslt = 0
- arg_msg = '请选择币种!'
- GOTO ext
- END IF
- IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
- rslt = 0
- arg_msg = "非编辑状态不可以提交"
- GOTO ext
- END IF
- SELECT Top 1 getdate() INTO :server_datetime FROM u_user ;
- //取得系统时间,借用操作员表
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,日期 "
- GOTO ext
- END IF
- IF it_mxbt = 0 THEN //如果输入库存物料资料错则已经清空
- rslt = 0
- arg_msg = "没有正确单据内容"
- GOTO ext
- END IF
- IF Year(Date(takedate)) < 2000 OR IsNull(takedate) THEN
- rslt = 0
- arg_msg = "缺少出仓发生时间或不合理"
- GOTO ext
- END IF
- //cnt = 0
- //SELECT count(*) INTO :cnt
- // FROM cw_banktype
- // Where banktypeid = :banktypeid;
- //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_cust
- Where cusid = :cusid ;
- 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 name
- INTO :ls_cusname
- FROM u_cust
- Where u_cust.cusid = :cusid ;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询操作失败,客户唯一码'
- rslt = 0
- GOTO ext
- END IF
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_user
- Where username = :opemp ;
- 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
- opdate = server_datetime //填写单据建立时间(最近修改时间)
- ////////////////////////////////////////////////开始区分:新建/更新 处理
- IF salebillid = 0 THEN //新建
- ls_newid = f_sys_scidentity(0,"U_salebill","salebillid",arg_msg,false,sqlca)
- IF ls_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- salebillcode = getid(0,"SB",Date(server_datetime),false,sqlca) //取得新单据编号
- IF salebillcode = "err" THEN
- salebillcode = ''
- rslt = 0
- arg_msg = "无法获取收入单编号"
- GOTO ext
- END IF
-
- INSERT INTO U_salebill (
-
- salebillid,
- salebillcode,
- takedate,
- Relcode,
- Msttakeamt,
- takeamt,
- cusid,
- dscrp,
- taketype,
- inrep,
- opdate,
- opemp,
- YwrepID,
- banktypeid,
- rapmoneyid ,
- accountsid,
- itemid,
- buildtype,
- moneyid)
- VALUES (
- :ls_newid,
- :salebillcode,
- :takedate,
- :Relcode,
- :Msttakeamt,
- :takeamt,
- :cusid,
- :dscrp,
- :taketype,
- :inrep,
- :opdate,
- :opemp,
- :YwrepID,
- :banktypeid,
- :ref_dateint ,
- :accountsid,
- :itemid,
- :buildtype,
- :moneyid) ;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "插入操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
-
-
-
- FOR i = 1 TO it_mxbt
- IF mx[i].relbillcode = '' THEN mx[i].relbillcode = salebillcode
- IF uo_take.add_takerecmx(mx[i].scid,mx[i].takeid,mx[i].relbillcode,mx[i].takedate,mx[i].banktypeid,mx[i].Msttakeamt,&
- mx[i].takeamt,mx[i].opemp,mx[i].dscrp,mx[i].inrep,2,ls_newid,0,cusid,moneyid,arg_msg,FALSE,'') = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
- salebillid = ls_newid
- FOR i = 1 TO it_mxbt
- INSERT INTO u_salebillmx
- (scid,
- salebillid,
- takeid,
- takedate,
- msttakeamt,
- takeamt,
- billcode,
- relbillcode,
- oriamt,
- mainmsttakeamt,
- maintakeamt
- )
- VALUES
- (:mx[i].scid,
- :ls_newid,
- :mx[i].takeid,
- :mx[i].takedate,
- :mx[i].msttakeamt,
- :mx[i].takeamt,
- :mx[i].billcode,
- :mx[i].relbillcode,
- :mx[i].oriamt,
- :mx[i].mainmsttakeamt,
- :mx[i].maintakeamt
- );
- IF sqlca.SQLCode <> 0 THEN
- salebillid = 0
- rslt = 0
- arg_msg = "插入明细操作失败"+"~n"+sqlca.SQLErrText
- ROLLBACK USING sqlca;
- GOTO ext
- END IF
- NEXT
- ELSE //////////////////////////////////////////////////更新
-
- SELECT msttakeamt,
- takeamt,
- itemid,
- rapmoneyid,
- takedate
- INTO :ls_msttakeamt,
- :ls_takeamt,
- :ll_itemid,
- :ll_dateint,
- :ld_takedate
- FROM u_salebill
- Where U_salebill.salebillid = :salebillid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = "查询应收帐建立类型失败,请重试!"+'~n'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
-
-
- UPDATE U_salebill
- SET takedate = :takedate,
- Relcode = :Relcode,
- Msttakeamt = :Msttakeamt,
- takeamt = :takeamt,
- cusid = :cusid,
- dscrp = :dscrp,
- taketype = :taketype,
- inrep = :inrep,
- opdate = :opdate,
- opemp = :opemp,
- YwrepID = :YwrepID,
- banktypeid = :banktypeid,
- rapmoneyid = :ref_dateint,
- accountsid = :accountsid,
- itemid = :itemid,
- moneyid = :moneyid
- Where U_salebill.salebillid = :salebillid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "更新单据操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
-
- //删除原有明细
- DELETE FROM U_salebillmx
- Where u_salebillmx.salebillid = :salebillid USING sqlca;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除旧有明细操作失败"+"~n"+sqlca.SQLErrText
- ROLLBACK USING sqlca;
- GOTO ext
- END IF
- FOR i = 1 TO it_mxbt
- INSERT INTO u_salebillmx
- (scid,
- salebillid,
- takeid,
- takedate,
- msttakeamt,
- takeamt,
- billcode,
- relbillcode,
- oriamt,
- mainmsttakeamt,
- maintakeamt
- )
- VALUES
- (:mx[i].scid,
- :ls_newid,
- :mx[i].takeid,
- :mx[i].takedate,
- :mx[i].msttakeamt,
- :mx[i].takeamt,
- :mx[i].billcode,
- :mx[i].relbillcode,
- :mx[i].oriamt,
- :mx[i].mainmsttakeamt,
- :mx[i].maintakeamt
- );
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "插入明细操作失败"+"~n"+sqlca.SQLErrText
- ROLLBACK USING sqlca;
- GOTO ext
- END IF
- NEXT
-
- IF uo_take.salebill_del_mx(salebillid,arg_msg,FALSE) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- FOR i = 1 TO it_mxbt
- IF uo_take.add_takerecmx(mx[i].scid,mx[i].takeid,mx[i].billcode,mx[i].takedate,mx[i].banktypeid,mx[i].Msttakeamt,&
- mx[i].takeamt,mx[i].opemp,mx[i].dscrp,mx[i].inrep,2,salebillid,0,cusid,moneyid,arg_msg,FALSE,'') = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
-
- END IF
- it_newbegin = FALSE
- it_updatebegin = FALSE
- salebillid = ls_newid
- ext:
- DESTROY uo_take
- IF rslt = 0 THEN
- ROLLBACK;
- //salebillid=0
- p_clearmx()
- ELSEIF rslt = 1 AND arg_ifcommt THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- public function integer save_sptcust (ref string arg_msg, boolean arg_ifcommt, ref long oldsptid, ref long oldcustid);//save_sptcust(arg_msg,arg_ifcommt,oldsptid,oldcustid)
- // 新建(oldsptid=0)\更新(oldsptid>0)
- //0 fail 1 success
- Integer rslt = 1,cnt = 0
-
- SELECT count(*) INTO :cnt
- FROM u_spt
- Where sptid = :sptid ;
- 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_cust
- Where cusid = :cusid ;
- 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
-
- ////////////////////////////////////////////////开始区分:新建/更新 处理
- IF oldsptid = 0 THEN //新建
-
- INSERT INTO u_associat_sptcust (
- sptid,
- cusid,
- dscrp
- )
- VALUES (
- :sptid,
- :cusid,
- :dscrp
- ) ;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "插入操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
-
- ELSE //////////////////////////////////////////////////更新
-
- UPDATE u_associat_sptcust
- SET sptid = :sptid,
- cusid = :cusid,
- dscrp = :dscrp
- Where u_associat_sptcust.sptid = :oldsptid
- and u_associat_sptcust.cusid=:oldcustid ;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "更新单据操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
-
- END IF
- it_newbegin = FALSE
- it_updatebegin = FALSE
- oldsptid = 0
- oldcustid = 0
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommt THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- public function integer del (long al_spt, long al_cusid, ref string as_msg);//0 FAIL, 1 SUCCESS
- Int rslt = 1
- delete from u_associat_sptcust
- where u_associat_sptcust.cusid = :al_cusid
- and u_associat_sptcust.sptid = :al_spt ;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- as_msg = "删除出仓单明细操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
-
- ext:
- IF rslt = 0 THEN
- ROLLBACK ;
- ELSEIF rslt = 1 THEN
- COMMIT ;
- END IF
- //
- Return (rslt)
- return 1
- end function
- public function integer save (ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1,cnt = 0,i
- DateTime server_dt
- Long ls_newid
- String ls_sccode
- IF IsNull(relid) THEN relid = 0
- IF IsNull(cusid) THEN cusid = 0
- IF IsNull(moneyid) THEN moneyid = 0
- IF IsNull(relcode) THEN relcode = ''
- IF IsNull(reissueemp) THEN reissueemp = ''
- IF IsNull(dscrp) THEN dscrp = ''
- 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 USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,日期 "
- GOTO ext
- END IF
- IF r_type = 2 THEN
- IF cusid = 0 THEN
- arg_msg = '请选择供应商'
- rslt = 0
- GOTO ext
- END IF
-
- SELECT count(*) INTO :cnt
- FROM u_spt
- WHERE sptid = :cusid
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询供应商资料失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = '错误的供应商资料'
- GOTO ext
- END IF
- ELSE
-
- IF cusid = 0 THEN
- arg_msg = '请选择客户'
- rslt = 0
- GOTO ext
- END IF
-
- SELECT count(*) INTO :cnt
- FROM u_cust
- WHERE cusid = :cusid
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询客户资料失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = '错误的客户资料'
- GOTO ext
- END IF
- END IF
- IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
- rslt = 0
- arg_msg = "没有正确进仓内容"
- GOTO ext
- END IF
- IF itemid = 0 THEN
- rslt = 0
- arg_msg = '请选择项目'
- GOTO ext
- END IF
- SELECT count(*) INTO :cnt
- FROM u_itemdef
- WHERE itemid = :itemid
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询项目资料失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = '错误的项目资料'
- GOTO ext
- END IF
- IF f_check_inoutdate(0,reissuedate,true,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ////////////////////////////////////////////// //开始区分:新建/更新 处理
- IF reissueid = 0 THEN //新建
- ls_newid = f_sys_scidentity(scid,"u_reissue","reissueid",arg_msg,if_getid_ture,commit_transaction)
- IF ls_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- //取分部代号
- IF f_get_sccode(scid,commit_transaction,ls_sccode,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- //取得新单据编号
- IF r_type = 0 THEN
- reissuecode = getid(scid,ls_sccode + 'FJ',Date(server_dt),if_getid_ture,commit_transaction)
- ELSEIF r_type = 1 THEN
- reissuecode = getid(scid,ls_sccode + 'FY',Date(server_dt),if_getid_ture,commit_transaction)
- ELSE
- reissuecode = getid(scid,ls_sccode + 'FS',Date(server_dt),if_getid_ture,commit_transaction)
- END IF
-
- IF reissuecode = "err" THEN
- reissuecode = ''
- rslt = 0
- arg_msg = "无法获取单据编号"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- INSERT INTO u_reissue (
- scid,
- reissueid,
- reissuecode,
- cusid,
- reissuedate,
- relid,
- relcode,
- dscrp,
- opdate,
- opemp,
- flag,
- reissueemp,
- type,
- moneyid,
- itemid)
- VALUES (
- :scid,
- :ls_newid,
- :reissuecode,
- :cusid,
- :reissuedate,
- :relid,
- :relcode,
- :dscrp,
- :server_dt,
- :publ_operator,
- :flag,
- :reissueemp,
- :r_type,
- :moneyid,
- :itemid) USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
-
- IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_reissue') > 0 THEN
- arg_msg = '插入操作失败,关键字单据ID重复'
- ELSEIF Pos(Lower(commit_transaction.SQLErrText),'IX_u_reissue') > 0 THEN
- arg_msg = '插入操作失败,关键字单据编号重复'
- ELSE
- arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
-
- GOTO ext
- END IF
-
- //读取新reissueid
- reissueid = ls_newid
-
- FOR i = 1 TO it_mxbt
- INSERT INTO u_reissuemx
- (scid,
- reissueid,
- mtrlid,
- printid,
- qty,
- price,
- amt,
- dscrp,
- mtrlname)
- VALUES (
- :scid,
- :ls_newid,
- :reissuemx[i].mtrlid,
- :reissuemx[i].printid,
- :reissuemx[i].qty,
- :reissuemx[i].price,
- :reissuemx[i].amt,
- :reissuemx[i].mxdscrp,
- :reissuemx[i].mtrlname) USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- // reissueid = 0 //还原reissueid
- rslt = 0
-
- IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_reissuemx') > 0 THEN
- arg_msg = '插入明细操作失败,关键字单据ID,序号重复'
- ELSE
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
-
- GOTO ext
- END IF
- NEXT
- ELSE //////////////////////////////////////////////// //更新
- UPDATE u_reissue
- SET cusid = :cusid,
- reissuedate = :reissuedate,
- relid = :relid,
- relcode = :relcode,
- dscrp = :dscrp,
- moddate = : server_dt,
- modemp = :publ_operator,
- reissueemp = :reissueemp,
- type = :r_type,
- moneyid = :moneyid,
- itemid = :itemid
- WHERE u_reissue.reissueid = :reissueid
- AND u_reissue.scid = :scid
- AND flag = 0 USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 OR commit_transaction.SQLNRows <= 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- //删除原有明细
- DELETE FROM u_reissuemx
- WHERE u_reissuemx.reissueid = :reissueid
- AND u_reissuemx.scid = :scid 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_reissuemx
- (scid,
- reissueid,
- mtrlid,
- printid,
- qty,
- price,
- amt,
- dscrp,
- mtrlname)
- VALUES (
- :scid,
- :reissueid,
- :reissuemx[i].mtrlid,
- :reissuemx[i].printid,
- :reissuemx[i].qty,
- :reissuemx[i].price,
- :reissuemx[i].amt,
- :reissuemx[i].mxdscrp,
- :reissuemx[i].mtrlname) USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_reissuemx') > 0 THEN
- arg_msg = '插入明细操作失败,关键字单据ID,序号重复'
- 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
- RETURN rslt
- end function
- public function integer getinfo (long arg_scid, long arg_reissueid, ref string arg_msg);//getinfo(arg_scid,arg_reissueid,arg_msg)
- //0 失败 1成功
- Int rslt = 1,i = 1,no_mxcheck = 0
- IF arg_reissueid <= 0 THEN
- rslt = 0
- arg_msg = "非法补件单唯一码"
- GOTO ext
- END IF
- sumamt = 0
- rslt = p_getinfo(arg_scid,arg_reissueid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- //用游标读取明细
- IF r_type = 0 THEN
- DECLARE cur_inwaermx_0 CURSOR FOR
- SELECT u_reissuemx.printid,
- u_reissuemx.mtrlid,
- u_mtrldef.mtrlcode,
- u_mtrldef.mtrlname,
- u_reissuemx.qty,
- u_reissuemx.price,
- u_reissuemx.dscrp,
- u_reissuemx.amt,
- u_reissuemx.relid
- FROM u_reissuemx left OUTER join u_mtrldef on
- u_reissuemx.mtrlid = u_mtrldef.mtrlid
- WHERE u_reissuemx.reissueid = :arg_reissueid AND
- u_reissuemx.scid = :arg_scid USING commit_transaction;
-
- OPEN cur_inwaermx_0;
- FETCH cur_inwaermx_0 INTO :reissuemx[i].printid,
- :reissuemx[i].mtrlid,:reissuemx[i].mtrlcode,
- :reissuemx[i].mtrlname,:reissuemx[i].qty,
- :reissuemx[i].price,
- :reissuemx[i].mxdscrp,
- :reissuemx[i].amt,
- :reissuemx[i].relid;
- DO WHILE commit_transaction.SQLCode = 0
-
- sumamt += reissuemx[i].amt
-
- i++
-
- FETCH cur_inwaermx_0 INTO :reissuemx[i].printid,
- :reissuemx[i].mtrlid,:reissuemx[i].mtrlcode,
- :reissuemx[i].mtrlname,:reissuemx[i].qty,
- :reissuemx[i].price,
- :reissuemx[i].mxdscrp,
- :reissuemx[i].amt,
- :reissuemx[i].relid;
- LOOP
- CLOSE cur_inwaermx_0;
- ELSEIF r_type = 1 THEN
- DECLARE cur_inwaermx_1 CURSOR FOR
- SELECT u_reissuemx.printid,
- u_reissuemx.mtrlid,
- U_Expenses.Expensescode,
- U_Expenses.Expensesname,
- u_reissuemx.qty,
- u_reissuemx.price,
- u_reissuemx.dscrp,
- u_reissuemx.amt,
- u_reissuemx.relid
- FROM u_reissuemx left OUTER join U_Expenses on
- u_reissuemx.mtrlid = U_Expenses.Expensesid
- WHERE u_reissuemx.reissueid = :arg_reissueid AND
- u_reissuemx.scid = :arg_scid USING commit_transaction;
-
- OPEN cur_inwaermx_1;
- FETCH cur_inwaermx_1 INTO :reissuemx[i].printid,
- :reissuemx[i].mtrlid,:reissuemx[i].mtrlcode,
- :reissuemx[i].mtrlname,:reissuemx[i].qty,
- :reissuemx[i].price,
- :reissuemx[i].mxdscrp,
- :reissuemx[i].amt,
- :reissuemx[i].relid;
- DO WHILE commit_transaction.SQLCode = 0
-
- sumamt += reissuemx[i].amt
-
- i++
-
- FETCH cur_inwaermx_1 INTO :reissuemx[i].printid,
- :reissuemx[i].mtrlid,:reissuemx[i].mtrlcode,
- :reissuemx[i].mtrlname,:reissuemx[i].qty,
- :reissuemx[i].price,
- :reissuemx[i].mxdscrp,
- :reissuemx[i].amt,
- :reissuemx[i].relid;
- LOOP
- CLOSE cur_inwaermx_1;
-
- ELSEIF r_type = 2 THEN
- DECLARE cur_inwaermx_2 CURSOR FOR
- SELECT u_reissuemx.printid,
- u_reissuemx.mtrlid,
- U_Expenses.Expensescode,
- u_reissuemx.mtrlname,
- u_reissuemx.qty,
- u_reissuemx.price,
- u_reissuemx.dscrp,
- u_reissuemx.amt,
- u_reissuemx.relid
- FROM u_reissuemx left OUTER join U_Expenses on
- u_reissuemx.mtrlid = U_Expenses.Expensesid
- WHERE u_reissuemx.reissueid = :arg_reissueid AND
- u_reissuemx.scid = :arg_scid USING commit_transaction;
-
- OPEN cur_inwaermx_2;
- FETCH cur_inwaermx_2 INTO :reissuemx[i].printid,
- :reissuemx[i].mtrlid,:reissuemx[i].mtrlcode,
- :reissuemx[i].mtrlname,:reissuemx[i].qty,
- :reissuemx[i].price,
- :reissuemx[i].mxdscrp,
- :reissuemx[i].amt,
- :reissuemx[i].relid;
- DO WHILE commit_transaction.SQLCode = 0
-
- sumamt += reissuemx[i].amt
-
- i++
-
- FETCH cur_inwaermx_2 INTO :reissuemx[i].printid,
- :reissuemx[i].mtrlid,:reissuemx[i].mtrlcode,
- :reissuemx[i].mtrlname,:reissuemx[i].qty,
- :reissuemx[i].price,
- :reissuemx[i].mxdscrp,
- :reissuemx[i].amt,
- :reissuemx[i].relid;
- LOOP
- CLOSE cur_inwaermx_2;
- END IF
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck
- FROM u_reissuemx
- WHERE u_reissuemx.reissueid = :arg_reissueid
- AND scid = :arg_scid 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
- reissueid = arg_reissueid
- scid = arg_scid
- it_mxbt = i - 1
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer p_getinfo (long arg_scid, long arg_reissueid, ref string arg_msg);//p_getinfo(arg_scid,arg_outwareid,arg_msg)
- //0 失败 1成功
- Int rslt = 1
- IF arg_reissueid <= 0 THEN
- rslt = 0
- arG_MSG = "非法补件单唯一码"
- GOTO ext
- END IF
- SELECT u_reissue.reissuecode,
- u_reissue.cusid,
- u_reissue.cuscode,
- u_reissue.cusname,
- u_reissue.reissuedate,
- u_reissue.relid,
- u_reissue.relcode,
- u_reissue.dscrp,
- u_reissue.flag,
- u_reissue.reissueemp,
- u_reissue.type,
- u_reissue.moneyid,
- u_reissue.relint_3,
- u_reissue.itemid,
- u_reissue.cwauditingflag,
- u_reissue.cwauditingrep,
- u_reissue.cwauditingdate
- INTO :reissuecode,
- :cusid,
- :cuscode,
- :cusname,
- :reissuedate,
- :relid,
- :relcode,
- :dscrp,
- :flag,
- :reissueemp,
- :r_type,
- :moneyid,
- :relint_3,
- :itemid,
- :cwauditingflag,
- :cwauditingrep,
- :cwauditingdate
- FROM u_reissue
- WHERE u_reissue.reissueid = :arg_reissueid
- AND scid = :arg_scid
- USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "查询操作失败(错误补件单唯一码),补件单"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- reissueid = arg_reissueid
- scid = arg_scid
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,ll_i
- //DateTime ld_viewdate
- //SetNull(ld_viewdate)
- uo_musttake uo_take
- uo_mustpay uo_pay
- uo_take = CREATE uo_musttake
- uo_pay = CREATE uo_mustpay
- String ls_about,ls_dscrp
- Decimal ld_takeamt = 0,ld_msttakeamt = 0
- Decimal ld_payamt = 0,ld_mstpayamt = 0
- IF reissueid = 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 flag = 1 THEN
- rslt = 0
- arg_msg = "单据已经审核"
- GOTO ext
- END IF
- Int li_btype
- Long ll_accountsid
- SELECT btype,accountsid INTO :li_btype,:ll_accountsid
- FROM cw_banktype
- Where banktypeid = :relid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询结算方式类型失败,'+ commit_transaction.SQLErrText
- GOTO ext
- END IF
- SELECT count(*) INTO :cnt
- FROM u_user
- Where username = :publ_operator USING commit_transaction ;
- IF commit_transaction.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_reissue
- SET auditingrep = :publ_operator,
- auditingdate = getdate(),
- flag = 1
- WHERE u_reissue.reissueid = :reissueid
- AND flag = 0
- AND scid = :scid USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- IF r_type = 0 THEN //补件单
-
- IF sumamt <> 0 THEN
- ls_about = reissuecode + "补件款"
-
- ls_dscrp = ls_about
- ld_msttakeamt = sumamt
- IF li_btype = 1 THEN
- ld_takeamt = ld_msttakeamt
- ELSE
- ld_takeamt = 0
- END IF
-
- s_bmsttake s_take
-
- s_take.scid = scid
- s_take.cusid = cusid
- s_take.takedate = reissuedate
- s_take.inrep = reissueemp
- s_take.oriamt = ld_msttakeamt
- s_take.msttakeamt = ld_msttakeamt
- s_take.takeamt = ld_takeamt
- s_take.dscrp = ls_dscrp
- s_take.billcode = reissuecode
- s_take.banktypeid = relid
- s_take.opemp = publ_operator
- s_take.buildtype = 1
- s_take.outwareid = reissueid
- s_take.accountsid = ll_accountsid
- s_take.itemid = itemid
- s_take.moneyid = moneyid
-
- // IF uo_take.add_takerec (s_take,arg_msg,FALSE) = 0 THEN
- // rslt = 0
- // GOTO ext
- // END IF
-
- IF uo_take.add_takerec(scid,cusid,reissuedate,reissueemp,ld_msttakeamt,Round(ld_msttakeamt,sys_saleamt_round),Round(ld_takeamt,sys_saleamt_round),ls_dscrp,&
- reissuecode,relid,1,publ_operator,reissueid,0,arg_msg,FALSE,reissuedate,ll_accountsid,itemid,moneyid,relcode) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- UPDATE u_reissue
- SET relint_3 = :uo_take.ref_takeid
- WHERE u_reissue.reissueid = :reissueid
- AND scid = :scid
- AND flag = 1 USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '更新补件单相关应收帐ID失败'
- rslt = 0
- GOTO ext
- END IF
- END IF
- ELSEIF r_type = 1 THEN //费用单
-
- FOR ll_i = 1 TO it_mxbt
-
- IF reissuemx[ll_i].amt <> 0 THEN
-
- IF Trim(reissuemx[ll_i].mxdscrp) = '' THEN
- ls_about = reissuecode + ',' + reissuemx[ll_i].mtrlname
- ELSE
- ls_about = reissuecode + ',' + reissuemx[ll_i].mtrlname + ',' + reissuemx[ll_i].mxdscrp
- END IF
-
- ls_dscrp = ls_about
- ld_msttakeamt = 0 - reissuemx[ll_i].amt
- IF li_btype = 1 THEN
- ld_takeamt = ld_msttakeamt
- ELSE
- ld_takeamt = 0
- END IF
-
- s_bmsttake s_take2
-
- s_take2.scid = scid
- s_take2.cusid = cusid
- s_take2.takedate = reissuedate
- s_take2.inrep = reissueemp
- s_take2.oriamt = ld_msttakeamt
- s_take2.msttakeamt = ld_msttakeamt
- s_take2.takeamt = ld_takeamt
- s_take2.dscrp = ls_dscrp
- s_take2.billcode = reissuecode
- s_take2.banktypeid = relid
- s_take2.opemp = publ_operator
- s_take2.buildtype = 1
- s_take2.outwareid = reissueid
- s_take2.accountsid = ll_accountsid
- s_take2.itemid = itemid
- s_take2.moneyid = moneyid
-
-
- // IF uo_take.add_takerec (s_take2,arg_msg,FALSE) = 0 THEN
- // rslt = 0
- // GOTO ext
- // END IF
- IF uo_take.add_takerec(scid,cusid,reissuedate,reissueemp,ld_msttakeamt,Round(ld_msttakeamt,sys_saleamt_round),Round(ld_takeamt,sys_saleamt_round),ls_dscrp,&
- reissuecode,relid,1,publ_operator,reissueid,0,arg_msg,FALSE,reissuedate,ll_accountsid,itemid,moneyid,relcode) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
-
- UPDATE u_reissuemx
- SET relid = :uo_take.ref_takeid
- FROM u_reissuemx,u_reissue
- WHERE u_reissuemx.reissueid = :reissueid
- AND u_reissuemx.printid = :reissuemx[ll_i].printid
- AND u_reissuemx.scid = :scid
- AND u_reissuemx.scid = u_reissue.scid
- AND u_reissuemx.reissueid = u_reissue.reissueid
- AND u_reissue.flag = 1 USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '更新费用单相关应收帐ID失败'
- rslt = 0
- GOTO ext
- END IF
- END IF
- NEXT
- ELSEIF r_type = 2 THEN //?
- FOR ll_i = 1 TO it_mxbt
- IF Trim(reissuemx[ll_i].mxdscrp) = '' THEN
- ls_about = reissuecode + ',' + reissuemx[ll_i].mtrlname
- ELSE
- ls_about = reissuecode + ',' + reissuemx[ll_i].mtrlname + ',' + reissuemx[ll_i].mxdscrp
- END IF
-
- ls_dscrp = ls_about
-
- ld_mstpayamt = reissuemx[ll_i].amt
-
- IF li_btype = 1 THEN
- ld_payamt = ld_mstpayamt
- ELSE
- ld_payamt = 0
- END IF
-
- s_bmstpay s_pay
- s_pay.scid = scid
- s_pay.sptid = cusid
- s_pay.paydate = reissuedate
- s_pay.inrep = reissueemp
- s_pay.oriamt = ld_mstpayamt
- s_pay.mstpayamt = ld_mstpayamt
- s_pay.payamt = ld_payamt
- s_pay.dscrp = ls_dscrp
- s_pay.billcode = reissuecode
- s_pay.banktypeid = relid
- //s_pay.viewdate
- s_pay.opemp = publ_operator
- s_pay.buildtype = 1
- s_pay.inwareid = reissueid
- s_pay.accountsid = ll_accountsid
- s_pay.itemid = itemid
-
- // IF uo_pay.add_payrec (s_pay,arg_msg,FALSE) = 0 THEN
- // rslt = 0
- // GOTO ext
- // END IF
-
- DateTime plandate
- SetNull(plandate)
- IF uo_pay.add_payrec (scid,cusid,reissuedate,reissueemp,ld_mstpayamt,ld_mstpayamt,ld_payamt,ls_dscrp,&
- reissuecode,relid,1,publ_operator,reissueid,0,arg_msg,FALSE,plandate,ll_accountsid,itemid,moneyid ,relcode) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- UPDATE u_reissuemx
- SET relid = :uo_pay.ref_payid
- FROM u_reissuemx,u_reissue
- WHERE u_reissuemx.reissueid = :reissueid
- AND u_reissuemx.printid = :reissuemx[ll_i].printid
- AND u_reissuemx.scid = :scid
- AND u_reissuemx.scid = u_reissue.scid
- AND u_reissuemx.reissueid = u_reissue.reissueid
- AND u_reissue.flag = 1 USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '更新相关应收帐ID失败'
- rslt = 0
- GOTO ext
- END IF
- NEXT
- END IF
- flag = 1
- ext:
- DESTROY uo_take
- DESTROY uo_pay
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- reissueid = 0 //还原reissueid
- RETURN rslt
- end function
- on uo_associat_sptcust.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_associat_sptcust.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|