主要的功能代码如下:
private void button1_Click(object sender, EventArgs e) {
if (textBox1.Text == \请输入ID!\ else { try {
string strconn = \Security=True\
SqlConnection connection = new SqlConnection(strconn); string sql2 = \ connection.Open();
SqlCommand command2 = new SqlCommand(sql2, connection); command2.ExecuteNonQuery(); connection.Close(); showlist();
textBox1.Text = \ }
catch (Exception ex)
{ MessageBox.Show(\添加错误!\ } }
4.5 车辆管理模块
4.5.1 车辆信息模块
程序运行结果如图4.9所示:
图4.9车辆信息模块
19
主要的功能代码如下: private void showlist() {
try {
string strconn, strsql;
strconn = \Security=True\
strsql = \车主ID,brand as 品牌 from car\ SqlConnection myconn = new SqlConnection(strconn); SqlDataAdapter myda = new SqlDataAdapter(strsql, myconn); DataSet myds = new DataSet(); myda.Fill(myds, \
dataGridView1.DataSource = myds.Tables[\ }
catch (Exception ex) {
MessageBox.Show(\刷新错误!\ } }
4.5.2新增车辆模块
程序运行结果如图4.10所示。
图4.10新增车辆模块
20
主要的功能代码如下:
private void button1_Click(object sender, EventArgs e) { try {
string strconn = \Security=True\
SqlConnection connection = new SqlConnection(strconn);
string sql2 = \into car(id,cus_id,brand) values('\+ textBox1.Text + \+ textBox2.Text + \ connection.Open();
SqlCommand command2 = new SqlCommand(sql2, connection); command2.ExecuteNonQuery(); connection.Close(); showlist();
textBox1.Text = textBox2.Text = textBox3.Text = \ }
catch (Exception ex) {
MessageBox.Show(\添加错误!\ } }
4.5.3车辆修改模块
程序运行结果如图4.11所示。
图4.11车辆修改模块
21
主要的功能代码如下:
private void button1_Click(object sender, EventArgs e)
{ if (textBox1.Text == \请输入ID!\
else if (textBox2.Text == \请输入修改值!\ else if (comboBox1.Text == \请输入修改项!\ else {try
{string cha = \
if (comboBox1.Text == \车主ID\ if (comboBox1.Text == \品牌\
string strconn = \Security=True\
SqlConnection connection = new SqlConnection(strconn);
string sql2 = \+ textBox1.Text + \
connection.Open();
SqlCommand command2 = new SqlCommand(sql2, connection); command2.ExecuteNonQuery(); connection.Close(); showlist();
textBox1.Text = textBox2.Text = \ }
catch (Exception ex) {
MessageBox.Show(\修改错误!\} } }
4.5.4车辆删除模块
程序运行结果如图4.12所示。
图4. 12车辆删除模块
22
主要的功能代码如下:
private void button1_Click(object sender, EventArgs e) {
if (textBox1.Text == \请输入ID!\ else { try {
string strconn = \Security=True\
SqlConnection connection = new SqlConnection(strconn); string sql2 = \ connection.Open();
SqlCommand command2 = new SqlCommand(sql2, connection); command2.ExecuteNonQuery(); connection.Close(); showlist(); textBox1.Text = \ }
catch (Exception ex) {
MessageBox.Show(\删除错误!\}}}
4.6 项目管理模块
4.6.1项目信息模块
程序运行结果如图4.13所示。
图4.13项目信息模块
23