Пример #1
0
        private void mitVerFormato_Click(object sender, EventArgs e)
        {
            MenuItem mitControl = (MenuItem)sender;

            int codigoFacturaVenta = (int)mitControl.Tag;

            FormatoBe.Factura dsCabecera = formatoBl.ObtenerFormatoFacturaVenta(codigoFacturaVenta);
            dsCabecera.QR = ObtenerQR(dsCabecera);
            List <ReportDataSource> rpd = new List <ReportDataSource>();

            rpd.Add(new ReportDataSource("dsCabecera", new List <FormatoBe.Factura>()
            {
                dsCabecera
            }));
            rpd.Add(new ReportDataSource("dsDetalle", dsCabecera.ListaDetalle));

            string nombreArchivo = dsCabecera.Serie + " - " + dsCabecera.Correlativo.ToString("00000000");

            FrmFormatoCompartido frm = new FrmFormatoCompartido(rpd.ToArray(), "rptFormatoFactura", nombreArchivo);

            frm.ShowInTaskbar = false;
            frm.BringToFront();
            frm.ShowDialog();
            //DialogResult dr = frm.ShowDialog();
            //if (dr == DialogResult.OK) BuscarLetras();
        }
Пример #2
0
        public FormatoBe.Factura ObtenerFormatoFacturaVenta(int codigoFacturaVenta, SqlConnection cn)
        {
            FormatoBe.Factura item = null;

            try
            {
                using (SqlCommand cmd = new SqlCommand("dbo.usp_formato_facturaventa", cn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@codigoFacturaVenta", codigoFacturaVenta.GetNullable());

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        if (dr.HasRows)
                        {
                            item = new FormatoBe.Factura();

                            if (dr.Read())
                            {
                                item.Serie       = dr.GetData <string>("Serie");
                                item.Correlativo = dr.GetData <int>("Correlativo");
                                item.CodigoTipoDocumentoIdentidadCliente = dr.GetData <int>("CodigoTipoDocumentoIdentidadCliente");
                                item.NombresCompletoCliente       = dr.GetData <string>("NombresCompletoCliente");
                                item.NroDocumentoIdentidadCliente = dr.GetData <string>("NroDocumentoIdentidadCliente");
                                item.DireccionCliente             = dr.GetData <string>("DireccionCliente");
                                item.CondicionPago     = dr.GetData <string>("CondicionPago");
                                item.TelefonoCliente   = dr.GetData <string>("TelefonoCliente");
                                item.AgenciaTransporte = dr.GetData <string>("AgenciaTransporte");
                                item.FechaEmision      = dr.GetData <DateTime>("FechaEmision");
                                item.FechaVencimiento  = dr.GetData <DateTime>("FechaVencimiento");
                                item.TipoCambio        = dr.GetData <decimal>("TipoCambio");
                                item.NroPedido         = dr.GetData <string>("NroPedido");
                                item.NroGuia           = dr.GetData <string>("NroGuia");
                                item.OrdenCompra       = dr.GetData <string>("OrdenCompra");
                                item.TotalGravada      = dr.GetData <decimal>("TotalGravada");
                                item.TotalIGV          = dr.GetData <decimal>("TotalIGV");
                                item.TotalImporte      = dr.GetData <decimal>("TotalImporte");
                                item.TotalPagar        = dr.GetData <decimal>("TotalPagar");
                                item.TotalEnLetras     = dr.GetData <string>("TotalEnLetras");
                                item.Hash = dr.GetData <string>("Hash");
                            }
                        }
                    }
                }
            }
            catch (Exception ex) { log.Error(ex.Message); }

            return(item);
        }
Пример #3
0
        public FormatoBe.Factura ObtenerFormatoFacturaVenta(int codigoFacturaVenta)
        {
            FormatoBe.Factura item = null;

            try
            {
                cn.Open();
                item = formatoDa.ObtenerFormatoFacturaVenta(codigoFacturaVenta, cn);
                if (item != null)
                {
                    item.ListaDetalle = formatoDa.ListarFormatoFacturaVentaDetalle(codigoFacturaVenta, cn);
                }
            }
            catch (Exception ex) { log.Error(ex); }
            finally { if (cn.State == ConnectionState.Open)
                      {
                          cn.Close();
                      }
            }

            return(item);
        }
Пример #4
0
        byte[] ObtenerQR(FormatoBe.Factura item)
        {
            byte[] imagen = null;

            QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.H);
            QrCode    qrCode    = new QrCode();

            string rucEmpresa = AppSettings.Get <string>("empresa.ruc");
            string codigoSunatTipoComprobante        = TipoComprobante.Factura.GetAttributeOfType <CategoryAttribute>().Category;
            string codigoSunatTipoDocumentoIdentidad = ((TipoDocumentoIdentidad)item.CodigoTipoDocumentoIdentidadCliente).GetAttributeOfType <CategoryAttribute>().Category;

            qrEncoder.TryEncode($"{rucEmpresa}|{codigoSunatTipoComprobante}|{item.Serie}-{item.Correlativo.ToString("00000000")}|{item.TotalIGV}|{item.TotalImporte}|{item.FechaEmision.ToString("dd/MM/yyyy")}|{codigoSunatTipoDocumentoIdentidad}|{item.NroDocumentoIdentidadCliente}|{item.Hash}", 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);

            imagen = ms.ToArray();

            return(imagen);
        }