【发布时间】:2015-10-14 14:11:58
【问题描述】:
我正在开发一个 Windows 应用程序并在其中使用 Crystal Report。
我可以将值传递给 Crystal Report 的一个参数。现在,我在 Crystal Report 中又添加了一个参数,但对我必须在下面的代码中进行哪些修改感到困惑。
下面的代码被编写为将值传递给 CR 的一个参数。
Private Sub btnLoadBatch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadBatch.Click
Try
Dim cr As New crMonthwiseBatch
Dim oBatches As New Batches
Dim Month As Integer = dtFrom.Value.Date.Month
Dim StartDateForBatch As Date = New DateTime(dtBatchStartFromMonth.Value.Year, dtBatchStartFromMonth.Value.Month, "1")
Dim DaysinMonths As Integer = System.DateTime.DaysInMonth(dtBatchStartFromMonth.Value.Year, dtBatchStartFromMonth.Value.Month)
Dim EndDateForBatch = StartDateForBatch.AddDays(DaysinMonths)
oBatches.LoadByQuery("CreatedDate >= #" + StartDateForBatch + "# and CreatedDate <= #" + EndDateForBatch + "#")
cr.SetDataSource(oBatches)
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues
Dim crParameterDiscreteValue As New ParameterDiscreteValue
crParameterDiscreteValue.Value = "Batch List of Month - " + MonthName(dtBatchStartFromMonth.Value.Month) + " " + dtBatchStartFromMonth.Value.Year.ToString
crParameterFieldDefinitions = cr.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions.Item("MonthName")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterValues.Clear()
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
CrystalReportViewerMonthwiseBatch.ReportSource = cr
CrystalReportViewerMonthwiseBatch.Refresh()
Catch ex As Exception
End Try
End Sub
【问题讨论】:
标签: vb.net parameters crystal-reports crystal-reports-xi