火车订票系统毕业论文(7)

1970-01-01 08:00

火车订票系统毕业论文

Response.Redirect(\); } else

Response.Write(\用户名或密码不正确,请重新输入!')\); dr.Close(); con.Close(); //用户订票界面的代码

string trainID = GridView1.Rows[0].Cells[0].Text.ToString();

string beginStation = GridView1.Rows[0].Cells[2].Text.ToString(); string type = GridView1.Rows[0].Cells[1].Text.ToString(); string beginTime = GridView1.Rows[0].Cells[3].Text.ToString(); string endStation = GridView1.Rows[0].Cells[4].Text.ToString(); string times = GridView1.Rows[0].Cells[10].Text.ToString(); string num = GridView1.Rows[0].Cells[11].Text.ToString(); string ticketKind = radbtn_list.SelectedItem.ToString(); string num2 = txt_papaer.Text.Trim(); int num1 = Convert.ToInt32(num); int num3 = Convert.ToInt32(num2); if (num3 > 10) {

Response.Write(\所订购车票数超过了最大能订购的数目!')\); } else {

int c1 = 0; //创建数据库连接

SqlConnection conn1 = new

SqlConnection(ConfigurationManager.ConnectionStrings[\].ConnectionString); conn1.Open(); //创建命令对象

SqlCommand comm1 = new SqlCommand(); //查找数据库表中的信息

comm1.CommandText = \ + trainID + \times='\ + times + \ + ticketKind + \; comm1.Connection = conn1;

SqlDataReader dr1 = comm1.ExecuteReader(); //c1记录tbl_orderhistory表中该类型的订票数 while (dr1.Read()) {

c1 = c1 + 1; }

dr1.Close();

29

火车订票系统毕业论文

//if (dr.HasRows) if (num3 > 120 - c1) {

Response.Write(\该类型余票不足!')\); } else

for (int num4 = 0; num4 < num3; num4++) {

//创建数据库连接

SqlConnection conn = new

SqlConnection(ConfigurationManager.ConnectionStrings[\].ConnectionString); conn.Open(); //创建命令对象

SqlCommand comm = new SqlCommand(); //查找数据库表中的信息 if (ticketKind == \硬座\) {

int k = 0;

for (int cars = 1; cars < 4 && k == 0; cars++) {

for (int Seat = 1; Seat <= 40; Seat++) {

comm.CommandText = \ + trainID + \times='\ + times + \ticketKind='\ + ticketKind + \cars='\ + cars + \Seat='\ + Seat + \;

comm.Connection = conn;

SqlDataReader dr = comm.ExecuteReader(); //判断用户名是否存在 if (dr.HasRows) {

dr.Close(); continue; } else {

dr.Close(); cars1 = cars; Seat1 = Seat; k++; break; } } } }

else if (ticketKind == \软座\)

30

火车订票系统毕业论文

{

int k = 0;

for (int cars = 4; cars < 7 && k == 0; cars++) {

for (int Seat = 1; Seat <= 40; Seat++) {

comm.CommandText = \ + trainID + \times='\ + times + \ticketKind='\ + ticketKind + \cars='\ + cars + \Seat='\ + Seat + \;

comm.Connection = conn;

SqlDataReader dr = comm.ExecuteReader(); //判断用户名是否存在 if (dr.HasRows) {

dr.Close(); continue; } else {

dr.Close(); cars1 = cars; Seat1 = Seat; k++; break; } } } }

else if (ticketKind == \硬卧\) {

int k = 0;

for (int cars = 7; cars < 10 && k == 0; cars++) {

for (int Seat = 1; Seat <= 40; Seat++) {

comm.CommandText = \ + trainID + \times='\ + times + \ticketKind='\ + ticketKind + \cars='\ + cars + \Seat='\ + Seat + \;

comm.Connection = conn;

SqlDataReader dr = comm.ExecuteReader(); //判断用户名是否存在 if (dr.HasRows) {

31

火车订票系统毕业论文

dr.Close(); continue; } else {

dr.Close(); cars1 = cars; Seat1 = Seat; k++; break; } } } }

else if (ticketKind == \软卧\) {

int k = 0;

for (int cars = 10; cars < 13 && k == 0; cars++) {

for (int Seat = 1; Seat <= 40; Seat++) {

comm.CommandText = \ + trainID + \times='\ + times + \ticketKind='\ + ticketKind + \cars='\ + cars + \Seat='\ + Seat + \;

comm.Connection = conn;

SqlDataReader dr = comm.ExecuteReader(); //判断用户名是否存在 if (dr.HasRows) {

dr.Close(); continue; } else {

cars1 = cars; Seat1 = Seat; dr.Close(); k++; break; } } } } {

if (Page.IsValid) { //创建连接

32

火车订票系统毕业论文

SqlConnection cn = new SqlConnection();

cn.ConnectionString = \Catalog=TicketsMS;Integrated Security=True\; cn.Open();

DateTime now = DateTime.Now; //创建命令对象

SqlCommand cm = new SqlCommand(); cm.Connection = cn;

cm.CommandText = \into tbl_orderhistory values('\ + Session[\] + \ + times + \ + beginTime + \ + trainID + \ + beginStation + \ + endStation + \ + type + \ + ticketKind + \ + DateTime.Now.ToShortDateString() + \ + cars1 + \ + Seat1 + \;

cm.ExecuteNonQuery();

SqlConnection con = new SqlConnection();

con.ConnectionString = \Catalog=TicketsMS;Integrated Security=True\; con.Open();

SqlCommand com = new SqlCommand(); com.Connection = con;

com.CommandText = \='\ + trainID + \ + times + \;

SqlDataReader dr = com.ExecuteReader(); dr.Close(); con.Close();

Response.Write(\订票成功!');window.location.href='information.aspx';\); cn.Close(); } } } } //分页代码

public void Datalistbind() {

SqlConnection cn = new

SqlConnection(ConfigurationManager.ConnectionStrings[\].ConnectionString); string sql = \; DataSet ds = new DataSet();//创建数据集

SqlDataAdapter sda = new SqlDataAdapter(sql, cn);//创建数据适配器对象; sda.Fill(ds, \);

PagedDataSource pds = new PagedDataSource(); pds.DataSource = ds.Tables[0].DefaultView; pds.PageSize = 8; pds.AllowPaging = true;

33


火车订票系统毕业论文(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:金融工程学 作业答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: