首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C#编机票预订系统的有关问题

2012-12-17 
C#编机票预订系统的问题代码如下:using Systemusing System.Collections.Genericusing System.Component

C#编机票预订系统的问题

代码如下:
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.Windows.Forms;

namespace 航空机票预订管理系统
{
    public partial class booking : Form
    {
        LinkDatabase link = new LinkDatabase();
        public booking()
        {
            InitializeComponent();
        }
        private bool checkEmpty()
        {
            bool result=true;
            if(addTno.Text.Trim()==string.Empty)
                result=false;
            else if(Pno.Text.Trim()==string.Empty)
                result=false;
            else if(Pseat.Text.Trim()==string.Empty)
                result=false;
            else if(Pleave.Text.Trim()==string.Empty)
                result=false;
            else if(Parrive.Text.Trim()==string.Empty)
                result=false;
            else if(Ptime.Text.Trim()==string.Empty)
                result=false;
            else if(Cname.Text.Trim()==string.Empty)
                result=false;
            else if(Csex.Text.Trim()==string.Empty)
                result=false;
            else if(Cno.Text.Trim()==string.Empty)
                result=false;
            else if(Ctele.Text.Trim()==string.Empty)
                result=false;
            else if(Ttime.Text.Trim()==string.Empty)
                result=false;
            else if(Tsum.Text.Trim()==string.Empty)
                result=false;
            else if(Sno.Text.Trim()==string.Empty)


                result=false;
            return result;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if(checkEmpty()==true)
            {try{
                string sendstrsql="INSERT INTO 订单 VALUES('"+addTno.Text+"','"+Pno.Text+"','"+Pseat.Text+"','"+Pleave.Text+"','"+Parrive.Text+"','"+Ptime.Text+"','"+Cname.Text+"','"+Csex.Text+"','"+Cno.Text+"','"+Ctele.Text+"','"+Ttime.Text+"','"+Tsum.Text+"','"+Sno.Text+"')";
                link.updatedb(sendstrsql);
                MessageBox.Show("成功添加");}
                catch(System.Exception ex)
            {
                    MessageBox.Show(ex.Message,"警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);}
            }
            else MessageBox.Show("输入不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string sendstrsql="SELECT 订单号,航班号,座位号,起飞地,目的地,起飞时间,旅客姓名,性别,身份证号,电话号码,订票时间,订票数量,员工编号 FROM 订单 WHERE 订单号=' + selTno.Text +'";
                DataTable dt1=link.dsresult(sendstrsql);
            dataGridView2.DataSource=dt1.DefaultView;
     
        }

        private void 删除_Click(object sender, EventArgs e)
        {
        try{
            string sendstrsql="DELETE FROM 订单 WHERE 订单号="+Convert.ToString(dataGridView2[0,dataGridView2.CurrentCell.RowIndex].Value).Trim()+"";
            link.updatedb(sendstrsql);
            MessageBox.Show("删除成功!","信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
        }catch(System.Exception ex)
        {
            MessageBox.Show(ex.Message,"警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
        }
        }

        private void 返回_Click(object sender, EventArgs e)


        {
            this.Hide();
            return;
        }
想从刚才那个窗体点返回,回到下面那个窗体(management),但是点击后现在不能返回,求代码!!!!

[最优解释]
        private void 返回_Click(object sender, EventArgs e)
         {
             Close();
         }

在前一个窗口:
this.Hide();
new booking().ShowDialog();
this.Show();
[其他解释]

引用:
private void 返回_Click(object sender, EventArgs e)
         {
             Close();
         }

在前一个窗口:
this.Hide();
new booking().ShowDialog();
this.Show();

对的,打开新窗体,其实就是隐藏主窗体,返回就是关闭子窗体,show出主窗体。
[其他解释]
谢谢你们!!!!!!!!!!!可以了!!!!!!!!

热点排行