Imports System.Data.SqlClient
Imports System.Data
Imports WindowsApplication1.DentalDataSet
Public Class ReportType
Dim cn As New SqlConnection(_conStr)
Dim da As SqlDataAdapter
Dim ds As DataSet
Private Sub ReportType_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.SelectedIndex = 0
DateTimePicker1.Format = DateTimePickerFormat.Custom
DateTimePicker1.CustomFormat = "dd/MM/yyyy"
DateTimePicker2.Format = DateTimePickerFormat.Custom
DateTimePicker2.CustomFormat = "dd/MM/yyyy"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.PatientTableAdapter1.Fill(Me.DentalDataSet1.Patient)
Me.Service_DetailTableAdapter1.Fill(Me.DentalDataSet1.Service_Detail)
Me.ServiceTableAdapter1.Fill(Me.DentalDataSet1.Service)
Me.AppointmentTableAdapter1.Fill(Me.DentalDataSet1.Appointment)
Me.AdminUserTableAdapter1.Fill(Me.DentalDataSet1.AdminUser)
If ComboBox1.SelectedIndex = 2 Then
Dim rpt As New CrystalReportpatientday
rpt.SetDataSource(Me.DentalDataSet1)
Dim f As New Report
rpt.RecordSelectionFormula = "{service.service_date}in (cdate('" & DateTimePicker1.Value.ToString("dd/MM/yyyy").Trim & "') to cdate('" & DateTimePicker2.Value.ToString("dd/MM/yyyy").Trim & "'))"
f.CrystalReportViewer1.ReportSource = rpt
f.Show()
ElseIf ComboBox1.SelectedIndex = 1 Then
Dim rpt As New CrystalReportappointday
rpt.SetDataSource(Me.DentalDataSet1)
Dim f As New Report
rpt.RecordSelectionFormula = "{appointment.appoint_date}in (cdate('" & DateTimePicker1.Value.ToString("dd/MM/yyyy").Trim & "') to cdate('" & DateTimePicker2.Value.ToString("dd/MM/yyyy").Trim & "'))"
f.CrystalReportViewer1.ReportSource = rpt
f.Show()
ElseIf ComboBox1.SelectedIndex = 3 Then
Dim rpt As New CrystalReportsum
rpt.SetDataSource(Me.DentalDataSet1)
Dim f As New Report
rpt.RecordSelectionFormula = "{service.service_date}in (cdate('" & DateTimePicker1.Value.ToString("dd/MM/yyyy").Trim & "') to cdate('" & DateTimePicker2.Value.ToString("dd/MM/yyyy").Trim & "'))"
f.CrystalReportViewer1.ReportSource = rpt
f.Show()
End If
End Sub
End Class
Tag : .NET, Ms SQL Server 2008, Crystal Report, VB.NET