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

📄 frmbase.vb

📁 生产管理系统。vb.net sql2
💻 VB
字号:
Public Class frmBase
    Inherits System.Windows.Forms.Form
    Protected bmData As BindingManagerBase
    Protected dtData As DataTable
    'bAdd = true 为新增
    'bAdd = false 为修改
    Protected bAdd As Boolean
#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 ToolBar1 As System.Windows.Forms.ToolBar
    Friend WithEvents tbbFirst As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbbBack As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbbForward As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbbLast As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbbNew As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbbModify As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbbDel As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbbSave As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbbUndo As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbbExit As System.Windows.Forms.ToolBarButton
    Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
    Friend WithEvents grbSearch As System.Windows.Forms.GroupBox
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents btnSearch As System.Windows.Forms.Button
    Friend WithEvents dgdList As System.Windows.Forms.DataGrid
    Friend WithEvents txbThree As System.Windows.Forms.TextBox
    Friend WithEvents txbTwo As System.Windows.Forms.TextBox
    Friend WithEvents txbOne As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmBase))
        Me.ToolBar1 = New System.Windows.Forms.ToolBar
        Me.tbbFirst = New System.Windows.Forms.ToolBarButton
        Me.tbbBack = New System.Windows.Forms.ToolBarButton
        Me.tbbForward = New System.Windows.Forms.ToolBarButton
        Me.tbbLast = New System.Windows.Forms.ToolBarButton
        Me.tbbNew = New System.Windows.Forms.ToolBarButton
        Me.tbbModify = New System.Windows.Forms.ToolBarButton
        Me.tbbDel = New System.Windows.Forms.ToolBarButton
        Me.tbbSave = New System.Windows.Forms.ToolBarButton
        Me.tbbUndo = New System.Windows.Forms.ToolBarButton
        Me.tbbExit = New System.Windows.Forms.ToolBarButton
        Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
        Me.grbSearch = New System.Windows.Forms.GroupBox
        Me.Label3 = New System.Windows.Forms.Label
        Me.txbThree = New System.Windows.Forms.TextBox
        Me.txbTwo = New System.Windows.Forms.TextBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label1 = New System.Windows.Forms.Label
        Me.txbOne = New System.Windows.Forms.TextBox
        Me.btnSearch = New System.Windows.Forms.Button
        Me.dgdList = New System.Windows.Forms.DataGrid
        Me.grbSearch.SuspendLayout()
        CType(Me.dgdList, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'ToolBar1
        '
        Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.tbbFirst, Me.tbbBack, Me.tbbForward, Me.tbbLast, Me.tbbNew, Me.tbbModify, Me.tbbDel, Me.tbbSave, Me.tbbUndo, Me.tbbExit})
        Me.ToolBar1.DropDownArrows = True
        Me.ToolBar1.ImageList = Me.ImageList1
        Me.ToolBar1.Location = New System.Drawing.Point(0, 0)
        Me.ToolBar1.Name = "ToolBar1"
        Me.ToolBar1.ShowToolTips = True
        Me.ToolBar1.Size = New System.Drawing.Size(536, 41)
        Me.ToolBar1.TabIndex = 1
        '
        'tbbFirst
        '
        Me.tbbFirst.ImageIndex = 0
        Me.tbbFirst.Text = "首记录"
        Me.tbbFirst.ToolTipText = "首记录"
        '
        'tbbBack
        '
        Me.tbbBack.ImageIndex = 1
        Me.tbbBack.Text = "上记录"
        Me.tbbBack.ToolTipText = "上一条记录"
        '
        'tbbForward
        '
        Me.tbbForward.ImageIndex = 2
        Me.tbbForward.Text = "下记录"
        Me.tbbForward.ToolTipText = "下一条记录"
        '
        'tbbLast
        '
        Me.tbbLast.ImageIndex = 3
        Me.tbbLast.Text = "尾记录"
        Me.tbbLast.ToolTipText = "尾记录"
        '
        'tbbNew
        '
        Me.tbbNew.ImageIndex = 4
        Me.tbbNew.Text = "新增"
        Me.tbbNew.ToolTipText = "新增"
        '
        'tbbModify
        '
        Me.tbbModify.ImageIndex = 5
        Me.tbbModify.Text = "修改"
        Me.tbbModify.ToolTipText = "修改"
        '
        'tbbDel
        '
        Me.tbbDel.ImageIndex = 6
        Me.tbbDel.Text = "删除"
        Me.tbbDel.ToolTipText = "删除"
        '
        'tbbSave
        '
        Me.tbbSave.Enabled = False
        Me.tbbSave.ImageIndex = 7
        Me.tbbSave.Text = "保存"
        Me.tbbSave.ToolTipText = "保存"
        '
        'tbbUndo
        '
        Me.tbbUndo.Enabled = False
        Me.tbbUndo.ImageIndex = 8
        Me.tbbUndo.Text = "取消"
        Me.tbbUndo.ToolTipText = "取消"
        '
        'tbbExit
        '
        Me.tbbExit.ImageIndex = 9
        Me.tbbExit.Text = "退出"
        Me.tbbExit.ToolTipText = "退出"
        '
        'ImageList1
        '
        Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16)
        Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
        Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
        '
        'grbSearch
        '
        Me.grbSearch.Controls.Add(Me.Label3)
        Me.grbSearch.Controls.Add(Me.txbThree)
        Me.grbSearch.Controls.Add(Me.txbTwo)
        Me.grbSearch.Controls.Add(Me.Label2)
        Me.grbSearch.Controls.Add(Me.Label1)
        Me.grbSearch.Controls.Add(Me.txbOne)
        Me.grbSearch.Controls.Add(Me.btnSearch)
        Me.grbSearch.Dock = System.Windows.Forms.DockStyle.Top
        Me.grbSearch.Location = New System.Drawing.Point(0, 41)
        Me.grbSearch.Name = "grbSearch"
        Me.grbSearch.Size = New System.Drawing.Size(536, 39)
        Me.grbSearch.TabIndex = 2
        Me.grbSearch.TabStop = False
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(320, 16)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(56, 15)
        Me.Label3.TabIndex = 6
        Me.Label3.Text = "物料拼音"
        '
        'txbThree
        '
        Me.txbThree.Location = New System.Drawing.Point(376, 11)
        Me.txbThree.Name = "txbThree"
        Me.txbThree.Size = New System.Drawing.Size(56, 21)
        Me.txbThree.TabIndex = 5
        Me.txbThree.Text = ""
        '
        'txbTwo
        '
        Me.txbTwo.Location = New System.Drawing.Point(248, 11)
        Me.txbTwo.Name = "txbTwo"
        Me.txbTwo.Size = New System.Drawing.Size(56, 21)
        Me.txbTwo.TabIndex = 4
        Me.txbTwo.Text = ""
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(192, 16)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(56, 15)
        Me.Label2.TabIndex = 3
        Me.Label2.Text = "物料名称"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(72, 16)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(56, 15)
        Me.Label1.TabIndex = 2
        Me.Label1.Text = "物料编号"
        '
        'txbOne
        '
        Me.txbOne.Location = New System.Drawing.Point(128, 11)
        Me.txbOne.Name = "txbOne"
        Me.txbOne.Size = New System.Drawing.Size(56, 21)
        Me.txbOne.TabIndex = 1
        Me.txbOne.Text = ""
        '
        'btnSearch
        '
        Me.btnSearch.Location = New System.Drawing.Point(8, 11)
        Me.btnSearch.Name = "btnSearch"
        Me.btnSearch.Size = New System.Drawing.Size(40, 22)
        Me.btnSearch.TabIndex = 0
        Me.btnSearch.Text = "搜索"
        '
        'dgdList
        '
        Me.dgdList.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.dgdList.CaptionVisible = False
        Me.dgdList.DataMember = ""
        Me.dgdList.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgdList.Location = New System.Drawing.Point(0, 80)
        Me.dgdList.Name = "dgdList"
        Me.dgdList.Size = New System.Drawing.Size(208, 213)
        Me.dgdList.TabIndex = 3
        '
        'frmBase
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(536, 293)
        Me.Controls.Add(Me.dgdList)
        Me.Controls.Add(Me.grbSearch)
        Me.Controls.Add(Me.ToolBar1)
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Name = "frmBase"
        Me.Text = "frmBase"
        Me.grbSearch.ResumeLayout(False)
        CType(Me.dgdList, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region
    
    Private Sub frmBase_Load(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
        Prepare()
        SetDataGrid()
        SetTextBoxState(True)
    End Sub

    Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, _
    ByVal e As ToolBarButtonClickEventArgs) _
    Handles ToolBar1.ButtonClick
        Select Case e.Button.Text
            Case "首记录"
                '返回首记录
                bmData.Position = 0
            Case "上记录"
                If bmData.Position <> 0 Then
                    bmData.Position -= 1
                End If
            Case "下记录"
                If bmData.Position <> bmData.Count Then
                    bmData.Position += 1
                End If
            Case "尾记录"
                '返回尾记录
                bmData.Position = bmData.Count
            Case "新增"
                SetTextBoxState(False)
                SetToolBarState(False)
                SetOpenButton(True)
                bAdd = True
                Clear()
            Case "修改"
                SetTextBoxState(False)
                SetToolBarState(False)
                SetOpenButton(True)
                bAdd = False
            Case "删除"
                '弹出询问对话框
                Dim dlgResult As DialogResult = _
                       MessageBox.Show("你确认删除此数据?", _
                      "删除", MessageBoxButtons.OKCancel)
                If dlgResult = DialogResult.OK Then
                    DeleteData()
                End If
            Case "保存"
                SetToolBarState(True)
                SetTextBoxState(True)
                SetOpenButton(False)
                If bAdd = True Then
                    '为新增数据保存
                    SaveForAdd()
                Else
                    '为更新数据保存
                    SaveForUpdate()
                End If
            Case "取消"
                SetTextBoxState(True)
                SetToolBarState(True)
                If Me.Name = "frmProductsDemand" Then
                    SetOpenButton(False)
                End If
            Case "退出"
                '关闭本窗体
                Me.Close()
        End Select
        Try
            Me.dgdList.CurrentRowIndex = bmData.Position
        Catch ex As Exception
        End Try
    End Sub


    Private Sub btnSearch_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnSearch.Click
        SearchResult()
    End Sub

    Private Sub dgdList_CurrentCellChanged(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles dgdList.CurrentCellChanged
        '判断bmData是否为Nothing
        If bmData Is Nothing Then
            Exit Sub
        End If
        If bmData.Position <> dgdList.CurrentCell.RowNumber Then
            bmData.Position = dgdList.CurrentCell.RowNumber
            SetProductName()
        End If
    End Sub

    Private Sub SetToolBarState(ByVal bState As Boolean)
        '设置Button的是否能够单击
        ToolBar1.Buttons("0").Enabled = bState
        ToolBar1.Buttons("1").Enabled = bState
        ToolBar1.Buttons("2").Enabled = bState
        ToolBar1.Buttons("3").Enabled = bState
        ToolBar1.Buttons("4").Enabled = bState
        ToolBar1.Buttons("5").Enabled = bState
        ToolBar1.Buttons("6").Enabled = bState
        ToolBar1.Buttons("7").Enabled = Not bState
        ToolBar1.Buttons("8").Enabled = Not bState
    End Sub
    Public Overridable Sub Prepare()
    End Sub
    '设置DataGrid控件
    Public Overridable Sub SetDataGrid()
    End Sub
    '查询函数
    Public Overridable Sub SearchResult()
    End Sub
    '新增函数
    Public Overridable Sub SaveForAdd()
    End Sub
    '更新函数
    Public Overridable Sub SaveForUpdate()
    End Sub
    '删除函数
    Public Overridable Sub DeleteData()
    End Sub
    '清除函数
    Public Overridable Sub Clear()
    End Sub
    '设置按钮函数
    Public Overridable Sub SetOpenButton(ByVal bEnable As Boolean)
    End Sub
    Public Overridable Sub SetProductName()
    End Sub
    '设置TextBox函数
    Public Overridable Sub SetTextBoxState(ByVal bState As Boolean)
    End Sub
End Class

⌨️ 快捷键说明

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