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

📄 gas.cpp

📁 一个模仿ATM提款机的MFC程序
💻 CPP
字号:
// GAS.cpp : implementation file
//
#include "stdafx.h"
#include "ATM.h"
#include "GAS.h"
#include "GasUser.h"
#include "Ref.h"

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

////////////////////煤气用户/////////////////////////////////////////////////////////
// GAS dialog


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


void GAS::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(GAS)
	DDX_Control(pDX, IDC_EDIT1, m_gasEdit);
	DDX_Text(pDX, IDC_EDIT1, m_gas);
	//}}AFX_DATA_MAP
	SetTimer(0,15000,NULL);
	
}


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

/////////////////////////////////////////////////////////////////////////////
// GAS message handlers
// Phoneno.cpp : implementation file
//


void GAS::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

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

void GAS::OnOK() 
{
	// TODO: Add extra validation here
	



	KillTimer(0);
	CSuggest suggestdlg;
	UpdateData(TRUE);
	
	
	if(CurrentAcnt *pCyrntAcnt=CurrentAcnt::searchAccount(CEnterPaswd::m_password))  //搜寻检测用户密码
	{
		if(CGasuser* ptCPhoneU=CGasuser::searchgasuser(m_gas))  //搜索检测用户
		{	
			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_gas="";
	UpdateData(FALSE);

	

}
void GAS::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 GAS::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 + -