Imprimir código de barra desde un Label a Crystal Report
Publicado por ELI_RD (8 intervenciones) el 17/12/2017 21:52:01
Buenas, programo en vb.net y uso SQL SERVER.
Tengo una pequeña aplicación que genera el código de barra en un Label, hasta hora función bien,
este es el código.
El problema es cuanto intento imprimir el código de barra que está en Label, a Cristal Report, solo imprime la numeración, pero no el código de barra.
Este el código del botón imprimir.
Espero su ayuda, como siempre, gracias.
Tengo una pequeña aplicación que genera el código de barra en un Label, hasta hora función bien,
este es el código.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Imports System.Drawing.Text
Public Partial Class MainForm
dim fuente as Font
Public Sub New()
' The Me.InitializeComponent call is required for Windows Forms designer support.
Me.InitializeComponent()
'
' TODO : Add constructor code after InitializeComponents
'
End Sub
Sub MainFormLoad(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
End Sub
Public Sub cargarfuente()
Dim pfc As PrivateFontCollection = New PrivateFontCollection()
Dim fontFamily As FontFamily
'Obtenemos la fuente que se encuentra en el directorio de la aplicacion
'y la cargamos
pfc.AddFontFile(my.Application.Info.DirectoryPath &"\BARCODE.TTF" )
fontFamily = pfc.Families(0)
fuente = New Font(fontFamily,50)
End Sub
Public Function FormatoCodigoBarras(ByVal code As String) As String
Dim barcode As String = String.Empty
barcode = String.Format("{0}", code)
Return barcode
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnImprimir.Click
Dim DataSetMemoria As New Reportes
Dim fila As Reportes.dtsFichaCodigoBarraRow = DataSetMemoria.dtsFichaCodigoBarra.NewdtsFichaCodigoBarraRow
''Pasamos los datos de los TextBox a los campos del dtsFicha que creamos en el DataSetReportes
If TXTPRODUCTO.Text = "" Then
fila.NombreProducto = ""
Else
fila.NombreProducto = TXTPRODUCTO.Text
End If
If txtcodigoProducto.Text = "" Then
fila.codigoProducto = ""
Else
fila.codigoProducto = txtcodigoProducto.Text
End If
If lblcodigoBarra.Text = "" Then
fila.codigoBarra = ""
Else
fila.codigoBarra = lblcodigoBarra.Text
End If
'*****************************************
DataSetMemoria.dtsFichaCodigoBarra.AdddtsFichaCodigoBarraRow(fila)
'Mostrando Reporte
Dim rpt As New FichaCodigoBarra 'Es el nombre del Reporte
rpt.SetDataSource(DataSetMemoria)
frmReporteFichaCodigoBarra.crvFichaGeneraCodigoBarra.ReportSource = rpt
frmReporteFichaCodigoBarra.Show()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerarCodigoBarra.Click
cargarfuente()
lblcodigoBarra.Font = fuente
lblcodigoBarra.Text = FormatoCodigoBarras(txtcodigoProducto.Text)
End Sub
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
'Private Sub lblcodigoBarra_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblcodigoBarra.Click
'End Sub
End Class
El problema es cuanto intento imprimir el código de barra que está en Label, a Cristal Report, solo imprime la numeración, pero no el código de barra.
Este el código del botón imprimir.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Dim DataSetMemoria As New Reportes
Dim fila As Reportes.dtsFichaCodigoBarraRow = DataSetMemoria.dtsFichaCodigoBarra.NewdtsFichaCodigoBarraRow
''Pasamos los datos de los TextBox a los campos del dtsFicha que creamos en el DataSetReportes
If TXTPRODUCTO.Text = "" Then
fila.NombreProducto = ""
Else
fila.NombreProducto = TXTPRODUCTO.Text
End If
If txtcodigoProducto.Text = "" Then
fila.codigoProducto = ""
Else
fila.codigoProducto = txtcodigoProducto.Text
End If
If lblcodigoBarra.Text = "" Then
fila.codigoBarra = ""
Else
fila.codigoBarra = lblcodigoBarra.Text
End If
'*****************************************
DataSetMemoria.dtsFichaCodigoBarra.AdddtsFichaCodigoBarraRow(fila)
'Mostrando Reporte
Dim rpt As New FichaCodigoBarra 'Es el nombre del Reporte
rpt.SetDataSource(DataSetMemoria)
frmReporteFichaCodigoBarra.crvFichaGeneraCodigoBarra.ReportSource = rpt
frmReporteFichaCodigoBarra.Show()
Espero su ayuda, como siempre, gracias.
Valora esta pregunta
0