12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685 |
- $PBExportHeader$uo_crm.sru
- forward
- global type uo_crm from nonvisualobject
- end type
- end forward
- global type uo_crm from nonvisualobject
- end type
- global uo_crm uo_crm
- type variables
- Long uo_cusid
- end variables
- forward prototypes
- public function integer uof_add_plan (s_cust_plan arg_s_cust_plan, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_add_interview (s_cust_interview arg_s_cust_interview, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_add_cust (s_custom arg_s_cust, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_del_interview (long arg_interviewid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_del_plan (long arg_planid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_del_rep (long arg_repid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_add_rep (s_cust_rep arg_s_cust_rep, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_del_cust (long arg_cusid, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_change_state (long arg_cusid, integer arg_state, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_del_station (long arg_cusid, long arg_stationid, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_add_station (s_cust_station arg_s_cust_station, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_set_dft_station (s_cust_station arg_s_cust_station, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_add_item (s_item_cust_spt arg_s_item, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_add_sample (s_cust_sample arg_s_cust_sample, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_del_sample (long arg_sampleid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_code_find (long arg_id, string arg_code, ref string arg_msg)
- public function integer uof_audit_cust_rq (long arg_rqid, boolean arg_approval, string arg_dscrp, ref string arg_msg, boolean arg_ifcommit)
- end prototypes
- public function integer uof_add_plan (s_cust_plan arg_s_cust_plan, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Long cnt,ll_planid
- IF IsNull(arg_s_cust_plan.saler) THEN arg_s_cust_plan.saler = ''
- IF IsNull(arg_s_cust_plan.planrep) THEN arg_s_cust_plan.planrep = ''
- IF IsNull(arg_s_cust_plan.plancontent) THEN arg_s_cust_plan.plancontent = ''
- IF IsNull(arg_s_cust_plan.dscrp) THEN arg_s_cust_plan.dscrp = ''
- IF IsNull(arg_s_cust_plan.cusid) THEN arg_s_cust_plan.cusid = 0
- IF IsNull(arg_s_cust_plan.planid) THEN arg_s_cust_plan.planid = 0
- IF IsNull(arg_s_cust_plan.accomplishrslt) THEN arg_s_cust_plan.accomplishrslt = ''
- IF arg_s_cust_plan.saler = '' THEN
- arg_msg = '请输入业务员'
- rslt = 0
- GOTO ext
- END IF
- IF arg_s_cust_plan.plancontent = '' THEN
- arg_msg = '请输入计划内容'
- rslt = 0
- GOTO ext
- END IF
- SELECT count(*) INTO :cnt
- FROM u_cust
- Where cusid = :arg_s_cust_plan.cusid;
- 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 arg_s_cust_plan.planid = 0 THEN
- ll_planid = f_sys_scidentity(0,"u_cust_plan","planid",arg_msg,TRUE,sqlca)
- IF ll_planid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- INSERT INTO u_cust_plan
- (planid,
- cusid,
- saler,
- plandate,
- planrep,
- plancontent,
- dscrp,
- opdate,
- opemp,
- planaccomplishdate,
- accomplishdate,
- accomplishrslt)
- VALUES(:ll_planid,
- :arg_s_cust_plan.cusid,
- :arg_s_cust_plan.saler,
- :arg_s_cust_plan.plandate,
- :arg_s_cust_plan.planrep,
- :arg_s_cust_plan.plancontent,
- :arg_s_cust_plan.dscrp,
- getdate(),
- :arg_opemp,
- :arg_s_cust_plan.planaccomplishdate,
- :arg_s_cust_plan.accomplishdate,
- :arg_s_cust_plan.accomplishrslt);
- IF sqlca.SQLCode <> 0 THEN
- if pos(lower(sqlca.SQLErrText),'pk_u_cust_plan') > 0 then
- arg_msg = '建立客户计划失败,关键字客户计划ID重复'
- else
- arg_msg = '建立客户计划失败,'+sqlca.SQLErrText
- end if
- rslt = 0
- GOTO ext
- END IF
- ELSE
- UPDATE u_cust_plan
- SET saler = :arg_s_cust_plan.saler,
- plandate = :arg_s_cust_plan.plandate,
- planrep = :arg_s_cust_plan.planrep,
- plancontent = :arg_s_cust_plan.plancontent,
- dscrp = :arg_s_cust_plan.dscrp,
- moddate = getdate(),
- modemp = :arg_opemp,
- planaccomplishdate = :arg_s_cust_plan.planaccomplishdate,
- accomplishdate = :arg_s_cust_plan.accomplishdate,
- accomplishrslt = :arg_s_cust_plan.accomplishrslt
- Where planid = :arg_s_cust_plan.planid;
- IF sqlca.SQLCode <> 0 THEN
- if pos(lower(sqlca.SQLErrText),'pk_u_cust_plan') > 0 then
- arg_msg = '更新客户计划失败,关键字客户计划ID重复'
- else
- arg_msg = '更新客户计划失败,'+sqlca.SQLErrText
- end if
- rslt = 0
- GOTO ext
- END IF
-
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- arg_msg = '客户管理,'+ arg_msg
- RETURN rslt
- end function
- public function integer uof_add_interview (s_cust_interview arg_s_cust_interview, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Long cnt,ll_interviewid
- IF IsNull(arg_s_cust_interview.saler) THEN arg_s_cust_interview.saler = ''
- IF IsNull(arg_s_cust_interview.interviewrep) THEN arg_s_cust_interview.interviewrep = ''
- IF IsNull(arg_s_cust_interview.interviewcontent) THEN arg_s_cust_interview.interviewcontent = ''
- IF IsNull(arg_s_cust_interview.dscrp) THEN arg_s_cust_interview.dscrp = ''
- IF IsNull(arg_s_cust_interview.cusid) THEN arg_s_cust_interview.cusid = 0
- IF IsNull(arg_s_cust_interview.interviewid) THEN arg_s_cust_interview.interviewid = 0
- IF IsNull(arg_s_cust_interview.amt) THEN arg_s_cust_interview.amt = 0
- IF IsNull(arg_s_cust_interview.interviewway) THEN arg_s_cust_interview.interviewway = ''
- IF IsNull(arg_s_cust_interview.interviewrslt) THEN arg_s_cust_interview.interviewrslt = ''
- IF IsNull(arg_s_cust_interview.interviewform) THEN arg_s_cust_interview.interviewform = ''
- IF IsNull(arg_s_cust_interview.custassess) THEN arg_s_cust_interview.custassess = ''
- IF IsNull(arg_s_cust_interview.custview) THEN arg_s_cust_interview.custview = ''
- IF arg_s_cust_interview.saler = '' THEN
- arg_msg = '请输入业务员'
- rslt = 0
- GOTO ext
- END IF
- IF arg_s_cust_interview.interviewcontent = '' THEN
- arg_msg = '请输入走访内容'
- rslt = 0
- GOTO ext
- END IF
- SELECT count(*) INTO :cnt
- FROM u_cust
- Where cusid = :arg_s_cust_interview.cusid;
- 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 arg_s_cust_interview.interviewid = 0 THEN
- ll_interviewid = f_sys_scidentity(0,"u_cust_interview","interviewid",arg_msg,TRUE,sqlca)
- IF ll_interviewid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- INSERT INTO u_cust_interview
- (interviewid,
- cusid,
- saler,
- interviewdate,
- interviewrep,
- interviewtime,
- interviewcontent,
- dscrp,
- amt,
- opdate,
- opemp,
- interviewway,
- interviewrslt,
- interviewform,
- custassess,
- custview)
- VALUES(:ll_interviewid,
- :arg_s_cust_interview.cusid,
- :arg_s_cust_interview.saler,
- :arg_s_cust_interview.interviewdate,
- :arg_s_cust_interview.interviewrep,
- :arg_s_cust_interview.interviewtime,
- :arg_s_cust_interview.interviewcontent,
- :arg_s_cust_interview.dscrp,
- :arg_s_cust_interview.amt,
- getdate(),
- :arg_opemp,
- :arg_s_cust_interview.interviewway,
- :arg_s_cust_interview.interviewrslt,
- :arg_s_cust_interview.interviewform,
- :arg_s_cust_interview.custassess,
- :arg_s_cust_interview.custview);
- IF sqlca.SQLCode <> 0 THEN
- if pos(lower(sqlca.SQLErrText),'pk_u_cust_interview') > 0 then
- arg_msg = '建立客户走访失败,关键字走访记录ID重复'
- else
- arg_msg = '建立客户走访失败,'+sqlca.SQLErrText
- end if
- rslt = 0
- GOTO ext
- END IF
- ELSE
- UPDATE u_cust_interview
- SET saler = :arg_s_cust_interview.saler,
- interviewdate = :arg_s_cust_interview.interviewdate,
- interviewrep = :arg_s_cust_interview.interviewrep,
- interviewtime = :arg_s_cust_interview.interviewtime,
- interviewcontent = :arg_s_cust_interview.interviewcontent,
- dscrp = :arg_s_cust_interview.dscrp,
- amt = :arg_s_cust_interview.amt,
- moddate = getdate(),
- modemp = :arg_opemp,
- interviewway = :arg_s_cust_interview.interviewway,
- interviewrslt = :arg_s_cust_interview.interviewrslt,
- interviewform = :arg_s_cust_interview.interviewform,
- custassess = :arg_s_cust_interview.custassess,
- custview = :arg_s_cust_interview.custview
- Where interviewid = :arg_s_cust_interview.interviewid;
- IF sqlca.SQLCode <> 0 THEN
- if pos(lower(sqlca.SQLErrText),'pk_u_cust_interview') > 0 then
- arg_msg = '更新客户走访失败,关键字走访记录ID重复'
- else
- arg_msg = '更新客户走访失败,'+sqlca.SQLErrText
- end if
- rslt = 0
- GOTO ext
- END IF
-
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- arg_msg = '客户管理,'+ arg_msg
- RETURN rslt
- end function
- public function integer uof_add_cust (s_custom arg_s_cust, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Long cnt,ll_cusid,ll_i,ll_repid
- String ls_cusareaname,ls_areaname
- IF IsNull(arg_s_cust.cusid) THEN arg_s_cust.cusid = 0
- IF IsNull(arg_s_cust.cuscode) THEN arg_s_cust.cuscode = ''
- IF IsNull(arg_s_cust.Name) THEN arg_s_cust.Name = ''
- IF IsNull(arg_s_cust.bsntype) THEN arg_s_cust.bsntype = ''
- IF IsNull(arg_s_cust.rep) THEN arg_s_cust.rep = ''
- IF IsNull(arg_s_cust.tele) THEN arg_s_cust.tele = ''
- IF IsNull(arg_s_cust.tele1) THEN arg_s_cust.tele1 = ''
- IF IsNull(arg_s_cust.bank) THEN arg_s_cust.bank = ''
- IF IsNull(arg_s_cust.cunt) THEN arg_s_cust.cunt = ''
- IF IsNull(arg_s_cust.Address) THEN arg_s_cust.Address = ''
- IF IsNull(arg_s_cust.code) THEN arg_s_cust.code = ''
- IF IsNull(arg_s_cust.dscrp) THEN arg_s_cust.dscrp = ''
- IF IsNull(arg_s_cust.givebackrate) THEN arg_s_cust.givebackrate = 0
- IF IsNull(arg_s_cust.freight) THEN arg_s_cust.freight = ''
- IF IsNull(arg_s_cust.freight_tele) THEN arg_s_cust.freight_tele = ''
- IF IsNull(arg_s_cust.fax) THEN arg_s_cust.fax = ''
- IF IsNull(arg_s_cust.upname) THEN arg_s_cust.upname = ''
- IF IsNull(arg_s_cust.inuse) THEN arg_s_cust.inuse = 0
- IF IsNull(arg_s_cust.cusareaid) THEN arg_s_cust.cusareaid = 0
- IF IsNull(arg_s_cust.areaname) THEN arg_s_cust.areaname = ''
- IF IsNull(arg_s_cust.cusareaname) THEN arg_s_cust.cusareaname = ''
- IF IsNull(arg_s_cust.email) THEN arg_s_cust.email = ''
- IF IsNull(arg_s_cust.State) THEN arg_s_cust.State = 0
- IF IsNull(arg_s_cust.peoplenum) THEN arg_s_cust.peoplenum = 0
- IF IsNull(arg_s_cust.mainmarket) THEN arg_s_cust.mainmarket = ''
- IF IsNull(arg_s_cust.saleamt) THEN arg_s_cust.saleamt = 0
- IF IsNull(arg_s_cust.nethttp) THEN arg_s_cust.nethttp = ''
- IF IsNull(arg_s_cust.trade) THEN arg_s_cust.trade = ''
- IF IsNull(arg_s_cust.corporation) THEN arg_s_cust.corporation = ''
- IF IsNull(arg_s_cust.grade) THEN arg_s_cust.grade = ''
- IF IsNull(arg_s_cust.ifself) THEN arg_s_cust.ifself = 0
- IF IsNull(arg_s_cust.cuskind) THEN arg_s_cust.cuskind = ''
- IF IsNull(arg_s_cust.simplename) THEN arg_s_cust.simplename = ''
- IF IsNull(arg_s_cust.viewdaynum) THEN arg_s_cust.viewdaynum = 0
- IF arg_s_cust.cuscode = '' THEN
- arg_msg = '请输入客户编号!'
- rslt = 0
- GOTO ext
- END IF
- IF arg_s_cust.Name = '' THEN
- arg_msg = '请输入客户名称!'
- rslt = 0
- GOTO ext
- END IF
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_cust
- WHERE name = :arg_s_cust.Name
- AND cusid <> :arg_s_cust.cusid;
- 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
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_Cusarea
- Where cusareaid = :arg_s_cust.cusareaid;
- 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 arg_s_cust.bsntype = '' THEN
- arg_msg = '请选择业务员'
- rslt = 0
- GOTO ext
- END IF
- IF arg_s_cust.viewdaynum < 0 THEN
- arg_msg = '不合理的预收款天数'
- rslt = 0
- GOTO ext
- END IF
- SELECT cusareaname,areaname
- INTO :ls_cusareaname,:ls_areaname
- FROM u_cusarea
- Where cusareaid = :arg_s_cust.cusareaid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询客户区域资料是否重复失败'
- rslt = 0
- GOTO ext
- END IF
- IF arg_s_cust.inuse = 0 AND arg_s_cust.cusid > 0 THEN
- IF f_check_cust_balcamt(arg_s_cust.cusid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- IF arg_s_cust.cusid = 0 THEN
- ll_cusid = f_sys_scidentity(0,"u_cust","cusid",arg_msg,FALSE,sqlca)
- IF ll_cusid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- INSERT INTO u_cust
- (cusid,
- cuscode,
- name,
- custype,
- rep,
- tele,
- tele1,
- bank,
- cunt,
- address,
- code,
- dscrp,
- faxno,
- inuse,
- cusareaid,
- cusareaname,
- areaname,
- email,
- givebackrate,
- freight,
- freight_tele,
- upname,
- state,
- peoplenum,
- mainmarket,
- saleamt,
- nethttp,
- trade,
- corporation,
- grade,
- ifself,
- opdate,
- opemp,
- cuskind,
- simplename,
- viewdaynum)
- VALUES(:ll_cusid,
- :arg_s_cust.cuscode,
- :arg_s_cust.name,
- :arg_s_cust.bsntype,
- :arg_s_cust.rep,
- :arg_s_cust.tele,
- :arg_s_cust.tele1,
- :arg_s_cust.bank,
- :arg_s_cust.cunt,
- :arg_s_cust.address,
- :arg_s_cust.code,
- :arg_s_cust.dscrp,
- :arg_s_cust.fax,
- :arg_s_cust.inuse,
- :arg_s_cust.cusareaid,
- :ls_cusareaname,
- :ls_areaname,
- :arg_s_cust.email,
- :arg_s_cust.givebackrate,
- :arg_s_cust.freight,
- :arg_s_cust.freight_tele,
- :arg_s_cust.upname,
- :arg_s_cust.state,
- :arg_s_cust.peoplenum,
- :arg_s_cust.mainmarket,
- :arg_s_cust.saleamt,
- :arg_s_cust.nethttp,
- :arg_s_cust.trade,
- :arg_s_cust.corporation,
- :arg_s_cust.grade,
- :arg_s_cust.ifself,
- getdate(),
- :arg_opemp,
- :arg_s_cust.cuskind,
- :arg_s_cust.simplename,
- :arg_s_cust.viewdaynum);
- IF sqlca.SQLCode <> 0 THEN
- IF Pos(Lower(sqlca.SQLErrText),'i_cus_code') > 0 THEN
- arg_msg = '建立客户资料失败,客户编号重复'
- ELSEIF Pos(Lower(sqlca.SQLErrText),'ix_u_cust') > 0 THEN
- arg_msg = '建立客户资料失败,客户名称重复'
- ELSEIF Pos(Lower(sqlca.SQLErrText),'pk_u_cust') > 0 THEN
- arg_msg = '建立客户资料失败,关键字客户ID重复'
- ELSE
- arg_msg = '建立客户资料失败,'+sqlca.SQLErrText
- END IF
-
- rslt = 0
- GOTO ext
- END IF
-
- uo_cusid = ll_cusid
- ELSE
-
- UPDATE u_cust
- SET cuscode = :arg_s_cust.cuscode,
- name = :arg_s_cust.name,
- custype = :arg_s_cust.bsntype,
- rep = :arg_s_cust.rep,
- tele = :arg_s_cust.tele,
- tele1 = :arg_s_cust.tele1,
- bank = :arg_s_cust.bank,
- cunt = :arg_s_cust.cunt,
- address = :arg_s_cust.address,
- code = :arg_s_cust.code,
- dscrp = :arg_s_cust.dscrp,
- faxno = :arg_s_cust.fax,
- inuse = :arg_s_cust.inuse,
- cusareaid = :arg_s_cust.cusareaid,
- cusareaname = :ls_cusareaname,
- areaname = :ls_areaname,
- email = :arg_s_cust.email,
- givebackrate = :arg_s_cust.givebackrate,
- freight = :arg_s_cust.freight,
- freight_tele = :arg_s_cust.freight_tele,
- upname = :arg_s_cust.upname,
- state = :arg_s_cust.state,
- peoplenum = :arg_s_cust.peoplenum,
- mainmarket = :arg_s_cust.mainmarket,
- saleamt = :arg_s_cust.saleamt,
- nethttp = :arg_s_cust.nethttp,
- trade = :arg_s_cust.trade,
- corporation = :arg_s_cust.corporation,
- grade = :arg_s_cust.grade,
- ifself = :arg_s_cust.ifself,
- moddate = getdate(),
- modemp = :arg_opemp,
- cuskind = :arg_s_cust.cuskind,
- simplename = :arg_s_cust.simplename,
- viewdaynum = :arg_s_cust.viewdaynum
- Where cusid = :arg_s_cust.cusid;
- IF sqlca.SQLCode <> 0 THEN
- /////zww 090916
- IF Pos(Lower(sqlca.SQLErrText),'i_cus_code') > 0 THEN
- arg_msg = '更新客户资料失败,客户编号重复'
- ELSEIF Pos(Lower(sqlca.SQLErrText),'ix_u_cust') > 0 THEN
- arg_msg = '更新客户资料失败,客户名称重复'
- ELSEIF Pos(Lower(sqlca.SQLErrText),'pk_u_cust') > 0 THEN
- arg_msg = '更新客户资料失败,关键字客户ID重复'
- ELSE
- arg_msg = '更新客户资料失败,'+sqlca.SQLErrText
- END IF
-
- // arg_msg = '更新客户资料失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- uo_cusid = arg_s_cust.cusid
-
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- /////////zww 090916
- arg_msg = '客户管理,'+ arg_msg
- RETURN rslt
- end function
- public function integer uof_del_interview (long arg_interviewid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- String ls_opemp
- SELECT opemp INTO :ls_opemp
- FROM u_cust_interview
- Where interviewid = :arg_interviewid;
- IF sqlca.SQLCode <> 0 THEN
- if pos(lower(sqlca.SQLErrText),'more than') > 0 then
- arg_msg = '查询客户走访资料失败,查询数据返回值多于一个'
- else
- arg_msg = '查询客户走访资料失败'
- end if
- rslt = 0
- GOTO ext
- END IF
- IF NOT sys_power_issuper AND arg_opemp <> ls_opemp THEN
- arg_msg = '不是资料建立人或系统管理员,不能删除'
- rslt = 0
- GOTO ext
- END IF
- DELETE FROM u_cust_interview Where interviewid = :arg_interviewid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '删除客户走访资料失败 '
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- arg_msg = '客户管理,'+ arg_msg
- RETURN rslt
- end function
- public function integer uof_del_plan (long arg_planid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- String ls_opemp
- SELECT opemp INTO :ls_opemp
- FROM u_cust_plan
- Where planid = :arg_planid;
- IF sqlca.SQLCode <> 0 THEN
- if pos(lower(sqlca.SQLErrText),'more than') > 0 then
- arg_msg = '查询客户工作计划失败,查询数据返回值多于一个'
- else
- arg_msg = '查询客户工作计划失败'
- end if
- rslt = 0
- GOTO ext
- END IF
- IF NOT sys_power_issuper AND arg_opemp <> ls_opemp THEN
- arg_msg = '不是资料建立人或系统管理员,不能删除'
- rslt = 0
- GOTO ext
- END IF
- DELETE FROM u_cust_plan Where planid = :arg_planid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '删除客户工作计划失败 '
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- arg_msg = '客户管理,'+ arg_msg
- RETURN rslt
- end function
- public function integer uof_del_rep (long arg_repid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- String ls_opemp
- SELECT opemp INTO :ls_opemp
- FROM u_cust_rep
- Where repid = :arg_repid;
- IF sqlca.SQLCode <> 0 THEN
- if pos(lower(sqlca.SQLErrText),'more than') > 0 then
- arg_msg = '查询客户联系人资料失败,查询数据返回值多于一个'
- else
- arg_msg = '查询客户联系人资料失败'
- end if
- rslt = 0
- GOTO ext
- END IF
- IF NOT sys_power_issuper AND arg_opemp <> ls_opemp THEN
- arg_msg = '不是资料建立人或系统管理员,不能删除'
- rslt = 0
- GOTO ext
- END IF
- DELETE FROM u_cust_rep Where repid = :arg_repid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '删除客户联系人失败'
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- arg_msg = '客户管理,'+ arg_msg
- RETURN rslt
- end function
- public function integer uof_add_rep (s_cust_rep arg_s_cust_rep, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Long cnt,ll_repid
- IF IsNull(arg_s_cust_rep.repname) THEN arg_s_cust_rep.repname = ''
- IF IsNull(arg_s_cust_rep.duty) THEN arg_s_cust_rep.duty = ''
- IF IsNull(arg_s_cust_rep.sex) THEN arg_s_cust_rep.sex = ''
- IF IsNull(arg_s_cust_rep.officetel) THEN arg_s_cust_rep.officetel = ''
- IF IsNull(arg_s_cust_rep.handtel) THEN arg_s_cust_rep.handtel = ''
- IF IsNull(arg_s_cust_rep.faxno) THEN arg_s_cust_rep.faxno = ''
- IF IsNull(arg_s_cust_rep.email) THEN arg_s_cust_rep.email = ''
- IF IsNull(arg_s_cust_rep.dscrp) THEN arg_s_cust_rep.dscrp = ''
- IF IsNull(arg_s_cust_rep.deptname) THEN arg_s_cust_rep.deptname = ''
- IF IsNull(arg_s_cust_rep.interest) THEN arg_s_cust_rep.interest = ''
- IF IsNull(arg_s_cust_rep.mainproduct) THEN arg_s_cust_rep.mainproduct = ''
- IF arg_s_cust_rep.repname = '' THEN
- arg_msg = '请输入联系人名称'
- rslt = 0
- GOTO ext
- END IF
- SELECT count(*) INTO :cnt
- FROM u_cust
- Where cusid = :arg_s_cust_rep.cusid;
- 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 arg_s_cust_rep.repid = 0 THEN
- ll_repid = f_sys_scidentity(0,"u_cust_rep","repid",arg_msg,TRUE,sqlca)
- IF ll_repid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- INSERT INTO u_cust_rep
- (repid,
- cusid,
- repname,
- duty,
- sex,
- officetel,
- handtel,
- faxno,
- email,
- dscrp,
- deptname,
- interest,
- mainproduct,
- opdate,
- opemp)
- VALUES(:ll_repid,
- :arg_s_cust_rep.cusid,
- :arg_s_cust_rep.repname,
- :arg_s_cust_rep.duty,
- :arg_s_cust_rep.sex,
- :arg_s_cust_rep.officetel,
- :arg_s_cust_rep.handtel,
- :arg_s_cust_rep.faxno,
- :arg_s_cust_rep.email,
- :arg_s_cust_rep.dscrp,
- :arg_s_cust_rep.deptname,
- :arg_s_cust_rep.interest,
- :arg_s_cust_rep.mainproduct,
- getdate(),
- :arg_opemp);
- IF sqlca.SQLCode <> 0 THEN
- if pos(lower(sqlca.SQLErrText),'ix_u_cust_rep') > 0 then
- arg_msg = '建立客户联系人失败,联系人名称重复'
- elseif pos(lower(sqlca.SQLErrText),'pk_u_cust_rep') > 0 then
- arg_msg = '建立客户联系人失败,违反关键字约束:客户ID、联系人ID重复'
- else
- arg_msg = '建立客户联系人失败,'+sqlca.SQLErrText
- end if
- rslt = 0
- GOTO ext
- END IF
- ELSE
- UPDATE u_cust_rep
- SET repname = :arg_s_cust_rep.repname,
- duty = :arg_s_cust_rep.duty,
- sex = :arg_s_cust_rep.sex,
- officetel = :arg_s_cust_rep.officetel,
- handtel = :arg_s_cust_rep.handtel,
- faxno = :arg_s_cust_rep.faxno,
- email = :arg_s_cust_rep.email,
- dscrp = :arg_s_cust_rep.dscrp,
- deptname = :arg_s_cust_rep.deptname,
- interest = :arg_s_cust_rep.interest,
- mainproduct = :arg_s_cust_rep.mainproduct,
- moddate = getdate(),
- modemp = :arg_opemp
- Where repid = :arg_s_cust_rep.repid;
- IF sqlca.SQLCode <> 0 THEN
- if pos(lower(sqlca.SQLErrText),'ix_u_cust_rep') > 0 then
- arg_msg = '更新客户联系人失败,联系人名称重复'
- elseif pos(lower(sqlca.SQLErrText),'pk_u_cust_rep') > 0 then
- arg_msg = '更新客户联系人失败,违反关键字约束:客户ID、联系人ID重复'
- else
- arg_msg = '更新客户联系人失败,'+sqlca.SQLErrText
- end if
- rslt = 0
- GOTO ext
- END IF
-
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- arg_msg = '客户管理,'+ arg_msg
- RETURN rslt
- end function
- public function integer uof_del_cust (long arg_cusid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Long cnt
- SELECT count(*) INTO :cnt
- FROM u_cust
- Where cusid = :arg_cusid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询客户资料失败 '
- rslt = 0
- GOTO ext
- END IF
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_cust_interview Where cusid = :arg_cusid ;
- 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
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_cust_plan Where cusid = :arg_cusid ;
- 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
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_saletask Where cusid = :arg_cusid ;
- 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
- cnt = 0
- SELECT COUNT(*) INTO :cnt
- FROM u_outware WHERE u_outware.cusid = :arg_cusid
- AND billtype = 1;
- 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
- cnt = 0
- SELECT COUNT(*) INTO :cnt
- FROM u_bmsttake Where cusid = :arg_cusid ;
- 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 f_check_cust_balcamt(arg_cusid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- DELETE FROM u_cust_rep Where cusid = :arg_cusid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '删除客户联系人失败 '
- rslt = 0
- GOTO ext
- END IF
- DELETE FROM u_cust_station Where cusid = :arg_cusid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '删除客户货运部失败 '
- rslt = 0
- GOTO ext
- END IF
- DELETE FROM u_item_cust_spt
- WHERE relid = :arg_cusid
- AND reltype = 0;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '删除客户辅助项目失败 '
- rslt = 0
- GOTO ext
- END IF
- DELETE FROM u_cust Where cusid = :arg_cusid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '删除客户资料失败 '
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- arg_msg = '客户管理,'+ arg_msg
- RETURN rslt
- end function
- public function integer uof_change_state (long arg_cusid, integer arg_state, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1,li_state
- SELECT state INTO :li_state
- FROM u_cust
- Where cusid = :arg_cusid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询客户资料失败 '
- rslt = 0
- GOTO ext
- END IF
- IF arg_state = 1 THEN
- IF li_state = 1 THEN
- arg_msg = '客户资料已成为正式客户资料,不能再操作'
- rslt = 0
- GOTO ext
- END IF
-
- UPDATE u_cust SET state = 1
- WHERE cusid = :arg_cusid
- AND State <> 1;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '更新客户资料类型失败 '
- rslt = 0
- GOTO ext
- END IF
- ELSEif arg_state = 0 THEN
- IF li_state = 0 THEN
- arg_msg = '客户资料已成为公共客户资料,不能再操作'
- rslt = 0
- GOTO ext
- END IF
-
- UPDATE u_cust SET state = 0
- WHERE cusid = :arg_cusid
- AND State <> 0;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '更新客户资料类型失败 '
- rslt = 0
- GOTO ext
- END IF
- ELSEif arg_state = 2 THEN
- IF li_state = 2 THEN
- arg_msg = '客户资料成为黑名单客户资料,不能再操作'
- rslt = 0
- GOTO ext
- END IF
-
- UPDATE u_cust SET state = 2
- WHERE cusid = :arg_cusid
- AND State <> 2;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '更新客户资料类型失败 '
- rslt = 0
- GOTO ext
- END IF
- ELSEif arg_state = 3 THEN
- IF li_state = 3 THEN
- arg_msg = '客户资料成为准客户资料,不能再操作'
- rslt = 0
- GOTO ext
- END IF
-
- UPDATE u_cust SET state = 3
- WHERE cusid = :arg_cusid
- AND State <> 3;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '更新客户资料类型失败 '
- rslt = 0
- GOTO ext
- END IF
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- arg_msg = '客户管理,'+ arg_msg
- RETURN rslt
- end function
- public function integer uof_del_station (long arg_cusid, long arg_stationid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- long cnt
- SELECT count(*) INTO :cnt
- FROM u_station
- Where stationid = :arg_stationid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询货运部资料失败 '
- rslt = 0
- GOTO ext
- END IF
- DELETE FROM u_cust_station
- Where cusid = :arg_cusid
- and stationid = :arg_stationid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '删除客户货运部资料失败'
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- arg_msg = '客户管理,'+ arg_msg
- RETURN rslt
- end function
- public function integer uof_add_station (s_cust_station arg_s_cust_station, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Long cnt
- IF IsNull(arg_s_cust_station.cusid) THEN arg_s_cust_station.cusid = 0
- IF IsNull(arg_s_cust_station.stationid) THEN arg_s_cust_station.stationid = 0
- IF IsNull(arg_s_cust_station.dftflag) THEN arg_s_cust_station.dftflag = 0
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_cust
- Where cusid = :arg_s_cust_station.cusid;
- 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
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_station
- Where stationid = :arg_s_cust_station.stationid;
- 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
- SELECT count(*)
- INTO :cnt
- FROM u_cust_station
- WHERE stationid = :arg_s_cust_station.stationid AND
- cusid = :arg_s_cust_station.cusid ;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询货运部资料失败 '
- rslt = 0
- GOTO ext
- END IF
- IF cnt = 0 THEN
- INSERT INTO u_cust_station
- (stationid,
- cusid,
- dftflag)
- VALUES(:arg_s_cust_station.stationid,
- :arg_s_cust_station.cusid,
- :arg_s_cust_station.dftflag);
- IF sqlca.SQLCode <> 0 THEN
- IF Pos(Lower(sqlca.SQLErrText),'pk_u_cust_station') > 0 THEN
- arg_msg = '建立客户货运部失败,违反关键字约束:客户ID、货运部ID重复'
- ELSE
- arg_msg = '建立客户货运部失败,'+sqlca.SQLErrText
- END IF
- rslt = 0
- GOTO ext
- END IF
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- arg_msg = '客户管理,'+ arg_msg
- RETURN rslt
-
- end function
- public function integer uof_set_dft_station (s_cust_station arg_s_cust_station, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Long cnt
- String ls_dft_name,ls_dft_tel
- IF IsNull(arg_s_cust_station.cusid) THEN arg_s_cust_station.cusid = 0
- IF IsNull(arg_s_cust_station.stationid) THEN arg_s_cust_station.stationid = 0
- IF IsNull(arg_s_cust_station.dftflag) THEN arg_s_cust_station.dftflag = 0
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_cust
- Where cusid = :arg_s_cust_station.cusid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询客户资料失败 '
- rslt = 0
- GOTO ext
- END IF
- SELECT stationname,tele
- INTO :ls_dft_name,:ls_dft_tel
- FROM u_station
- Where stationid = :arg_s_cust_station.stationid;
- IF sqlca.SQLCode <> 0 THEN
- if pos(lower(sqlca.SQLErrText),'more than') > 0 then
- arg_msg = '查询货运部资料失败,查询数据返回值多于一个'
- else
- arg_msg = '查询货运部资料失败'
- end if
- rslt = 0
- GOTO ext
- END IF
- UPDATE u_cust_station
- SET dftflag = 1
- WHERE stationid = :arg_s_cust_station.stationid
- AND cusid = :arg_s_cust_station.cusid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '设置客户默认货运部失败 '
- rslt = 0
- GOTO ext
- END IF
- UPDATE u_cust_station
- SET dftflag = 0
- WHERE stationid <> :arg_s_cust_station.stationid
- AND cusid = :arg_s_cust_station.cusid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '取消设置客户其它默认货运部失败 '
- rslt = 0
- GOTO ext
- END IF
- UPDATE u_cust
- SET freight = :ls_dft_name,
- freight_tele = :ls_dft_tel
- Where cusid = :arg_s_cust_station.cusid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '更新客户默认货运部失败 '
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- arg_msg = '客户管理,'+ arg_msg
- RETURN rslt
- end function
- public function integer uof_add_item (s_item_cust_spt arg_s_item, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Long cnt,ll_repid
- IF IsNull(arg_s_item.itemid) THEN arg_s_item.itemid = 0
- IF IsNull(arg_s_item.relid) THEN arg_s_item.relid = 0
- IF IsNull(arg_s_item.reltype) THEN arg_s_item.reltype = 0
- IF IsNull(arg_s_item.dscrp) THEN arg_s_item.dscrp = ''
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_item_cust_spt_def
- Where itemid = :arg_s_item.itemid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询辅助项目资料失败'
- rslt = 0
- GOTO ext
- END IF
- cnt = 0
- IF arg_s_item.reltype = 0 THEN
- SELECT count(*) INTO :cnt
- FROM u_cust
- Where cusid = :arg_s_item.relid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询客户资料失败'
- rslt = 0
- GOTO ext
- END IF
- ELSE
- arg_msg = '错误的项目类型'
- rslt = 0
- GOTO ext
- END IF
- UPDATE u_item_cust_spt
- SET dscrp = :arg_s_item.dscrp
- WHERE itemid = :arg_s_item.itemid
- AND relid = :arg_s_item.relid
- AND reltype = :arg_s_item.reltype;
- IF sqlca.SQLCode = 0 THEN
- IF sqlca.SQLNRows = 0 THEN
- INSERT INTO u_item_cust_spt
- (itemid,
- relid,
- reltype,
- dscrp)
- VALUES(:arg_s_item.itemid,
- :arg_s_item.relid,
- :arg_s_item.reltype,
- :arg_s_item.dscrp);
- IF sqlca.SQLCode <> 0 THEN
- IF Pos(Lower(sqlca.SQLErrText),'pk_u_item_cust_spt') > 0 THEN
- arg_msg = '建立辅助项目资料失败,违反关键字约束:客户、辅助项目重复'
- ELSE
- arg_msg = '建立辅助项目资料失败,'+sqlca.SQLErrText
- END IF
-
- rslt = 0
- GOTO ext
- END IF
- END IF
- ELSE
- IF Pos(Lower(sqlca.SQLErrText),'pk_u_item_cust_spt') > 0 THEN
- arg_msg = '更新辅助项目资料失败,违反关键字约束:客户、辅助项目重复'
- ELSE
- arg_msg = '更新辅助项目资料失败,'+sqlca.SQLErrText
- END IF
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- arg_msg = '客户管理,'+ arg_msg
- RETURN rslt
- end function
- public function integer uof_add_sample (s_cust_sample arg_s_cust_sample, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Long cnt,ll_sampleid
- IF IsNull(arg_s_cust_sample.saler) THEN arg_s_cust_sample.saler = ''
- IF IsNull(arg_s_cust_sample.mtrlid) THEN arg_s_cust_sample.mtrlid = 0
- IF IsNull(arg_s_cust_sample.samplecontent) THEN arg_s_cust_sample.samplecontent = ''
- IF IsNull(arg_s_cust_sample.cusid) THEN arg_s_cust_sample.cusid = 0
- IF IsNull(arg_s_cust_sample.sampleid) THEN arg_s_cust_sample.sampleid = 0
- IF IsNull(arg_s_cust_sample.qty) THEN arg_s_cust_sample.qty = 0
- IF arg_s_cust_sample.saler = '' THEN
- arg_msg = '请输入业务员'
- rslt = 0
- GOTO ext
- END IF
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_cust
- Where cusid = :arg_s_cust_sample.cusid;
- 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
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_mtrldef
- Where mtrlid = :arg_s_cust_sample.mtrlid;
- 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 arg_s_cust_sample.sampleid = 0 THEN
- ll_sampleid = f_sys_scidentity(0,"u_cust_sample","sampleid",arg_msg,TRUE,sqlca)
- IF ll_sampleid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- INSERT INTO u_cust_sample
- (sampleid,
- cusid,
- saler,
- sampledate,
- mtrlid,
- samplecontent,
- qty,
- opdate,
- opemp)
- VALUES(:ll_sampleid,
- :arg_s_cust_sample.cusid,
- :arg_s_cust_sample.saler,
- :arg_s_cust_sample.sampledate,
- :arg_s_cust_sample.mtrlid,
- :arg_s_cust_sample.samplecontent,
- :arg_s_cust_sample.qty,
- getdate(),
- :arg_opemp);
- IF sqlca.SQLCode <> 0 THEN
- if pos(lower(sqlca.SQLErrText),'pk_u_cust_sample') > 0 then
- arg_msg = '建立客户样版失败,关键字客户样版ID重复'
- else
- arg_msg = '建立客户样版失败,'+sqlca.SQLErrText
- end if
- rslt = 0
- GOTO ext
- END IF
- ELSE
- UPDATE u_cust_sample
- SET saler = :arg_s_cust_sample.saler,
- sampledate = :arg_s_cust_sample.sampledate,
- mtrlid = :arg_s_cust_sample.mtrlid,
- samplecontent = :arg_s_cust_sample.samplecontent,
- qty = :arg_s_cust_sample.qty,
- moddate = getdate(),
- modemp = :arg_opemp
- Where sampleid = :arg_s_cust_sample.sampleid;
- IF sqlca.SQLCode <> 0 THEN
- if pos(lower(sqlca.SQLErrText),'pk_u_cust_sample') > 0 then
- arg_msg = '更新客户样版失败,关键字客户样版ID重复'
- else
- arg_msg = '更新客户样版失败,'+sqlca.SQLErrText
- end if
- rslt = 0
- GOTO ext
- END IF
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- arg_msg = '客户管理,'+ arg_msg
- RETURN rslt
- end function
- public function integer uof_del_sample (long arg_sampleid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- String ls_opemp
- SELECT opemp INTO :ls_opemp
- FROM u_cust_sample
- Where sampleid = :arg_sampleid;
- IF sqlca.SQLCode <> 0 THEN
- if pos(lower(sqlca.SQLErrText),'more than') > 0 then
- arg_msg = '查询客户样版失败,查询数据返回值多于一个'
- else
- arg_msg = '查询客户样版失败'
- end if
- rslt = 0
- GOTO ext
- END IF
- IF NOT sys_power_issuper AND arg_opemp <> ls_opemp THEN
- arg_msg = '不是资料建立人或系统管理员,不能删除'
- rslt = 0
- GOTO ext
- END IF
- DELETE FROM u_cust_sample Where sampleid = :arg_sampleid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '删除客户样版失败'
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- arg_msg = '客户管理,'+ arg_msg
- RETURN rslt
- end function
- public function integer uof_code_find (long arg_id, string arg_code, ref string arg_msg);Int rslt = 1
- long cnt
- SELECT count(*) INTO :cnt
- FROM u_cust
- WHERE cusid <> :arg_id
- AND cuscode = :arg_code;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询客户编号:'+arg_code+',是否已用失败 '
- rslt = 0
- GOTO ext
- END IF
- IF cnt > 0 THEN
- arg_msg = '查询客户编号:'+arg_code+',已用,请重新输入'
- rslt = 0
- GOTO ext
- END IF
- ext:
- arg_msg = '客户管理,'+ arg_msg
- RETURN rslt
- end function
- public function integer uof_audit_cust_rq (long arg_rqid, boolean arg_approval, string arg_dscrp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Long cnt
- Long ll_cusid
- String ls_custype, ls_dscrp
- Int li_flag
- SELECT cusid, custype, flag
- INTO :ll_cusid, :ls_custype, :li_flag
- FROM u_cust_rq
- Where rqid = :arg_rqid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询客户申请状况操作失败"
- GOTO ext
- END IF
- IF li_flag = 1 THEN
- rslt = 0
- arg_msg = "客户申请已审核"
- GOTO ext
- END IF
- IF arg_approval THEN
- ls_dscrp = "批准"
- ELSE
- ls_dscrp = "驳回"
- END IF
- IF arg_dscrp <> "" THEN
- ls_dscrp += ",原因:"+arg_dscrp
- END IF
- UPDATE u_cust_rq
- SET flag = 1,
- auditdate = getdate(),
- auditemp = :publ_operator,
- dscrp = :ls_dscrp
- WHERE rqid = :arg_rqid
- And flag = 0;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "审核客户申请状况操作失败"
- GOTO ext
- ELSEIF sqlca.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "审核客户申请状况操作失败,正在审核中......"
- GOTO ext
- END IF
- IF arg_approval THEN //更新客户状态
- UPDATE u_cust
- SET state = 1
- Where cusid = :ll_cusid;
- ELSE
- UPDATE u_cust
- SET state = 0
- Where cusid = :ll_cusid;
- END IF
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "更新客户类型操作失败"
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT;
- END IF
- arg_msg = '客户资料,'+ arg_msg
- RETURN rslt
- end function
- on uo_crm.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_crm.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|