标题:.net开发机票查询
只看楼主
lovewar_ms
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-3-30
 问题点数:0 回复次数:0 
.net开发机票查询
我想实现的效果是,点击哪一行,(我用DataGridView做的),GroupBox航班详细信息中显示出对应的。下面是我写的代码

private void dgvTicketInfo_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                DBHelper.con.Open();
                int Id = Convert.ToInt32(dgvTicketInfo.SelectedRows[0].Cells["Id"].Value);
                string sql = string.Format("select LeaveCity,Destination,LeaveTime,SecondClass,FirstClass from TicketInfo where Id={0}", Id);
                SqlCommand com = new SqlCommand(sql, DBHelper.con);
                SqlDataReader reader = com.ExecuteReader();
                while (reader.Read())
                {
                    txtTo.Text = reader[0].ToString();
                    txtFrom.Text = reader[1].ToString();
                    txtLeaveTime.Text = reader[2].ToString();
                    txtSecondClass.Text = reader[3].ToString();
                    txtFirstClass.Text = reader[4].ToString();
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                DBHelper.con.Close();
            }


航班详细信息是一个grp,里面又多个Text box 想选中DGV里面的某一列,显示在下面的Text box里(不可编辑)
搜索更多相关主题的帖子: 机票查询 private 详细信息 where 
2011-03-30 23:10



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-335249-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.049882 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved