datetimepicker如何与单选按钮链接

时间:2018-12-26 06:28:01

标签: c# sql-server radio-button datetimepicker datetime-format

朋友

如果有时间请 现在我想在单选按钮和datetimepicker之间建立链接,形式可能是3个单选按钮(年,月,日)和2个datetimepicker(从,到),我正在使用sql server wis列类型(datetime2(0))它是完整的日期时间(2018-12-18 08:25:10.0000000)和一个搜索按钮。 我想要做的是使datetimepicker的单选按钮更改格式,并通过我选择的按钮进行搜索。 my fome

我的搜索代码

DataTable sd = new DataTable();
        if (comboBox1.Text == "all")
        {
            con.Open();
            SqlCommand command = new SqlCommand("select * from sreport3 where Time between'" + dateTimePicker1.Value.ToString() + "'and'" + dateTimePicker2.Value.ToString() + "'", con);
            SqlDataReader reader = command.ExecuteReader();

            sd.Load(reader);
            dataGridView1.DataSource = sd;
            reader.Close();
            con.Close();
        }
        else
        {
            con.Open();
            SqlCommand command = new SqlCommand("select * from sreport2 where Time between'" + dateTimePicker1.Value.ToString() + "'and'" + dateTimePicker2.Value.ToString() + "' INTERSECT select * from sreport2 where username = '" + comboBox1.Text.ToString() + "'", con);
            SqlDataReader reader = command.ExecuteReader();

            sd.Load(reader);
            dataGridView1.DataSource = sd;
            reader.Close();
            con.Close();
        }

        chart1.Series["Live"].XValueMember = "Time";
        chart1.Series["Live"].XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.DateTime;
        chart1.Series["Live"].YValueMembers = "CountOfusername";
        chart1.Series["Live"].YValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;
        chart1.DataSource = sd;
        chart1.DataBind();

可以成功还是不可以
投票回答我的问题,以帮助我获得答案

热烈的问候

0 个答案:

没有答案