Exemplo n.º 1
0
        private void btn_pdf_Click(object sender, EventArgs e)
        {
            try
            {
                btn_pdf.Enabled = false;
                int index = grd_Facturas.SelectedCells[0].RowIndex;

                objDocumentoCab = objListaDocumentoCab[index];
                String codigoagenerar = "20300166611|07" + "|" +
                                        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);
                NotaFecha cr = new NotaFecha();

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

                saveFileDialog1.FileName = "20300166611-07-" + objDocumentoCab.DocumentoCabSerie +
                                           "-" + objDocumentoCab.DocumentoCabNro + ".pdf";
                saveFileDialog1.DefaultExt = "pdf";
                saveFileDialog1.Filter     = "Pdf files (*.pdf)|*.pdf";
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    cr.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @saveFileDialog1.FileName);
                }
                btn_pdf.Enabled = true;
            }
            catch
            {
                MessageBox.Show("No ha seleccionado ningún registro");
                btn_pdf.Enabled = true;
            }


            // System.Web.HttpResponse res = new System.Web.HttpResponse();
        }
        private void btn_excel_Click(object sender, EventArgs e)
        {
            String codigoagenerar = "20300166611|08" + "|" +
                                    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);

            NotaFecha cr = new NotaFecha();

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

            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);
            }
        }