1、基于c#窗体的航空订票管理系统的设计与实现 一. 系统分工 管理资料 查询航线 航空订票管理系统 管理员 用户 修改公告 修改航班 管理用户 查看信息 订票管理 退票管理 二. 需求分析 进入21世纪,人们计算机处理事情的需求有了进一步的要求。小到商店缴费管理系统的快速运行,大到国家航空航天计算机的管理系统的进一步提升。我们每时每刻都在追求着计算机处理事情的快速,稳定,运算量大等一系列优点。由于人们为了方便快捷的生活方式,上网已经成为潮流,这样快速稳定的航空订票系统应运而生。航空订票系统需要满足一般的查询航线,订票,退票等一系列基本操作,当然我们也可以设置黑
2、名单,以屏蔽违规用户。当然人人都追求美感,那么系统界面的设计也要符合大众的审美要求。资料的安全与隐私性也是至关重要的,我们每个人,都不想别人知道自己的一些隐私,对自己资金的安全也格外重视。所以订票系统对不同的角色赋予不同的权限从而保证用户资料的安全性与隐私性。 三. 系统功能 (1)游客功能 对游客我们系统只为其提供查询航班信息的功能,不可进行订票操作。当游客点击购票按钮时,将提醒其注册或登录。 (2)用户注册 用户只有注册成为我们的会员,才可以进行订票操作。一旦注册,用户名将不可修改。注册时不可与数据库中存在的用户名相同,即系统中只能存在唯一一个用户名。 (3)用户中心 提供用
3、户对自己的资料的查看与修改的功能。还可以对自己的密码进行修改,在修改密码时需要输入原始密码进而进行验证。由于时间问题,对个人钱包功能先暂停使用,默认钱够买票了。 (4)订票功能 用户可根据航班时间,和航班号或航班价格进行订票。订票时系统会提醒确认,订票成功后系统会将用户的信息加入订票信息表。并改变航班的余票额。 (5)退票功能 用户在不需要票的情况下进行退票操作。退票时必须输入订票时随机生成的订单号,与航班号。退票成功后,航班自动将余票量加一操作。 (6)本系统还添加了管理员界面。当管理员进入后,可对用户的信息进行查看,但不能修改,也可将用户加入黑名单,如果用户有订单,则不允许管理员
4、做加入黑名单操作。当然加入黑名单时,管理员需要说明理由,作为存档。管理员,也可根据实际情况对航班进行管理操作。增删改查。他也可以对公告进行修改操作。 (7)系统也实现了,对于不同的角色进入,会产生不同的界面效果。保证了数据的安全性,和保密性。 数据库设计 (1)管理员表 (2) 航班表 (3)黑名单表 (4)订单信息表 (5)用户信息表 四. 运行截图 五. 源代码 using System; using System.Collections.Generic; using System.Linq; usin
5、g System.Windows.Forms;
namespace 航空订票管理系统
{
static class Program
{
///
6、ataDir.EndsWith(@"\bin\Debug\") || dataDir.EndsWith(@"\bin\Release\")) { dataDir = System.IO.Directory.GetParent(dataDir).Parent.Parent.FullName; AppDomain.CurrentDomain.SetData("DataDirectory", dataDir); } App
7、lication.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } } using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.L
8、inq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace 航空订票管理系统 { public partial class Form1 : Form { zhuce zc = new zhuce(); Userlaunch lch=new Userlaunch(); public string status1 { get; set; } int label1x;
9、 public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { label1x = label1.Right; timer1.Enabled = true; timer2.Enabled = true; timer3.Enab
10、led = true; timer2.Start(); novisible2(); novisible1(); textBox1.Focus(); timer1.Start(); } //隐藏管理员可做的操作 public void novisible1() { 客户信息ToolStripMenuItem.Visible = false;
11、航班信息ToolStripMenuItem.Visible = false; 修改公告ToolStripMenuItem.Visible = false; } //隐藏用户可做的操作 public void novisible2() { 用户补全资料ToolStripMenuItem.Visible = false; //个人中心 用户充值ToolStripMenuItem.Visible = false; //办理业务
12、 } //隐藏登陆前界面 public void novisible3() { 用户登录ToolStripMenuItem.Visible = false; 浏览信息ToolStripMenuItem.Visible = false; 管理员登陆ToolStripMenuItem.Visible = false; } //控制公告字段 private void timer1_Tick
13、object sender, EventArgs e) { label1.Location = new Point(label1.Location.X-1,label1.Location.Y); if (label1.Right == 0) { label1.Left = label1x; } } //当点到按钮时,进行图片变换 private void button1_M
14、ouseEnter(object sender, EventArgs e) { Button bttn; timer2.Enabled = false; bttn = (Button)sender; if (bttn == button1) picture1(); else if (bttn == button2) picture2(); else if (bttn == button3) picture3();
15、 else if (bttn == button4) picture4(); else if (bttn == button5) picture5(); } private void radioButton1_CheckedChanged(object sender, EventArgs e) { textBox5.Enabled = false; textBox1.Enabled = true; textBox2.E
16、nabled = true; textBox5.Text = ""; textBox1.Focus(); } private void radioButton2_CheckedChanged(object sender, EventArgs e) { textBox5.Enabled = true; textBox1.Text = ""; textBox2.Text = "";
17、textBox1.Enabled = false; textBox2.Enabled = false; } private void radioButton4_CheckedChanged(object sender, EventArgs e) { textBox6.Enabled = false; textBox3.Enabled = true; textBox4.Enabled = true; text
18、Box6.Text = ""; textBox4.Focus(); } private void radioButton3_CheckedChanged(object sender, EventArgs e) { textBox6.Enabled = true; textBox4.Text = ""; textBox3.Text = ""; textBox3.Enabled = false;
19、 textBox4.Enabled = false; textBox6.Focus(); } //安全退出 private void 用户退出ToolStripMenuItem_Click(object sender, EventArgs e) { if (toolStripStatusLabel4.Text == "未登录") { MessageBox.Show("当前你未登录,请登录或注册
20、"); } else { MessageBox.Show(toolStripStatusLabel4.Text+"您已下线,谢谢使用!"); toolStripStatusLabel4.Text = "未登录"; status1 = ""; novisible2(); novisible1(); 用户登录Too
21、lStripMenuItem.Visible = true; 浏览信息ToolStripMenuItem.Visible = true; 管理员登陆ToolStripMenuItem.Visible = true; } } //注册界面 private void 浏览信息ToolStripMenuItem_Click(object sender, EventArgs e) {
22、 zhuce zc = new zhuce(); zc.ShowDialog(); } //图片变换 private void timer2_Tick(object sender, EventArgs e) { Random rd = new Random(); int r = rd.Next(1,6); switch (r) { case 1: pi
23、cture1(); break; case 2: picture2(); break; case 3: picture3(); break; case 4: picture4(); break; case 5: picture5(); break; } } //图片显示方法 private void picture1() { pict
24、ureBox1.Show(); pictureBox2.Hide(); pictureBox3.Hide(); pictureBox4.Hide(); pictureBox5.Hide(); } private void picture2() { pictureBox2.Show(); pictureBox1.Hide(); pictureBox3.Hide()
25、 pictureBox4.Hide(); pictureBox5.Hide(); } private void picture3() { pictureBox3.Show(); pictureBox2.Hide(); pictureBox1.Hide(); pictureBox4.Hide(); pictureBox5.Hide(); }
26、 private void picture4() { pictureBox4.Show(); pictureBox2.Hide(); pictureBox3.Hide(); pictureBox1.Hide(); } private void picture5() { pictureBox5.Show(); pictureBox2.Hide();
27、 pictureBox3.Hide(); pictureBox4.Hide(); pictureBox1.Hide(); } //当不用手动控制图片时,执行 private void button1_MouseLeave(object sender, EventArgs e) { timer2.Enabled = true; } //用户登陆 private void 用户
28、登录ToolStripMenuItem_Click(object sender, EventArgs e) { Userlaunch uch = new Userlaunch(); if (uch.ShowDialog() == DialogResult.OK) { status1 = uch.UserName; toolStripStatusLabel4.Text = "尊敬的用户"+status1+"你好!";
29、 用户补全资料ToolStripMenuItem.Visible = true; 用户充值ToolStripMenuItem.Visible = true; novisible1(); novisible3(); } uch.Dispose(); } //管理员登陆 private void 管理员登陆ToolStripMenuItem_Click(object s
30、ender, EventArgs e) { Admain adn = new Admain(); if (adn.ShowDialog() == DialogResult.OK) { toolStripStatusLabel4.Text = adn.AdmainName; novisible2(); novisible3(); 客户信息ToolStripMenuIt
31、em.Visible = true; 航班信息ToolStripMenuItem.Visible = true; 修改公告ToolStripMenuItem.Visible = true; } } //机票预订 private void button6_Click(object sender, EventArgs e) { if (toolStripStatusLabe
32、l4.Text == "未登录") { MessageBox.Show("请先登录"); textBox1.Text = textBox2.Text = textBox5.Text = ""; } else if (toolStripStatusLabel4.Text.Substring(0, 3) == "亲爱的") { MessageBox.Show("对不起,管理员,您不能订票的!")
33、 textBox1.Text = textBox2.Text = textBox5.Text = ""; } else { if (textBox1.Text != "" && textBox2.Text != "" || textBox5.Text != "") { int n = 1; jipiaoyuding jyd =
34、new jipiaoyuding(textBox1.Text, textBox2.Text, textBox5.Text, n, status1); jyd.ShowDialog(); } else { MessageBox.Show("对不起,你输入的信息不符合查询条件,请重新输入"); } }
35、 } //系统时间 private void timer3_Tick(object sender, EventArgs e) { this.toolStripStatusLabel3.Text = "当前系统时间:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); } //查询航班动态 private void button7_Click(object sender, EventArgs e)
36、 { if (textBox4.Text != "" && textBox3.Text != "" || textBox6.Text != "") { int n = 2; jipiaoyuding jyd = new jipiaoyuding(textBox4.Text, textBox3.Text, textBox6.Text,n,status1); jyd.ShowDialog(); textBo
37、x4.Text = textBox3.Text = textBox6.Text = ""; } else { MessageBox.Show("对不起,你输入的信息不符合查询条件,请重新输入"); textBox4.Text = textBox3.Text = textBox6.Text = ""; } } private void 订票信息ToolStripMenuItem_C
38、lick(object sender, EventArgs e) { 订票信息 dp = new 订票信息(); dp.ShowDialog(); } private void 用户资料ToolStripMenuItem_Click(object sender, EventArgs e) { 用户资料 yz = new 用户资料(); yz.ShowDialog(); } pr
39、ivate void 订票ToolStripMenuItem_Click(object sender, EventArgs e) { jipiaoyuding jyd = new jipiaoyuding("", "", "", 1, status1); jyd.ShowDialog(); } private void 查询订单ToolStripMenuItem_Click(object sender, EventArgs e) { 个人订单
40、 gd = new 个人订单(status1); gd.ShowDialog(); } private void 黑名单资料ToolStripMenuItem_Click(object sender, EventArgs e) { 黑名单表 hm = new 黑名单表(); hm.ShowDialog(); } private void 航班信息ToolStripMenuItem_Click(object sender,
41、 EventArgs e) { 航班信息 hbx = new 航班信息(); hbx.ShowDialog(); } private void 修改公告ToolStripMenuItem_Click(object sender, EventArgs e) { 修改公告 xg=new 修改公告 (); if (xg.ShowDialog() == DialogResult.OK) {
42、 label1.Text = xg.gonggao; } } private void 查看自己资料ToolStripMenuItem_Click(object sender, EventArgs e) { 个人资料 gz = new 个人资料(status1,1); gz.ShowDialog(); } private void 修改个人资料ToolStripMenuItem_Click(object s
43、ender, EventArgs e) { 个人资料 gz1 = new 个人资料(status1,2); gz1.ShowDialog(); } private void 我想退票ToolStripMenuItem_Click(object sender, EventArgs e) { 退票系统 tp = new 退票系统(status1); if (tp.ShowDialog() == DialogResult.
44、OK) { MessageBox.Show("退票成功"); } } private void button8_Click(object sender, EventArgs e) { if (toolStripStatusLabel4.Text=="未登录") { MessageBox.Show("你还未登陆,请先登录!"); tex
45、tBox7.Text = textBox8.Text = textBox9.Text = ""; textBox1.Focus(); } else if (toolStripStatusLabel4.Text.Substring(0,3)=="亲爱的") { MessageBox.Show("管理员,您是无权退票的啊!"); textBox7.Text = textBox8.Text = textBox9.Text
46、 ""; textBox1.Focus(); } else { 退票系统 tp = new 退票系统(status1); tp.tuibiao(textBox7.Text, textBox8.Text, textBox9.Text); { if (tp.DialogResult == DialogResult.OK)
47、 { MessageBox.Show("退票成功"); } } } } //取消退票 private void button9_Click(object sender, EventArgs e) { textBox7.Text =textBox8.Text=textBox9.Text= ""; t
48、extBox7.Focus(); } } } using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace 航空订票管理系统 { publ
49、ic partial class zhuce : Form { public string Username { get; set; } public string Userpassword1 { get; set; } public string Userpassword2 { get; set; } public int flag1,flag2,flag3; string connectionString = Properties.Settings.Default.HKDPConnectio
50、nString; public zhuce() { InitializeComponent(); flag1 = 1; flag2 = 1; flag3 = 1; toolTip1.InitialDelay = 0; toolTip1.ReshowDelay = 0; toolTip1.SetToolTip(textBox1,"用户名不能超过20个字符,而且只能用字母,数字!"); toolTip1.Se






