⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pt_car_repair.cs

📁 此系统开发了一个公交车管理系统。系统根据权限的不同
💻 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;
using System.Configuration;

namespace CarManage
{
    public partial class PT_Car_Repair : Form
    {
        public PT_Car_Repair()
        {
            InitializeComponent();
        }

        private void label19_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string CheckRepairNumber = this.textCheckRepairNumber.Text.ToString().Trim();
            string CheckRepairName = this.textCheckRepairName.Text.ToString().Trim();
            DateTime CheckRepairTime = Convert.ToDateTime(this.textCheckRepairTime.Value.ToShortDateString());
            string sqlstr = "select repair_id as 序号,repair_number as 车牌号码,repair_name as 修车姓名,repair_time as 修车时间,repair_money as 修车费用,repair_reason as 修车原因,repair_worktime as 工时,repair_remark as 备注 from db_repair where 1 = 1";
            //调用config配置文件对象dl连接对象
            string dl = ConfigurationManager.AppSettings["sqlString"];
            //创建connection对象con进行连接
            SqlConnection con = new SqlConnection(dl);
            //打开连接
            con.Open();
            if (textCheckRepairTime.Checked)
            {
                sqlstr = sqlstr + "and repair_time = '" + CheckRepairTime + "'";

            }
            if (CheckRepairNumber != "")
            {
                sqlstr = sqlstr + "and repair_number = '" + CheckRepairNumber + "'";

            }
            if (CheckRepairName != "")
            {
                sqlstr = sqlstr + "and repair_name = '" + CheckRepairName + "'";

            }
            SqlCommand cmd = new SqlCommand(sqlstr, con);
            //创建读取器对象sdr
            SqlDataAdapter sdr = new SqlDataAdapter();
            //sdr的查询方法为cmd
            sdr.SelectCommand = cmd;
            //创建一个dataset容器
            DataSet ds = new DataSet();
            //填充数据ds
            sdr.Fill(ds);
            //绑定datagriview数据源为ds
            this.GridViewCheckResult.DataSource = ds.Tables[0].DefaultView;
            //关闭连接
            con.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.textCheckRepairNumber.Clear();
            this.textCheckRepairName.Clear();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -