Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.Shared
Imports System.Data.SqlClient
Imports CrystalDecisions.Windows.Forms
Imports System.Configuration
Imports System.Threading
Public Class frmPurchaseAnalysis
Dim dA1 As New SqlDataAdapter
Dim dS1 As New DataSet
Dim fmRptStr As String
Dim lCnt As Integer
Dim stritm As String
Dim strwrk As String
Private Sub frmPurchaseAnalysis_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Itemmtype
dA1 = New SqlDataAdapter("Select ItemTypeID,ItemType from ItemTypeRoot order by ItemTypeID ", cnnDbOne)
dA1.Fill(dS1)
cmbItemType.Items.Add("Select ItemType")
For lCnt = 0 To dS1.Tables(0).Rows.Count - 1
SmQryStr = Mid(dS1.Tables(0).Rows(lCnt)("ItemType"), 1, 30)
SmQryStr &= Space(31 - SmQryStr.Length) & dS1.Tables(0).Rows(lCnt)("ItemTypeID")
cmbItemType.Items.Add(SmQryStr)
Next
cmbItemType.SelectedIndex = 0
dS1.Clear()
dA1.Dispose()
End Sub
Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
Me.Dispose()
Me.Close()
End Sub
Public Sub cmdView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdView.Click
Dim Obj1 As New Thread(AddressOf T1)
Dim Obj2 As New Thread(AddressOf T2)
Obj1.Start()
Obj2.Start()
Dim strwrk As String
strwrk = txtdays.Text
If cmbItemType.Text <> "Select ItemType" And cmbItemType.Text <> "" Then
stritm = Mid(cmbItemType.Text, 32)
End If
SmSqlCmd = New SqlCommand
SmSqlCmd.Connection = cnnDbOne
SmSqlCmd.CommandTimeout = 200
SmSqlCmd.CommandType = CommandType.StoredProcedure
SmSqlCmd.CommandText = "Rpt_PurchaseAnalysis"
SmSqlCmd.Parameters.AddWithValue("@itemType", stritm)
SmSqlCmd.Parameters.AddWithValue("@Targetdays", strwrk)
SmSqlCmd.Parameters.AddWithValue("@enddate", Format(DTP2.Value, "MM/dd/yyyy"))
dA1 = New SqlDataAdapter(SmSqlCmd)
dS1.Clear()
dA1.Fill(dS1)
End Sub
Private Sub T1()
Dim i As Integer
i += 1
PrgrsBar.Value = i
If PrgrsBar.Value = PrgrsBar.Maximum Then
End If
End Sub
Private Sub T2()
Dim SmReport As ReportDocument
Try
SmReport = New RptPurchaseAnalysis
SmReport.SetDataSource(dS1.Tables(0))
SmReport.DataDefinition.FormulaFields("StartDate").Text = """" + Format(DTP1.Value, "dd-MMM-yyyy") + """"
SmReport.DataDefinition.FormulaFields("enddate").Text = """" + Format(DTP2.Value, "dd-MMM-yyyy") + """"
Dim frmRptViewer As New frmRptViewer
frmRptViewer.CrRptVwer1.ReportSource = SmReport
frmRptViewer.Show()
dS1.Clear()
Catch ex As Exception
MsgBox("Some Reporting Error Has Been Occured. " + vbCrLf + ex.Message, MsgBoxStyle.Information, "Sales Statistics Reporting")
End Try
End Sub
End Class
告訴我,我做錯了代碼?我想說明進度增加而我的報告已被載入vb.net中的進度條線程