Пример #1
0
        private void Button_Query_Click(object sender, EventArgs e)
        {
            ProgressScreen.Current.ShowSplashScreen();
            this.AddOwnedForm(ProgressScreen.Current);

            ProgressScreen.Current.SetStatus = "正在初始化报表参数......";
            String descriptor = cBox_Types.SelectedItem.ToString();

            Guid reportID = ReportService.GetReportIDByName(descriptor);
            List <ReportParameter> Parameters = ReportService.GetReportParameters(reportID);

            foreach (ReportParameter parameter in Parameters)
            {
                if (parameter.Name.ToLower() == "@startdate")
                {
                    parameter.Value = string.Format("{0}-{1}-{2} 00:00:00", @startdate.Value.Year, @startdate.Value.Month, @startdate.Value.Day);
                }
                if (parameter.Name.ToLower() == "@enddate")
                {
                    parameter.Value = string.Format("{0}-{1}-{2} 23:59:59", @enddate.Value.Year, @enddate.Value.Month, @enddate.Value.Day);
                }
            }

            ProgressScreen.Current.SetStatus = "正在分析并生成报表......";
            String ReportXml = ReportService.GetReportString(reportID,
                                                             string.Format("{0}-{1}-{2} 00:00:00", @startdate.Value.Year, @startdate.Value.Month, @startdate.Value.Day),
                                                             string.Format("{0}-{1}-{2} 23:59:59", @enddate.Value.Year, @enddate.Value.Month, @enddate.Value.Day),
                                                             "",
                                                             Parameters);

            if (ReportXml != "")
            {
                ProgressScreen.Current.SetStatus = "正在显示报表......";
                FpSpread           ReportSpread = Serializer.LoadObjectXml(typeof(FpSpread), ReportXml, "FpSpread") as FpSpread;
                OwnerPrintDocument Document     = new OwnerPrintDocument(ReportSpread);
                Document.ShowPrinterDialog = false;
                reportViewer1.UseAntiAlias = true;
                reportViewer1._FpSpreed    = ReportSpread;
                reportViewer1.Document     = Document;
            }

            this.RemoveOwnedForm(ProgressScreen.Current);
            ProgressScreen.Current.CloseSplashScreen();
            this.Activate();

            if (ReportXml == "")
            {
                MessageBox.Show("报表‘" + descriptor + "’没有找到!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            this.RemoveOwnedForm(ProgressScreen.Current);
            ProgressScreen.Current.CloseSplashScreen();
            this.Activate();
        }
Пример #2
0
        private void tsBtnPageSettings_Click(object sender, EventArgs e)
        {
            OwnerPrintDocument Document = this.mDocument as OwnerPrintDocument;

            if (Document != null)
            {
                PrintInfoDialog.PrintSet = Document.PrintInfo;
                if (DialogResult.OK == PrintInfoDialog.ShowDialog())
                {
                    Document.PrintInfo = PrintInfoDialog.PrintSet;
                    PrintPreviewControl1.InvalidatePreview();
                }
            }
        }
Пример #3
0
        public new void PrintSheet(int SheetIndex)
        {
            if (SheetIndex >= 0 && SheetIndex < Sheets.Count)
            {
                SheetView sheetView = Sheets[SheetIndex];

                FpSpread Spread = new FpSpread();
                Spread.Sheets.Add(sheetView);
                OwnerPrintDocument Document = new OwnerPrintDocument(Spread);
                Document.PrintInfo = sheetView.PrintInfo;

                if (Sheets[SheetIndex].PrintInfo.Preview)
                {
                    PrintPreviewDialog Dialog = new PrintPreviewDialog();
                    Dialog.WindowState = FormWindowState.Maximized;
                    Dialog.PrintPreviewControl.Zoom = 1.0;
                    Dialog.Document     = Document;
                    Dialog.UseAntiAlias = true;
                    Dialog.ShowDialog();
                }
                else
                {
                    Document.Print();
                }
            }
            else if (SheetIndex == -1)
            {
                PrintDialog Dialog = new PrintDialog();
                Dialog.AllowSomePages             = true;
                Dialog.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.SomePages;
                Dialog.PrinterSettings.FromPage   = 1;
                Dialog.PrinterSettings.ToPage     = 1;
                Dialog.UseEXDialog = true;

                if (DialogResult.OK == Dialog.ShowDialog())
                {
                    foreach (SheetView Sheet in Sheets)
                    {
                        FpSpread Spread = new FpSpread();
                        Spread.Sheets.Add(Sheet);
                        OwnerPrintDocument Document = new OwnerPrintDocument(Spread);
                        Document.ShowPrinterDialog = false;
                        Document.PrinterSettings   = Dialog.PrinterSettings;
                        Document.PrintInfo         = Sheet.PrintInfo;
                        Document.Print();
                    }
                }
            }
        }
Пример #4
0
        private void Button_Query_Click(object sender, EventArgs e)
        {
            if (IsNullStatLocation())
            {
                MessageBox.Show("请选择一个统计范围!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            ProgressScreen.Current.ShowSplashScreen();
            this.AddOwnedForm(ProgressScreen.Current);

            ProgressScreen.Current.SetStatus = "正在初始化报表参数......";
            String descriptor = cBox_Types.SelectedItem.ToString();

            Guid reportID = ReportService.GetReportIDByName(descriptor);
            List <ReportParameter> Parameters = ReportService.GetReportParameters(reportID);
            String SegmentName   = "";
            String CompanyName   = "";
            String testRoomCodes = "";

            testRoomCodes = GetFirstSelectInfo(out SegmentName, out CompanyName);
            foreach (ReportParameter parameter in Parameters)
            {
                if (parameter.Name.ToLower() == "@startdate")
                {
                    parameter.Value = string.Format("{0}-{1}-{2}", StartDateTimePicker.Value.Year, StartDateTimePicker.Value.Month, StartDateTimePicker.Value.Day);
                }
                else if (parameter.Name.ToLower() == "@enddate")
                {
                    parameter.Value = string.Format("{0}-{1}-{2}", EndDateTimePicker.Value.Year, EndDateTimePicker.Value.Month, EndDateTimePicker.Value.Day);
                }
                else if (parameter.Name.ToLower() == "@segmentname")
                {
                    parameter.Value = SegmentName;
                }
                else if (parameter.Name.ToLower() == "@companyname")
                {
                    parameter.Value = CompanyName;
                }
                else if (parameter.Name.ToLower() == "@now")
                {
                    parameter.Value = DateTime.Now.ToString("yyyy-MM-dd");
                }
            }

            ProgressScreen.Current.SetStatus = "正在分析并生成报表......";
            String ReportXml = ReportService.GetReportString(reportID,
                                                             string.Format("{0}-{1}-{2} 00:00:00", StartDateTimePicker.Value.Year, StartDateTimePicker.Value.Month, StartDateTimePicker.Value.Day),
                                                             string.Format("{0}-{1}-{2} 23:59:59", EndDateTimePicker.Value.Year, EndDateTimePicker.Value.Month, EndDateTimePicker.Value.Day),
                                                             testRoomCodes,
                                                             Parameters);

            if (ReportXml != "")
            {
                ProgressScreen.Current.SetStatus = "正在显示报表......";
                FpSpread  ReportSpread = new FpSpread();
                SheetView sv           = Serializer.LoadObjectXml(typeof(SheetView), ReportXml, "SheetView") as SheetView;
                ReportSpread.Sheets.Add(sv);
                OwnerPrintDocument Document = new OwnerPrintDocument(ReportSpread);
                Document.ShowPrinterDialog = false;
                reportViewer1.UseAntiAlias = true;
                reportViewer1._FpSpreed    = ReportSpread;
                reportViewer1.Document     = Document;
            }

            this.RemoveOwnedForm(ProgressScreen.Current);
            ProgressScreen.Current.CloseSplashScreen();
            this.Activate();

            if (ReportXml == "")
            {
                MessageBox.Show("报表‘" + descriptor + "’没有找到!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }