Exemplo n.º 1
0
        private void BtnGenerarReporte_Click(object sender, EventArgs e)
        {
            try
            {
                if (LookUpMeses.Text.Equals("Seleccione"))
                {
                    XtraMessageBox.Show("Por favor seleccione mes.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    mes = LookUpMeses.EditValue.ToString();
                }
                if (LookUpAño.Text.Equals("Seleccione"))
                {
                    XtraMessageBox.Show("Por favor seleccione año.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    año = LookUpAño.EditValue.ToString();
                }
                splash.ShowWaitForm();
                splash.SetWaitFormCaption("Generando Reporte..");
                XtraReport reporte;
                reporte = new Reports.RepNomina(mes, año);
                ReportPrintTool printTool    = new ReportPrintTool(reporte);
                PrintControl    printControl = printTool.PreviewForm.PrintControl;
                //PrintControl printControl = printTool.PreviewRibbonForm.PrintControl;


                // Zoom the document, so that it fits the entire page into the Print Preview's dimensions.
                if (printControl.CanExecCommand(PrintingSystemCommand.ViewWholePage))
                {
                    printControl.ExecCommand(PrintingSystemCommand.ViewWholePage);
                }

                // Invoke the Hand tool to scroll the document using the mouse.
                if (printControl.CanExecCommand(PrintingSystemCommand.HandTool))
                {
                    printControl.ExecCommand(PrintingSystemCommand.HandTool, new object[] { true });
                }

                // Hide the Hand tool.
                //if (printControlCanExecCommand(PrintingSystemCommand.HandTool)) {
                //    printControl.ExecCommand(PrintingSystemCommand.HandTool, new object[] { false });
                //}

                // Show the report's Print Preview in a dialog window.
                printControl.Zoom = 1.2F;
                printTool.ShowPreview();
                splash.CloseWaitForm();
                //printTool.ShowPreviewDialog();
                //printTool.ShowRibbonPreviewDialog();
            }
            catch (Exception genRep)
            {
                splash.CloseWaitForm();
                XtraMessageBox.Show(genRep.Message + "mostrarReporte()", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }