Пример #1
0
        private void btn_excel_Click(object sender, EventArgs e)
        {
            btn_excel.Enabled = false;
            String codigoagenerar = "20300166611|03" + "|" +
                                    txt_Serie.Text + "|" + txt_Numero.Text + "|" + txt_IGV.Text.Trim() + "|"
                                    + txt_TotalsinPercep.Text.Trim() + "|" + dpick_Fecha.Value.ToString("dd-MM-yyyy") + "|" + "6|" + txt_Ruc.Text + "|";
            String nombreArchivo = txt_Serie.Text + "-" + txt_Numero.Text;
            String qr            = objProceso.genearQr(nombreArchivo, codigoagenerar);


            formatearFactura(qr);
            FacturaFecha cr = new FacturaFecha();

            // System.Web.HttpResponse res = new System.Web.HttpResponse();
            cr.SetDataSource(objListFacturaReporte);

            saveFileDialog1.FileName   = ".xls";
            saveFileDialog1.DefaultExt = "xls";
            saveFileDialog1.Filter     = "Excel files (*.xls)|*.xls";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                cr.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.ExcelRecord, @saveFileDialog1.FileName);
            }
            btn_excel.Enabled = true;
        }
Пример #2
0
        private void btn_excel_Click(object sender, EventArgs e)
        {
            try
            {
                btn_excel.Enabled = false;
                int index = grd_Facturas.SelectedCells[0].RowIndex;

                objDocumentoCab = objListaDocumentoCab[index];
                String codigoagenerar = "20300166611|01" + "|" +
                                        objDocumentoCab.DocumentoCabSerie + "|" + objDocumentoCab.DocumentoCabNro + "|" + objDocumentoCab.DocumentoCabIGV.ToString("C").Substring(3).Trim() + "|"
                                        + objDocumentoCab.DocumentoCabTotal.ToString("C").Substring(3).Trim() + "|" + objDocumentoCab.DocumentoCabFecha.ToString("dd-MM-yyyy") + "|" + "6|" + objDocumentoCab.DocumentoCabClienteDocumento + "|";
                String nombreArchivo = objDocumentoCab.DocumentoCabSerie + "-" + objDocumentoCab.DocumentoCabNro;
                String qr            = objProceso.genearQr(nombreArchivo, codigoagenerar);


                formatearFactura(qr);
                FacturaFecha cr = new FacturaFecha();

                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                cr.SetDataSource(objListFacturaReporte);

                saveFileDialog1.FileName = "20300166611-07-" + objDocumentoCab.DocumentoCabSerie +
                                           "-" + objDocumentoCab.DocumentoCabNro + ".xls";
                saveFileDialog1.DefaultExt = "xls";
                saveFileDialog1.Filter     = "Excel files (*.xls)|*.xls";
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    cr.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.ExcelRecord, @saveFileDialog1.FileName);
                }
                btn_excel.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR :" + ex.Message);
                btn_excel.Enabled = true;
            }
        }
Пример #3
0
        public ReporteView(String tipo)
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.Manual;
            crystalReportViewer1.ToolPanelView = ToolPanelViewType.None;
            this.Location    = new Point(100, 0);
            this.MaximumSize = new Size(1500, 900);
            switch (tipo)
            {
            case "FF":
                FacturaFecha cr = new FacturaFecha();
                crystalReportViewer1.ReportSource = cr;
                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                cr.SetDataSource(FacturaReporte.objListFacturaReporte);
                FacturaReporte.objListFacturaReporte.Clear();
                break;

            case "BF":
                FacturaFecha cr2 = new FacturaFecha();
                crystalReportViewer1.ReportSource = cr2;
                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                cr2.SetDataSource(BoletaReporte.objListFacturaReporte);
                BoletaReporte.objListFacturaReporte.Clear();
                break;

            case "CF":
                NotaFecha cr3 = new NotaFecha();
                crystalReportViewer1.ReportSource = cr3;
                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                cr3.SetDataSource(NotaCreditoReporte.objListNotaReporte);
                NotaCreditoReporte.objListNotaReporte.Clear();
                break;

            case "DF":
                NotaFecha cr4 = new NotaFecha();
                crystalReportViewer1.ReportSource = cr4;
                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                cr4.SetDataSource(NotaDebitoReporte.objListNotaReporte);
                NotaDebitoReporte.objListNotaReporte.Clear();
                break;

            case "LF":
                FacturaFecha cr5 = new FacturaFecha();
                crystalReportViewer1.ReportSource = cr5;
                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                cr5.SetDataSource(ListaFactura.objListFacturaReporte);
                ListaFactura.objListFacturaReporte.Clear();
                break;

            case "LB":
                FacturaFecha cr6 = new FacturaFecha();
                crystalReportViewer1.ReportSource = cr6;
                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                cr6.SetDataSource(ListaBoleta.objListFacturaReporte);
                ListaBoleta.objListFacturaReporte.Clear();
                break;

            case "LC":
                NotaFecha cr7 = new NotaFecha();
                crystalReportViewer1.ReportSource = cr7;
                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                cr7.SetDataSource(ListaNotaCredito.objListNotaReporte);
                ListaNotaCredito.objListNotaReporte.Clear();
                break;

            case "LD":
                NotaFecha cr8 = new NotaFecha();
                crystalReportViewer1.ReportSource = cr8;
                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                cr8.SetDataSource(ListaNotaDebito.objListNotaReporte);
                ListaNotaDebito.objListNotaReporte.Clear();
                break;

            case "LL":
                Letras cr9 = new Letras();
                crystalReportViewer1.ReportSource = cr9;
                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                cr9.SetDataSource(ListaLetraCambio.objListaLetraReporte);
                ListaLetraCambio.objListaLetraReporte.Clear();
                break;

            case "EF":
                DocumentoExcel cr10 = new DocumentoExcel();
                crystalReportViewer1.ReportSource = cr10;
                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                cr10.SetDataSource(ReporteDocumentosPorFecha.objListaReporteExcel);
                ReporteDocumentosPorFecha.objListaReporteExcel.Clear();
                break;

            case "EC":
                DocumentoExcel cr11 = new DocumentoExcel();
                crystalReportViewer1.ReportSource = cr11;
                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                cr11.SetDataSource(ReporteDocumentosPorCliente.objListaReporteExcel);
                ReporteDocumentosPorCliente.objListaReporteExcel.Clear();
                break;

            case "VO":
                VoucherRpt cr12 = new VoucherRpt();
                crystalReportViewer1.ReportSource = cr12;
                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                cr12.SetDataSource(Caja.EmisionVoucher.objListaVoucherReporte);
                Caja.EmisionVoucher.objListaVoucherReporte.Clear();
                break;

            case "VOD":
                VoucherRptDolar cr13 = new VoucherRptDolar();
                crystalReportViewer1.ReportSource = cr13;
                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                cr13.SetDataSource(Caja.EmisionVoucher.objListaVoucherReporte);
                Caja.EmisionVoucher.objListaVoucherReporte.Clear();
                break;

            case "LCRC":
                CanjeLetra cr14 = new CanjeLetra();
                crystalReportViewer1.ReportSource = cr14;
                cr14.SetDataSource(Facturacion.CanjeLetraNuevo.objListaLetraReporte);
                Facturacion.CanjeLetraNuevo.objListaLetraReporte.Clear();
                break;

            case "RDC":
                ReporteDiarioC cr15 = new ReporteDiarioC();
                crystalReportViewer1.ReportSource = cr15;
                cr15.SetDataSource(Reporte.ReporteDiario.objListaReporte);
                Reporte.ReporteDiario.objListaReporte.Clear();
                break;

            case "RFMP":
                ReporteMensualProveedor cr16 = new ReporteMensualProveedor();
                crystalReportViewer1.ReportSource = cr16;
                cr16.SetDataSource(Reporte.ReporteFacturaProveeodr.objListaVenReporte);
                Reporte.ReporteFacturaProveeodr.objListaVenReporte.Clear();
                break;

            case "RFTP":
                ReporteTotalizadoProveedor cr17 = new ReporteTotalizadoProveedor();
                crystalReportViewer1.ReportSource = cr17;
                cr17.SetDataSource(Reporte.ReporteFacturaProveedorTotalizado.objListaVenReporte);
                Reporte.ReporteFacturaProveedorTotalizado.objListaVenReporte.Clear();
                break;

            case "RLV":
                ReporteLetraVencimineto cr18 = new ReporteLetraVencimineto();
                crystalReportViewer1.ReportSource = cr18;
                cr18.SetDataSource(Facturacion.CanjeLetra.objListaVenReporte);
                Facturacion.CanjeLetra.objListaVenReporte.Clear();
                break;

            case "RLVC":
                ReporteLetraVencimineto cr19 = new ReporteLetraVencimineto();
                crystalReportViewer1.ReportSource = cr19;
                cr19.SetDataSource(Reporte.ReporteLetraCliente.objListaVenReporte);
                Reporte.ReporteLetraCliente.objListaVenReporte.Clear();
                break;
            }
        }
