0% found this document useful (0 votes)
9 views3 pages

3-Programacion de Reportes en Vbasic Net

The document outlines a report for employees from the Northwind database, detailing the design of a form and its properties in Visual Basic .NET. It includes code for loading employee data into a DataGridView, creating a print page, and handling preview and print functionalities. The report is structured with sections for form design, properties, and main coding logic.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

3-Programacion de Reportes en Vbasic Net

The document outlines a report for employees from the Northwind database, detailing the design of a form and its properties in Visual Basic .NET. It includes code for loading employee data into a DataGridView, creating a print page, and handling preview and print functionalities. The report is structured with sections for form design, properties, and main coding logic.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

UNIVERSIDAD NACIONAL DE TRUJILLO

FACULTAD DE INGENIERÍA

REPORTE DE EMPLEADOS
DE LA BASE DE DATOS NORTHWIND

1. DISEÑO DEL FORMULARIO

2. PROPIEDADES

OBJETO PROPIEDAD VALOR


Form1 Text REPORTE DE EMPLEADOS
Name frmREPORTEEMPLEADOS
MinimizeBox False
MaximizeBox False
DataGridView1 Name DGVEmpleados
Dock Fi1
ReadOnly True
MenuStrap Name MnuPrincipal
MenuItem1 Name MnuReporte
Text Reporte
MenuItem11 Name MnuPreview
Text Preview
MenuItem1 Name MnuImprimir
Text Imprimir
PrintDocument1 Name pdt

3. CODIFICACIÓN PRINCIPAL EN VISUAL BASIC .NET

Imports System.Data.SqlClient
Imports System.Text

DR. LUIS BOY CHAVIL Página 1


Public Class frmReporteEmpleado
Private dvw As DataView

Private Sub CargarDatos(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Dim Cnn As New SqlConnection("server=(local); integrated security=true;
database=NorthWind")
Dim oDataAdapter As New SqlDataAdapter("select EmployeeID, LastName,
FirstName from Employees", Cnn)
Dim oDataSet As New DataSet
oDataAdapter.Fill(oDataSet, "Empleados")
dvw = oDataSet.Tables("Empleados").DefaultView
DGVEmpleado.DataSource = dvw
End Sub

Private Sub CrearPagina(ByVal sender As System.Object, ByVal e As


System.Drawing.Printing.PrintPageEventArgs) Handles Pdt.PrintPage
Dim i As Integer
Dim stb As New StringBuilder()
Dim Texto As String
Dim Fuente As New Font("Courier New", 10)
Dim Brocha As Brush = Brushes.Blue
Dim x As Integer = e.MarginBounds.Left
Dim y As Integer = e.MarginBounds.Top
For i = 0 To dvw.Count - 1
stb.Append(dvw(i)(0).ToString.PadRight(10))
stb.Append(dvw(i)(1).ToString.PadRight(25))
stb.Append(dvw(i)(2).ToString.PadRight(15))
Texto = stb.ToString
e.Graphics.DrawString(Texto, Fuente, Brocha, x, y)
y = y + Fuente.GetHeight
stb.Length = 0
Next
End Sub

Private Sub MostrarPreview(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MnuPreview.Click
Dim ppc As New PrintPreviewControl()
ppc.Document = Pdt
ppc.Zoom = 1
ppc.Dock = DockStyle.Fill
Dim frmPreview As New Form()
With frmPreview
.Text = "Preview del Reporte de Empleados"
.WindowState = FormWindowState.Maximized
.Controls.Add(ppc)
.ShowDialog()
End With
End Sub

Private Sub ImprimirReporte(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MnuImprimir.Click

DR. LUIS BOY CHAVIL Página 2


Pdt.Print()
End Sub
End Class

DR. LUIS BOY CHAVIL Página 3

You might also like