-
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
栏目列表
最新更新
nodejs爬虫
Python正则表达式完全指南
爬取豆瓣Top250图书数据
shp 地图文件批量添加字段
爬虫小试牛刀(爬取学校通知公告)
【python基础】函数-初识函数
【python基础】函数-返回值
HTTP请求:requests模块基础使用必知必会
Python初学者友好丨详解参数传递类型
如何有效管理爬虫流量?
SQL SERVER中递归
2个场景实例讲解GaussDB(DWS)基表统计信息估
常用的 SQL Server 关键字及其含义
动手分析SQL Server中的事务中使用的锁
openGauss内核分析:SQL by pass & 经典执行
一招教你如何高效批量导入与更新数据
天天写SQL,这些神奇的特性你知道吗?
openGauss内核分析:执行计划生成
[IM002]Navicat ODBC驱动器管理器 未发现数据
初入Sql Server 之 存储过程的简单使用
这是目前我见过最好的跨域解决方案!
减少回流与重绘
减少回流与重绘
如何使用KrpanoToolJS在浏览器切图
performance.now() 与 Date.now() 对比
一款纯 JS 实现的轻量化图片编辑器
关于开发 VS Code 插件遇到的 workbench.scm.
前端设计模式——观察者模式
前端设计模式——中介者模式
创建型-原型模式