Imports CrystalDecisions.Shared
Public Class F_Check
Public Customer As String
Public Sub GetReport()
Dim rpt As New RC_Payment
rpt.Load(Application.StartupPath & "\RC_Payment.rpt")
Dim pfields As New ParameterFields
Dim pfield As New ParameterField
Dim pdiscrete As New ParameterDiscreteValue
rpt.SetDatabaseLogon("Sa", "12345")
pfield.Name = "srat_id"
pdiscrete.Value = Customer
pfield.CurrentValues.Add(pdiscrete)
pfields.Add(pfield)
'rpt.ParameterFields = "{Payment.PaymentDate1} = '2016-09-21'"
CrystalReportViewer1.ReportSource = rpt
CrystalReportViewer1.ParameterFieldInfo = pfields
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
' Me.Customer = TextBox1.Text
'Call GetReport()
End Sub
Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker2.ValueChanged
GetReport()
End Sub
End Class
Code (VB.NET)
Imports CrystalDecisions.Shared
Public Class FFCheck
Public FirstDay As String
Public Sub GetReport()
Dim rpt As New FCheck
rpt.Load(Application.StartupPath & "\FCheck.rpt")
Dim pfields As New ParameterFields
Dim pfield As New ParameterField
Dim pdiscrete As New ParameterDiscreteValue
rpt.SetDatabaseLogon("Sa", "12345")
pfield.Name = "srat_id"
pdiscrete.Value = FirstDay
pfield.CurrentValues.Add(pdiscrete)
pfields.Add(pfield)
CrystalReportViewer1.SelectionFormula = " Month({Chack.Date1}) = " & Now.Month & " and Year({Chack.Date1}) = " & Now.Year + 543
CrystalReportViewer1.ReportSource = rpt
CrystalReportViewer1.ParameterFieldInfo = pfields
End Sub
Private Sub FFCheck_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
GetReport()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.FirstDay = TextBox1.Text
Call GetReport()
End Sub
End Class
Imports CrystalDecisions.Shared
Imports System.Data.SqlClient
Imports System.Data
Public Class F_Check
Public FirstDay As Date
Public secondDate As Date
Public Sub GetReport()
Dim rpt As New RC_Payment
rpt.Load(Application.StartupPath & "\RC_Payment.rpt")
Dim pfields As New ParameterFields
Dim pfield As New ParameterField
Dim pdiscrete As New ParameterDiscreteValue
Dim pfield1 As New ParameterField
Dim pdiscrete1 As New ParameterDiscreteValue
rpt.SetDatabaseLogon("Sa", "12345")
pfield.Name = "date"
pdiscrete.Value = FirstDay
pfield.CurrentValues.Add(pdiscrete)
pfields.Add(pfield)
pfield.Name = "end_date"
pdiscrete.Value = FirstDay
pfield.CurrentValues.Add(pdiscrete1)
pfields.Add(pfield1)
CrystalReportViewer1.ReportSource = rpt
CrystalReportViewer1.ParameterFieldInfo = pfields
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.FirstDay = DateTimePicker1.Value
Me.secondDate = DateTimePicker2.Value
Call GetReport()
End Sub
End Class