?? dealwithqueue.cpp
字號:
// DealWithQueue.cpp : implementation file
//
#include "stdafx.h"
#include "AviationBS.h"
#include "DealWithQueue.h"
#include "UsedLine.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// DealWithQueue dialog
extern int Index[8];
extern UsedLine usedLine;
extern CClient client;
extern Queue queue;
DealWithQueue::DealWithQueue(CWnd* pParent /*=NULL*/)
: CDialog(DealWithQueue::IDD, pParent)
{
//{{AFX_DATA_INIT(DealWithQueue)
m_fc = 0;
m_tc = 0;
//}}AFX_DATA_INIT
}
BOOL DealWithQueue::OnInitDialog()
{
CDialog::OnInitDialog();
//把航班信息和排隊候票客戶的信息,在控件上顯示出來
CString str;
str.Format("%s",QElem->queuer.name);
str=str.Left(20);
str.Remove(' ');
m_nameCtrl.SetWindowText(str);//姓名
m_nameCtrl.SetReadOnly();
str.Format("%s",QElem->queuer.ID);
str=str.Left(20);
str.Remove(' ');
m_idCtrl.SetWindowText(str);//身份證號
m_idCtrl.SetReadOnly();
str.Format("%s",usedLine.lineArray[Index[6]].destination);
str=str.Left(10);
str.Remove(' ');
m_lineCtrl.SetWindowText(str);//目的地
m_lineCtrl.SetReadOnly();
str.Format("%d年%d月%d日-%d時%d分%d秒",Qlink->qFlight[Index[2]].FlyTime.GetYear(),
Qlink->qFlight[Index[2]].FlyTime.GetMonth(),Qlink->qFlight[Index[2]].FlyTime.GetDay(),
Qlink->qFlight[Index[2]].FlyTime.GetHour(),Qlink->qFlight[Index[2]].FlyTime.GetMinute(),
Qlink->qFlight[Index[2]].FlyTime.GetSecond());
m_timeCtrl.SetWindowText(str); //起飛時間
m_timeCtrl.SetReadOnly();
str.Format("%s",usedLine.flightArray[Index[6]].flight[Index[7]].PlaneNum);
str=str.Left(6);
str.Remove(' ');
m_planeCtrl.SetWindowText(str); //航班號
m_planeCtrl.SetReadOnly();
str.Format("%d",QElem->queuer.FCNum);
m_fcCtrl.SetWindowText(str); //所需的頭等艙票數
str.Format("%d",QElem->queuer.TCNum);
m_tcCtrl.SetWindowText(str); //所需的經濟艙票數
str.Format("%d",Index[0]);
m_fcRestCtrl.SetWindowText(str); //頭等艙剩余票數
m_fcRestCtrl.SetReadOnly();
str.Format("%d",Index[1]);
m_tcRestCtrl.SetWindowText(str); //經濟艙剩余票數
m_tcRestCtrl.SetReadOnly();
return true;
}
void DealWithQueue::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DealWithQueue)
DDX_Control(pDX, IDC_TIMEEDIT, m_timeCtrl);
DDX_Control(pDX, IDC_TCRESTEDIT, m_tcRestCtrl);
DDX_Control(pDX, IDC_TCEDIT1, m_tcCtrl);
DDX_Control(pDX, IDC_PLANENUMEDIT, m_planeCtrl);
DDX_Control(pDX, IDC_LINEEDIT, m_lineCtrl);
DDX_Control(pDX, IDC_FCRESTEDIT, m_fcRestCtrl);
DDX_Control(pDX, IDC_FCEDIT, m_fcCtrl);
DDX_Control(pDX, IDC_IDEDIT, m_idCtrl);
DDX_Control(pDX, IDC_NAME, m_nameCtrl);
DDX_Text(pDX, IDC_FCEDIT, m_fc);
DDV_MinMaxInt(pDX, m_fc, 0, 1000);
DDX_Text(pDX, IDC_TCEDIT1, m_tc);
DDV_MinMaxInt(pDX, m_tc, 0, 1000);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(DealWithQueue, CDialog)
//{{AFX_MSG_MAP(DealWithQueue)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DealWithQueue message handlers
void DealWithQueue::Exchange(BuildQLink* qbuildLink,QLink* qtemp,Link* ctemp)
{ Qlink=qbuildLink;QElem=qtemp;CElem=ctemp;}
void DealWithQueue::OnOK()
{
// TODO: Add extra validation here
UpdateData();
int fc,tc;//訂票的數量
//當空閑票不能滿足要求時,IDNO表示買下空閑票并繼續排隊,IDYES表示買下票后不排隊,IDCANCEL取消操作
int isOut=-100;
if(m_fc>usedLine.flightArray[Index[6]].flight[Index[7]].FirCNum
|| m_tc>usedLine.flightArray[Index[6]].flight[Index[7]].TouCNum)
{MessageBox("你需要的票數超過了總票數,請重新輸入!");return;}
if(m_fc>Index[0] || m_tc>Index[1])
isOut=MessageBox("你需要的票數大于空閑票數,按Yes訂下現有的空閑票不排隊,按No訂下票并繼續排隊,按Cancel退出不進行操作!",
"SmartBoy",MB_ICONQUESTION|MB_YESNOCANCEL);
if(IDCANCEL==isOut)return; //退出不進行操作
else
{
fc=m_fc<Index[0]?m_fc:Index[0];//訂票的數量
tc=m_tc<Index[1]?m_tc:Index[1];
QElem->queuer.FCNum=m_fc-fc;//處理排隊客戶的票數
QElem->queuer.TCNum=m_tc-tc;
Index[0]-=fc;//處理剩余票數
Index[1]-=tc;
}
//將客戶加入訂票客戶信息
int ret=CElem->insert(QElem->queuer.name,QElem->queuer.ID,
Qlink->qFlight[Index[2]].FlyTime,fc,tc);
if(ret==1)MessageBox("訂票成功!");
else if(ret==0)MessageBox("你之前已經訂過該航班的機票,已經把剛剛訂的票數加入到你的名下!");
else MessageBox("訂票失敗,原因是你在排隊時已經輸入的身份證號跟你所訂的航班出現相同,但名字不同!");
//IDNO的情況已在上邊處理過,剩下IDYES和空閑票能滿足要求時的情況,需將客戶信息從隊列里面刪除
if(IDYES==isOut || -100==isOut)
{
//將客戶信息從隊列里面刪除
QLink* temp=QElem;
QElem=NULL;
Qlink->remove(temp,Index[2]); //Index[2]指出所要刪除的結點屬于哪個航班
}
queue.queueData[Index[3]].isChange=true;
CDialog::OnOK();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -