📄 frmmain.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写处置以清理组件列表。
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 MainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents ToolBar1 As System.Windows.Forms.ToolBar
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
Friend WithEvents menuBuy As System.Windows.Forms.MenuItem
Friend WithEvents menuPurchase As System.Windows.Forms.MenuItem
Friend WithEvents menuFlow As System.Windows.Forms.MenuItem
Friend WithEvents menuBorrow As System.Windows.Forms.MenuItem
Friend WithEvents menuReLend As System.Windows.Forms.MenuItem
Friend WithEvents menuReturn As System.Windows.Forms.MenuItem
Friend WithEvents ToolBarButton0 As System.Windows.Forms.ToolBarButton
Friend WithEvents ToolBarButton1 As System.Windows.Forms.ToolBarButton
Friend WithEvents ToolBarButton2 As System.Windows.Forms.ToolBarButton
Friend WithEvents ToolBarButton3 As System.Windows.Forms.ToolBarButton
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.menuBuy = New System.Windows.Forms.MenuItem
Me.menuPurchase = New System.Windows.Forms.MenuItem
Me.menuFlow = New System.Windows.Forms.MenuItem
Me.menuBorrow = New System.Windows.Forms.MenuItem
Me.menuReLend = New System.Windows.Forms.MenuItem
Me.menuReturn = New System.Windows.Forms.MenuItem
Me.ToolBar1 = New System.Windows.Forms.ToolBar
Me.ToolBarButton0 = New System.Windows.Forms.ToolBarButton
Me.ToolBarButton1 = New System.Windows.Forms.ToolBarButton
Me.ToolBarButton2 = New System.Windows.Forms.ToolBarButton
Me.ToolBarButton3 = New System.Windows.Forms.ToolBarButton
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
Me.SuspendLayout()
'
'MainMenu1
'
Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuBuy, Me.menuFlow})
'
'menuBuy
'
Me.menuBuy.Index = 0
Me.menuBuy.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuPurchase})
Me.menuBuy.Text = "图书采购"
'
'menuPurchase
'
Me.menuPurchase.Index = 0
Me.menuPurchase.Text = "图书采购"
'
'menuFlow
'
Me.menuFlow.Index = 1
Me.menuFlow.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuBorrow, Me.menuReLend, Me.menuReturn})
Me.menuFlow.Text = "图书流通"
'
'menuBorrow
'
Me.menuBorrow.Index = 0
Me.menuBorrow.Text = "借阅"
'
'menuReLend
'
Me.menuReLend.Index = 1
Me.menuReLend.Text = "续借"
'
'menuReturn
'
Me.menuReturn.Index = 2
Me.menuReturn.Text = "还书"
'
'ToolBar1
'
Me.ToolBar1.Appearance = System.Windows.Forms.ToolBarAppearance.Flat
Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.ToolBarButton0, Me.ToolBarButton1, Me.ToolBarButton2, Me.ToolBarButton3})
Me.ToolBar1.ButtonSize = New System.Drawing.Size(16, 16)
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(680, 44)
Me.ToolBar1.TabIndex = 1
'
'ToolBarButton0
'
Me.ToolBarButton0.ImageIndex = 0
Me.ToolBarButton0.ToolTipText = "图书采购"
'
'ToolBarButton1
'
Me.ToolBarButton1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator
'
'ToolBarButton2
'
Me.ToolBarButton2.ImageIndex = 3
Me.ToolBarButton2.ToolTipText = "图书借阅"
'
'ToolBarButton3
'
Me.ToolBarButton3.Style = System.Windows.Forms.ToolBarButtonStyle.Separator
'
'ImageList1
'
Me.ImageList1.ImageSize = New System.Drawing.Size(32, 32)
Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(680, 449)
Me.Controls.Add(Me.ToolBar1)
Me.IsMdiContainer = True
Me.Menu = Me.MainMenu1
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "图书馆管理系统"
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
Me.ResumeLayout(False)
End Sub
#End Region
Public Function OpenOnce(ByVal frm As Form) As Boolean
Dim mdifrm As Form
For Each mdifrm In Me.MdiChildren
If frm.Text = mdifrm.Text Then
mdifrm.Activate() '子窗体获得焦点 激活
Return False
Exit Function
End If
Next
Return True
End Function
Private Sub menuBorrow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuBorrow.Click
Dim frmLend As New frmUtterBook '借阅实现代码 定义借阅类的实例
If OpenOnce(frmLend) = True Then
frmLend.MdiParent = Me
frmLend.TabCtr.SelectedIndex = 0 '下标
frmLend.Show()
End If
End Sub
Private Sub menuReLend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuReLend.Click
Dim frmLend As New frmUtterBook '续借实现代码 定义借阅类的实例
If OpenOnce(frmLend) = True Then
frmLend.MdiParent = Me
frmLend.TabCtr.SelectedIndex = 1
frmLend.Show()
End If
End Sub
Private Sub menuReturn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuReturn.Click
Dim frmLend As New frmUtterBook()
If OpenOnce(frmLend) = True Then
frmLend.MdiParent = Me
frmLend.TabCtr.SelectedIndex = 2
frmLend.Show()
End If
End Sub
Private Sub menuPurchase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuPurchase.Click
Dim frmBuy As New frmStockBook '定义采购类的实例
If OpenOnce(frmBuy) = True Then
frmBuy.MdiParent = Me
frmBuy.Show()
End If
End Sub
Private Sub menuArrange_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.LayoutMdi(MdiLayout.Cascade)
End Sub
Private Sub menuHorizion_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.LayoutMdi(MdiLayout.TileHorizontal)
End Sub
Private Sub menuVertical_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.LayoutMdi(MdiLayout.TileVertical)
End Sub
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) _
Handles ToolBar1.ButtonClick
Select Case Me.ToolBar1.Buttons.IndexOf(e.Button)
Case 0
Me.menuPurchase.PerformClick() '模仿button click事件
Case 1
Me.menuBorrow.PerformClick()
Case 2
Me.menuReturn.PerformClick()
Case 3
Me.menuReLend.PerformClick()
End Select
End Sub
Private Sub Form1_Closing(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If MsgBox("您真的要退出图书馆管理系统吗?", _
MsgBoxStyle.YesNo + MsgBoxStyle.Question, "退出系统") _
= MsgBoxResult.Yes Then
Application.Exit()
Else
e.Cancel = True
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -