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

📄 bookingdlg.cpp

📁 航空订票系统 学校大作业开发的
💻 CPP
字号:
// BookingDlg.cpp : implementation file
//

#include "stdafx.h"
#include "AviationBS.h"
#include "BookingDlg.h"
#include "UsedLine.h"
#include "Client.h"
#include "QueueDlg.h"

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

extern UsedLine usedLine;
extern CClient  client;
extern int Index[5];
/////////////////////////////////////////////////////////////////////////////
// CBookingDlg dialog


CBookingDlg::CBookingDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CBookingDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CBookingDlg)
	m_name = _T("");
	m_ID = _T("");
	m_FCBookingN = 0;
	m_TCBookingN = 0;
	//}}AFX_DATA_INIT
}

BOOL CBookingDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	int LineIndex=Index[6];
	int FlightIndex=Index[7];
	CString str,str1;
	str.Format("%s",usedLine.lineArray[LineIndex].destination);
	str=str.Left(10);
	str.Remove(' ');
	m_LineCtrl.SetWindowText(str);
	m_LineCtrl.SetReadOnly();
	str.Format("%s",usedLine.flightArray[LineIndex].flight[FlightIndex].PlaneNum);
	str=str.Left(6);
    str.Remove(' ');//MessageBox(str1);
    m_FCtrl.SetWindowText(str);
    m_FCtrl.SetReadOnly();
	str.Format("%d:%d:%d",usedLine.flightArray[LineIndex].flight[FlightIndex].FlyTime.GetHour(),
		  usedLine.flightArray[LineIndex].flight[FlightIndex].FlyTime.GetMinute(),
		  usedLine.flightArray[LineIndex].flight[FlightIndex].FlyTime.GetSecond());
	m_FlyTimeCtrl.SetWindowText(str);
    m_FlyTimeCtrl.SetReadOnly();
	str.Format("%d",usedLine.flightArray[LineIndex].flight[FlightIndex].FirCFreeNum);
	m_FCFreeNum.SetWindowText(str);
	m_FCFreeNum.SetReadOnly();
	str.Format("%d",usedLine.flightArray[LineIndex].flight[FlightIndex].TouCFreeNum);
	m_TCFreeNum.SetWindowText(str);
	m_TCFreeNum.SetReadOnly();
    return TRUE;
}

void CBookingDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CBookingDlg)
	DDX_Control(pDX, IDC_EDIT3, m_FCtrl);
	DDX_Control(pDX, IDC_EDIT2, m_FlyTimeCtrl);
	DDX_Control(pDX, IDC_EDIT1, m_LineCtrl);
	DDX_Control(pDX, IDC_TCEDIT, m_TCFreeNum);
	DDX_Control(pDX, IDC_FCEDIT, m_FCFreeNum);
	DDX_Text(pDX, IDC_NAMEEDIT, m_name);
	DDV_MaxChars(pDX, m_name, 20);
	DDX_Text(pDX, IDC_IDEDIT, m_ID);
	DDV_MaxChars(pDX, m_ID, 20);
	DDX_Text(pDX, IDC_FCNUM, m_FCBookingN);
	DDV_MinMaxInt(pDX, m_FCBookingN, 0, 1000);
	DDX_Text(pDX, IDC_TCNUM, m_TCBookingN);
	DDV_MinMaxInt(pDX, m_TCBookingN, 0, 1000);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CBookingDlg, CDialog)
	//{{AFX_MSG_MAP(CBookingDlg)
	ON_BN_CLICKED(IDC_BUTTON1, OnQueue)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBookingDlg message handlers

void CBookingDlg::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData();
    m_ID.Remove(' ');
    m_name.Remove(' ');	
	if(m_name.IsEmpty()!=0){MessageBox("请输入您的姓名!");return;}
	if(m_ID.IsEmpty()!=0){MessageBox("请输入身份证号码!");return;}
	 else for(int i=0;i<m_ID.GetLength();i++)
		 if(m_ID.GetAt(i)>'9'||m_ID.GetAt(i)<'0'){MessageBox("身份证号码不能为字符");return;}
	if(	m_FCBookingN ==0&&m_TCBookingN == 0){MessageBox("请输入你要预定的票数!");return;}
	int LineIndex=Index[6];
	int FlightIndex=Index[7];
	if(usedLine.flightArray[LineIndex].flight[FlightIndex].FirCFreeNum<m_FCBookingN ||
		usedLine.flightArray[LineIndex].flight[FlightIndex].TouCFreeNum<m_TCBookingN)
	{
		MessageBox("你所订的票数已超过余额数,请确定返回订票窗口调整票数或者按<排队候票>等待!");
			  return;
	}
	///////////////////////////////进行订票操作//////////////////////////////////////
	//客户信息登记
	int temp=client.InsertClient(m_name,m_ID,usedLine.flightArray[LineIndex].flight[FlightIndex].FlyTime,
		   m_FCBookingN,m_TCBookingN,LineIndex);
    if(-1==temp)
	   {MessageBox("你已经订了该去同一地点的其他航班的票或者身份证号与他人重复,请重新输入身份证号!");return;}
	 else if(0==temp)
		 MessageBox("你之前已定阅了该航班的票,已把你现在的订的票加到同一账号!");
	 else {MessageBox("恭喜你,订票成功!");}
	//修改航线信息
    usedLine.flightArray[LineIndex].flight[FlightIndex].FirCFreeNum-=m_FCBookingN;
	usedLine.flightArray[LineIndex].flight[FlightIndex].TouCFreeNum-=m_TCBookingN;
	CDialog::OnOK();
}

void CBookingDlg::OnQueue() 
{
	// TODO: Add your control notification handler code here
	CQueueDlg Dlg;
	Dlg.DoModal();
	CDialog::OnOK();
}

⌨️ 快捷键说明

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