'******************************** ' PM共用程式區 '******************************** const ERR_FMT="日期格式錯誤" const ERR_FMT_YY="日期格式錯誤(年)" const ERR_FMT_MM="日期格式錯誤(月)" const ERR_FMT_DD="日期格式錯誤(日)" const ERR_FMT_UNKNOW="未支援格式" ' 宣告為全區變數 Dim xmlDoc,xmlhttp Dim xmlAddr, xmlSubc, xmlPspt,G_CQ_117_FDAT,G_CQ_117_TDAT,G_USE_PONT set xmlDoc=createobject("microsoft.xmlDOM") xmlDoc.async=false set xmlhttp=createobject("microsoft.XMLHTTP") '******************************************************** ' 功能函數: ldt2cdt ' 說明 : 西元年轉中國年 ' 使用方式: rc=ldt2cdt(ldt, cdt, msg) ' 輸入 : ldt (YYYY/M(M)/D(D) or YYYY-M(M)-D(D)) ' 輸出 : cdt (YYYMMDD), msg ' function ldt2cdt ( ldt, cdt, msg) cdt="" msg="" yyy="" mm="" dd="" ldt2cdt=false ' 檢查輸入日期格式 if instr(1,ldt,"/")>0 then dttype="1" splitbar="/" else if instr(1,ldt,"-")>0 then dttype="2" splitbar="-" else if len(ldt)=8 then dttype="3" else dttype="4" end if end if end if select case dttype case "1","2" tdt=split(ldt, splitbar) if ubound(tdt)=2 then if isdate(ldt) then yyy=cint(tdt(0))-1911 if yyy>0 then if yyy<100 then yyy="0" & yyy mm=tdt(1) if mm<10 then mm="0" & mm dd=tdt(2) if dd<10 then dd="0" & dd else msg=ERR_FMT_YY end if else msg=ERR_FMT end if else msg=ERR_FMT end if case "3" yyy=mid(ldt,1,4) mm=mid(ldt,5,2) dd=mid(ldt,7,2) if isdate(yyy & "/" & mm & "/" & dd) then yyy=yyy-1911 if yyy>0 then if yyy<100 then yyy="0" & yyy else msg=ERR_FMT_YY end if else msg=ERR_FMT end if case "4" msg=ERR_FMT_UNKNOW end select if msg="" then cdt=yyy & mm & dd ldt2cdt=true end if end function '******************************************************** ' 功能函數: cdt2ldt ' 說明 : 中國年轉西元年 ' 使用方式: rc=cdt2ldt(cdt, ldt, delm, msg) ' 輸入 : cdt (YYYMMDD/YYMMDD), delm 分隔符號("/","-","") ' 輸出 : ldt (YYYY/MM/DD), msg ' function cdt2ldt ( cdt, ldt, delm, msg) ldt="" msg="" yyyy="" mm="" dd="" cdt2ldt=false if len(cdt)<>7 and len(cdt)<>6 then msg=ERR_FMT exit function end if if isnumeric(cdt) then if len(cdt)=6 then yyyy=mid(cdt,1,2)+1911 mm=mid(cdt,3,2) dd=mid(cdt,5,2) else yyyy=mid(cdt,1,3)+1911 mm=mid(cdt,4,2) dd=mid(cdt,6,2) end if for cCnt=1 to len(cdt) if instr(1,"0123456789",mid(cdt,cCnt,1))<=0 then msg=ERR_FMT exit function end if next if isdate(yyyy & "/" & mm & "/" & dd) then ldt=yyyy & delm & mm & delm & dd if len(cdt)=6 then cdt="0" & cdt cdt2ldt=true else msg=ERR_FMT end if else msg=ERR_FMT end if end function '******************************************************** ' 功能函數: checkFullChineseLength ' 說明 : 中文長度檢查 ' 使用方式: rc=checkChineseLength(inputStr, sLen, rLen) ' 輸入 : inputStr (字串) , sLen(期望長度), rLen(真正長度) ' 輸出 : true/false ' function checkFullChineseLength(inputStr, sLen, rLen) checkFullChineseLength=true rLen=0 if trim(inputStr)<>"" then iCnt=0 inputStr=trim(inputStr) for i=1 to len(inputStr) if midb(inputStr,i*2-1,2) >= chr(32) and midb(inputStr,i*2-1,2) =< chr(127) then checkFullChineseLength=false exit function else iCnt=iCnt+2 end if next if iCnt>sLen then checkFullChineseLength=false end if end if rLen=iCnt end function '******************************************************** ' 功能函數: checkChineseLength ' 說明 : 中文長度檢查 ' 使用方式: rc=checkChineseLength(inputStr, sLen, rLen) ' 輸入 : inputStr (字串) , sLen(期望長度), rLen(真正長度) ' 輸出 : true/false ' function checkChineseLength(inputStr, sLen, rLen) dim iCnt checkChineseLength=true rLen=0 if trim(inputStr)<>"" then iCnt=0 inputStr=trim(inputStr) for i=1 to len(inputStr) if midb(inputStr,i*2-1,2)>=chr(32) and midb(inputStr,i*2-1,2)=sLen then checkChineseLength=false end if end if rLen=iCnt end function '******************************************************** ' 功能函數: getField ' 說明 : 資料擷取副程式 ' 使用方式: rc=getField(i_txt) ' 輸入 : i_txt 文字 ' 輸出 : 文字 ' function getField(i_txt) on error resume next set root=xmlDoc.GetElementsByTagName(i_txt) if root(0).childnodes.length=1 then getField=root(0).childNodes(0).text else getField="" end if set root=nothing on error goto 0 end function '******************************************************** ' 功能函數: checkFullChineseLength ' 說明 : 中文長度檢查 ' 使用方式: rc=checkChineseLength(inputStr, sLen, rLen) ' 輸入 : inputStr (字串) , sLen(期望長度), rLen(真正長度) ' 輸出 : true/false ' function checkFullChineseLength(inputStr, sLen, rLen) checkFullChineseLength=true rLen=0 if trim(inputStr)<>"" then iCnt=0 inputStr=trim(inputStr) for i=1 to len(inputStr) if midb(inputStr,i*2-1,2) >= chr(32) and midb(inputStr,i*2-1,2) =< chr(127) then checkFullChineseLength=false exit function else iCnt=iCnt+2 end if next if iCnt>sLen then checkFullChineseLength=false end if end if rLen=iCnt end function sub getXMLData(xmlcmd) xmlhttp.open "POST",replace(document.location,"#","") ,false xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=big5" xmlhttp.send xmlCmd set xmlDoc=xmlhttp.responseXML if xmlDoc.parseError.errorCode <> 0 then window.navigate "PGOC01.aspx","_top" end if end sub '*****94/10/17增加,依系統日計算出點數計費起迄區間及已使用點數******* sub charge_between_date(sys_date,tel) '傳入的基準日期(sys_date)型態為西元年月日 yyyy-mm-dd or yyyy/mm/dd xmlDoc.load("PMcomxml.aspx?xmlData=PGO871" & tel & "") cq_106_fnum=csng(xmldoc.childnodes(1).childnodes(0).text) '計算起日月數加減值(-1) cq_106_fdd=xmldoc.childnodes(1).childnodes(1).text '計費起日-日 cq_106_tnum=csng(xmldoc.childnodes(1).childnodes(2).text) '計算迄日月數加減值(0) cq_106_tdd=xmldoc.childnodes(1).childnodes(3).text '計費迄日-日 cq_113_dat1=xmldoc.childnodes(1).childnodes(4).text '電話開卡日 '計費起日 f_yyyymmdd=dateadd("m",cq_106_fnum, sys_date) '西元 f_date=right("0" & year(f_yyyymmdd)-1911,3) & right("0" & month(f_yyyymmdd),2) & cq_106_fdd '民國 '計費迄日 t_yyyymmdd=dateadd("m",cq_106_tnum, sys_date) '西元 t_date=right("0" & year(t_yyyymmdd)-1911,3) & right("0" & month(t_yyyymmdd),2) & cq_106_tdd '民國 '系統日(民國) sdate=right("0" & year(sys_date)-1911,3) & right("0" & month(sys_date),2) & right("0" & day(sys_date),2) if sdate>t_date then f_yyyymmdd=dateadd("m",1,f_yyyymmdd) t_yyyymmdd=dateadd("m",1,t_yyyymmdd) f_date=right("0" & year(f_yyyymmdd)-1911,3) & right("0" & month(f_yyyymmdd),2) & cq_106_fdd '民國 t_date=right("0" & year(t_yyyymmdd)-1911,3) & right("0" & month(t_yyyymmdd),2) & cq_106_tdd '民國 end if if cq_113_dat1>f_date then '開卡日(cq_113_dat1)>計費起日 ==> 則計費起日=開卡日 f_date=cq_113_dat1 end if '中國年轉西元年 rc=cdt2ldt(f_date, ldt, "-", msg) G_CQ_117_FDAT=ldt rc=cdt2ldt(t_date, ldt, "-", msg) G_CQ_117_TDAT=ldt '***計算已使用點數 xmlDoc.load("PMcomxml.aspx?xmlData=PGO872" & tel & "" & f_date & "" & t_date & "") G_USE_PONT=csng(xmldoc.childnodes(1).childnodes(0).text) end sub