$PBExportHeader$uo_custdef.sru forward global type uo_custdef from nonvisualobject end type type s_cust_rep from structure within uo_custdef end type end forward type s_cust_rep from structure long repid long cusid string repname string duty string sex string officetel string handtel string faxno string email string dscrp end type global type uo_custdef from nonvisualobject end type global uo_custdef uo_custdef type variables public protectedwrite long cusid //进仓单表自动增量id public protectedwrite datetime opdate //建立时间,自动 public protectedwrite string opemp //建立操作员 s_custom s_cust boolean if_getid_ture=false transaction commit_transaction //数据commit事务 PRIVATE: s_cust_rep custmx[] //明细结构数组 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_cusid, ref string arg_msg) public function integer save (boolean arg_ifcommit, ref string arg_msg) public function integer newbegin (long arg_cusid) public function integer updatebegin (long arg_cusid, ref string arg_msg) public function integer del (long arg_cusid, string arg_cuscode, ref string arg_msg, boolean arg_ifcommit) public function integer p_clearmx () public function integer getinfo (long arg_cusid, ref string arg_msg) public function integer uof_cust_score (long arg_cusid, decimal arg_score, ref string arg_msg, boolean arg_ifcommit) public function integer uof_update_member (long arg_cusid, ref string arg_msg, boolean arg_ifcommit) public function integer uof_update_state (long arg_cusid, integer arg_state, ref string arg_msg, boolean arg_ifcommit) public function integer uof_audit_cust_rq (long arg_rqid, ref string arg_msg, boolean arg_ifcommit) public function integer uof_c_audit_cust_rq (long arg_rqid, ref string arg_msg, boolean arg_ifcommit) public function integer uof_add_cust_rq (long arg_cusid, string arg_custype, datetime arg_rqdate, string arg_dscrp, ref string arg_msg, boolean arg_ifcommit) public function integer acceptmx (long arg_repid, long arg_cusid, 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) end prototypes public function integer p_reset ();//int p_reset() s_cust.cuscode = '' s_cust.name = '' s_cust.custype = '' s_cust.rep = '' s_cust.tele = '' s_cust.tele1 = '' s_cust.bank = '' s_cust.cunt = '' s_cust.address = '' s_cust.code = '' s_cust.dscrp = '' s_cust.faxno = '' s_cust.maxmtnum = 0 s_cust.pricelistid =0 s_cust.inuse =1 s_cust.cusareaid = 0 s_cust.cusareaname = '' s_cust.areaname = '' s_cust.email = '' s_cust.givebackrate = 0 s_cust.freight = '' s_cust.freight_tele = '' it_newbegin=false it_updatebegin=false //清除明细 p_clearmx() return 1 end function public function integer p_getinfo (long arg_cusid, ref string arg_msg);//p_getinfo(arg_scid,arg_inwareid,arg_msg) //0 失败 1成功 Int rslt = 1 IF arg_cusid <= 0 THEN rslt = 0 arG_MSG = "非法客户唯一码" GOTO ext END IF SELECT cuscode, name, custype, rep, tele, tele1, bank, cunt, address, code, dscrp, faxno, maxmtnum, pricelistid, inuse, cusareaid, cusareaname, areaname, email, givebackrate, freight, freight_tele, lsflag, bhflag INTO :s_cust.cuscode, :s_cust.name, :s_cust.custype, :s_cust.rep, :s_cust.tele, :s_cust.tele1, :s_cust.bank, :s_cust.cunt, :s_cust.address, :s_cust.code, :s_cust.dscrp, :s_cust.faxno, :s_cust.maxmtnum, :s_cust.pricelistid, :s_cust.inuse, :s_cust.cusareaid, :s_cust.cusareaname, :s_cust.areaname, :s_cust.email, :s_cust.givebackrate, :s_cust.freight, :s_cust.freight_tele, :s_cust.lsflag, :s_cust.bhflag FROM u_cust Where cusid = :arg_cusid 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 cusid = arg_cusid 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_cusid IF IsNull(s_cust.cuscode) THEN s_cust.cuscode = '' IF IsNull(s_cust.Name) THEN s_cust.Name = '' IF IsNull(s_cust.custype) THEN s_cust.custype = '' IF IsNull(s_cust.rep) THEN s_cust.rep = '' IF IsNull(s_cust.tele) THEN s_cust.tele = '' IF IsNull(s_cust.bank) THEN s_cust.bank = '' IF IsNull(s_cust.tele1) THEN s_cust.tele1 = '' IF IsNull(s_cust.cunt) THEN s_cust.cunt = '' IF IsNull(s_cust.Address) THEN s_cust.Address = '' IF IsNull(s_cust.code) THEN s_cust.code = '' IF IsNull(s_cust.dscrp) THEN s_cust.dscrp = '' IF IsNull(s_cust.faxno) THEN s_cust.faxno = '' IF IsNull(s_cust.maxmtnum) THEN s_cust.maxmtnum = 0 IF IsNull(s_cust.pricelistid) THEN s_cust.pricelistid = 0 IF IsNull(s_cust.inuse) THEN s_cust.inuse = 1 IF IsNull(s_cust.cusareaid) THEN s_cust.cusareaid = 0 IF IsNull(s_cust.cusareaname) THEN s_cust.cusareaname = '' IF IsNull(s_cust.areaname) THEN s_cust.areaname = '' IF IsNull(s_cust.email) THEN s_cust.email = '' IF IsNull(s_cust.givebackrate) THEN s_cust.givebackrate = 0 IF IsNull(s_cust.freight) THEN s_cust.freight = '' IF IsNull(s_cust.freight_tele) THEN s_cust.freight_tele = '' IF IsNull(s_cust.freight_address) THEN s_cust.freight_address = '' IF IsNull(s_cust.lsflag) THEN s_cust.lsflag = 0 IF IsNull(s_cust.grade) THEN s_cust.grade = '' IF IsNull(s_cust.memberid) THEN s_cust.memberid = 0 IF IsNull(s_cust.score) THEN s_cust.score = 0 IF IsNull(s_cust.pricelistid) THEN s_cust.pricelistid = 0 IF IsNull(s_cust.upname) THEN s_cust.upname = '' IF IsNull(s_cust.industry) THEN s_cust.industry = '' IF IsNull(s_cust.bhflag) THEN s_cust.bhflag = 0 IF IsNull(s_cust.tele_sms) THEN s_cust.tele_sms = '' IF IsNull(s_cust.banktypeid) THEN s_cust.banktypeid = 0 IF IsNull(s_cust.tax) THEN s_cust.tax = 0 IF IsNull(s_cust.bmstday) THEN s_cust.bmstday = 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 cusid = 0 THEN //新建 ls_newid = f_sys_scidentity(0,"u_Cust","cusid",arg_msg,if_getid_ture,commit_transaction) IF ls_newid <= 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, maxmtnum, inuse, opdate, opemp, cusareaid, cusareaname, areaname, email, givebackrate, freight, freight_tele, freight_address, lsflag, memberid, score, pricelistid, banktypeid, tele_sms , upname, industry, grade, bhflag, tax, bmstday) VALUES (:ls_newid, :s_cust.cuscode, :s_cust.name, :s_cust.custype, :s_cust.rep, :s_cust.tele, :s_cust.tele1, :s_cust.bank, :s_cust.cunt, :s_cust.address, :s_cust.code, :s_cust.dscrp, :s_cust.faxno, :s_cust.maxmtnum, :s_cust.inuse, :server_dt, :publ_operator, :s_cust.cusareaid, :s_cust.cusareaname, :s_cust.areaname, :s_cust.email, :s_cust.givebackrate, :s_cust.freight, :s_cust.freight_tele, :s_cust.freight_address, :s_cust.lsflag, :s_cust.memberid, :s_cust.score, :s_cust.pricelistid, :s_cust.banktypeid, :s_cust.tele_sms , :s_cust.upname, :s_cust.industry, :s_cust.grade, :s_cust.bhflag, :s_cust.tax, :s_cust.bmstday) Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 IF Pos(Lower(commit_transaction.SQLErrText),'pk_u_cust') > 0 THEN arg_msg = '插入操作失败,关键字客户ID重复' ELSEIF Pos(Lower(commit_transaction.SQLErrText),'ix_u_cust') > 0 THEN arg_msg = '插入操作失败,客户名称重复' ELSEIF Pos(Lower(commit_transaction.SQLErrText),'i_cus_code') > 0 THEN arg_msg = '插入操作失败,客户编号重复' ELSE arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF //读取新cusid cusid = ls_newid ELSE //////////////////////////////////////////////// //更新 UPDATE u_cust SET cuscode = :s_cust.cuscode, name = :s_cust.name, custype = :s_cust.custype, rep = :s_cust.rep, tele = :s_cust.tele, tele1 = :s_cust.tele1, bank = :s_cust.bank, cunt = :s_cust.cunt, address = :s_cust.address, code = :s_cust.code, dscrp = :s_cust.dscrp, faxno = :s_cust.faxno, maxmtnum = :s_cust.maxmtnum, inuse = :s_cust.inuse, cusareaid = :s_cust.cusareaid, cusareaname = :s_cust.cusareaname, areaname = :s_cust.areaname, email = :s_cust.email, givebackrate = :s_cust.givebackrate, freight = :s_cust.freight, freight_tele = :s_cust.freight_tele, freight_address = :s_cust.freight_address, lsflag = :s_cust.lsflag, memberid = :s_cust.memberid, score = :s_cust.score, pricelistid = :s_cust.pricelistid, banktypeid = :s_cust.banktypeid, tele_sms = :s_cust.tele_sms , upname = :s_cust.upname, industry = :s_cust.industry, grade = :s_cust.grade, bhflag = :s_cust.bhflag, tax = :s_cust.tax, moddate=:server_dt, modemp=:publ_operator, bmstday=:s_cust.bmstday Where cusid = :cusid Using commit_transaction; IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN rslt = 0 IF Pos(Lower(commit_transaction.SQLErrText),'pk_u_cust') > 0 THEN arg_msg = '更新操作失败,关键字客户ID重复' ELSEIF Pos(Lower(commit_transaction.SQLErrText),'ix_u_cust') > 0 THEN arg_msg = '更新操作失败,客户名称重复' ELSEIF Pos(Lower(commit_transaction.SQLErrText),'i_cus_code') > 0 THEN arg_msg = '更新操作失败,客户编号重复' ELSE arg_msg = "因网络或其它原因导致更新操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF //删除原有明细 DELETE FROM u_cust_rep Where u_cust_rep.cusid = :cusid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "删除客户联系人明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF END IF FOR i = 1 To it_mxbt INSERT INTO u_cust_rep (repid, cusid, repname, duty, sex, officetel, handtel, faxno, email, dscrp) VALUES ( :custmx[i].repid, :cusid, :custmx[i].repname, :custmx[i].duty, :custmx[i].sex, :custmx[i].officetel, :custmx[i].handtel, :custmx[i].faxno, :custmx[i].email, :custmx[i].dscrp ) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN IF it_newbegin THEN cusid = 0 //cusid rslt = 0 IF Pos(Lower(commit_transaction.SQLErrText),'pk_u_cust_rep') > 0 THEN arg_msg = '插入明细操作失败,关键字客户ID、联系人ID重复' ELSEIF Pos(Lower(commit_transaction.SQLErrText),'ix_u_cust_rep') > 0 THEN arg_msg = '插入明细操作失败,联系人名称重复' ELSE arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText END IF GOTO ext END IF NEXT 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 arg_msg = '客户资料,'+ arg_msg RETURN rslt end function public function integer newbegin (long arg_cusid);long rslt = 1 it_newbegin =true it_updatebegin =false cusid = arg_cusid return rslt end function public function integer updatebegin (long arg_cusid, ref string arg_msg);long rslt=1 if arg_cusid<=0 then rslt=0 arg_msg = '错误客户唯一码' goto ext end if rslt=p_getinfo(arg_cusid,arg_msg) if rslt=0 then goto ext cusid=arg_cusid 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_cusid, string arg_cuscode, ref string arg_msg, boolean arg_ifcommit); Int rslt = 1 Long ls_long IF arg_cusid = 0 THEN rslt = 0 arg_msg = "没有删除对象,操作取消" GOTO ext END IF ls_long = 0 SELECT count(*) Into :ls_long From u_saletask Where cusid = :arg_cusid 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_outware Where u_outware.cusid = :arg_cusid 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_bmsttake Where cusid = :arg_cusid 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_cust Where cusid = :arg_cusid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "删除客户操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF DELETE FROM u_cust_rep Where cusid = :arg_cusid 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_cusid)+',code:'+arg_cuscode,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 p_clearmx ();//int p_clearmx() //清除明细 it_mxbt=0 return 1 end function public function integer getinfo (long arg_cusid, ref string arg_msg);//getinfo(arg_scid,arg_cusid,arg_msg) //0 失败 1成功 Int rslt = 1,i = 1,no_mxcheck = 0 IF arg_cusid <= 0 THEN rslt = 0 arg_msg = "非法客户唯一码" GOTO ext END IF rslt = p_getinfo(arg_cusid,arg_msg) IF rslt = 0 THEN GOTO ext //用游标读取明细 DECLARE cur_inwaermx CURSOR FOR SELECT repid, cusid, repname, duty, sex, officetel, handtel, faxno, email, dscrp FROM u_cust_rep WHERE u_cust_rep.cusid = :arg_cusid USING commit_transaction; OPEN cur_inwaermx; FETCH cur_inwaermx INTO :custmx[i].repid,:custmx[i].cusid, :custmx[i].repname,:custmx[i].duty,:custmx[i].sex, :custmx[i].officetel,:custmx[i].handtel,:custmx[i].faxno, :custmx[i].email,:custmx[i].dscrp; DO WHILE commit_transaction.SQLCode = 0 i++ FETCH cur_inwaermx INTO :custmx[i].repid,:custmx[i].cusid, :custmx[i].repname,:custmx[i].duty,:custmx[i].sex, :custmx[i].officetel,:custmx[i].handtel,:custmx[i].faxno, :custmx[i].email,:custmx[i].dscrp; LOOP CLOSE cur_inwaermx; //检验明细是否读入完整 SELECT count(*) INTO :no_mxcheck FROM u_cust_rep WHERE u_cust_rep.cusid = :arg_cusid 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 cusid = arg_cusid it_mxbt = i - 1 it_newbegin = FALSE it_updatebegin = FALSE ext: IF rslt = 0 THEN p_reset() RETURN rslt end function public function integer uof_cust_score (long arg_cusid, decimal arg_score, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Decimal ld_score IF arg_score < 0 THEN SELECT score - exchangescore INTO :ld_score FROM u_cust Where cusid = :arg_cusid; IF commit_transaction.SQLCode <> 0 THEN IF Pos(Lower(commit_transaction.SQLErrText),'more than') > 0 THEN arg_msg = '查询客户积分失败,查询数据返回值多于一个' ELSE arg_msg = '查询客户积分失败,'+commit_transaction.SQLErrText END IF rslt = 0 GOTO ext END IF IF arg_score + ld_score < 0 THEN arg_msg = '客户积分只有:'+String(ld_score,'#,##0.##')+',不能兑换:'+String(Abs(arg_score),'#,##0.##') rslt = 0 GOTO ext END IF UPDATE u_cust SET exchangescore = exchangescore + :arg_score Where cusid = :arg_cusid; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '更新客户积分失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF ELSE UPDATE u_cust SET score = score + :arg_score Where cusid = :arg_cusid; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '更新客户积分失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF IF sys_autoupdate_member = 1 THEN ////会员自动升级 IF uof_update_member(arg_cusid,arg_msg,arg_ifcommit) = 0 THEN rslt = 0 GOTO ext END IF 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_update_member (long arg_cusid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Long ll_memberid Dec ld_cusscore SELECT memberid , score INTO :ll_memberid, :ld_cusscore FROM u_cust Where cusid = :arg_cusid; IF commit_transaction.SQLCode <> 0 THEN IF Pos(Lower(commit_transaction.SQLErrText),'more than') > 0 THEN arg_msg = '查询客户会员类型失败,查询数据返回值多于一个' ELSE arg_msg = '查询客户会员类型失败,'+commit_transaction.SQLErrText END IF rslt = 0 GOTO ext END IF if ll_memberid = 0 then goto ext Decimal ld_score[] Long ld_memberid[] long ld_Pricelistid[] Long i = 1,NO_MXCHECK DECLARE CUR_member CURSOR FOR SELECT u_cust_member.updatescore, u_cust_member.memberid, u_cust_member.Pricelistid FROM u_cust_member Order By updatescore Desc; OPEN CUR_member; FETCH CUR_member INTO :ld_score[i],:ld_memberid[i],:ld_Pricelistid[i]; DO WHILE commit_transaction.SQLCode = 0 i++ FETCH CUR_member INTO :ld_score[i],:ld_memberid[i],:ld_Pricelistid[i]; LOOP CLOSE CUR_member; //检验明细是否读入完整 SELECT COUNT(*) INTO :NO_MXCHECK FROM u_cust_member ; 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 FOR i = 1 TO NO_MXCHECK IF ld_score[i] > 0 AND ld_cusscore >= ld_score[i] THEN UPDATE u_cust SET memberid = :ld_memberid[i], Pricelistid = :ld_Pricelistid[i] Where u_cust.cusid = :arg_cusid; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "更新客户会员类型操作失败" GOTO ext END IF EXIT END IF NEXT 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_update_state (long arg_cusid, integer arg_state, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Int li_state SELECT state INTO :li_state FROM u_cust Where cusid = :arg_cusid; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询客户类型操作失败" GOTO ext END IF IF arg_state = 1 THEN //申请为正式客户 IF li_state <> 3 THEN rslt = 0 arg_msg = "非准客户不能审核为正式客户" GOTO ext END IF ELSEIF arg_state = 3 THEN //申请为准客户 IF li_state <> 0 THEN rslt = 0 arg_msg = "非公共客户不能申请准客户" GOTO ext END IF END IF UPDATE u_cust SET state = :arg_state Where cusid = :arg_cusid; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "更新客户类型操作失败,"+sqlca.sqlerrtext 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_audit_cust_rq (long arg_rqid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Long cnt Long ll_cusid String ls_custype 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 UPDATE u_cust_rq SET flag = 1, auditdate = getdate(), auditemp = :publ_operator 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 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_c_audit_cust_rq (long arg_rqid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Long cnt Long ll_cusid String ls_custype 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 = 0 THEN rslt = 0 arg_msg = "客户申请未审核" GOTO ext END IF UPDATE u_cust_rq SET flag = 0, auditdate = null, auditemp = '' WHERE rqid = :arg_rqid And flag = 1; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "撤审客户申请状况操作失败" GOTO ext ELSEIF sqlca.SQLNRows = 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 public function integer uof_add_cust_rq (long arg_cusid, string arg_custype, datetime arg_rqdate, string arg_dscrp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Long cnt Long ll_newid SELECT count(*) INTO :cnt FROM u_cust_rq WHERE cusid = :arg_cusid And flag = 0; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询客户申请状况操作失败,"+sqlca.sqlerrtext GOTO ext END IF IF cnt > 0 THEN //未审批的 rslt = 0 arg_msg = "当前客户还有未审批记录,不能申请" GOTO ext END IF ll_newid = f_sys_scidentity(0,"u_cust_rq","rqid",arg_msg,False,sqlca) IF ll_newid <= 0 THEN rslt = 0 GOTO ext END IF INSERT INTO u_cust_rq (rqid, cusid, custype, rqdate, dscrp, opdate, opemp) VALUES (:ll_newid, :arg_cusid, :arg_custype, :arg_rqdate, :arg_dscrp, getdate(), :publ_operator); IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "插入客户申请状况操作失败,"+sqlca.sqlerrtext GOTO ext END IF IF uof_update_state(arg_cusid, 3, arg_msg, false) = 0 THEN 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 acceptmx (long arg_repid, long arg_cusid, 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_cusid) THEN arg_cusid = 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 //检查客户id cnt = 0 SELECT count(*) INTO :cnt FROM u_cust Where cusid = :arg_cusid USING commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败 " GOTO ext END IF //写入内容 it_mxbt++ custmx[it_mxbt].repid = arg_repid custmx[it_mxbt].cusid = arg_cusid custmx[it_mxbt].repname = arg_repname custmx[it_mxbt].duty = arg_duty custmx[it_mxbt].sex = arg_sex custmx[it_mxbt].officetel = arg_officetel custmx[it_mxbt].handtel = arg_handtel custmx[it_mxbt].faxno = arg_faxno custmx[it_mxbt].email = arg_email custmx[it_mxbt].dscrp = arg_dscrp ext: IF rslt = 0 THEN p_clearmx() arg_msg = '客户资料,'+ arg_msg Return(rslt) end function on uo_custdef.create call super::create TriggerEvent( this, "constructor" ) end on on uo_custdef.destroy TriggerEvent( this, "destructor" ) call super::destroy end on