C#报表问题,求高手指导
本人有一C#报表程序,现在想在主界面上添加一按日期筛选的条件来操作报表,但是我的数据库语句些在累里面,筛选条件在主界面,实在不知道怎么写,以下是我的程序,求指导这是报表的类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace EmcsSys.BLL
{
public class EmcsManager
{
private string conStr = "Data Source=.;Initial Catalog=306hist;User ID=sa;Password=chenguangwei;";
public List<equipmentrun> GetEquipmentrun() {
List<equipmentrun> Equipmentrun = new List<equipmentrun>();
string sql = "select * from equipmentrun ; //日期字段为logtime
using (SqlConnection conn = new SqlConnection(conStr)) {
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
using (SqlDataReader reader = cmd.ExecuteReader()) {
while (reader.Read()) {
equipmentrun Equipmentrun1 = new equipmentrun();
Equipmentrun1.Logtime = Convert.ToDateTime(reader["logtime"]);
Equipmentrun1.Tagname = Convert.ToString(reader["tagname"]);
Equipmentrun1.Tagvalue = Convert.ToInt32(reader["tagvalue"]);
Equipmentrun.Add(Equipmentrun1);
}
}
}
return Equipmentrun;
}
}
}
这是界面程序(本人想从界面上添加一按日期查询的条件,不知道怎样写进去):
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace EmcsSys.UI
{
public partial class Home : Form
{
public Home()
{
InitializeComponent();
}
private void tlsDTrun_Click(object sender, EventArgs e)
{
Form1 for1 = new Form1();
for1.MdiParent = this;
for1.Show(); //输出报表界面
}
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
这是报表界面程序:
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using EmcsSys.BLL;
using Microsoft.Reporting.WinForms;
namespace EmcsSys.UI
{
..........
private void Form1_Load(object sender, EventArgs e)
{
this.reportViewer1.LocalReport.ReportEmbeddedResource = "EmcsSys.UI.rptEquipmentrun.rdlc";
EmcsManager manager = new EmcsManager();
List<equipmentrun> list = manager.GetEquipmentrun();
ReportDataSource source = new ReportDataSource();
source.Name = "EmcsSys_BLL_equipmentrun";
source.Value = list;
this.reportViewer1.LocalReport.DataSources.Add(source);
this.reportViewer1.RefreshReport();
}
}
}