⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gen.cpp

📁 VC6.0环境下编写的一个交换机计费程序。
💻 CPP
字号:

#include "stdafx.h"
#include "fee.h"

#include "feeext.h"
#include "feeDoc.h"
#include "feeView.h"

#include "math.h"

long timevalid(long ljudgeyear,long ljudgemonth,long ljudgeday)
{
	long flag;
	
	flag=0;

	if (ljudgeyear<2000)
		flag=1;
	if (ljudgemonth<1||ljudgemonth>12)
		flag=1;
	if (ljudgeday<1||ljudgeday>31)
		flag=1;
	if (ljudgemonth==1||ljudgemonth==3||ljudgemonth==5||ljudgemonth==7||ljudgemonth==8||ljudgemonth==10||ljudgemonth==12)
	{
		if (ljudgeday>31)
		{
			flag=1;
		}
	}
	if (ljudgemonth==4||ljudgemonth==6||ljudgemonth==9||ljudgemonth==11)
	{
		if (ljudgeday>30)
		{
			flag=1;
		}
	}
	if(ljudgemonth==2)
	{
		if ((ljudgeyear%4)==0)
		{
			if (ljudgeday>29)
			{
				flag=1;
			}
		}
		else
		{
			if (ljudgeday>28)
			{
				flag=1;
			}
		}
	}
	
	return flag;

}


double round(double num , int i)
{return int(num*pow(10,i)+0.5)/float(pow(10,i));}

long feepro(CString strcallingnum,CString strcallednum,CString strcallstartdate,\
					  CString strcallstarttime,CString strcallenddate,CString strcallendtime,\
					  CString strtalktime)
{
	int n;
	int lentemp,dirflag,ltmp,ltmp1;
	unsigned long lchip,i;
	float chipper[72000],startchipper;
	CString strfee,strfeestarttime,strfeestartfee,strfeesteptime;
	CString strfeestepfee,strfeedirkind,strfeeaddfee;
	CString strdirkind;
	CString strSql,strTemp;
	TCHAR strcalleddir[50];
	CString strstartper,strstepper,straddper;
	HRESULT result;

	CFeeApp* pApp=(CFeeApp *)AfxGetApp();
	strSql.Format("select * from feefreecalled where callednum='%s'",strcallednum);

	result=pApp->m_pjifeiRecordset->Open(strSql.AllocSysString(),
		pApp->m_pjifeiConnection.GetInterfacePtr(),
		adOpenDynamic,adLockOptimistic,adCmdText);
	if (!SUCCEEDED(result))
	{
		AfxMessageBox("can't open feetele table");
	}
	if(!pApp->m_pjifeiRecordset->adoEOF)
	{
		strfeedirkind=(char*)(_bstr_t)pApp->m_pjifeiRecordset->GetCollect(_variant_t("property"));
		strgetfeedirkind=strfeedirkind;
		pApp->m_pjifeiRecordset->Close();
		return 0;
	}
	pApp->m_pjifeiRecordset->Close();
	lentemp=strlen(strcallednum);
	dirflag=0;
	strdirkind="";
	lchip=0;

	for(n=0;n<lentemp;n++)
	{
		lstrcpyn(strcalleddir,strcallednum,n+2);
		strSql.Format("select * from feedirection where feedirection='%s'",strcalleddir);
		result=pApp->m_pjifeiRecordset->Open(strSql.AllocSysString(),
			pApp->m_pjifeiConnection.GetInterfacePtr(),
			adOpenDynamic,adLockOptimistic,adCmdText);
		if (!SUCCEEDED(result))
		{
			AfxMessageBox("can't open feedirection table");
		}
		if (!pApp->m_pjifeiRecordset->adoEOF)  //找到被叫局向
		{
			_variant_t varport;
			varport=pApp->m_pjifeiRecordset->GetCollect(_variant_t("feestarttime"));
			if (varport.vt!=VT_NULL)
				strfeestarttime =(char*)_bstr_t(varport);
			else 
				strfeestarttime="null";
			varport=pApp->m_pjifeiRecordset->GetCollect(_variant_t("feestartfee"));
			if (varport.vt!=VT_NULL)
				strfeestartfee =(char*)_bstr_t(varport);
			else 
				strfeestartfee="null";
			varport=pApp->m_pjifeiRecordset->GetCollect(_variant_t("feesteptime"));
			if (varport.vt!=VT_NULL)
				strfeesteptime =(char*)_bstr_t(varport);
			else 
				strfeesteptime="null";
			varport=pApp->m_pjifeiRecordset->GetCollect(_variant_t("feestepfee"));
			if (varport.vt!=VT_NULL)
				strfeestepfee =(char*)_bstr_t(varport);
			else 
				strfeestepfee="null";
			varport=pApp->m_pjifeiRecordset->GetCollect(_variant_t("feeaddfee"));
			if (varport.vt!=VT_NULL)
				strfeeaddfee =(char*)_bstr_t(varport);
			else 
				strfeeaddfee="null";
			varport=pApp->m_pjifeiRecordset->GetCollect(_variant_t("feedirectionkind"));
			if (varport.vt!=VT_NULL)
				strfeedirkind =(char*)_bstr_t(varport);
			else 
				strfeedirkind="null";

			//strfeestarttime=(char*)(_bstr_t)pApp->m_pjifeiRecordset->GetCollect(_variant_t("feestarttime"));
			//strfeestartfee=(char*)(_bstr_t)pApp->m_pjifeiRecordset->GetCollect(_variant_t("feestartfee"));
			//strfeesteptime=(char*)(_bstr_t)pApp->m_pjifeiRecordset->GetCollect(_variant_t("feesteptime"));
			//strfeestepfee=(char*)(_bstr_t)pApp->m_pjifeiRecordset->GetCollect(_variant_t("feestepfee"));
			//strfeeaddfee=(char*)(_bstr_t)pApp->m_pjifeiRecordset->GetCollect(_variant_t("feeaddfee"));
			//strfeedirkind=(char*)(_bstr_t)pApp->m_pjifeiRecordset->GetCollect(_variant_t("feedirectionkind"));

			strgetfeedirkind=strfeedirkind;
			n=lentemp+1;
			if (atol(strtalktime)>atol(strfeestarttime))
			{
				ltmp=atol(strtalktime)-atol(strfeestarttime);
				ltmp1=atol(strfeesteptime);
				lchip=ltmp/ltmp1;
				if ((ltmp%ltmp1)!=0)
					lchip++;
				for(i=0;i<(lchip+1);i++)
				{
					chipper[i]=1;
				}
			}
			startchipper=1;
			dirflag=1;
			//clean black sub
			strSql.Format("delete * from blackSub where blackCallingNum='%s' and \
				blackCalledNum='%s'",strcallingnum,strcallednum);
			result=pApp->m_pjifei2Recordset->Open(strSql.AllocSysString(),
				pApp->m_pjifei2Connection.GetInterfacePtr(),
				adOpenDynamic,adLockOptimistic,adCmdText);
			//clean black sub
		}
		pApp->m_pjifeiRecordset->Close();
	}
	if (dirflag==0)
	{
		return (99999);
	}
	/*
	else
	{
		dirflag=0;
		strSql.Format("select * from telephone where telephoneCode='%s'",strcallingnum);
		result=pApp->m_pjifeiRecordset->Open(strSql.AllocSysString(),
				pApp->m_pjifeiConnection.GetInterfacePtr(),
				adOpenDynamic,adLockOptimistic,adCmdText);
		if (!pApp->m_pjifeiRecordset->adoEOF)  //找到主叫特征表
		{
		//	strstartper=(char*)(_bstr_t)pApp->m_pjifeiRecordset->GetCollect(_variant_t("feestartper"));
		//	strstepper=(char*)(_bstr_t)pApp->m_pjifeiRecordset->GetCollect(_variant_t("feestepper"));
		//	straddper=(char*)(_bstr_t)pApp->m_pjifeiRecordset->GetCollect(_variant_t("feeaddper"));
			dirflag=1;
		}
		pApp->m_pjifeiRecordset->Close();
	}
	if (dirflag==0)
	{
		return (88888);
	}
	*/
	/*
	else
	{
		strSql.Format("select * from feetimechange");
		result=pApp->m_pjifeiRecordset->Open(strSql.AllocSysString(),
				pApp->m_pjifeiConnection.GetInterfacePtr(),
				adOpenDynamic,adLockOptimistic,adCmdText);
		while (!pApp->m_pjifeiRecordset->adoEOF)  //找到优惠时段
		{
			COleDateTime ttime,ttdate;
			long lchangestarttime,lchangeendtime;
			long lspcstarttime,lspcendtime,ltime,lday;
			long lhour,lminute,lsecond;

			CString strchangeper,strchangestartdate;
			CString strchangeenddate,strchangekind;
			CString strdaychangestarttime,strdaychangeendtime;
			long ldirkind,lchangekind;

			strchangekind=(char*)(_bstr_t)pApp->m_pjifeiRecordset->GetCollect(_variant_t("feetimechangekind"));
			ldirkind=atol(strfeedirkind);
			lchangekind=atol(strchangekind);
			strchangeper=(char*)(_bstr_t)pApp->m_pjifeiRecordset->GetCollect(_variant_t("feetimechangedecper"));
			strchangestartdate=(char*)(_bstr_t)pApp->m_pjifeiRecordset->GetCollect(_variant_t("feetimechangestartdate"));
			strchangeenddate=(char*)(_bstr_t)pApp->m_pjifeiRecordset->GetCollect(_variant_t("feetimechangeenddate"));
			strdaychangestarttime=(char*)(_bstr_t)pApp->m_pjifeiRecordset->GetCollect(_variant_t("feedaychangestarttime"));
			strdaychangeendtime=(char*)(_bstr_t)pApp->m_pjifeiRecordset->GetCollect(_variant_t("feedaychangeendtime"));
			if ((ldirkind&lchangekind)!=0)
			{
				//只有优惠时段。
				if ((strchangestartdate=="1970-1-1")&&\
					(strchangeenddate=="1970-1-1"))
				{
					ttime.ParseDateTime(strdaychangestarttime,VAR_TIMEVALUEONLY);
					lhour=ttime.GetHour();
					lminute=ttime.GetMinute();
					lsecond=ttime.GetSecond();
					lchangestarttime=lhour*3600+lminute*60+lsecond;
					ttime.ParseDateTime(strdaychangeendtime,VAR_TIMEVALUEONLY);
					lhour=ttime.GetHour();
					lminute=ttime.GetMinute();
					lsecond=ttime.GetSecond();
					lchangeendtime=lhour*3600+lminute*60+lsecond;
					ttime.ParseDateTime(strcallstarttime,VAR_TIMEVALUEONLY);
					lhour=ttime.GetHour();
					lminute=ttime.GetMinute();
					lsecond=ttime.GetSecond();
					lspcstarttime=lhour*3600+lminute*60+lsecond;
					ttime.ParseDateTime(strcallendtime,VAR_TIMEVALUEONLY);
					lhour=ttime.GetHour();
					lminute=ttime.GetMinute();
					lsecond=ttime.GetSecond();
					lspcendtime=lhour*3600+lminute*60+lsecond;
					ltime=lspcstarttime;
					for(i=0;i<lchip;i++)
					{
						if ((ltime>=lchangestarttime)&&
							(ltime<=lchangeendtime))
						{
							float flotmp;
							flotmp=atol(strchangeper)*0.01;
							chipper[i]=chipper[i]*(1-flotmp);
						}
						if (i==0)
							ltime=ltime+atol(strfeestarttime);
						else
							ltime=ltime+atol(strfeesteptime);
						if (ltime>3600*24)
						{
							ltime=0;
						}
					}
				}
				//有优惠日期和优惠时段
				else
				{
					double lchangestartday,lchangeendday;
					double lspcstartday,lspcendday;
					//以2006-1-1为相对起点进行计算
					strTemp="2006-1-1";
					COleDateTime ttdate1;
					ttdate1.ParseDateTime(strTemp,VAR_DATEVALUEONLY);
					ttdate.ParseDateTime(strchangestartdate,VAR_DATEVALUEONLY);
					lchangestartday=difftime(ttdate, ttdate1);
					ttdate.ParseDateTime(strchangeenddate,VAR_DATEVALUEONLY);
					lchangeendday=difftime(ttdate, ttdate1);
					ttdate.ParseDateTime(strcallstartdate,VAR_DATEVALUEONLY);
					lspcstartday=difftime(ttdate, ttdate1);
					ttdate.ParseDateTime(strcallstartdate,VAR_DATEVALUEONLY);
					lspcendday=difftime(ttdate, ttdate1);
					ttime.ParseDateTime(strdaychangestarttime,VAR_TIMEVALUEONLY);
					lhour=ttime.GetHour();
					lminute=ttime.GetMinute();
					lsecond=ttime.GetSecond();
					lchangestarttime=lhour*3600+lminute*60+lsecond;
					ttime.ParseDateTime(strdaychangeendtime,VAR_TIMEVALUEONLY);
					lhour=ttime.GetHour();
					lminute=ttime.GetMinute();
					lsecond=ttime.GetSecond();
					lchangeendtime=lhour*3600+lminute*60+lsecond;
					ttime.ParseDateTime(strcallstarttime,VAR_TIMEVALUEONLY);
					lhour=ttime.GetHour();
					lminute=ttime.GetMinute();
					lsecond=ttime.GetSecond();
					lspcstarttime=lhour*3600+lminute*60+lsecond;
					ttime.ParseDateTime(strcallendtime,VAR_TIMEVALUEONLY);
					lhour=ttime.GetHour();
					lminute=ttime.GetMinute();
					lsecond=ttime.GetSecond();
					lspcendtime=lhour*3600+lminute*60+lsecond;


					ltime=lspcstarttime;
					lday=lspcstartday;
					if ((lday>=lchangestartday)&&
						(lday<=lchangeendday))
					{
						if ((ltime>=lchangestarttime)&&
							(ltime<=lchangeendtime))
						{
							float flotmp;
							flotmp=atol(strchangeper)*0.01;
							startchipper=startchipper*(1-flotmp);
						}
						ltime=ltime+atol(strfeestarttime);
					}

					for(i=0;i<lchip;i++)
					{
						if (i==5631)
						{
							long tt;
							tt=0;
						}
						if ((lday>=lchangestartday)&&
							(lday<=lchangeendday))
						{
							if ((ltime>=lchangestarttime)&&
								(ltime<=lchangeendtime))
							{
								float flotmp;
								flotmp=atol(strchangeper)*0.01;
								chipper[i]=chipper[i]*(1-flotmp);
							}
							ltime=ltime+atol(strfeesteptime);
							if (ltime>=3600*24)
							{
								lday++;
								ltime=0;
							}
						}
					}
				}
			}
			pApp->m_pjifeiRecordset->MoveNext();
		}
		pApp->m_pjifeiRecordset->Close();
	}
	*/
/*
	float flotemptalkfee,flotemp;
	long ltemptalkfee;

	flotemptalkfee=0;
	flotemptalkfee=atol(strstartper)*0.01*atof(strfeestartfee)*startchipper;
	
	flotemp=round(flotemptalkfee,2);
	flotemptalkfee=flotemp;

	for(i=0;i<lchip;i++)
	{
		flotemptalkfee=flotemptalkfee+chipper[i]*(atol(strstepper)*0.01)*atof(strfeestepfee);
		flotemp=round(flotemptalkfee,2);
		flotemptalkfee=flotemp;
	}

	flotemptalkfee=flotemptalkfee+(atol(straddper)*0.01)*atof(strfeeaddfee);
	flotemp=round(flotemptalkfee,2);
	flotemptalkfee=flotemp;

	return(flotemptalkfee);
	*/

	long flotemptalkfee,flotemp;
	long ltemptalkfee;

	flotemptalkfee=0;
	flotemptalkfee=atol(strfeestartfee);
	
	
	for(i=0;i<lchip;i++)
	{
		flotemptalkfee=flotemptalkfee+chipper[i]*(atol(strfeestepfee));
	}

	return(flotemptalkfee);
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -