课程设计做一个飞机订票系统,c语言实现,功能如下:
录入:
可以录入航班情况(数据可以存储在一个数据文件中,数据结构、具体数据自定)
查询:
可以查询某个航线的情况(如,输入航班号,查询起降时间,起飞抵达城市,航班票价,票价折扣,确定航班是否满仓);
可以输入起飞抵达城市,查询飞机航班情况;
订票:(订票情况可以存在一个数据文件中,结构自己设定)
可以订票,如果该航班已经无票,可以提供相关可选择航班;
退票: 可退票,退票后修改相关数据文件;
客户资料有姓名,证件号,订票数量及航班情况,订单要有编号。
修改航班信息:
当航班信息改变可以修改航班数据文件
要求:
根据以上功能说明,设计航班信息,订票信息的存储结构,设计程序完成功能;
写惯了控制台程序,所以打算做个界面出来,时间也很充裕,于是就自学了windows API,开发环境为vs2013。
代码以及程序已打包,下载地址:http://download.csdn.net/download/u013805360/8213827
下面就开始一步一步晒代码了
下面代码是头文件
// stdafx.h : 标准系统包含文件的包含文件,
// 或是经常使用但不常更改的
// 特定于项目的包含文件
//
#pragma once
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_NON_CONFORMING_SWPRINTFS
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的信息
// Windows 头文件:
#include <windows.h>
// C 运行时头文件
#include <stdlib.h>
#include <math.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <string.h>
#include <stdio.h>
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
#include <SDKDDKVer.h>
// TODO: 在此处引用程序需要的其他头文件
#include<commctrl.h>
#include "resource.h"
#pragma comment(lib, "comctl32.lib")
下面是资源头文件
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
// 供 Flight.rc 使用
//
#define IDC_MYICON 2
#define IDOK2 2
#define IDD_MYHOMEWORK_DIALOG 102
#define IDD_ABOUTBOX 103
#define IDD_LOGINDLG 103
#define IDI_ICON1 128
#define IDB_BITMAP1 133
#define IDR_MAINFRAME 134
#define IDD_MAINDLG 136
#define IDD_NAMEDLG 138
#define IDB_BITMAP2 144
#define IDD_FLTNUM 147
#define IDD_ENTRY 149
#define IDD_MODIFYFLT 150
#define IDC_ID 1002
#define IDC_PASSWORD 1003
#define IDC_IDEDIT 1005
#define IDC_PSWEDIT 1006
#define IDC_LOGIN 1007
#define IDC_REGISTER 1008
#define IDC_IMAGE 1009
#define IDC_GETNAMEOK 1011
#define IDC_GETNAME 1012
#define IDC_GETNAMECANCEL 1014
#define IDC_DEPARTURE 1019
#define IDC_DESTINATION 1020
#define IDC_FLIGHTNUM 1021
#define IDC_FLTNUM 1022
#define IDC_FARE 1023
#define IDC_LANDINGTIME 1024
#define IDC_DATE 1037
#define IDC_SEARCH 1038
#define IDC_TICKET 1039
#define IDC_RETURNTICKET 1040
#define IDC_ENTRY 1041
#define IDC_MODIFYFLIGHT 1042
#define IDC_INFORMATION 1043
#define IDC_TICKETNUM 1044
#define IDC_TAKEOFFTIME 1051
#define IDC_SEATNUM 1053
#define IDC_DISCOUNT 1054
#define IDC_ADDFLT 1055
#define IDC_QUIT 1056
#define IDC_MDFFLTNUM 1058
#define IDC_MDFDATE 1059
#define IDC_MODIFY 1060
#define IDC_STATIC -1
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 152
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1064
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif
资源文件:
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// 中文(简体,中国) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_LOGINDLG DIALOGEX 230, 120, 307, 175
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "登陆"
FONT 9, "MS Shell Dlg", 0, 0, 0x1
BEGIN
CTEXT "身份证号",IDC_ID,99,60,31,8,SS_CENTERIMAGE
CONTROL IDB_BITMAP1,IDC_IMAGE,"Static",SS_BITMAP,14,19,74,103
CTEXT "密码",IDC_PASSWORD,99,87,31,8,SS_CENTERIMAGE
EDITTEXT IDC_IDEDIT,138,58,116,13,ES_AUTOHSCROLL
EDITTEXT IDC_PSWEDIT,138,84,116,13,ES_PASSWORD | ES_AUTOHSCROLL | ES_WANTRETURN
CTEXT "灰机订票系统",IDC_STATIC,105,18,111,24,SS_CENTERIMAGE
DEFPUSHBUTTON "登陆",IDC_LOGIN,139,118,39,17
PUSHBUTTON "注册",IDC_REGISTER,202,118,39,17
END
IDD_MAINDLG DIALOGEX 0, 0, 358, 226
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "飞机订票系统"
FONT 10, "Microsoft YaHei UI", 400, 0, 0x86
BEGIN
CTEXT "欢迎来到飞机订票系统",IDC_STATIC,145,16,67,8
EDITTEXT IDC_DEPARTURE,38,39,57,12,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP
EDITTEXT IDC_DESTINATION,130,39,57,12,ES_AUTOHSCROLL | ES_WANTRETURN
CONTROL "出发地:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,9,41,24,11
CONTROL "目的地:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,102,41,24,11
CONTROL "日期:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,102,70,18,8
CTEXT "航班号:",IDC_STATIC,10,70,26,8
CTEXT "航班信息",IDC_STATIC,16,120,31,8
CONTROL IDB_BITMAP2,IDC_STATIC,"Static",SS_BITMAP,271,27,75,70
EDITTEXT IDC_FLIGHTNUM,38,68,57,12,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP
CONTROL "",IDC_DATE,"SysDateTimePick32",DTS_RIGHTALIGN | WS_TABSTOP,130,68,57,12
DEFPUSHBUTTON "查询",IDC_SEARCH,38,96,33,14
PUSHBUTTON "订票",IDC_TICKET,95,96,33,14
PUSHBUTTON "退票",IDC_RETURNTICKET,152,96,33,14
PUSHBUTTON "航班录入",IDC_ENTRY,229,52,43,15
PUSHBUTTON "修改航班信息",IDC_MODIFYFLIGHT,229,81,43,15
EDITTEXT IDC_INFORMATION,18,131,322,88,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL
END
IDD_NAMEDLG DIALOGEX 0, 0, 260, 116
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "注册"
FONT 9, "Microsoft YaHei UI", 400, 0, 0x86
BEGIN
EDITTEXT IDC_GETNAME,99,47,81,12,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP
CTEXT "请输入用户真实姓名",IDC_STATIC,98,21,63,8
CTEXT "姓名:",IDC_STATIC,61,49,33,11
DEFPUSHBUTTON "确认提交",IDC_GETNAMEOK,78,83,44,16,WS_GROUP
PUSHBUTTON "取消",IDC_GETNAMECANCEL,146,83,44,16
END
IDD_FLTNUM DIALOGEX 0, 0, 181, 87
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "机票数量"
FONT 10, "Microsoft YaHei UI", 400, 0, 0x86
BEGIN
EDITTEXT IDC_TICKETNUM,72,35,37,12,ES_AUTOHSCROLL
CONTROL "机票数量:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,37,37,33,8
DEFPUSHBUTTON "确定",IDOK,126,34,31,13
END
IDD_ENTRY DIALOGEX 0, 0, 266, 153
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "航班录入"
FONT 10, "Microsoft YaHei UI", 400, 0, 0x0
BEGIN
CONTROL "请输入录入航班信息",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,103,18,59,8
EDITTEXT IDC_DEPARTURE,41,35,31,12,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP
EDITTEXT IDC_DESTINATION,123,35,31,12,ES_AUTOHSCROLL | ES_WANTRETURN
CONTROL "出发地:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,16,36,24,11
CONTROL "目的地:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,98,36,24,8
CONTROL "日期:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,174,98,18,8
CTEXT "航班号:",IDC_STATIC,16,67,26,8
EDITTEXT IDC_TAKEOFFTIME,206,35,35,12,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP
CONTROL "价格:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,98,67,24,8
CONTROL "座位数:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,16,98,24,8
CONTROL "折扣:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,98,98,24,8
EDITTEXT IDC_FLTNUM,41,65,31,12,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP
EDITTEXT IDC_FARE,123,65,31,12,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP
EDITTEXT IDC_LANDINGTIME,206,65,35,12,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP
CONTROL "起飞时间:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,174,36,30,8
CONTROL "降落时间:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,174,67,30,8
EDITTEXT IDC_SEATNUM,41,96,31,12,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP
EDITTEXT IDC_DISCOUNT,123,96,31,12,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP
CONTROL "",IDC_DATE,"SysDateTimePick32",DTS_RIGHTALIGN | WS_TABSTOP,198,96,57,12
DEFPUSHBUTTON "添加",IDC_ADDFLT,75,120,37,15
PUSHBUTTON "退出",IDC_QUIT,153,120,37,15
END
IDD_MODIFYFLT DIALOGEX 0, 0, 323, 200
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "航班录入"
FONT 10, "Microsoft YaHei UI", 400, 0, 0x0
BEGIN
EDITTEXT IDC_MDFFLTNUM,59,34,44,12,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP
CTEXT "航班号:",IDC_STATIC,28,36,26,8
GROUPBOX "请输入要修改的信息",IDC_STATIC,7,65,309,128
LTEXT "请输入修改航班航班号",IDC_STATIC,10,14,65,8
CTEXT "日期:",IDC_STATIC,149,36,26,8
CONTROL "",IDC_MDFDATE,"SysDateTimePick32",DTS_RIGHTALIGN | WS_TABSTOP,175,34,57,12
EDITTEXT IDC_FARE,56,96,28,12,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP
CONTROL "价格:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,23,99,24,8
CONTROL "座位数:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,198,99,24,8
CONTROL "折扣:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,110,99,24,8
EDITTEXT IDC_DISCOUNT,144,96,31,12,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP
EDITTEXT IDC_SEATNUM,228,96,31,12,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP
CONTROL "起飞时间:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,23,136,30,8
CONTROL "降落时间:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,111,136,30,8
EDITTEXT IDC_TAKEOFFTIME,56,133,35,12,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP
EDITTEXT IDC_LANDINGTIME,144,133,35,12,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP
DEFPUSHBUTTON "确认修改",IDC_MODIFY,104,168,37,15
PUSHBUTTON "退出",IDC_QUIT,182,168,37,15
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_LOGINDLG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 300
TOPMARGIN, 7
BOTTOMMARGIN, 168
END
IDD_MAINDLG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 351
TOPMARGIN, 6
BOTTOMMARGIN, 220
END
IDD_NAMEDLG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 253
TOPMARGIN, 7
BOTTOMMARGIN, 108
END
IDD_FLTNUM, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 174
TOPMARGIN, 7
BOTTOMMARGIN, 80
END
IDD_ENTRY, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 259
TOPMARGIN, 7
BOTTOMMARGIN, 146
END
IDD_MODIFYFLT, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 316
TOPMARGIN, 7
BOTTOMMARGIN, 193
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#ifndef APSTUDIO_INVOKED\r\n"
"#include ""targetver.h""\r\n"
"#endif\r\n"
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_BITMAP1 BITMAP "login_2.bmp"
IDB_BITMAP2 BITMAP "main_2.bmp"
IDB_BITMAP3 BITMAP "login.bmp"
IDB_BITMAP4 BITMAP "main.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON "icon.ico"
#endif // 中文(简体,中国) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
具体实现代码见下篇博文吧,写代码的过程中还是遇到不少问题的。先附几张程序效果图,包含了一些个人二次元爱好….