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

📄 frmdepotselect.vb

📁 visual Basic 数据库开发实例导航
💻 VB
字号:
Public Class frmDepotSelect
    Inherits System.Windows.Forms.Form
    Private sGoodsId As String
    Public dv As DataView
    Private gridMouseDownTime As DateTime
#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 dgdDepotList As System.Windows.Forms.DataGrid
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.dgdDepotList = New System.Windows.Forms.DataGrid
        CType(Me.dgdDepotList, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'dgdDepotList
        '
        Me.dgdDepotList.CaptionVisible = False
        Me.dgdDepotList.DataMember = ""
        Me.dgdDepotList.Dock = System.Windows.Forms.DockStyle.Fill
        Me.dgdDepotList.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgdDepotList.Location = New System.Drawing.Point(0, 0)
        Me.dgdDepotList.Name = "dgdDepotList"
        Me.dgdDepotList.Size = New System.Drawing.Size(232, 173)
        Me.dgdDepotList.TabIndex = 0
        '
        'frmDepotSelect
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(232, 173)
        Me.Controls.Add(Me.dgdDepotList)
        Me.MaximizeBox = False
        Me.Name = "frmDepotSelect"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "选择仓库"
        CType(Me.dgdDepotList, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region
    Sub New(ByVal id As String)
        MyBase.New()
        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()
        '在 InitializeComponent() 调用之后添加任何初始化
        sGoodsId = id
    End Sub

    Private Sub frmDepotSelect_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
        Try

            Dim db As DataBase = New DataBase
            '查看库存情况
            dv = db.RunSelectSQL( _
            "select 仓库,库存数量 from 库存库 where 货号='" _
            + sGoodsId + "'" + " and 库存数量 > 0 ")
            dv.AllowEdit = False
            dv.AllowNew = False
            Dim ts As New DataGridTableStyle
            Dim aColumnTextColumn As DataGridTextBoxColumn
            Dim numCols As Integer = dv.Table.Columns.Count
            Dim i As Integer
            For i = 0 To numCols - 1
                aColumnTextColumn = New DataGridTextBoxColumn
                With aColumnTextColumn
                    .MappingName = dv.Table.Columns(i).ColumnName
                    .HeaderText = dv.Table.Columns(i).ColumnName
                    .NullText = ""
                    .Format = "f"
                End With
                AddHandler aColumnTextColumn.TextBox.MouseDown, _
                New MouseEventHandler(AddressOf DGDoubleClick)
                AddHandler aColumnTextColumn.TextBox.DoubleClick, _
                New EventHandler(AddressOf dgdDepotList_DoubleClick)
                ts.GridColumnStyles.Add(aColumnTextColumn)
            Next
            ts.MappingName = dv.Table.TableName
            Me.dgdDepotList.TableStyles.Add(ts)
            '给DataGrid设置数据源
            Me.dgdDepotList.DataSource = dv
            db.Dispose()
        Catch ex As Exception
            MessageBox.Show("错误")
        End Try
    End Sub

    Public Function SetInfo() As String
        Dim sReturn As String
        Dim iRow As Integer = Me.dgdDepotList.CurrentRowIndex
        Dim sId, sName, sUnit As String
        sId = dv(iRow)("仓库")
        sName = dv(iRow)("库存数量")
        sReturn = sId.Trim + "|" + sName.Trim
        Return sReturn
    End Function

    Private Sub dgdDepotList_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgdDepotList.DoubleClick
        Me.Close()
    End Sub
    Private Sub DGDoubleClick(ByVal sender As Object, ByVal e As MouseEventArgs)
        If (DateTime.Now < gridMouseDownTime.AddMilliseconds(SystemInformation.DoubleClickTime)) Then
            dgdDepotList_DoubleClick(Nothing, Nothing)
        End If
    End Sub

    Private Sub dgdSupplyInfo_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgdDepotList.MouseDown
        gridMouseDownTime = DateTime.Now
    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -