0% found this document useful (0 votes)
25 views

Codigo para Formulario 1: Form1 Dataset

The document contains code for two forms - Form1 and Form2. Form1 contains code to generate a CrystalReport using data from a dataset populated from a database table. Form2 contains code to display data from the same database table in a datagrid and allows searching/filtering the data by name. It also contains buttons to clear searches, show all data, and open Form1.

Uploaded by

Matthew Lee
Copyright
© Attribution Non-Commercial (BY-NC)
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)
25 views

Codigo para Formulario 1: Form1 Dataset

The document contains code for two forms - Form1 and Form2. Form1 contains code to generate a CrystalReport using data from a dataset populated from a database table. Form2 contains code to display data from the same database table in a datagrid and allows searching/filtering the data by name. It also contains buttons to clear searches, show all data, and open Form1.

Uploaded by

Matthew Lee
Copyright
© Attribution Non-Commercial (BY-NC)
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

CODIGO PARA FORMULARIO 1

Imports System.Data.OleDb Imports System.Data Public Class Form1 Dim trab As String Dim dset As New DataSet Sub crystal_report() If valor = 1 Then trab = "SELECT * FROM TRABAJADOR WHERE NOMBRE LIKE '" & Form2.TextBox1.Text & "%'" Else trab = "SELECT * FROM TRABAJADOR" End If Dim tablatrab As New OleDbDataAdapter(trab, CN) tablatrab.Fill(dset, "TRABAJADOR") Dim report As New CrystalReport1 report.SetDataSource(dset) CrystalReportViewer1.ReportSource = report End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Call crystal_report() End Sub End Class

CODIGO PARA FORMULARIO 2


Imports System.Data.OleDb Public Class Form2 Dim consulta As String Sub mostrar() Dim DA As New OleDbDataAdapter("SELECT COD, DNI, NOMBRE, APELLIDO, CARGO, TURNO, SUELDO FROM TRABAJADOR", CN) Dim DS As New DataSet DA.Fill(DS, "TRABAJADOR") DataGridView1.DataSource = DS.Tables("TRABAJADOR")

End Sub Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Call mostrar() End Sub Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged TextBox1.Clear() TextBox1.Enabled = True

valor = 1 End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If valor = 1 Then consulta = "SELECT COD, DNI, NOMBRE, APELLIDO, CARGO, TURNO, SUELDO FROM TRABAJADOR WHERE NOMBRE LIKE '" & TextBox1.Text & "%'" Dim DA As New OleDbDataAdapter(consulta, CN) Dim DS As New DataSet DA.Fill(DS, "TRABAJADOR") DataGridView1.DataSource = DS.Tables("TRABAJADOR") End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click mostrar() TextBox1.Clear() RadioButton1.Checked = True End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Form1.Show() End Sub Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick End Sub End Class

You might also like