?? frmdepotsearch.vb
字號:
Imports System.Data
Imports System.Data.SqlClient
Public Class frmDepotSearch
Inherits System.Windows.Forms.Form
#Region " Windows 窗體設計器生成的代碼 "
Public Sub New()
MyBase.New()
'該調用是 Windows 窗體設計器所必需的。
InitializeComponent()
'在 InitializeComponent() 調用之后添加任何初始化
End Sub
'窗體重寫 dispose 以清理組件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗體設計器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下過程是 Windows 窗體設計器所必需的
'可以使用 Windows 窗體設計器修改此過程。
'不要使用代碼編輯器修改它。
Friend WithEvents dgdResult As System.Windows.Forms.DataGrid
Friend WithEvents grbDepotSearch As System.Windows.Forms.GroupBox
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents cbbDepot As System.Windows.Forms.ComboBox
Friend WithEvents btnSearch As System.Windows.Forms.Button
Friend WithEvents txbGoodPY As System.Windows.Forms.TextBox
Friend WithEvents lblDepotId As System.Windows.Forms.Label
Friend WithEvents lblGoodPY As System.Windows.Forms.Label
Friend WithEvents txbGoodId As System.Windows.Forms.TextBox
Friend WithEvents lblGoodId As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.dgdResult = New System.Windows.Forms.DataGrid
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.cbbDepot = New System.Windows.Forms.ComboBox
Me.btnSearch = New System.Windows.Forms.Button
Me.txbGoodPY = New System.Windows.Forms.TextBox
Me.lblDepotId = New System.Windows.Forms.Label
Me.lblGoodPY = New System.Windows.Forms.Label
Me.txbGoodId = New System.Windows.Forms.TextBox
Me.lblGoodId = New System.Windows.Forms.Label
CType(Me.dgdResult, System.ComponentModel.ISupportInitialize).BeginInit()
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'dgdResult
'
Me.dgdResult.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.dgdResult.CaptionVisible = False
Me.dgdResult.DataMember = ""
Me.dgdResult.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.dgdResult.Location = New System.Drawing.Point(0, 69)
Me.dgdResult.Name = "dgdResult"
Me.dgdResult.Size = New System.Drawing.Size(608, 208)
Me.dgdResult.TabIndex = 7
'
'GroupBox1
'
Me.GroupBox1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.GroupBox1.Controls.Add(Me.cbbDepot)
Me.GroupBox1.Controls.Add(Me.btnSearch)
Me.GroupBox1.Controls.Add(Me.txbGoodPY)
Me.GroupBox1.Controls.Add(Me.lblDepotId)
Me.GroupBox1.Controls.Add(Me.lblGoodPY)
Me.GroupBox1.Controls.Add(Me.txbGoodId)
Me.GroupBox1.Controls.Add(Me.lblGoodId)
Me.GroupBox1.Location = New System.Drawing.Point(0, 16)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(608, 56)
Me.GroupBox1.TabIndex = 8
Me.GroupBox1.TabStop = False
'
'cbbDepot
'
Me.cbbDepot.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cbbDepot.ItemHeight = 12
Me.cbbDepot.Location = New System.Drawing.Point(257, 21)
Me.cbbDepot.Name = "cbbDepot"
Me.cbbDepot.Size = New System.Drawing.Size(56, 20)
Me.cbbDepot.TabIndex = 15
'
'btnSearch
'
Me.btnSearch.Location = New System.Drawing.Point(328, 20)
Me.btnSearch.Name = "btnSearch"
Me.btnSearch.Size = New System.Drawing.Size(42, 23)
Me.btnSearch.TabIndex = 14
Me.btnSearch.Text = "查詢"
'
'txbGoodPY
'
Me.txbGoodPY.Location = New System.Drawing.Point(154, 21)
Me.txbGoodPY.Name = "txbGoodPY"
Me.txbGoodPY.Size = New System.Drawing.Size(56, 21)
Me.txbGoodPY.TabIndex = 13
Me.txbGoodPY.Text = ""
'
'lblDepotId
'
Me.lblDepotId.Location = New System.Drawing.Point(225, 26)
Me.lblDepotId.Name = "lblDepotId"
Me.lblDepotId.Size = New System.Drawing.Size(32, 16)
Me.lblDepotId.TabIndex = 12
Me.lblDepotId.Text = "倉庫"
'
'lblGoodPY
'
Me.lblGoodPY.Location = New System.Drawing.Point(103, 26)
Me.lblGoodPY.Name = "lblGoodPY"
Me.lblGoodPY.Size = New System.Drawing.Size(56, 16)
Me.lblGoodPY.TabIndex = 11
Me.lblGoodPY.Text = "商品拼音"
'
'txbGoodId
'
Me.txbGoodId.Location = New System.Drawing.Point(35, 21)
Me.txbGoodId.Name = "txbGoodId"
Me.txbGoodId.Size = New System.Drawing.Size(56, 21)
Me.txbGoodId.TabIndex = 10
Me.txbGoodId.Text = ""
'
'lblGoodId
'
Me.lblGoodId.Location = New System.Drawing.Point(7, 26)
Me.lblGoodId.Name = "lblGoodId"
Me.lblGoodId.Size = New System.Drawing.Size(32, 12)
Me.lblGoodId.TabIndex = 9
Me.lblGoodId.Text = "貨號"
'
'frmDepotSearch
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(608, 277)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.dgdResult)
Me.Name = "frmDepotSearch"
Me.Text = "庫存查詢"
CType(Me.dgdResult, System.ComponentModel.ISupportInitialize).EndInit()
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub btnSearch_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSearch.Click
Dim strFilter As String = ""
'判斷貨號是否為空
If txbGoodId.Text.Trim().Length > 0 Then
strFilter = " and a.貨號='" + txbGoodId.Text + "'"
End If
'判斷拼音編碼是否為空
If txbGoodPY.Text.Trim().Length > 0 Then
strFilter += " and 拼音編碼 like '"
strFilter += txbGoodPY.Text.Trim() + "%'"
End If
'判斷選擇的倉庫
If cbbDepot.SelectedIndex > 0 Then
strFilter += " and 倉庫 = '"
strFilter += cbbDepot.Items(cbbDepot.SelectedIndex) + "'"
End If
Dim dvResult As DataView
'執行SQL進行查詢
Dim db As DataBase = New DataBase
Dim strSQL = "select a.貨號,b.品名,拼音編碼,單位,"
strSQL += "倉庫,庫存數量,庫存單價,庫存金額 from 庫存庫 as a, "
strSQL += "商品清單 as b where a.貨號=b.貨號 and 庫存數量 > 0"
dvResult = db.RunSelectSQL(strSQL + strFilter)
dvResult.AllowEdit = False
dvResult.AllowNew = False
dvResult.RowFilter = ""
dgdResult.DataSource = dvResult
db.Dispose()
End Sub
Private Sub frmDepotSearch_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim db As DataBase = New DataBase
'執行SQL語句并對cbbDepot控件進行數據綁定
Dim dv As DataView = _
db.RunSelectSQL("select 倉庫號,倉庫名 from 倉庫清單")
Me.cbbDepot.Items.Add("")
'設置顯示的字段
For Each dr As DataRow In dv.Table.Rows
Me.cbbDepot.Items.Add(dr("倉庫名"))
Next
Dim dvResult As DataView
'執行SQL語句選取所有庫存貨物
Dim strSQL As String = "select a.貨號,b.品名,拼音編碼,單位,倉庫,"
strSQL += "庫存數量,庫存單價,庫存金額 from 庫存庫 as a,商品清單 as b "
strSQL += "where a.貨號=b.貨號 and 庫存數量 > 0"
dvResult = db.RunSelectSQL(strSQL)
dvResult.AllowEdit = False
dvResult.AllowNew = False
Dim ts As New DataGridTableStyle
Dim aColumnTextColumn As DataGridTextBoxColumn
Dim numCols As Integer = dvResult.Table.Columns.Count
Dim i As Integer
For i = 0 To numCols - 1
aColumnTextColumn = New DataGridTextBoxColumn
With aColumnTextColumn
.MappingName = dvResult.Table.Columns(i).ColumnName
.HeaderText = dvResult.Table.Columns(i).ColumnName
.NullText = ""
.Format = "F"
End With
ts.GridColumnStyles.Add(aColumnTextColumn)
Next
ts.AlternatingBackColor = Color.LightGray
ts.MappingName = dvResult.Table.TableName
Me.dgdResult.TableStyles.Add(ts)
Me.dgdResult.DataSource = dvResult
'釋放資源
db.Dispose()
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -