📄 queuedlg.cpp
字号:
// QueueDlg.cpp : implementation file
//
#include "stdafx.h"
#include "AviationBS.h"
#include "QueueDlg.h"
#include "UsedLine.h"
#include "Client.h"
#include "Queue.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern UsedLine usedLine;
extern CClient client;
extern Queue queue;
extern int Index[5];
/////////////////////////////////////////////////////////////////////////////
// CQueueDlg dialog
CQueueDlg::CQueueDlg(CWnd* pParent /*=NULL*/)
: CDialog(CQueueDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CQueueDlg)
m_name = _T("");
m_ID = _T("");
m_FC = 0;
m_TC = 0;
//}}AFX_DATA_INIT
}
BOOL CQueueDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//写入客户欲排队候票的航班的信息
m_check.SetCheck(BST_CHECKED);
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(' ');
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].FirCNum);
m_FCCtrl.SetWindowText(str);
m_FCCtrl.SetReadOnly();
str.Format("%d",usedLine.flightArray[LineIndex].flight[FlightIndex].TouCNum);
m_TCCtrl.SetWindowText(str);
m_TCCtrl.SetReadOnly();
return TRUE;
}
void CQueueDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CQueueDlg)
DDX_Control(pDX, IDC_CHECK1, m_check);
DDX_Control(pDX, IDC_TCEDIT, m_TCCtrl);
DDX_Control(pDX, IDC_FCEDIT, m_FCCtrl);
DDX_Control(pDX, IDC_EDIT2, m_FlyTimeCtrl);
DDX_Control(pDX, IDC_EDIT3, m_FCtrl);
DDX_Control(pDX, IDC_EDIT1, m_LineCtrl);
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_FC);
DDV_MinMaxInt(pDX, m_FC, 0, 1000);
DDX_Text(pDX, IDC_TCNUM, m_TC);
DDV_MinMaxInt(pDX, m_TC, 0, 1000);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CQueueDlg, CDialog)
//{{AFX_MSG_MAP(CQueueDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CQueueDlg message handlers
void CQueueDlg::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_FC==0&&m_TC == 0){MessageBox("请输入你需要的票数!");return;}
int LineIndex=Index[6]; //所选航线的下标及航班下标
int FlightIndex=Index[7];
if(usedLine.flightArray[LineIndex].flight[FlightIndex].FirCNum<m_FC ||
usedLine.flightArray[LineIndex].flight[FlightIndex].TouCNum<m_TC)
{
MessageBox("你所订的票数已超过总票数,请重新调整!");
return;
}
if(m_FC<=usedLine.flightArray[LineIndex].flight[FlightIndex].FirCFreeNum&&
m_TC<=usedLine.flightArray[LineIndex].flight[FlightIndex].TouCFreeNum)
{MessageBox("你需要的票数小于该航班空余票,请按【取消】退出后按【订票】进行订票!");return;}
//进行排队登记
bool Try=false;
if(m_check.GetCheck()==1)Try=true;
int dayInWeek=usedLine.flightArray[LineIndex].flight[FlightIndex].FlyTime.GetDayOfWeek()-1;
queue.queueData[dayInWeek].LineLink[LineIndex].insert(
usedLine.flightArray[LineIndex].flight[FlightIndex].FlyTime,
m_name,m_ID,m_FC,m_TC,Try);
queue.queueData[dayInWeek].isChange=true; //客户信息已经更改
MessageBox("你好,你已经成功填写排队登记表!一有空余票,我们会马上通知你!");
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -