📄 keshe_flightview.cpp
字号:
// Keshe_flightView.cpp : implementation of the CKeshe_flightView class
//
#include "stdafx.h"
#include "Keshe_flight.h"
#include "Keshe_flightDoc.h"
#include "Keshe_flightView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CKeshe_flightView
#include "dingpiaodlg.h"
#include "TuiPiaoDlg.h"
IMPLEMENT_DYNCREATE(CKeshe_flightView, CView)
BEGIN_MESSAGE_MAP(CKeshe_flightView, CView)
//{{AFX_MSG_MAP(CKeshe_flightView)
ON_WM_SIZE()
ON_COMMAND(IDM_DINGPIAO, OnDingpiao)
ON_UPDATE_COMMAND_UI(IDM_DINGPIAO, OnUpdateDingpiao)
ON_COMMAND(IDM_HANGBAN_CHAXUN, OnHangbanChaxun)
ON_UPDATE_COMMAND_UI(IDM_HANGBAN_CHAXUN, OnUpdateHangbanChaxun)
ON_COMMAND(IDM_CHENGKE_LIEBIAO, OnChengkeLiebiao)
ON_UPDATE_COMMAND_UI(IDM_CHENGKE_LIEBIAO, OnUpdateChengkeLiebiao)
ON_COMMAND(IDM_TUIPIAO, OnTuipiao)
ON_UPDATE_COMMAND_UI(IDM_TUIPIAO, OnUpdateTuipiao)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CKeshe_flightView construction/destruction
CKeshe_flightView::CKeshe_flightView()
{
// TODO: add construction code here
cus=m_flight.start_cus();
air=m_flight.start_air();
m_flight.creat_air(&air);
m_flight.creat_cus(&cus);
m_bShowView=TRUE;
m_first=TRUE;
}
CKeshe_flightView::~CKeshe_flightView()
{
m_ListCtrl.DestroyWindow();
}
BOOL CKeshe_flightView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CKeshe_flightView drawing
void CKeshe_flightView::OnDraw(CDC* pDC)
{
CKeshe_flightDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CKeshe_flightView printing
BOOL CKeshe_flightView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CKeshe_flightView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CKeshe_flightView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CKeshe_flightView diagnostics
#ifdef _DEBUG
void CKeshe_flightView::AssertValid() const
{
CView::AssertValid();
}
void CKeshe_flightView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CKeshe_flightDoc* CKeshe_flightView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CKeshe_flightDoc)));
return (CKeshe_flightDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CKeshe_flightView message handlers
void CKeshe_flightView::OnInitialUpdate()
{
CView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
CRect rt;
this->GetClientRect(rt);
DWORD dwStyle=LVS_ALIGNLEFT
|LVS_SHOWSELALWAYS|WS_VISIBLE|LVS_OWNERDRAWFIXED|LVS_REPORT;
m_ListCtrl.Create(this,rt,IDC_LISTCTRL);
m_ListCtrl.ShowWindow(SW_SHOW);
}
void CKeshe_flightView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
CRect rect(0,0,cx,cy);
if(m_ListCtrl.GetSafeHwnd())
m_ListCtrl.MoveWindow(rect);
}
/**********订票************/
void CKeshe_flightView::OnDingpiao()
{
// TODO: Add your command handler code here
CDingPiaoDlg dlg;
if(dlg.DoModal()==IDOK)
{
if (!(dlg.m_dingpiao_hangbanhao.IsEmpty()|dlg.m_dingpiao_name.IsEmpty()))
{
int m_b=m_flight.book(air,(LPTSTR)(LPCTSTR)dlg.m_dingpiao_hangbanhao,cus,(LPTSTR)(LPCTSTR)dlg.m_dingpiao_name);
if(m_b==1)
{
AfxMessageBox("订票成功!");
if(!m_bShowView)
{
customer *p=cus->next;
UpdateCusView(p);
}
else
{
airline *a=air->next;
UpdateAirLineView(a);
}
}
else
if(m_b==0)
AfxMessageBox("票已售完!");
else
if(m_b==2)
AfxMessageBox("没有此航班号!");
else
AfxMessageBox("此乘客已订票!");
}
else AfxMessageBox("请确认无空输入....");
}
}
void CKeshe_flightView::OnUpdateDingpiao(CCmdUI* pCmdUI)
{
}
/*************退票*************/
void CKeshe_flightView::OnTuipiao()
{
// TODO: Add your command handler code here
CTuiPiaoDlg dlg;
if (dlg.DoModal()==IDOK)
{
if (!(dlg.m_strTuipiao.IsEmpty()))
{
if (m_flight.del_cus(cus,air,(LPTSTR)(LPCTSTR)dlg.m_strTuipiao))
{
AfxMessageBox("退票成功!");
if(!m_bShowView)
{
customer *p=cus->next;
UpdateCusView(p);
}
else
{
airline *a=air->next;
UpdateAirLineView(a);
}
}
else
AfxMessageBox("无此乘客!");
}
else AfxMessageBox("请确认输入姓名....");
}
}
/**********航班查询************/
void CKeshe_flightView::OnHangbanChaxun()
{
// TODO: Add your command handler code here
airline *p=air->next;
m_bOld=m_bShowView;
m_bShowView=TRUE;
//第一次判断
if (m_first)
{
UpdateAirLineView(p);
m_first=FALSE;
}
//和前一次状态比较,相同状态则不刷新
if(!(m_bShowView&m_bOld))
{
m_ListCtrl.ChangeColumn(m_bShowView,m_bOld);
UpdateAirLineView(p);
}
}
void CKeshe_flightView::OnUpdateHangbanChaxun(CCmdUI* pCmdUI)
{
}
void CKeshe_flightView::OnChengkeLiebiao()
{
// TODO: Add your command handler code here
customer *p=cus->next;
m_bOld=m_bShowView;
m_bShowView=FALSE;
if(!(m_bShowView&m_bOld))
{
m_ListCtrl.ChangeColumn(m_bShowView,m_bOld);
UpdateCusView(p);
m_first=FALSE;
}
}
void CKeshe_flightView::OnUpdateChengkeLiebiao(CCmdUI* pCmdUI)
{
}
void CKeshe_flightView::OnUpdateTuipiao(CCmdUI* pCmdUI)
{
}
void CKeshe_flightView::UpdateCusView(customer * c)
{
CString str;
m_ListCtrl.DeleteAllItems();
/************遍历链表***************/
for(;c!=NULL;c=c->next)
{
str.Format("%d",c->seat_num);
m_ListCtrl.AddStr(c->name,c->air_num,str,"","");
}
/*************遍历链表**************/
}
void CKeshe_flightView::UpdateAirLineView(airline *p)
{
CString str_total,str_left;
m_ListCtrl.DeleteAllItems();
for(;p!=NULL;p=p->next)
{
str_total.Format("%d",p->total);
str_left.Format("%d",p->left);
m_ListCtrl.AddStr(p->air_num,p->plane_num,p->end_place,str_total,str_left);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -