?? storeseek.vb
字號:
Imports System.Data.SqlClient
Public Class StoreSeek
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 GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents cbGoods As System.Windows.Forms.ComboBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents cbSign As System.Windows.Forms.ComboBox
Friend WithEvents tbRemain As System.Windows.Forms.TextBox
Friend WithEvents btBack As System.Windows.Forms.Button
Friend WithEvents btOK As System.Windows.Forms.Button
Friend WithEvents dgStore As System.Windows.Forms.DataGrid
Friend WithEvents ToolTip1 As System.Windows.Forms.ToolTip
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.dgStore = New System.Windows.Forms.DataGrid
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.btBack = New System.Windows.Forms.Button
Me.btOK = New System.Windows.Forms.Button
Me.tbRemain = New System.Windows.Forms.TextBox
Me.cbSign = New System.Windows.Forms.ComboBox
Me.Label1 = New System.Windows.Forms.Label
Me.cbGoods = New System.Windows.Forms.ComboBox
Me.Label3 = New System.Windows.Forms.Label
Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
CType(Me.dgStore, System.ComponentModel.ISupportInitialize).BeginInit()
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'dgStore
'
Me.dgStore.DataMember = ""
Me.dgStore.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.dgStore.Location = New System.Drawing.Point(10, 10)
Me.dgStore.Name = "dgStore"
Me.dgStore.Size = New System.Drawing.Size(222, 166)
Me.dgStore.TabIndex = 0
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.btBack)
Me.GroupBox1.Controls.Add(Me.btOK)
Me.GroupBox1.Controls.Add(Me.tbRemain)
Me.GroupBox1.Controls.Add(Me.cbSign)
Me.GroupBox1.Controls.Add(Me.Label1)
Me.GroupBox1.Controls.Add(Me.cbGoods)
Me.GroupBox1.Controls.Add(Me.Label3)
Me.GroupBox1.Location = New System.Drawing.Point(240, 8)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(144, 168)
Me.GroupBox1.TabIndex = 1
Me.GroupBox1.TabStop = False
Me.ToolTip1.SetToolTip(Me.GroupBox1, "選擇了商品條件,庫存條件將不起作用")
'
'btBack
'
Me.btBack.Location = New System.Drawing.Point(80, 104)
Me.btBack.Name = "btBack"
Me.btBack.Size = New System.Drawing.Size(56, 23)
Me.btBack.TabIndex = 33
Me.btBack.Text = "還原"
'
'btOK
'
Me.btOK.Location = New System.Drawing.Point(16, 104)
Me.btOK.Name = "btOK"
Me.btOK.Size = New System.Drawing.Size(56, 23)
Me.btOK.TabIndex = 32
Me.btOK.Text = "確定"
'
'tbRemain
'
Me.tbRemain.Location = New System.Drawing.Point(104, 64)
Me.tbRemain.Name = "tbRemain"
Me.tbRemain.Size = New System.Drawing.Size(32, 21)
Me.tbRemain.TabIndex = 13
Me.tbRemain.Text = ""
'
'cbSign
'
Me.cbSign.Items.AddRange(New Object() {"<", ">", "="})
Me.cbSign.Location = New System.Drawing.Point(56, 64)
Me.cbSign.Name = "cbSign"
Me.cbSign.Size = New System.Drawing.Size(48, 20)
Me.cbSign.TabIndex = 12
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(8, 64)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(40, 23)
Me.Label1.TabIndex = 11
Me.Label1.Text = "庫存"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'cbGoods
'
Me.cbGoods.Location = New System.Drawing.Point(56, 32)
Me.cbGoods.Name = "cbGoods"
Me.cbGoods.Size = New System.Drawing.Size(80, 20)
Me.cbGoods.TabIndex = 10
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(8, 32)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(40, 23)
Me.Label3.TabIndex = 9
Me.Label3.Text = "商品"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'StoreSeek
'
Me.AcceptButton = Me.btOK
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(392, 186)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.dgStore)
Me.MaximizeBox = False
Me.Name = "StoreSeek"
Me.Text = "庫存查詢"
CType(Me.dgStore, System.ComponentModel.ISupportInitialize).EndInit()
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private sql As String = "SELECT * FROM STOREVIEW"
Private Sub StoreSeek_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As DataTable = Sample02.GetDataTable("SELECT CATEGORYNAME FROM CATEGORY ORDER BY CATEGORYNAME")
For Each dr As DataRow In dt.Rows
Me.cbGoods.Items.Add(dr(0))
Next
Me.SetDefault()
End Sub
Private Sub btOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btOK.Click
Dim Goods As String = Me.cbGoods.Text.Trim()
Dim Sign As String = Me.cbSign.Text.Trim()
Dim Remain As String = Me.tbRemain.Text.Trim()
If Goods <> String.Empty Then
Me.sql += " WHERE CATEGORYNAME = '" + Goods.Trim() + "'"
Else
If (Sign = String.Empty) <> (Remain = String.Empty) Then
MessageBox.Show("庫存條件不能只填一個")
If Sign = String.Empty Then
Me.cbSign.Focus()
Return
Else
Me.tbRemain.Focus()
Return
End If
Else
Try
If Int16.Parse(Remain) < 0 Then
MessageBox.Show("庫存只能為非負整數")
Me.tbRemain.Focus()
Return
End If
Catch
MessageBox.Show("數字格式不正確")
Me.tbRemain.Focus()
Return
End Try
End If
Me.sql += " WHERE GOODSCOUNT " + Sign + " " + Remain
End If
Me.BindDg()
Me.sql = "SELECT * FROM STOREVIEW"
End Sub
Private Sub btBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btBack.Click
Me.SetDefault()
End Sub
Private Sub SetDefault()
sql = "SELECT * FROM STOREVIEW"
Me.BindDg()
Me.cbGoods.Text = String.Empty
Me.cbSign.Text = String.Empty
Me.tbRemain.Text = String.Empty
End Sub
Private Sub BindDg()
Dim dtNew As DataTable
Dim SqlAda As New SqlDataAdapter
Dim SqlCmd As New SqlCommand(sql, Sample02.SqlCon)
Dim ds As New DataSet
Try
SqlAda.SelectCommand = SqlCmd
ds.Clear()
SqlAda.Fill(ds)
Me.dgStore.DataSource = ds.Tables(0)
Catch ex As Exception
Sample02.WriteErr(ex)
End Try
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -