winForm 报表使用

来源:互联网 发布:秦始皇南京 知乎 编辑:程序博客网 时间:2024/05/16 04:51

//winform ——formReport窗体放置reportViewer1控件

private void formReport_Load(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            
            this.reportViewer1.LocalReport.ReportEmbeddedResource = "System.Report1.rdlc";//报表文件路径
            this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("view_DataSet", this.GetData()));
            this.reportViewer1.RefreshReport();
            this.Cursor = Cursors.Default;
        }
        private DataTable GetData()
        {
            return dao.GetData("Select * from wind Order BY ID");
        }

//另一窗体调用

     private void button1_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.Rows.Count == 0)
            {
                MessageBox.Show("当前没有数据!", "警告!");
            }
            else
            {
                this.Cursor = Cursors.WaitCursor;
                new formReport().ShowDialog();
                this.Cursor = Cursors.Default;
            }
        }

==============使用域账号

引用

 [DllImport("advapi32.dll")]
        public static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);

----------程序中调用

LogonUser(this.txtUserName.Text.Trim(), Environment.UserDomainName, this.txtPassWord.Text.Trim(), 2, 0, ref phToken)

原创粉丝点击