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

📄 feequery.cpp

📁 VC6.0环境下编写的一个交换机计费程序。
💻 CPP
📖 第 1 页 / 共 3 页
字号:
			}
		}
	}


	BOOL	binflag;
	BOOL	boutflag;

	binflag=recorddetailDlg.m_bin;
	boutflag=recorddetailDlg.m_bout;


	long lstartyear,lstartmonth,lstartday;
	long lendyear,lendmonth,lendday;
	long startdateflag,enddateflag;
	startdateflag=0;
	enddateflag=0;
	if (recorddetailDlg.m_strstartyear!="" 
		&& recorddetailDlg.m_strstartmonth!=""
		&& recorddetailDlg.m_strstartday!="")
	{
		lstartyear=atol(recorddetailDlg.m_strstartyear);
		lstartmonth=atol(recorddetailDlg.m_strstartmonth);
		lstartday=atol(recorddetailDlg.m_strstartday);
		startdateflag=availdate(lstartyear,lstartmonth,lstartday);
		if (startdateflag==1)
		{
			AfxMessageBox("start dateset error");
			return;
		}
		startdateflag=2;
	}
	if (startdateflag!=2)
	{
		AfxMessageBox("start dateset error");
		return;
	}
	if (recorddetailDlg.m_strendyear!="" 
		&& recorddetailDlg.m_strendmonth!=""
		&& recorddetailDlg.m_strendday!="")
	{
		lendyear=atol(recorddetailDlg.m_strendyear);
		lendmonth=atol(recorddetailDlg.m_strendmonth);
		lendday=atol(recorddetailDlg.m_strendday);
		enddateflag=availdate(lendyear,lendmonth,lendday);
		if (enddateflag==1)
		{
			AfxMessageBox("end dateset error");
			return;
		}
		enddateflag=2;
	}	
	if (enddateflag!=2)
	{
		AfxMessageBox("end dateset error");
		return;
	}

	long lstarthour,lstartminute,lstartsecond;
	long lendhour,lendminute,lendsecond;
	long starttimeflag,endtimeflag;

	if (recorddetailDlg.m_strstarthour!="" 
		&& recorddetailDlg.m_strstartminute!=""
		&& recorddetailDlg.m_strstartsecond!="")
	{
		lstarthour=atol(recorddetailDlg.m_strstarthour);
		lstartminute=atol(recorddetailDlg.m_strstartminute);
		lstartsecond=atol(recorddetailDlg.m_strstartsecond);
		starttimeflag=availdate(lstartyear,lstartmonth,lstartday);
		if (lstarthour>=24||lstartminute>=60||lstartsecond>=60)
		{
			AfxMessageBox("start timeset error");
			return;
		}
		starttimeflag=2;
	}
	if (starttimeflag!=2)
	{
		AfxMessageBox("start timeset error");
		return;
	}
	if (recorddetailDlg.m_strendhour!="" 
		&& recorddetailDlg.m_strendminute!=""
		&& recorddetailDlg.m_strendsecond!="")
	{
		lendhour=atol(recorddetailDlg.m_strendhour);
		lendminute=atol(recorddetailDlg.m_strendminute);
		lendsecond=atol(recorddetailDlg.m_strendsecond);
		endtimeflag=availdate(lendyear,lendmonth,lendday);
		if (lendhour>=24||lendminute>=60||lendsecond>=60)
		{
			AfxMessageBox("end timeset error");
			return;
		}
		endtimeflag=2;
	}	
	if (endtimeflag!=2)
	{
		AfxMessageBox("end timeset error");
		return;
	}

	CTime cstarttime(lstartyear,lstartmonth,lstartday,lstarthour,lstartminute,lstartsecond);
	CTime cendtime(lendyear,lendmonth,lendday,lendhour,lendminute,lendsecond);

	if (cstarttime>cendtime)
	{
		AfxMessageBox("start end set error");
		return;
	}

	CFeeApp* pApp=(CFeeApp *)AfxGetApp();	
	CString callingnum;
	long fillflag;
	if (querycallingnum==0)
	{
		fillflag=0;
		if (binflag==TRUE && boutflag==TRUE)
			strSql.Format("select * from spcrecord");
		else if (binflag==TRUE)
		{
			strSql.Format("select * from spcrecord where spcType='INE'");
			fillflag=1;
		}
		else if (boutflag==TRUE)
		{
			strSql.Format("select * from spcrecord where spcType='OUT'");
			fillflag=1;
		}
		else
		{
			AfxMessageBox("direction is error");
			return;
		}

		if (startdateflag==2)
		{
			if (fillflag==0)
				strtemp.Format(" where spcEndDate>=#%d-%d-%d#",lstartyear,lstartmonth,lstartday);
			else
				strtemp.Format(" and spcEndDate>=#%d-%d-%d#",lstartyear,lstartmonth,lstartday);
			strSql+=strtemp;
		}
		if (enddateflag==2)
		{
			if (startdateflag==2)
				strtemp.Format(" and spcEndDate<=#%d-%d-%d#",lendyear,lendmonth,lendday);
			else
				strtemp.Format(" where spcEndDate<=#%d-%d-%d#",lendyear,lendmonth,lendday);
			strSql+=strtemp;		
		}

		CString strcallingnum[1000];
		long feecallingnumshuliang;

		feecallingnumshuliang=0;

		result=pApp->m_pspcRecordset->Open(strSql.AllocSysString(),
			pApp->m_pspcConnection.GetInterfacePtr(),
			adOpenDynamic,adLockOptimistic,adCmdText);
		if (!SUCCEEDED(result))
		{
			AfxMessageBox("can't open spc table");
		}
		long i=0;
		long existflag;
		while(!pApp->m_pspcRecordset->adoEOF)
		{
			_variant_t varport;

			CString strstartdate,strstarttime;
			unsigned long lcmpdatetime;
			long lcmpyear,lcmpmonth,lcmpday;
			long lcmphour,lcmpminute,lcmpsecond;
			int pos;

			strstartdate="";
			strstarttime="";
			varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcStartDate"));
			if (varport.vt!=VT_NULL)
				strstartdate=(char*)_bstr_t(varport);
			else 
				strstartdate="null";	
			varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcStartTime"));
			if (varport.vt!=VT_NULL)
				strstarttime=(char*)_bstr_t(varport);
			else 
				strstarttime="null";	
			pos=strstartdate.Find("-");
			lcmpyear=atol(strstartdate.Left(pos));
			strstartdate.Delete(0,pos+1);
			pos=strstartdate.Find("-");
			lcmpmonth=atol(strstartdate.Left(pos));
			strstartdate.Delete(0,pos+1);
			lcmpday=atol(strstartdate);

			pos=strstartdate.Find(":");
			lcmphour=atol(strstarttime.Left(pos));
			strstarttime.Delete(0,pos+1);
			pos=strstarttime.Find(":");
			lcmpminute=atol(strstarttime.Left(pos));
			strstarttime.Delete(0,pos+1);
			lcmpsecond=atol(strstarttime);
	
			
			CTime ccmpdatetime(lcmpyear,lcmpmonth,lcmpday,lcmphour,lcmpminute,lcmpsecond);

			if(ccmpdatetime>=cstarttime 
			&& ccmpdatetime<=cendtime)
			{
				varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcCallingNum"));
				if (varport.vt!=VT_NULL)
					strtemp=(char*)_bstr_t(varport);
				else 
					strtemp="null";	
				ctl->InsertItem(i,strtemp);
				ctl->SetItemData(i,i);
				varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcCalledNum"));
				if (varport.vt!=VT_NULL)
					strtemp=(char*)_bstr_t(varport);
				else 
					strtemp="null";
				ctl->SetItemText(i,1,strtemp);
				varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcStartDate"));
				if (varport.vt!=VT_NULL)
					strtemp=(char*)_bstr_t(varport);
				else 
					strtemp="null";	
				ctl->SetItemText(i,2,strtemp);
				varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcStartTime"));
				if (varport.vt!=VT_NULL)
					strtemp=(char*)_bstr_t(varport);
				else 
					strtemp="null";	
				ctl->SetItemText(i,3,strtemp);
				varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcEndDate"));
				if (varport.vt!=VT_NULL)
					strtemp=(char*)_bstr_t(varport);
				else 
					strtemp="null";	
				ctl->SetItemText(i,4,strtemp);
				varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcEndTime"));
				if (varport.vt!=VT_NULL)
					strtemp=(char*)_bstr_t(varport);
				else 
					strtemp="null";	
				ctl->SetItemText(i,5,strtemp);
				varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcTalkTime"));
				if (varport.vt!=VT_NULL)
					strtemp=(char*)_bstr_t(varport);
				else 
					strtemp="null";	
				ctl->SetItemText(i,6,strtemp);
			}
			pApp->m_pspcRecordset->MoveNext();
		}
		pApp->m_pspcRecordset->Close();
	}
	else 
	{
		for(i=0;i<querycallingnum;i++)
		{
			callingnum=querycalling[i];
			localcodeflag=0;
			if (strlocalcode!="")
			{
				localcodeflag=1;
				ltemp=atol(callingnum);
				straddlocal=strlocalcode;
				straddlocal+=callingnum;
			}

			if (binflag==TRUE && boutflag==TRUE)
			{
				strSql.Format("select * from spcrecord where spcCallingNum='%s' or spcCalledNum='%s'", callingnum,callingnum);
				if (localcodeflag==1)
				{
					strtemp.Format(" or spcCallingNum='%s'",straddlocal);	
					strSql+=strtemp;	
				}
			}
			else if (binflag==TRUE)
				strSql.Format("select * from spcrecord where spcCalledNum='%s'", callingnum);
			else if (boutflag==TRUE)
			{
				strSql.Format("select * from spcrecord where spcCallingNum='%s'", callingnum);
				if (localcodeflag==1)
				{
					strtemp.Format(" or spcCallingNum='%s'",straddlocal);				
					strSql+=strtemp;	
				}
			}
			else
			{
				AfxMessageBox("direction is error");
				return;
			}

			if (startdateflag==2)
			{
				strtemp.Format(" and spcEndDate>=#%d-%d-%d#",lstartyear,lstartmonth,lstartday);
				strSql+=strtemp;
			}
			if (enddateflag==2)
			{
				strtemp.Format(" and spcEndDate<=#%d-%d-%d#",lendyear,lendmonth,lendday);
				strSql+=strtemp;		
			}
			
			result=pApp->m_pspcRecordset->Open(strSql.AllocSysString(),
				pApp->m_pspcConnection.GetInterfacePtr(),
				adOpenDynamic,adLockOptimistic,adCmdText);
			if (!SUCCEEDED(result))
			{
				AfxMessageBox("can't open spc table");
			}

			while(!pApp->m_pspcRecordset->adoEOF)
			{
				_variant_t varport;

				CString strstartdate,strstarttime;
				long lcmpyear,lcmpmonth,lcmpday;
				long lcmphour,lcmpminute,lcmpsecond;
				int pos;

				strstartdate="";
				strstarttime="";
				varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcStartDate"));
				if (varport.vt!=VT_NULL)
					strstartdate=(char*)_bstr_t(varport);
				else 
					strstartdate="null";	
				varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcStartTime"));
				if (varport.vt!=VT_NULL)
					strstarttime=(char*)_bstr_t(varport);
				else 
					strstarttime="null";	
				pos=strstartdate.Find("-");
				lcmpyear=atol(strstartdate.Left(pos));
				strstartdate.Delete(0,pos+1);
				pos=strstartdate.Find("-");
				lcmpmonth=atol(strstartdate.Left(pos));
				strstartdate.Delete(0,pos+1);
				lcmpday=atol(strstartdate);

				pos=strstartdate.Find(":");
				lcmphour=atol(strstarttime.Left(pos));
				strstarttime.Delete(0,pos+1);
				pos=strstarttime.Find(":");
				lcmpminute=atol(strstarttime.Left(pos));
				strstarttime.Delete(0,pos+1);
				lcmpsecond=atol(strstarttime);
				
				CTime ccmpdatetime(lcmpyear,lcmpmonth,lcmpday,lcmphour,lcmpminute,lcmpsecond);

				if(ccmpdatetime>=cstarttime 
				&& ccmpdatetime<=cendtime)
				{
					varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcCallingNum"));
					if (varport.vt!=VT_NULL)
						strtemp=(char*)_bstr_t(varport);
					else 
						strtemp="null";	
					ctl->InsertItem(i,strtemp);
					ctl->SetItemData(i,i);
					varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcCalledNum"));
					if (varport.vt!=VT_NULL)
						strtemp=(char*)_bstr_t(varport);
					else 
						strtemp="null";
					ctl->SetItemText(i,1,strtemp);
					varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcStartDate"));
					if (varport.vt!=VT_NULL)
						strtemp=(char*)_bstr_t(varport);
					else 
						strtemp="null";	
					ctl->SetItemText(i,2,strtemp);
					varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcStartTime"));
					if (varport.vt!=VT_NULL)
						strtemp=(char*)_bstr_t(varport);
					else 
						strtemp="null";	
					ctl->SetItemText(i,3,strtemp);
					varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcEndDate"));
					if (varport.vt!=VT_NULL)
						strtemp=(char*)_bstr_t(varport);
					else 
						strtemp="null";	
					ctl->SetItemText(i,4,strtemp);
					varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcEndTime"));
					if (varport.vt!=VT_NULL)
						strtemp=(char*)_bstr_t(varport);
					else 
						strtemp="null";	
					ctl->SetItemText(i,5,strtemp);
					varport=pApp->m_pspcRecordset->GetCollect(_variant_t("spcTalkTime"));
					if (varport.vt!=VT_NULL)
						strtemp=(char*)_bstr_t(varport);
					else 
						strtemp="null";	
					ctl->SetItemText(i,6,strtemp);
				}
				pApp->m_pspcRecordset->MoveNext();
			}
			pApp->m_pspcRecordset->Close();

		}
	}

}

⌨️ 快捷键说明

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