📄 goupiao.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 goupiao : Form
{
public goupiao()
{
InitializeComponent();
}
public int price;
public int number;
public int sum;
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();
while (odr.Read())
{
textBox4.Text = odr["价格"].ToString();
}
odr.Close();
conn.Close();
}
private void button3_Click(object sender, EventArgs e)
{
number = int.Parse(textBox2.Text);
price = int.Parse(textBox4.Text);
sum = number * price;
textBox3.Text = sum.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
static int i=0;
static int j=0;
static int k=1;
static int r=0;
private void button4_Click(object sender, EventArgs e)
{
string arrivel = textBox1.Text;
string lieci = null;
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();
while (odr.Read())
{
lieci = odr["车次"].ToString();
}
label6.Text ="泉州-" + textBox1.Text +" 车次是: " +lieci+"车票日期是: "+textBox5.Text;
if (i < 30)
{
k = j;
j=j+int.Parse(textBox2.Text);
r = i;
if (j > 8)
{
i++;
j = j - 8;
}
}
else
MessageBox.Show("该车已经满座了");
if (int.Parse(textBox2.Text) == 1)
{
label8.Text = "您的座位是: " + (i+1).ToString() + "排 " + j.ToString() + "座";
if (r != i)
{
label8.Text = "您的座位是: " + (r+1).ToString() + "排" + (k+1).ToString() + " ~ " + "8座" + (i+1).ToString() + "排" +" 1 ~ "+ j.ToString() + "座";
}
}
else
{
label8.Text = "您的座位是: " + (i+1).ToString() + "排 " + (k+1).ToString() + " ~ " + j.ToString() + "座";
if (r != i)
{
label8.Text = "您的座位是: " + (r + 1).ToString() + "排" + (k+1).ToString() + " ~ " + "8座" + (i + 1).ToString() + "排" + " 1 ~ " + j.ToString() + "座";
}
}
odr.Close();
conn.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -