private void GenerarPDF()
 {
     try
     {
         if (dtgrFactura.SelectedRows.Count > 0)
         {
             int             codFactura = Convert.ToInt32(dtgrFactura.CurrentRow.Cells["codigo"].Value);
             string          fecha      = Convert.ToString(dtgrFactura.CurrentRow.Cells["fecha"].Value);
             var             respuesta  = new BLL.DetalleFacturaService.Respuesta();
             Infraestructura pdf        = new Infraestructura();
             IList <Detalle> detalles   = new List <Detalle>();
             respuesta = detalleServicio.Buscar(codFactura);
             string  ruta    = @"sarasoft3.pdf";
             Factura factura = new Factura();
             factura.Codigo = codFactura;
             factura.Fecha  = fecha;
             pdf.GuardarFactura(respuesta.Detalles, ruta, factura);
         }
         else
         {
             MessageBox.Show("Seleccione una fila de la tabla");
         }
     }
     catch (Exception) { }
 }
        private void MostrarDatos()
        {
            int codigoFactura = Convert.ToInt32(this.dtgrFactura.CurrentRow.Cells["codigo"].Value);
            var respuesta     = new BLL.DetalleFacturaService.Respuesta();

            respuesta = detalleServicio.Consultar();
            if (!respuesta.IsError)
            {
                //dataGridClientes.DataSource = null;

                dtgrDetalleFactura.DataSource = respuesta.Detalles.Where(p => p.CodigoFactura == codigoFactura).ToList();
                dtgrDetalleFactura.Refresh();
            }
            else
            {
                MessageBox.Show(respuesta.Mensaje, respuesta.Mensaje, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }