?? 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
#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 + -