4.2.2 登记收费模块
登记收费界面实现收费管理。程序运行结果如图4.4所示。
图4.4登记收费模块
主要的功能代码如下:
private void button1_Click(object sender, EventArgs e) {
if (textBox1.Text == \请输入ID!\
else if (textBox2.Text == \请输入车辆ID!\ else if (textBox3.Text == \请输入项目!\ else if (textBox4.Text == \请输入日期!\ else { try
{ string strconn = \Security=True\
string sql2 = \into record values('\+ textBox1.Text + \+ textBox2.Text + \ connection.Open();
SqlCommand command2 = new SqlCommand(sql2, connection); command2.ExecuteNonQuery(); connection.Close(); showlist();
textBox1.Text = textBox2.Text = textBox3.Text = textBox4.Text=\ }
catch (Exception ex) {
MessageBox.Show(\登记错误!\ } } }
14
4.4客户管理模块
4.4.1 客户信息模块
客户信息界面实现客户信息查询功能。程序运行结果如图4.5所示。
图4.5客户信息模块
主要的功能代码如下:
private void button1_Click(object sender, EventArgs e) {
string cha= \
if (comboBox1.Text == \姓名\ if (comboBox1.Text == \性别\ if (comboBox1.Text == \年龄\ if (comboBox1.Text == \联系方式\ if (comboBox1.Text == \地址\ string strconn, strsql;
strconn = \ strsql = \姓名,sex as 性别,age as 年龄 ,tel as 联系方式, addr as 地址 from customer where \ SqlConnection myconn = new SqlConnection(strconn); SqlDataAdapter myda = new SqlDataAdapter(strsql, myconn); DataSet myds = new DataSet(); myda.Fill(myds, \
dataGridView1.DataSource = myds.Tables[\ }
15
4.4.2 新增客户模块
登陆界面实现管理员登录。程序运行结果如图4.6所示。
图4.6新增客户模块
主要的功能代码如下:
private void button1_Click(object sender, EventArgs e) {
if (textBox1.Text == \请输入ID!\ else if (textBox2.Text == \请输入姓名!\ else if (textBox3.Text == \请输入性别!\ else if (textBox4.Text == \请输入年龄!\ else if (textBox5.Text == \请输入联系方式!\ else if (textBox6.Text == \请输入地址!\ else { try {
string strconn = \Security=True\
SqlConnection connection = new SqlConnection(strconn );
string sql2 = \textBox1.Text + \textBox5.Text + \ connection.Open();
SqlCommand command2 = new SqlCommand(sql2, connection); command2.ExecuteNonQuery(); connection.Close(); showlist();
16
textBox1.Text = textBox2.Text = textBox3.Text = textBox4.Text = textBox5.Text = textBox6.Text = \ }
catch (Exception ex) {
MessageBox.Show(\添加错误!\ } } }
4.4.3客户修改模块
登陆界面实现管理员登录。程序运行结果如图4.7所示。
图4.7客户修改模块
主要的功能代码如下:
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 == \姓名\
17
if (comboBox1.Text == \性别\ if (comboBox1.Text == \年龄\ if (comboBox1.Text == \联系方式\ if (comboBox1.Text == \地址\
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=textBox2.Text = \ }
catch (Exception ex) {
MessageBox.Show(\修改错误!\ } } }
4.4.4客户删除模块
登陆界面实现管理员登录。程序运行结果如图4.8所示。
图4.8客户删除模块
18