本文介绍了从文本框和日期时间选择器C#中过滤数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Filter datatable from text box and datetime picker
一些帮助?
我尝试过:
Some help?
What I have tried:
private void izvjestajoprodanimartiklima()
{
using (SqlConnection openCon = new SqlConnection(cs))
{
String saveStaff = "SELECT roba as 'Naziv artikla', SUM (cast(kolicina as float)) as 'Kolicina' from (select roba, kolicina from mp_racun_roba union all select roba, kolicina from mp_faktura_roba) as alltables group by roba";
if (!string.IsNullOrEmpty(textBox1.Text))
{
saveStaff += "roba LIKE '%" + textBox1.Text + "%' ";
}
if (checkBox1.Checked)
{
String strFilterDTP1 = dateTimePicker1.Value.ToString("yyyy-MM-dd");
String strFilterDTP2 = dateTimePicker2.Value.ToString("yyyy-MM-dd");
saveStaff += strFilterDTP1 + " 00:00:00' AND '" + strFilterDTP2 + " 23:59:59' ";
}
推荐答案
这篇关于从文本框和日期时间选择器C#中过滤数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!