C源码飞机订票系统.docx
- 文档编号:4354776
- 上传时间:2022-11-30
- 格式:DOCX
- 页数:14
- 大小:17.75KB
C源码飞机订票系统.docx
《C源码飞机订票系统.docx》由会员分享,可在线阅读,更多相关《C源码飞机订票系统.docx(14页珍藏版)》请在冰豆网上搜索。
C源码飞机订票系统
//飞机票定票和退票系统Dlg.cpp
#include"stdafx.h"
#include"飞机票定票和退票系统.h"
#include"飞机票定票和退票系统Dlg.h"
#include"string.h"
#include"stdlib.h"
#include"compare.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//CAboutDlgdialogusedforAppAbout
classCAboutDlg:
publicCDialog
{
public:
CAboutDlg();
//DialogData
//{{AFX_DATA(CAboutDlg)
enum{IDD=IDD_ABOUTBOX};
//}}AFX_DATA
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport
//}}AFX_VIRTUAL
//Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg:
:
CAboutDlg():
CDialog(CAboutDlg:
:
IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
voidCAboutDlg:
:
DoDataExchange(CDataExchange*pDX)
{
CDialog:
:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//Nomessagehandlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CMyDlgdialog
CMyDlg:
:
CMyDlg(CWnd*pParent/*=NULL*/)
:
CDialog(CMyDlg:
:
IDD,pParent)
{
//{{AFX_DATA_INIT(CMyDlg)
m_remain=_T("");
m_passenger=_T("");
m_pt=_T("");
m_destinenum=_T("");
m_ticketnum=0;
//}}AFX_DATA_INIT
//NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32
m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
voidCMyDlg:
:
DoDataExchange(CDataExchange*pDX)
{
CDialog:
:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyDlg)
DDX_Control(pDX,IDC_COMBO_fly,m_fly);
DDX_Control(pDX,IDC_EDIT_information,m_information);
DDX_Control(pDX,IDC_EDIT_p_information,m_p_information);
DDX_Control(pDX,IDC_EDIT_name,m_name);
DDX_Control(pDX,IDC_EDIT_destination,m_destination);
DDX_Text(pDX,IDC_EDIT_remain,m_remain);
DDX_Text(pDX,IDC_EDIT_passenger,m_passenger);
DDX_Text(pDX,IDC_EDIT_pt,m_pt);
DDX_Text(pDX,IDC_EDIT__destinenum,m_destinenum);
DDX_Text(pDX,IDC_EDIT_ticketnum,m_ticketnum);
DDV_MinMaxInt(pDX,m_ticketnum,0,100);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMyDlg,CDialog)
//{{AFX_MSG_MAP(CMyDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_OK,OnButtonOk)
ON_BN_CLICKED(IDC_BUTTON_CANCEL,OnButtonCancel)
ON_CBN_SELCHANGE(IDC_COMBO_fly,OnSelchangeCOMBOfly)
ON_EN_CHANGE(IDC_EDIT_ticketnum,OnChangeEDITticketnum)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CMyDlgmessagehandlers
BOOLCMyDlg:
:
OnInitDialog()
{
CDialog:
:
OnInitDialog();
//Add"About..."menuitemtosystemmenu.
//IDM_ABOUTBOXmustbeinthesystemcommandrange.
ASSERT((IDM_ABOUTBOX&0xFFF0)==IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX<0xF000);
CMenu*pSysMenu=GetSystemMenu(FALSE);
if(pSysMenu!
=NULL)
{
CStringstrAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if(!
strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);
}
}
//Settheiconforthisdialog.Theframeworkdoesthisautomatically
//whentheapplication'smainwindowisnotadialog
SetIcon(m_hIcon,TRUE);//Setbigicon
SetIcon(m_hIcon,FALSE);//Setsmallicon
//TODO:
Addextrainitializationhere
totlep=0;
destinenum=0;
m_ticketnum=1;
totle[0]=100;totle[1]=100;totle[2]=100;
remain[0]=100;remain[1]=100;remain[2]=100;
now[0]=0;now[1]=0;now[2]=0;
m_fly.AddString("CF_101");
m_fly.AddString("CF_108");
m_fly.AddString("CF_134");
m_fly.SelectString(-1,"CF_101");
fly=0;
m_remain.Format("%d",remain[0]);
m_passenger.Format("%d",now[1]);
m_pt.Format("%d",totlep);
m_destinenum.Format("%d",destinenum);
m_destination.SetSel(0,-1);
m_destination.ReplaceSel("武汉");
UpdateData(0);
returnTRUE;//returnTRUEunlessyousetthefocustoacontrol
}
voidCMyDlg:
:
OnSysCommand(UINTnID,LPARAMlParam)
{
if((nID&0xFFF0)==IDM_ABOUTBOX)
{
CAboutDlgdlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog:
:
OnSysCommand(nID,lParam);
}
}
//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow
//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,
//thisisautomaticallydoneforyoubytheframework.
voidCMyDlg:
:
OnPaint()
{
if(IsIconic())
{
CPaintDCdc(this);//devicecontextforpainting
SendMessage(WM_ICONERASEBKGND,(WPARAM)dc.GetSafeHdc(),0);
//Centericoninclientrectangle
intcxIcon=GetSystemMetrics(SM_CXICON);
intcyIcon=GetSystemMetrics(SM_CYICON);
CRectrect;
GetClientRect(&rect);
intx=(rect.Width()-cxIcon+1)/2;
inty=(rect.Height()-cyIcon+1)/2;
//Drawtheicon
dc.DrawIcon(x,y,m_hIcon);
}
else
{
CDialog:
:
OnPaint();
}
}
//Thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags
//theminimizedwindow.
HCURSORCMyDlg:
:
OnQueryDragIcon()
{
return(HCURSOR)m_hIcon;
}
voidCMyDlg:
:
OnCancel()
{
//TODO:
Addextracleanuphere
CDialog:
:
OnCancel();
}
voidCMyDlg:
:
OnButtonOk()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
m_destination.GetWindowText(p[destinenum].destination,20);
m_name.GetWindowText(p[destinenum].name,20);
m_fly.GetWindowText(p[destinenum].fly,20);
p[destinenum].ticketnum=m_ticketnum;
intRADIO;
RADIO=GetCheckedRadioButton(IDC_RADIO_man,IDC_RADIO_woman);
p[destinenum].sex=RADIO;
if(remain[fly]>=m_ticketnum&&m_name.GetWindowText(p[totlep].name,20)&&m_destination.GetWindowText(p[totlep].destination,20)&&(RADIO==IDC_RADIO_man||RADIO==IDC_RADIO_woman))
{
totlep+=m_ticketnum;
destinenum++;
now[fly]+=m_ticketnum;
remain[fly]-=m_ticketnum;
m_passenger.Format("%d",(now[fly]));
m_remain.Format("%d",(remain[fly]));
m_pt.Format("%d",totlep);
m_destinenum.Format("%d",destinenum);
//m_p_information.SetSel(0,-1);
//m_p_information.ReplaceSel(p[now].destination);
//m_p_information.ReplaceSel("");
//if(RADIO==IDC_RADIO_man)m_p_information.ReplaceSel("男");
//elseif(RADIO==IDC_RADIO_woman)m_p_information.ReplaceSel("女");
//m_p_information.ReplaceSel(p[now].name);
m_information.SetSel(0,-1);
m_information.ReplaceSel("定票成功");
UpdateData(0);
}
elseif(remain[fly] { m_information.SetSel(0,-1); if(fly==1) { m_information.ReplaceSel("当前航线的票数已不能满足,定票失败"); } elseif(fly==0) { if(remain[2]>=m_ticketnum) m_information.ReplaceSel("当前航线的票数已不能满足,订票失败CF_134次航班能满足您的要求,请订CF_134次航班"); elsem_information.ReplaceSel("当前航线的票数已不能满足,定票失败"); } elseif(fly==2) { if(remain[0]>=m_ticketnum) m_information.ReplaceSel("当前航线的票数已不能满足,订票失败CF_101次航班能满足您的要求,请订CF_101次航班"); elsem_information.ReplaceSel("当前航线的票数已不能满足,定票失败"); } UpdateData(0); } else { m_information.SetSel(0,-1); m_information.ReplaceSel("乘客信息填写不完整,定票失败"); UpdateData(0); } if(now[fly]>100) { m_information.SetSel(0,-1); m_information.ReplaceSel("机票已售完,请选择其他航线"); now[fly]=100; remain[fly]=100; } m_p_information.SetSel(0,-1); m_p_information.ReplaceSel(""); qsort((void*)p,destinenum,sizeof(p[1]),compare); for(inti=0;i { m_p_information.SetSel(-1,0); m_p_information.ReplaceSel(p[i].name); m_p_information.ReplaceSel(""); if(p[i].sex==IDC_RADIO_man)m_p_information.ReplaceSel("男"); elseif(p[i].sex==IDC_RADIO_woman)m_p_information.ReplaceSel("女"); m_p_information.ReplaceSel(p[i].destination); m_p_information.ReplaceSel(""); m_p_information.ReplaceSel(p[i].fly); m_p_information.ReplaceSel(""); chartemp[10]; _gcvt(p[i].ticketnum,10,temp); m_p_information.ReplaceSel(temp); m_p_information.ReplaceSel("\n"); //m_p_information.FmtLines(NULL); } UpdateData(0); } voidCMyDlg: : OnButtonCancel() { //TODO: Addyourcontrolnotificationhandlercodehere chartemp_name[20]; inttemp_sex; chartemp_destination[20]; m_destination.GetWindowText(temp_destination,20); m_name.GetWindowText(temp_name,20); temp_sex=GetCheckedRadioButton(IDC_RADIO_man,IDC_RADIO_woman); if(now[fly]==0) { m_information.SetSel(0,-1); m_information.ReplaceSel("当前无人定票,退票失败"); } else { for(inti=0;i { if(strcmp(p[i].destination,temp_destination)==0) { if(strcmp(p[i].name,temp_name)==0) { if(p[i].sex==temp_sex&&p[i].ticketnum==m_ticketnum) { //addyourcodehere for(intj=i;j { p[j]=p[j+1]; } now[fly]-=m_ticketnum; remain[fly]+=m_ticketnum; totlep-=m_ticketnum; destinenum--; m_passenger.Format("%d",(now[fly])); m_remain.Format("%d",(remain[fly])); m_destinenum.Format("%d",destinenum); m_pt.Format("%d",totlep); m_information.SetSel(0,-1); m_information.ReplaceSel("退票成功"); break; } elseif(p[i].sex! =temp_sex) { m_information.SetSel(0,-1); m_information.ReplaceSel("查无此记录,退票失败"); } elseif(p[i].ticketnum>m_ticketnum) { now[fly]-=m_ticketnum; remain[fly]+=m_ticketnum; totlep-=m_ticketnum; p[i].ticketnum-=m_ticketnum; m_passenger.Format("%d",(now[fly])); m_remain.Format("%d",(remain[fly])); m_pt.Format("%d",totlep); m_information.SetSel(0,-1); m_information.ReplaceSel("退票成功"); } elseif(p[i].ticketnum { m_information.SetSel(0,-1); m_information.ReplaceSel("此乘客所定票数少于所输入的票数,退票失败"); } } else { m_information.SetSel(0,-1); m_information.ReplaceSel("查无此记录,退票失败");
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 源码 飞机 订票 系统
![提示](https://static.bdocx.com/images/bang_tan.gif)