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

📄 frmdepotsearch.vb

📁 vfp开发的进销存管理系统,运行相应系统的Setup安装程序
💻 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 + -