zoukankan      html  css  js  c++  java
  • 机票查询与订购系统

      public void Find()
            {
                DBHelper db = new DBHelper();
                string sql = "select Id,CityName from CityInfo  ";
                MessageBox.Show(sql);
                SqlConnection conn = new SqlConnection(db.str);

                SqlCommand cmd = new SqlCommand(sql, conn);
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;

                DataSet ds = new DataSet();

                da.Fill(ds, "s");

                //增加“全部”到查询数据的前面
                DataRow rows = ds.Tables["s"].NewRow();
                // rows["Id"] = -1;
                rows["CityName"] = "请选择";
                ds.Tables["s"].Rows.InsertAt(rows, 0);

                comboBox1.DataSource = ds.Tables["s"];
                comboBox1.DisplayMember = "CityName";
                comboBox1.ValueMember = "Id";

            }
            public void ine()
            {
                DBHelper db = new DBHelper();
                string sql = "select Id,CityName from CityInfo  ";
                MessageBox.Show(sql);
                SqlConnection conn = new SqlConnection(db.str);

                SqlCommand cmd = new SqlCommand(sql, conn);
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;

                DataSet ds = new DataSet();

                da.Fill(ds, "s");

                //增加“全部”到查询数据的前面
                DataRow rows = ds.Tables["s"].NewRow();
                //rows["Id"]=-1;
                rows["CityName"] = "请选择";
                ds.Tables["s"].Rows.InsertAt(rows, 0);

                comboBox2.DataSource = ds.Tables["s"];
                comboBox2.DisplayMember = "CityName";
                comboBox2.ValueMember = "Id";
            }

      public void findall()
            {
                DBHelper db = new DBHelper();
                int fromCityNum = Convert.ToInt32(comboBox1.SelectedValue);
                int toCityNum = Convert.ToInt32(comboBox2.SelectedValue);
                string sql = @"select * from AirwaysInfo as A,FlightInfo as F where A.Id = F.AirwaysId
                               and LeaveCity = '" + fromCityNum + "' and Destination = '" + toCityNum + "'";
                SqlConnection conn = new SqlConnection(db.str);

                SqlDataAdapter da = new SqlDataAdapter(sql, conn);
                DataSet ds = new DataSet();
                ds.Tables.Clear();
                da.Fill(ds, "ss");
                dataGridView1.DataSource = ds.Tables["ss"];
            }

       private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
            {
                string no = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
                //string xue = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
                string yes = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
                string qw = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
                string ew = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
                //string rw = dataGridView1.SelectedRows[0].Cells[5].Value.ToString();
                string aw = dataGridView1.SelectedRows[0].Cells[4].Value.ToString();
                textBox1.Text = no;
                textBox2.Text = comboBox2.Text;
                textBox3.Text = yes;
                textBox4.Text = qw;
                textBox5.Text = ew;
                textBox6.Text = comboBox1.Text;
                textBox7.Text = aw;
            }

      public void ding()
            {
                DBHelper db = new DBHelper();
                SqlConnection conn = new SqlConnection(db.str);
                if ((textBox1.Text).Equals(string.Empty))
                {
                    MessageBox.Show("请选择正确的航班!", "提示", MessageBoxButtons.OK);
                }
                else
                {
                    if (Convert.ToDateTime(dateTimePicker1.Text) < Convert.ToDateTime(DateTime.Now.ToString()))
                    {
                        MessageBox.Show("请输入正确日期", "提示", MessageBoxButtons.OK);
                    }
                    else
                    {
                        if (numericUpDown1.Value > 0)
                        {
                            Random r = new Random();
                            int a = r.Next(10000, 1000000);
                            string sql = @"insert into OrderInfo(OrderId,FlightNo,LeaveDate,Number) Values
                    ('" + a + "','" + textBox1.Text + "','" + dateTimePicker1.Value.ToString() + "','" + numericUpDown1.Value.ToString() + "')";

                            conn.Open();
                            SqlCommand cmd = new SqlCommand(sql, conn);

                            int b = cmd.ExecuteNonQuery();
                            if (b == 1)
                            {
                                MessageBox.Show("成功,您的机票编号为:" + a, "提示", MessageBoxButtons.OK);
                                conn.Close();
                            }
                        }
                        else
                        {
                            MessageBox.Show("乘坐人数为0!", "警告", MessageBoxButtons.OK);
                        }
                    }
                }
            }
        }
    }

     

      private void button3_Click(object sender, EventArgs e)
            {
                DialogResult result = MessageBox.Show("确定退出吗!!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (result == DialogResult.Yes)
                {
                    this.Close();
                }

            }

    要注意细节   事件 方法 属性 等等!!!

  • 相关阅读:
    elasticsearch 中的Multi Match Query
    activiti 流程部署的各种方式
    elasticsearch 嵌套对象之嵌套类型
    elasticsearch Java High Level REST 相关操作封装
    elasticsearch 字段数据类型
    ubuntu 安装 docker
    elasticsearch 通过HTTP RESTful API 操作数据
    facenet 人脸识别(二)——创建人脸库搭建人脸识别系统
    POJ 3093 Margaritas(Kind of wine) on the River Walk (背包方案统计)
    墨卡托投影, GPS 坐标转像素, GPS 坐标转距离
  • 原文地址:https://www.cnblogs.com/caiguoxin/p/8523813.html
Copyright © 2011-2022 走看看