航班预定系统

写这个项目用到的Windows窗体有button标签 ,comboBox组合框,dataGridView数据显示,panel,numericUpDown数字选择,dateTimePicker日期表,label。

1:先把所有属性中的name和text改了 ,目的是方便于接下来的使用。

2:改项目中所需要的所有属性值,增删改查。

3:连接数据库,用代码完成相关信息的转换。

具体代码:

全部参考代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BookPlane
{
public partial class FIightOrderMSG : Form
{
public FIightOrderMSG()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
FillDataGridView();
}

private void Form1_Load(object sender, EventArgs e)
{
dgvList.AutoGenerateColumns = false;
FindCityInfo();
}

DBHelper db = new DBHelper();
/// <summary>
/// 查询航班出发地
/// </summary>
public void FindCityInfo()
{
string sql = "select * from CityInfo";

try
{
db.conOpen();
SqlCommand comm = new SqlCommand(sql, db.conn);
SqlDataReader reader = comm.ExecuteReader();
cboStart.Items.Add("请选择");
cboStart.Items.IndexOf(0);
cboStart.SelectedIndex = 0;
cboEnd.Items.Add("请选择");
cboEnd.Items.IndexOf(0);
cboEnd.SelectedIndex = 0;
if (reader.HasRows)
{
while (reader.Read())
{
string city = reader["CityName"].ToString();
cboStart.Items.Add(city);
cboEnd.Items.Add(city);
}
reader.Close();
}
else
{
MessageBox.Show("未检测到有效信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception)
{
MessageBox.Show("发生错误!");
}
finally
{
db.conClose();
}
}

/// <summary>
/// 填充DataGridView中的数据
/// </summary>
public void FillDataGridView()
{

//连接数据库
SqlConnection conn = new SqlConnection(db.strCon);
//创建SQL语句
StringBuilder sql = new StringBuilder();
//获取comboBox被选中的下标
int AirId = cboStart.SelectedIndex;
int DestinationId = cboEnd.SelectedIndex;
//创建SQL语句
sql.AppendLine(" select * from FlightInfo,AirwaysInfo");
sql.AppendLine(" where AirwaysInfo.Id = FlightInfo.AirwaysId");
sql.AppendLine(" and FlightInfo.LeaveCity=‘" + AirId + "‘ and FlightInfo.Destination=‘" + DestinationId + "‘");
//创建适配器,卡车对象
SqlDataAdapter da = new SqlDataAdapter(sql.ToString(), conn);
DataSet ds = new DataSet();
da.Fill(ds, "air");
dgvList.DataSource = ds.Tables["air"];

//string FlightNo = reader["FlightNo"].ToString();
//string Airways = reader["Airways"].ToString();
//string LeaveTime = reader["LeaveTime"].ToString();
//string LandTime = reader["LandTime"].ToString();
//string Price = reader["Price"].ToString();

}

private void dgvList_CellClick(object sender, DataGridViewCellEventArgs e)
{
//获取DataGridView中的值,显示在各个文本框中
txtFlightNo.Text = Convert.ToString(dgvList.SelectedCells[0].Value);
txtFlightCompany.Text = dgvList.SelectedRows[0].Cells[1].Value.ToString();
txtStartTime.Text = dgvList.SelectedRows[0].Cells[2].Value.ToString();
txtEndTime.Text = dgvList.SelectedRows[0].Cells[3].Value.ToString();
txtPrice.Text = dgvList.SelectedRows[0].Cells[4].Value.ToString();
txtStart.Text = cboStart.SelectedItem.ToString();
txtEnd.Text = cboEnd.SelectedItem.ToString();
}

private void btnOrder_Click(object sender, EventArgs e)
{
//产生6位随机数
Random r = new Random();
string random = Convert.ToString(r.Next(100000, 1000000));
string flightNo = txtFlightNo.Text;
int num = Convert.ToInt32(nudOrderNum.Value);
if (txtFlightCompany.Text != string.Empty)
{
if (dtpStart.Value < DateTime.Now)
{
MessageBox.Show("请选择一个有效的时间!", "提示");
}
else
{
SqlConnection conn = new SqlConnection(db.strCon);
DateTime leaveTime = dtpStart.Value;
try
{

//连接数据库
conn.Open();
string sql = @"insert into OrderInfo values(‘" + random + "‘,‘" + flightNo + "‘,‘" + leaveTime + "‘," + num + ")";
SqlCommand comm = new SqlCommand(sql, conn);
int isReact = comm.ExecuteNonQuery();
if (isReact > 0)
{
MessageBox.Show("预定成功!祝您旅途愉快!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show("发生错误!" + ex);
}
finally
{
conn.Close();
}
}
}
else
{
MessageBox.Show("请选择一个航班!", "提示");
}

}

private void btnClose_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("确定要关闭吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if (result == DialogResult.OK)
{
this.Close();
}
}
}
}

原文地址:https://www.cnblogs.com/dujuanly/p/8523758.html

时间: 2024-08-04 13:45:58

航班预定系统的相关文章

2.3为方便旅客,某航空公司拟开发一个机票预定系统。 写出问题定义并分析系统的可行性。

为方便旅客,某航空公司拟开发一个机票预定系统.旅行社把预定机票的旅客信息(姓名.性别.工作单位.身份证号码.旅行时间.旅行目的地等)输入进 入该系统,系统为旅客安排航班,印出取票通知和账单,旅客在飞机起飞的前一天凭取票通知和账单交款取票,系统校对无误即印出机票给旅客. 写出问题定义并分析系统的可行性. 1>     目标:在一个月内建立一个高效率,无差错的航空公司机票预定系统 2>     存在的主要问题:人工不易管理,手续繁琐 3>     建立新系统 ①  经济可行性        

为方便旅客,某航空公司拟开发一个机票预定系统。

航空订票系统技术在目前是一个技术上成熟的系统,并且在航空公司内部准备采取有力措施保证资金和人员配置等. 因此,分阶段开发“航空订票系统”的构想是可行的.为了使航空公司适应现代化市场竞争的需求,促进机票预订管理信息 化,不断满足旅客预订机票的要求,争取更好的经济效益,可立即着手系统的开发与完善. 1> 目标:在一个月内建立一个高效率,无差错的航空公司机票预定系统 2> 存在的主要问题:人工不易管理,手续繁琐 3> 建立新系统 ① 经济可行性                成本效益分析 成本

喜羊羊系列之【项目一】:c基础+数据结构+线程+冒泡实现《航班查询系统》

博客:http://blog.csdn.net/muyang_ren 1.实现功能: 1)信息录入 2)信息显示(按照起飞时间先后顺序显示) 3)信息查询(可根据不同的关键字进行查询) 4)信息删除 2.  要求: 1)使用链表对录入的信息进行存储 2)对录入的信息进行排序(可按起飞时间进行排序) 3)Make管理项目 3.结构体: struct flydate{ int ID; //航班号 char staddress[18]; //起点站 char arraddress[18]; //终点站

启明星会议室预定系统更新日志-通用版

启明星会议室预定系统更新日志 V9.1更新说明 1.解决资源释放bug. bug说明:用户预定了“投影仪",在更新预定时,如果在投影仪选项里,直接删除了”投影仪“文字,这意味着用户不使用投影仪.更新成功,应该释放投影仪占用的资源.       但是目前更新成功后,该资源仍被占用,不会释放 2.增加了周查询功能,以及快速预定 V9.0更新说明 从9.0开始,启明星系统采用全新的构架,并且不在兼容早期的版本.而且,V9不再支持IE6与IE7. 除了界面上变更,V9对预定系统进行了简化.主要功能说明如

php 会议预定系统

最近这段时间,在用php做一个会议室预定系统,由于刚开始接触php语言,所以对于语法不是很熟悉,在这个学习和制作项目的过程中,发现了一些问题,借着今天周末的时间,总结一下,希望能对像我这样的菜鸟,有所帮助,如果发现bug或者有争议的地方,欢迎指出,沟通互动与交流,谢谢. 我使用的是yaf框架,ngnix服务器,mysql数据库,php5.5.关于系统的安装,请参考上一篇帖子,地址如下:http://mig1924615.blog.51cto.com/9385857/1755532 刚开始觉得,用

2-3为了方便旅客,某航空公司拟开发一个机票预定系统。旅行社把预定机票的旅客信息(姓名、性别、工作单位、身份证号码、旅行时间、旅行目的地等)输入该系统,系统为旅客安排航班,旅客在飞机起飞前一天凭取票通知和账单交款取票,系统核对无误即印出机票给顾客

关于启明星系统(OA系统,预定系统,请假系统等)安全性的说明

启明星系统推荐是安装在内网里,因此,系统采用了较为简单的身份验证. 事实上,在访问页面时,系统会判断当前cookie的uid是否大于0,如果是,则表示用户已经登录,否则表示未登录. public static int GetUserId { get { return (HttpContext.Current.Request.Cookies["userinfo"] == null) ? -1 : int.Parse(HttpContext.Current.Request.Cookies[

酒店预定系统

酒店预定系统功能模块结构图 原文地址:https://www.cnblogs.com/my1998/p/9044453.html

图书预定系统

题目: 图书预订系统 书店向顾客发放订单,顾客将所填订单交由系统处理,系统首先依据图书目录对订单进行检查并对合格订单进行处理,处理过程中根据顾客情况和订单数目将订单分为优先订单和正常订单两种,随时处理优先订单,定期处理正常订单.最后系统将所处理的订单汇总,并按出版社要求发给出版社. 顶层数据流图 0层数据流图 1层数据流图 原文地址:https://www.cnblogs.com/wacyy/p/10530198.html