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

📄 querydlg.cpp

📁 话费语音查询及点歌软件.C++ 语言编写的.一款很有意思的小软件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// QueryDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Query.h"
#include "QueryDlg.h"
#include "CallerInfoSet.h"
#include "CallCostSet.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CQueryDlg dialog

CQueryDlg::CQueryDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CQueryDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CQueryDlg)
	m_strStatus0 = _T("");
	m_strStatus1 = _T("");
	m_strStatus2 = _T("");
	m_strStatus3 = _T("");
	m_strStatus4 = _T("");
	m_strStatus5 = _T("");
	m_strStatus6 = _T("");
	m_strStatus7 = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_LY);
}

void CQueryDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CQueryDlg)
	DDX_Text(pDX, IDC_STATIC0, m_strStatus0);
	DDX_Text(pDX, IDC_STATIC1, m_strStatus1);
	DDX_Text(pDX, IDC_STATIC2, m_strStatus2);
	DDX_Text(pDX, IDC_STATIC3, m_strStatus3);
	DDX_Text(pDX, IDC_STATIC4, m_strStatus4);
	DDX_Text(pDX, IDC_STATIC5, m_strStatus5);
	DDX_Text(pDX, IDC_STATIC6, m_strStatus6);
	DDX_Text(pDX, IDC_STATIC7, m_strStatus7);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CQueryDlg, CDialog)
	//{{AFX_MSG_MAP(CQueryDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_DESTROY()
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CQueryDlg message handlers

BOOL CQueryDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	CFile file;
	CFileStatus status;
	if(!CFile::GetStatus("DSN.query",status))
	{
		AfxMessageBox("数据库连接配置文件打开失败!\n系统无法正常工作!",MB_OK,NULL);
		return FALSE;
	}
	else
	{
		if(file.Open("DSN.query",CFile::modeRead))
		{
			char buff[100];
			DWORD b=file.GetLength();
			file.Read(buff,b);
			for(DWORD a=0;a<b;a++)
			{
				strConnection+=buff[a];
			}
			
		}
		else
			return FALSE;
	}
	//load caller info from database
	try{
		CDatabase db;
		
		db.OpenEx(strConnection);
		CCallerInfoTable m_callerinfoset;	
		m_callerinfoset.m_strSort="phonenumber";
		m_callerinfoset.m_pDatabase=&db;
	if(!m_callerinfoset.Open(AFX_DB_USE_DEFAULT_TYPE,"SELECT * FROM query"))
	{
		MessageBox("打开电话查询表出错!");
		CDialog::OnOK();
	}
	m_callerinfoset.MoveFirst();
	m_iCallerNumber=0;
	while(!m_callerinfoset.IsEOF())
	{
		callerinfo[m_iCallerNumber].m_callerid=m_callerinfoset.m_phonenumber;
		callerinfo[m_iCallerNumber].m_password=m_callerinfoset.m_password;
		callerinfo[m_iCallerNumber].m_callerid.TrimRight();
		callerinfo[m_iCallerNumber].m_password.TrimRight();
		m_iCallerNumber++;
		m_callerinfoset.MoveNext();
	}
	m_callerinfoset.Close();
	}
	catch(...)
	{MessageBox("Error!");}
	// now initialize the voice card object

	for(int i=0;i<8;i++)
	{
		channelstatus[i].used=0;//
		bIsRecording[i]=FALSE;//NOT RECORDING
		channelstatus[i].step=0;
		m_strRecDTMF[i].Empty();
		this->m_strDuty[i]="9";

	}
	//INITALIZATION THE MEMBER OF DJ CARD
	m_djcard.pCallerInfo=this->callerinfoofch;
	m_djcard.pChannelStatus=channelstatus;
	m_djcard.pcosttype=costtype;
	m_djcard.pDtmfChar=this->dtmfchar;
	m_djcard.pIsRecording=this->bIsRecording;
	m_djcard.pstrDuty=this->m_strDuty;
	m_djcard.pstrenddate=this->enddate;
	m_djcard.pstrRecDTMF=this->m_strRecDTMF;
	m_djcard.pstrstartdate=this->startdate;
	m_djcard.pRecordFileName=this->m_strRecordFileName;

	if(!m_djcard.InitCard())
	{
		MessageBox("Load Drive of Voice Card Falt!");
		CDialog::OnOK();
	}
	this->ScreenStatus();
	this->SetTimer(2345,100,NULL);

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CQueryDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CQueryDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CQueryDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

BEGIN_EVENTSINK_MAP(CQueryDlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CQueryDlg)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

//DEL void CQueryDlg::OnOnStatusChangeDmfax1(short ChannelNo, short CurStatus) 
//DEL {
//DEL 	// TODO: Add your control notification handler code here
//DEL 	switch(CurStatus)//other side has hook on
//DEL 	{
//DEL 	case 3:
//DEL 		if(bIsRecording[ChannelNo])//stop recording
//DEL 		{
//DEL 			this->bIsRecording[ChannelNo]=FALSE;
//DEL 			m_dmfax.StopRP(ChannelNo);
//DEL 		}
//DEL 		ResetChannel(ChannelNo);
//DEL 		break;
//DEL 	case 4:
//DEL 		if(this->m_strDuty[ChannelNo]=="4"&&bIsRecording[ChannelNo]==FALSE)//need recording
//DEL 		{
//DEL 			strFileName[ChannelNo]="c:\\voc\\recordfiles\\"+CTime::GetCurrentTime().Format("%y%m%d%H%M%S")+".voc";
//DEL 			m_dmfax.RecordFile(ChannelNo,strFileName[ChannelNo]);
//DEL 			this->bIsRecording[ChannelNo]=TRUE;
//DEL 		}
//DEL 		break;
//DEL 	default :
//DEL 		break;
//DEL 	}
//DEL 	this->ScreenStatus();
//DEL 
//DEL 
//DEL }

void CQueryDlg::OnOnReceiveDTMFDmfax1(short ChannelNo, char DTMFBuf) 
{
	// TODO: Add your control notification handler code here
	if((CString)DTMFBuf!="#")
	{
		this->m_strRecDTMF[ChannelNo]+=DTMFBuf;
		return;
	}
	else
		if(!bIsRecording[ChannelNo])// be sure this channel is not recording
		{
			//m_dmfax.StopRP(ChannelNo);//stop play file;
			if(this->m_strRecDTMF[ChannelNo]=="*")//play song
				this->channelstatus[ChannelNo].step=3;
		}
	 BOOL bcheck=FALSE;
     int i=0;
	 int j=0;
	 if(this->m_strRecDTMF[ChannelNo].IsEmpty())
	 {
		 this->m_djcard.PlayFile(ChannelNo,"sorry.voc");
		 return;
	 }
	switch(channelstatus[ChannelNo].step)
	{
	case 1 ://in put caller id
		if(m_strRecDTMF[ChannelNo].GetAt(0)!='1')
			callerinfoofch[ChannelNo].m_callerid="1"+m_strRecDTMF[ChannelNo].Mid(1);
		else	
			callerinfoofch[ChannelNo].m_callerid=m_strRecDTMF[ChannelNo];
		m_strRecDTMF[ChannelNo].Empty();
		channelstatus[ChannelNo].step++;
		m_djcard.PlayFile(ChannelNo,"password.voc");
		break;

	case 2 ://input password
		callerinfoofch[ChannelNo].m_password=m_strRecDTMF[ChannelNo];
		m_strRecDTMF[ChannelNo].Empty();
		channelstatus[ChannelNo].step++;
		//now check the password
		for ( i;i<=m_iCallerNumber;i++)
		{
			if(callerinfoofch[ChannelNo].m_callerid==callerinfo[i].m_callerid)
				if(callerinfoofch[ChannelNo].m_password==callerinfo[i].m_password)
				{
					bcheck=TRUE;
					m_djcard.PlayFile(ChannelNo,"dutytype.voc");
				}
		}
		if(!bcheck)//password error ,hook on
		{
//			callerinfoofch[ChannelNo].m_callerid.Empty();
//			callerinfoofch[ChannelNo].m_password.Empty();
			channelstatus[ChannelNo].step--;
//			channelstatus[ChannelNo].used=0;
//			m_strRecDTMF[ChannelNo].Empty();
			m_djcard.PlayFile(ChannelNo,"errorpassword.voc");
//			m_dmfax.SetChProCtrl(ChannelNo,0);//hook on

//			ResetChannel(ChannelNo);
		}
		break;

	case 3 ://set the duty
		if((m_strRecDTMF[ChannelNo].GetLength()!=1)&&(m_strRecDTMF[ChannelNo]!="*9*"))
			this->ResetChannel(ChannelNo);
	
		if(m_strRecDTMF[ChannelNo]=="1"||m_strRecDTMF[ChannelNo]=="*9*")//call cost query
		{
			m_strDuty[ChannelNo]=m_strRecDTMF[ChannelNo];
			m_strRecDTMF[ChannelNo].Empty();
			channelstatus[ChannelNo].step++;
			m_djcard.PlayFile(ChannelNo,"costtype.voc");
			break;
		}
		

⌨️ 快捷键说明

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