📄 fmmain.vb
字号:
Imports System.Data.SqlClient
Public Class fmMain
Inherits System.Windows.Forms.Form
Dim strProgramID As String
Dim bnFirstRun As Boolean
Dim strUserID As String
#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 Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents TreeView1 As System.Windows.Forms.TreeView
Friend WithEvents bnRunning As System.Windows.Forms.Button
Friend WithEvents bnExit As System.Windows.Forms.Button
Friend WithEvents cnKS As System.Data.SqlClient.SqlConnection
Friend WithEvents cmdSQL As System.Data.SqlClient.SqlCommand
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button()
Me.Button2 = New System.Windows.Forms.Button()
Me.TreeView1 = New System.Windows.Forms.TreeView()
Me.bnRunning = New System.Windows.Forms.Button()
Me.bnExit = New System.Windows.Forms.Button()
Me.cnKS = New System.Data.SqlClient.SqlConnection()
Me.cmdSQL = New System.Data.SqlClient.SqlCommand()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(352, 16)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(64, 24)
Me.Button1.TabIndex = 0
Me.Button1.Text = "确定"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(352, 64)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(64, 24)
Me.Button2.TabIndex = 1
Me.Button2.Text = "取消"
'
'TreeView1
'
Me.TreeView1.ImageIndex = -1
Me.TreeView1.Location = New System.Drawing.Point(24, 16)
Me.TreeView1.Name = "TreeView1"
Me.TreeView1.Nodes.AddRange(New System.Windows.Forms.TreeNode() {New System.Windows.Forms.TreeNode("进销存管理系统", New System.Windows.Forms.TreeNode() {New System.Windows.Forms.TreeNode("BA 基本资料", New System.Windows.Forms.TreeNode() {New System.Windows.Forms.TreeNode("BA110业务员资料维护"), New System.Windows.Forms.TreeNode("BA120客户资料维护"), New System.Windows.Forms.TreeNode("BA130供应商资料维护"), New System.Windows.Forms.TreeNode("BA140商品资料维护"), New System.Windows.Forms.TreeNode("BA150银行资料维护"), New System.Windows.Forms.TreeNode("BA210业务员基本资料"), New System.Windows.Forms.TreeNode("BA220客户基本资料"), New System.Windows.Forms.TreeNode("BA230供应商基本资料"), New System.Windows.Forms.TreeNode("BA240商品基本资料"), New System.Windows.Forms.TreeNode("BA250银行编号对照表")}), New System.Windows.Forms.TreeNode("PR进货作业", New System.Windows.Forms.TreeNode() {New System.Windows.Forms.TreeNode("PR110进货单维护"), New System.Windows.Forms.TreeNode("PR120进货明细表"), New System.Windows.Forms.TreeNode("PR130进货统计表"), New System.Windows.Forms.TreeNode("PR140进货排行榜"), New System.Windows.Forms.TreeNode("PR150进货年统计表")}), New System.Windows.Forms.TreeNode("DL出货作业", New System.Windows.Forms.TreeNode() {New System.Windows.Forms.TreeNode("DL110出货单维护"), New System.Windows.Forms.TreeNode("DL120出货单明细表"), New System.Windows.Forms.TreeNode("DL130出货统计表"), New System.Windows.Forms.TreeNode("DL140出货排行榜"), New System.Windows.Forms.TreeNode("DL150出货年统计表")}), New System.Windows.Forms.TreeNode("IN库存管理", New System.Windows.Forms.TreeNode() {New System.Windows.Forms.TreeNode("IN110存货异动单维护"), New System.Windows.Forms.TreeNode("IN210库存排点表"), New System.Windows.Forms.TreeNode("IN220商品异动明细表"), New System.Windows.Forms.TreeNode("IN230商品异动汇总表"), New System.Windows.Forms.TreeNode("IN240商品低于安全存量表"), New System.Windows.Forms.TreeNode("IN250商品滞销分析表")}), New System.Windows.Forms.TreeNode("AP付账冲账作业", New System.Windows.Forms.TreeNode() {New System.Windows.Forms.TreeNode("AP110付账冲账作业"), New System.Windows.Forms.TreeNode("AP210付款日报表"), New System.Windows.Forms.TreeNode("AP220付款对账单"), New System.Windows.Forms.TreeNode("AP230应付帐款统计表"), New System.Windows.Forms.TreeNode("AP240暂付款统计表"), New System.Windows.Forms.TreeNode("AP250应付帐款帐龄分析表"), New System.Windows.Forms.TreeNode("AP260逾期应付帐款统计表")}), New System.Windows.Forms.TreeNode("AR收款冲账作业", New System.Windows.Forms.TreeNode() {New System.Windows.Forms.TreeNode("AR110收款冲账作业"), New System.Windows.Forms.TreeNode("AR210收款日报表"), New System.Windows.Forms.TreeNode("AR220请款单"), New System.Windows.Forms.TreeNode("AR230应收账款统计表"), New System.Windows.Forms.TreeNode("AR240暂收款统计表"), New System.Windows.Forms.TreeNode("AR250应收账款帐龄统计表"), New System.Windows.Forms.TreeNode("AR260逾期账款逾期表"), New System.Windows.Forms.TreeNode("AR270客户应收账账款异动表"), New System.Windows.Forms.TreeNode("AR280信用额度超限明细表")}), New System.Windows.Forms.TreeNode("SY系统管理", New System.Windows.Forms.TreeNode() {New System.Windows.Forms.TreeNode("SY110用户资料维护"), New System.Windows.Forms.TreeNode("SY120用户权限维护"), New System.Windows.Forms.TreeNode("SY130程序使用权限维护"), New System.Windows.Forms.TreeNode("SY140用户密码变更"), New System.Windows.Forms.TreeNode("SY210用户基本数据表"), New System.Windows.Forms.TreeNode("SY220程序编号对照表"), New System.Windows.Forms.TreeNode("SY230用户执行权限明细表"), New System.Windows.Forms.TreeNode("Sy240程序执行权限明细表")})})})
Me.TreeView1.SelectedImageIndex = -1
Me.TreeView1.Size = New System.Drawing.Size(320, 264)
Me.TreeView1.TabIndex = 2
'
'bnRunning
'
Me.bnRunning.Location = New System.Drawing.Point(248, 288)
Me.bnRunning.Name = "bnRunning"
Me.bnRunning.Size = New System.Drawing.Size(72, 24)
Me.bnRunning.TabIndex = 3
Me.bnRunning.Text = "执行"
'
'bnExit
'
Me.bnExit.Location = New System.Drawing.Point(344, 288)
Me.bnExit.Name = "bnExit"
Me.bnExit.Size = New System.Drawing.Size(64, 24)
Me.bnExit.TabIndex = 4
Me.bnExit.Text = " 结束"
'
'cnKS
'
Me.cnKS.ConnectionString = "initial catalog=KS;persist security info=False;user id=SA;workstation id=YEXIAOJI" & _
"AO;packet size=4096"
'
'cmdSQL
'
Me.cmdSQL.Connection = Me.cnKS
'
'fmMain
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(424, 319)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.bnExit, Me.bnRunning, Me.TreeView1, Me.Button2, Me.Button1})
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "fmMain"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "进销存管理系统"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub fmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
bnFirstRun = True
End Sub
Private Sub fmMain_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
'判断是否首次执行, 假如是的话, 就要进行身份确认
If bnFirstRun Then
'改成非首次执行
bnFirstRun = False
'开启身份确认的对话框
Dim fmPassword As New fmpassword()
If fmPassword.ShowDialog = DialogResult.Cancel Then
'若是按取消钮, 则结束程序的执行
Me.Close()
Else
'纪录使用者的编号
strUserID = fmPassword.MyUser
End If
End If
End Sub
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
strProgramID = Microsoft.VisualBasic.Left(e.Node.Text, 5)
End Sub
'检查执行权限的程序
Private Function CheckAuthority(ByVal ProgramID As String) As Boolean
'可否执行的变量
Dim bnRunning As Boolean
'先预设为可执行
bnRunning = True
'如果不是系统预设的管理员, 则要检查权限
If strUserID <> "Admin" Then
Try
'指定查询是否具有执行权限的SQL指令
cmdSQL.CommandText = "SELECT Running FROM UserAuthority " & _
"WHERE UserID = '" & strUserID & "'" & _
"AND ProgramID = '" & ProgramID & "'"
'开启查询
cnKS.Open()
'将结果丢给可否执行的变量
bnRunning = CType(cmdSQL.ExecuteScalar(), Boolean)
Finally
'关闭查询
cnKS.Close()
End Try
End If
'传回结果
CheckAuthority = bnRunning
End Function
Private Sub bnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnExit.Click
'确认是否离开
If MessageBox.Show("离开进销存管理系统?", "结束系统?", _
MessageBoxButtons.YesNo, MessageBoxIcon.Question, _
MessageBoxDefaultButton.Button1) = DialogResult.Yes Then
Me.Close()
End If
End Sub
Private Sub bnRunning_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnRunning.Click
If Not CheckAuthority(strProgramID) Then
MessageBox.Show("您无执行本程序的权限!", "权限检查", _
MessageBoxButtons.OK, MessageBoxIcon.Warning)
Exit Sub
End If
Select Case strProgramID
Case "BA110"
'BA110业务员数据维护
Dim fmBA110 As New fmBA110()
fmBA110.ShowDialog()
Case "BA120"
'BA120客户数据维护
Dim fmBA120 As New fmBA120()
fmBA120.ShowDialog()
Case "BA130"
'BA130供货商数据维护
Dim fmBA130 As New fmBA130()
fmBA130.ShowDialog()
Case "BA140"
'BA140商品数据维护
Dim fmBA140 As New fmBA140()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -