jl_tixing.cs

来自「此系统开发了一个公交车管理系统。系统根据权限的不同」· CS 代码 · 共 100 行

CS
100
字号
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 JL_tixing : Form
    {
        public JL_tixing()
        {
            InitializeComponent();
        }

        private void JL_tixing_Load(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;
            DateTime dt1 = dt.AddDays(-1);
            string str1 = dt.ToString("yyyy-MM-dd");
            String str = dt1.ToString("yyyy-MM-dd");
            this.lbLoadTime.Text = str1;
            this.lbBiaoxian.Text = str1;
            this.Way();
            this.Baoxian();

        }
        private void Way()
        {
            DateTime dt = DateTime.Now;
            DateTime dt1 = dt.AddDays(-1);
            string str1 = dt.ToString("yyyy-MM-dd");
            String str = dt1.ToString("yyyy-MM-dd");
            this.lbLoadTime.Text = str1;
            this.lbBiaoxian.Text = str1;
            DateTime loadtime =Convert.ToDateTime(str.ToString());
            string dl = ConfigurationManager.AppSettings["sqlString"];
            //创建connection对象con进行连接
            SqlConnection con = new SqlConnection(dl);
            //打开连接
            con.Open();
            string sql = "select car_number as 车牌号,car_rank as 品牌,car_fee as 养路费,car_feestart as 养路费起始时间,car_feeend as 养路费结束时间,car_remark as 备注 from db_car where car_feeend = '" + loadtime + "'";
            SqlCommand cmd = new SqlCommand(sql, con);
            SqlDataAdapter sdr = new SqlDataAdapter();
            //sdr的查询方法为cmd
            sdr.SelectCommand = cmd;
            //创建一个dataset容器
            DataSet ds = new DataSet();
            //填充数据ds
            sdr.Fill(ds);
            this.GridViewLoad.DataSource = ds.Tables[0].DefaultView;
            GridViewLoad.Columns[0].Width = 75;
            GridViewLoad.Columns[1].Width = 100;
            GridViewLoad.Columns[2].Width = 70;
            GridViewLoad.Columns[3].Width = 120;
            GridViewLoad.Columns[4].Width = 120;
            GridViewLoad.Columns[5].Width = 150;
        }
        private void Baoxian()
        {
            DateTime dt = DateTime.Now;
            DateTime dt1 = dt.AddDays(-1);
            string str1 = dt.ToString("yyyy-MM-dd");
            String str = dt1.ToString("yyyy-MM-dd");
            this.lbLoadTime.Text = str1;
            this.lbBiaoxian.Text = str1;
            DateTime Biaoxian = Convert.ToDateTime(str.ToString());
            string dl = ConfigurationManager.AppSettings["sqlString"];
            //创建connection对象con进行连接
            SqlConnection con = new SqlConnection(dl);
            //打开连接
            con.Open();
            string sql = "select car_number as 车牌号,car_rank as 品牌,car_insurance as 保险费,car_instart as 保险费起始时间,car_inend as 保险费结束时间,car_remark as 备注 from db_car where car_inend = '" + Biaoxian + "'";
            SqlCommand cmd = new SqlCommand(sql, con);
            SqlDataAdapter sdr = new SqlDataAdapter();
            //sdr的查询方法为cmd
            sdr.SelectCommand = cmd;
            //创建一个dataset容器
            DataSet ds = new DataSet();
            //填充数据ds
            sdr.Fill(ds);
            this.GridViewbaoxian.DataSource = ds.Tables[0].DefaultView;
            GridViewbaoxian.Columns[0].Width = 75;
            GridViewbaoxian.Columns[1].Width = 100;
            GridViewbaoxian.Columns[2].Width = 70;
            GridViewbaoxian.Columns[3].Width = 120;
            GridViewbaoxian.Columns[4].Width = 120;
            GridViewbaoxian.Columns[5].Width = 150;
        }

        private void tabPage2_Click(object sender, EventArgs e)
        {

        }
    }
}

⌨️ 快捷键说明

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