Ejemplo n.º 1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            ComprobanteVenta rpt = new ComprobanteVenta();

            rpt.Site = this.Site;
            return(rpt);
        }
Ejemplo n.º 2
0
        private void btRegistraVenta_Click(object sender, EventArgs e)
        {
            if (dgvVenta.Rows.Count > 0)
            {
                using (FormComprobanteVenta formC = new FormComprobanteVenta()) {
                    /*if(formC.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                     * {
                     *
                     *
                     * }*/
                    QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.H);
                    QrCode    qrCode    = new QrCode();
                    qrEncoder.TryEncode(lblSerie + " - " + lblNroCorrelativo, out qrCode);

                    GraphicsRenderer renderer = new GraphicsRenderer(new FixedCodeSize(400, QuietZoneModules.Zero), Brushes.Black, Brushes.White);

                    MemoryStream ms = new MemoryStream();

                    renderer.WriteToStream(qrCode.Matrix, ImageFormat.Png, ms);
                    var imageTemporal = new Bitmap(ms);
                    var imagen        = new Bitmap(imageTemporal, new Size(new Point(200, 200)));
                    //panelResultado.BackgroundImage = imagen;

                    //Guardar en el disco duro la imagen (Carpeta del proyecto)

                    String urlSave = "C:\\Users\\AlphaLeader\\Desktop\\SisFVS2\\SistemaFigueri\\SistemaFigueri\\Resources\\" + lblSerie.Text + lblNroCorrelativo.Text + "QR.png";
                    imagen.Save(urlSave, ImageFormat.Png);

                    FileStream fs;
                    // define te binary reader to read the bytes of image

                    BinaryReader br;
                    // check the existance of image

                    if (File.Exists(urlSave))
                    {
                        // open image in file stream

                        fs = new FileStream(urlSave, FileMode.Open);
                    }
                    else
                    {
                        // if phot does not exist show the nophoto.jpg file

                        fs = new FileStream(urlSave, FileMode.Open);
                    }
                    // initialise the binary reader from file streamobject

                    br = new BinaryReader(fs);
                    // define the byte array of filelength

                    byte[] imgbyte = new byte[fs.Length + 1];
                    // read the bytes from the binary reader

                    imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));


                    br.Close();
                    // close the binary reader

                    fs.Close();
                    // close the file stream


                    Reportes.DsDetalleVenta dsdet = new Reportes.DsDetalleVenta();
                    int filas = dgvVenta.Rows.Count;
                    MessageBox.Show(filas.ToString());
                    String client = "";
                    client = chkcliente.Checked == true ? tbClienteNombre.Text : tbrazonsocial.Text;
                    String       letraImporte = "";
                    Conversiones conv         = new Conversiones();
                    letraImporte = conv.enletras(SumaTotal.ToString());



                    for (int i = 0; i < filas - 4; i++)
                    {
                        dsdet.Tables[0].Rows.Add(
                            new Object[]
                        {
                            dgvVenta["CANTIDAD", i].Value.ToString(),
                            dgvVenta["DESCRIPCION", i].Value.ToString(),
                            Double.Parse(dgvVenta["PRECIO", i].Value.ToString()),
                            Double.Parse(dgvVenta["IMPORTE", i].Value.ToString())
                        }
                            );
                    }
                    dsdet.Tables[1].Rows.Add(
                        new Object[]
                    {
                        //DIRECCION
                        "---- LA ERA Ñaña LT. 01 MZ. R ---- CP VIRGEN DEL CARMEN",
                        //SUCURSAL
                        "LURIGANCHO - LIMA - LIMA",
                        //RUC FIGUERI
                        "RUC 20268781529",
                        //TIPO DOC
                        lblTipo.Text + " ELECTRÓNICA",
                        //N DOC
                        lblSerie + " - " + lblNroCorrelativo,
                        //DNI
                        tbDocumento.Text,
                        //CLIENTE
                        client,
                        //FECHA EMISION
                        dtpFechaEmision.Text,
                        //FECHA VENCIMIENTO
                        dtFechaV.Text,
                        "SOLES",
                        "18.00 %",
                        SumaSubTotal,
                        SumaIgv,
                        SumaTotal,
                        letraImporte,
                        imgbyte
                    }
                        );
                    Reportes.ComprobanteVenta comp = new Reportes.ComprobanteVenta();
                    comp.Load("C:\\Users\\AlphaLeader\\Desktop\\SisFVS2\\SistemaFigueri\\SistemaFigueri\\Reportes\\ComprobanteVenta.rpt");
                    comp.SetDataSource(dsdet);
                    formC.crystalReportViewer1.ReportSource = comp;
                    formC.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show("No Existe Ningún Elemento en la Lista.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }