📄 chaxun.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace pwxt
{
public partial class chaxun : Form
{
public chaxun()
{
InitializeComponent();
}
private void chaxun_Load(object sender, EventArgs e)
{
lv.View = View.Details;
lv.Columns.Add("站名", lv.Width / 4, HorizontalAlignment.Left);
lv.Columns.Add("车次", lv.Width / 4, HorizontalAlignment.Left);
lv.Columns.Add("时间", lv.Width / 4, HorizontalAlignment.Left);
lv.Columns.Add("价格", lv.Width / 4, HorizontalAlignment.Left);
}
private void button1_Click(object sender, EventArgs e)
{
string arrivel=textBox1.Text;
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["connectionstring"]);
SqlCommand cmd=new SqlCommand ("Select * From LCtable Where 站名='"+arrivel+"'",conn);
SqlDataReader odr = null;
conn.Open();
odr = cmd.ExecuteReader();
if (odr != null)
{
while (odr.Read())
{
ListViewItem lvi = new ListViewItem();
lvi.Text = odr["站名"].ToString();
lvi.SubItems.Add(odr["车次"].ToString());
lvi.SubItems.Add(odr["时间"].ToString());
lvi.SubItems.Add(odr["价格"].ToString());
lv.Items.Add(lvi);
}
}
else
MessageBox.Show("目前还没有到达该目的站的列车", "error",MessageBoxButtons.OK);
odr.Close();
conn.Close();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -