public FrmCrystalReport(HandoverStatisticReport report, UserInfo userInfo)
 {
     InitializeComponent();
     _userInfo = userInfo;
     crystalReportViewer1.ReportSource = report;
     this.WindowState = FormWindowState.Maximized;
 }
        private void btnPrintReport_Click(object sender, EventArgs e)
        {
            ECustoms.HandoverStatisticReport report = new HandoverStatisticReport();
            // Cuc hai quan
            ((TextObject)report.Section1.ReportObjects["SuperiorCompany"]).Text = GetUserConfig().ToUpper();
            // Chi cuc hai quan
            ((TextObject)report.Section1.ReportObjects["CompanyName"]).Text = GlobalInfo.CompanyName.ToUpper();

            //StringBuilder buffer = new StringBuilder();
            //buffer.Append(" SELECT * FROM ViewAllDeclarationTNTX ");
            //buffer.Append(" WHERE DeclarationID != 0 AND DeclarationID != 1 ");


            //var connection = new SqlConnection(Common.Decrypt(System.Configuration.ConfigurationSettings.AppSettings["connectionString"], true));

            //var adpater = new SqlDataAdapter(buffer.ToString(), connection);
            //var dt = new DataTable();
            //adpater.Fill(dt);
            //report.SetDataSource(dt);

            DataSet2 dataSet2 = new DataSet2();
            DataTable table1 = dataSet2.ViewAllDeclarationTNTX;
            foreach (ViewAllDeclaration obj in _listDeclarationinfo)
            {
                table1.Rows.Add(
                    obj.DeclarationID,
                    obj.Number,
                    null,
                    null,
                    null,
                    obj.Unit,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    obj.Type,
                    null,
                    obj.RegisterDate,
                    null,
                    null,
                    null,
                    obj.RegisterPlace,
                    null,
                    obj.NumberHandover,
                    obj.DateHandover,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    obj.Seal,
                    1,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null);
            }

            report.SetDataSource(dataSet2);
            //preview report
            var reportForm = new FrmCrystalReport(report, _userInfo);
            reportForm.MaximizeBox = true;
            reportForm.Show(this);

        }
 public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() {
     HandoverStatisticReport rpt = new HandoverStatisticReport();
     rpt.Site = this.Site;
     return rpt;
 }