VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > VB.net教程 >
  • vb.net 教程 20-4 库存管理系统3.5 主界面(FormMain)

版权声明:本文为博主原创文章,转载请在显著位置标明本文出处以及作者网名,未经作者允许不得用于商业目的。
 
    关于《Visual Basic.Net 循序渐进》请到百度网盘下载,具体下载地址:
    链接:https://pan.baidu.com/s/1IfaLvlklx-nT4KK4VKZuIw 
    提取码:ip5n
 
 
 
  主界面是多文档界面容器,需要将窗体属性IsMdiContainer设置为True。关于多文档界面编程请参看教程第7.12节《多文档界面》。
    主界面并不提供具体操作,只是一个显示其它窗口的容器,其工具栏上按钮打开对应功能的窗体。
    为了更好控制用户界面,FormMain窗体中showWindow()方法仅允许同一时间显示一个子窗体。
    全部代码如下:
 
Imports System.ComponentModel
 
Public Class FormMain
 
    Private Sub FormMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        If permissions = 0 Then
            tsbSupplier.Visible = True
            tsbExpress.Visible = True
            tsbOperator.Visible = True
        Else
            tsbSupplier.Visible = False
            tsbExpress.Visible = False
            tsbOperator.Visible = False
        End If
    End Sub
 
    Private Sub showWindow(ByVal windowName As String)
        If Me.MdiChildren.Length = 1 Then
            If Me.MdiChildren(0).Name = windowName Then
                If Me.MdiChildren(0).WindowState <> FormWindowState.Maximized Then
                    Me.MdiChildren(0).WindowState = FormWindowState.Maximized
                    Exit Sub
                End If
            Else
                Me.MdiChildren(0).Close()
            End If
        End If
 
        Select Case windowName
            Case "FormStorageInfo"
                Dim formShow = New FormStorageInfo()
                formShow = CType(formShow, FormStorageInfo)
                formShow.WindowState = FormWindowState.Maximized
                formShow.MdiParent = Me
                formShow.Show()
 
            Case "FormStorageOut"
                Dim formShow = New FormStorageOut()
                formShow.WindowState = FormWindowState.Maximized
                formShow.MdiParent = Me
                formShow.Show()
            Case "FormStorageIn"
                Dim formShow = New FormStorageIn()
                formShow.WindowState = FormWindowState.Maximized
                formShow.MdiParent = Me
                formShow.Show()
        End Select
 
    End Sub
 
    '检查库存信息窗体是否打开
    Private Function checkWindowOpen(ByVal windowName As String) As Boolean
        Dim findWindow As Boolean = False
 
        If Me.MdiChildren.Length = 1 Then
            If Me.MdiChildren(0).Name = windowName Then
                findWindow = True
            End If
        End If
        Return findWindow
    End Function
 
    '库存信息
    Private Sub tsbStorageInfo_Click(sender As Object, e As EventArgs) Handles tsbStorageInfo.Click
        Call showWindow("FormStorageInfo")
    End Sub
 
    Private Sub tsbStorageOut_Click(sender As Object, e As EventArgs) Handles tsbStorageOut.Click
        Call showWindow("FormStorageOut")
    End Sub
 
    Private Sub tsbStorageIn_Click(sender As Object, e As EventArgs) Handles tsbStorageIn.Click
        Call showWindow("FormStorageIn")
    End Sub
 
    Private Sub tsbPass_Click(sender As Object, e As EventArgs) Handles tsbPass.Click
        FormPass.ShowDialog()
    End Sub
 
    Private Sub tsbOperator_Click(sender As Object, e As EventArgs) Handles tsbOperator.Click
        FormAdmin.ShowDialog()
    End Sub
 
    Private Sub tsbSupplier_Click(sender As Object, e As EventArgs) Handles tsbSupplier.Click
        FormSupplier.ShowDialog()
    End Sub
 
    Private Sub tsbExpress_Click(sender As Object, e As EventArgs) Handles tsbExpress.Click
        FormExpress.ShowDialog()
    End Sub
 
    Private Sub tsbAbout_Click(sender As Object, e As EventArgs) Handles tsbAbout.Click
        FormAbout.ShowDialog()
    End Sub
 
    Private Sub tsbExit_Click(sender As Object, e As EventArgs) Handles tsbExit.Click
        If MessageBox.Show("是否退出系统", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.Yes Then
            Application.Exit()
        End If
    End Sub
 
    Private Sub FormMain_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
        Application.Exit()
    End Sub
End Class
由于.net平台下C#和vb.NET很相似,本文也可以为C#爱好者提供的参考。
————————————————
版权声明:本文为CSDN博主「VB.Net」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/UruseiBest/article/details/114224313

相关教程