Пример #4
0
        private void btn_imprimir_Click(object sender, EventArgs e)
        {
            string root = @"N:\PDF";

            if (!Directory.Exists(root))
            {
                Directory.CreateDirectory(root);
            }
            try
            {
                btn_imprimir.Enabled = false;
                int index = grd_Facturas.SelectedCells[0].RowIndex;

                objDocumentoCab = objListaDocumentoCab[index];
                String codigoagenerar = "20300166611|01" + "|" +
                                        objDocumentoCab.DocumentoCabSerie + "|" + objDocumentoCab.DocumentoCabNro + "|" + objDocumentoCab.DocumentoCabIGV.ToString("C").Substring(3).Trim() + "|"
                                        + objDocumentoCab.DocumentoCabTotal.ToString("C").Substring(3).Trim() + "|" + objDocumentoCab.DocumentoCabFecha.ToString("dd-MM-yyyy") + "|" + "6|" + objDocumentoCab.DocumentoCabClienteDocumento + "|";
                String nombreArchivo = objDocumentoCab.DocumentoCabSerie + "-" + objDocumentoCab.DocumentoCabNro;
                String qr            = objProceso.genearQr(nombreArchivo, codigoagenerar);


                formatearFactura(qr);
                FacturaFecha cr  = new FacturaFecha();
                string       rut = @"N:\PDF\20300166611-" + objDocumentoCab.DocumentoCabSerie + "-" + objDocumentoCab.DocumentoCabNro + ".pdf";
                // System.Web.HttpResponse res = new System.Web.HttpResponse();
                if (File.Exists(rut))
                {
                    File.Delete(rut);
                }
                cr.SetDataSource(objListNotaReporte);
                cr.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, rut);
                using (PrintDialog Dialog = new PrintDialog())
                {
                    Dialog.ShowDialog();

                    ProcessStartInfo printProcessInfo = new ProcessStartInfo()
                    {
                        Verb           = "print",
                        CreateNoWindow = true,
                        FileName       = rut,
                        WindowStyle    = ProcessWindowStyle.Hidden
                    };

                    Process printProcess = new Process();
                    printProcess.StartInfo = printProcessInfo;
                    printProcess.Start();

                    printProcess.WaitForInputIdle();

                    Thread.Sleep(3000);

                    if (false == printProcess.CloseMainWindow())
                    {
                        printProcess.Kill();
                    }
                }
                btn_imprimir.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
                btn_imprimir.Enabled = true;
            }
        }