标题:C#报表问题,求高手指导
取消只看楼主
C_Guangwei
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-10-10
结帖率:100%
已结贴  问题点数:20 回复次数:0 
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();
        }
    }
}
搜索更多相关主题的帖子: 论文 大学生 中国 资源 
2011-10-10 16:45



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-351997-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.598982 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved