📄 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 + -