文档详情

C数据库应用系统(机票预定系统)源代码.pdf

发布:2025-02-15约3.4千字共3页下载文档
文本预览下载声明

C#数据库应用系统(机票预定系统)源代码

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Linq;

usingSystem.Text;

usingSystem.Data.SqlClient;

usingSystem.Windows.Forms;

namespaceTicketOrder

{

publicpartialclassForm1:Form

{

publicForm1()

{

InitializeComponent();

}

stringsql=;

stringconnStr=@server=sa\SQLEXPRESS;database=Ticket;trusted_connection=true;

SqlDataAdapterda;

DataSetds;

privatevoidForm1_Load(objectsender,EventArgse)

{

sql=selectFlightNOas航班号,LeaveCityas出发城市,Destinationas目的城

市,LeaveTimeas出发时间fromTicketInfowhere1=1;

Fill();

}

///summary

///初始化函数

////summary

privatevoidFill()

{

da=newSqlDataAdapter(sql,connStr);

ds=newDataSet();

try

{

da.Fill(ds);

dataGridView1.DataSource=ds.Tables[0];

}

catch(Exceptionex)

{

MessageBox.Show(输入信息有误,可能有不能识别的字符!

+ex.Message);

}

}

privatevoidbutton3_Click(objectsender,EventArgse)

{

boolisNew=true;

while(isNew)

{

if(txtChufa.Text!=)

{

sql+=string.Format(andLeaveCitylike%{0}%,txtChufa.Text);

Fill();

}

if(txtMudi.Text!=)

{

sql+=string.Format(andDestinationlike%{0}%,txtMudi.Text);

Fill();

}

显示全部
相似文档