[font=Verdana]หมายเหตุ ทำไมผมไม่ใช้ Combobox เหมือนตัวอื่นในการรับค่า ตอบ เพราะผมไม่อย่างไปยุ่งกับ Store Proceder อีกเมื่อมีการเพื่มข้อมูลหรือเปลี่ยนแปลงข้อมูล[/font]
Code (VB.NET)
Private Sub btnPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreview.Click
Dim dsrv As New imsDataServices
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Dim dsItemList As New DataSet
Dim dt As New DataTable
Dim rpt As New ReportDocument
Dim rpt1 As New rptbalanceAdjustDetail
Dim chk As Boolean
Dim directory As String = My.Application.Info.DirectoryPath
'If chkDetail.Checked = True Then
'chk = 0
'End If
Try
'rpt.Load(Application.StartupPath & "\Dotnet\IntuitiveCustomReports\rptbalanceAdjustNoDetail.rpt")
rpt.Load(Application.StartupPath & "\Dotnet\IntuitiveCustomReports\rptbalanceAdjustDetail.rpt")
'rpt.Load("C:\IntuitiveDev\Projects\crystalReport\IntuitiveUI_MAC_BalanceAdjust\IntuitiveUI_MAC_BalanceAdjust\CrystalReport1.rpt")
With cmd 'Main
.Connection = dsrv.Connection
.CommandType = CommandType.StoredProcedure
.CommandText = "sp_MAC_balanceAdjust1"
'da.SelectCommand = cmd
.Parameters.AddWithValue("@Site", cboSite.Text)
.Parameters.AddWithValue("@Type", cboType.Text)
.Parameters.AddWithValue("@Location", ListLocation.Text)
' .Parameters.AddWithValue("@Location", chkLocation.Text)
'.Parameters.AddWithValue("@Location", ListLocation.Text)
.Parameters.AddWithValue("@YearCutStock", cboYear.Text)
.Parameters.AddWithValue("@MonthCutStock", cboMonth.Text)
.Parameters.AddWithValue("@strSortby", rdbModel.Checked)
End With
da.SelectCommand = cmd
da.Fill(ds, "dsBalanceAdjustviewer")
dt = ds.Tables(0)
' da = Nothing
rpt.SetDataSource(dt)
Me.CrystalReportViewer1.ReportSource = rpt
Me.CrystalReportViewer1.Show()
Catch exsql As SqlException
MsgBox(exsql.Message, MsgBoxStyle.Exclamation)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
End Sub
Tag : .NET, Ms SQL Server 2005, Crystal Report, VB.NET