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

📄 telephone.cpp

📁 一个模仿ATM提款机的MFC程序
💻 CPP
字号:
// TELEPHONE.cpp : implementation file
//

#include "stdafx.h"
#include "atm.h"
#include "TELEPHONE.h"
#include "TelephoneUser.h"
#include "Ref.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

////////////////////////////电话用户/////////////////////////////////////////////////
// TELEPHONE dialog


TELEPHONE::TELEPHONE(CWnd* pParent /*=NULL*/)
	: CDialog(TELEPHONE::IDD, pParent)
{
	//{{AFX_DATA_INIT(TELEPHONE)
	m_TELEPHONE = _T("");
	//}}AFX_DATA_INIT
}


void TELEPHONE::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(TELEPHONE)
	DDX_Control(pDX, IDC_EDIT1, m_TELEPHONEEDIT);
	DDX_Text(pDX, IDC_EDIT1, m_TELEPHONE);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(TELEPHONE, CDialog)
	//{{AFX_MSG_MAP(TELEPHONE)
	ON_BN_CLICKED(IDCORRECT, OnCorrect)
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// TELEPHONE message handlers

void TELEPHONE::OnCorrect() 
{
	// TODO: Add your control notification handler code here
	m_TELEPHONEEDIT.SetWindowText("");
}

void TELEPHONE::OnOK() 
{
	// TODO: Add extra validation here
	KillTimer(0);
	CSuggest suggestdlg;
	UpdateData(TRUE);
	
	
	if(CurrentAcnt *pCyrntAcnt=CurrentAcnt::searchAccount(CEnterPaswd::m_password))  //搜寻检测用户密码
	{
		if(TelephoneUser* ptCPhoneU=TelephoneUser::searchtelephoneuser(m_TELEPHONE))  //搜索检测电话用户
		{	
			double remain=pCyrntAcnt->AcntBalan();
			double pcost=ptCPhoneU->Getcost();
			if(pcost>remain)    //余额不足
			{
				suggestdlg.m_suggest="余额不足";
				suggestdlg.DoModal();
			}
			else    //交费成功
			{
				remain-=pcost;
				pCyrntAcnt->reloadbalance(remain);
				ptCPhoneU->reloadcost(0);  //话费清零
				CPrint2 print2dlg;         //打印凭条
				print2dlg.DoModal();
				CDialog::OnOK();
				Ref ref;
				ref.Refresh(pCyrntAcnt->GetacntNo(),remain,pcost,"固定电话交费");
				
			}
		}
		else            //查无此号
		{
			suggestdlg.m_suggest="查无此号";
			suggestdlg.DoModal();
		}
	}
	else             
	{
		CPassworderror passerrordlg;  //密码错误
		passerrordlg.DoModal();
		CEnterPaswd  enterpaswdlg;
		enterpaswdlg.m_password="";   //重输密码
		enterpaswdlg.DoModal();
		CDialog::OnOK();
	}
	
	m_TELEPHONE="";
	UpdateData(FALSE);
	
	
}
void TELEPHONE::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	Beep(1000,500);
	KillTimer(0);
	CAlarm alarmdlg;
	alarmdlg.DoModal();
	
	CDialog::OnTimer(nIDEvent);
}
BOOL TELEPHONE::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	switch(pMsg->message)
	{
	case WM_KEYUP:SetTimer(0,15000,NULL);break;
	case WM_KEYDOWN:KillTimer(0);break;
	}
	
	return CDialog::PreTranslateMessage(pMsg);
}

⌨️ 快捷键说明

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