⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 storeseek.vb

📁 vb.net+sql进销存管理系统
💻 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 + -