C#2012连接SQL server2008设计机票预订系统
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 ticket : Form
{
LinkDatabase link = new LinkDatabase();
public ticket()
{
InitializeComponent();
}
private void button4_Click(object sender, EventArgs e)
{
string sendstrsql = "SELECT 航班号,座位号,机票类型 FROM 机票 WHERE 航班号='+ sel_Pno.Text +' AND 座位号='+ sel_Pseat.Text +'";
DataTable dt1 = link.dsresult(sendstrsql);
dataGridView2.DataSource= dt1.DefaultView;
}
private bool checkEmpty()
{
bool result = true;
if (add_Pseat.Text.Trim() == string.Empty)
result = false;
else if (add_Tno.Text.Trim() == string.Empty)
result = false;
else if (add_Ttype.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('" + add_Pseat.Text + "','" + add_Tno + "','" + add_Ttype + "')";