📄 frmlimit.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form frmLimit
BorderStyle = 1 'Fixed Single
Caption = "权限设定"
ClientHeight = 5025
ClientLeft = 45
ClientTop = 330
ClientWidth = 6315
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 5025
ScaleWidth = 6315
Begin VB.TextBox txtId
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 375
Left = 840
MaxLength = 6
TabIndex = 10
Top = 240
Width = 1215
End
Begin MSComctlLib.ImageList ImageList1
Left = 1080
Top = 3120
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 38
ImageHeight = 38
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 1
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmLimit.frx":0000
Key = ""
EndProperty
EndProperty
End
Begin MSComctlLib.ListView LViewLimit
Height = 3015
Left = 0
TabIndex = 9
Top = 2040
Width = 6255
_ExtentX = 11033
_ExtentY = 5318
View = 3
LabelWrap = -1 'True
HideSelection = -1 'True
FullRowSelect = -1 'True
GridLines = -1 'True
_Version = 393217
Icons = "ImageList1"
SmallIcons = "ImageList1"
ColHdrIcons = "ImageList1"
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 0
End
Begin VB.CommandButton cmdDelete
Caption = "删除"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 450
Left = 2040
TabIndex = 8
Top = 1440
Width = 1000
End
Begin VB.CommandButton cmdSave
Caption = "保存"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 450
Left = 480
TabIndex = 7
Top = 1440
Width = 1000
End
Begin VB.ComboBox ComboProgram
Height = 300
Left = 840
TabIndex = 3
Top = 880
Width = 2295
End
Begin VB.Frame Frame1
Caption = "权限"
ClipControls = 0 'False
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 1815
Left = 3840
TabIndex = 2
Top = 120
Width = 1695
Begin VB.OptionButton OptionLimit
Caption = "管理"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 255
Index = 2
Left = 240
TabIndex = 6
Top = 1360
Width = 975
End
Begin VB.OptionButton OptionLimit
Caption = "维护"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 255
Index = 1
Left = 240
TabIndex = 5
Top = 860
Width = 1215
End
Begin VB.OptionButton OptionLimit
Caption = "查询"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 255
Index = 0
Left = 240
TabIndex = 4
Top = 360
Width = 1335
End
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "程序"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 240
TabIndex = 1
Top = 900
Width = 450
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "用户"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 240
TabIndex = 0
Top = 300
Width = 450
End
End
Attribute VB_Name = "frmLimit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public mrc As ADODB.Recordset
Dim txtSql As String
Dim arrayLimit(2, 1) As String
Dim arrayProgram() As String
Dim ProgramCount As Integer
Private Sub cmdDelete_Click()
If Not check_Limit Then
Exit Sub
End If
'判断是否新增的SQL语句
txtSql = "delete from limit where Id='" & txtId.Text & "' and Program='" & Trim(findProgramId(ComboProgram.Text)) & "'"
Set mrc = Nothing
Set mrc = ExecuteSQL(txtSql)
ShowListLimit ' 刷新数据
Cleartxt '清除文本中的数据
End Sub
Private Sub cmdSave_Click()
Dim i As Integer
If Not check_Limit Then
Exit Sub
End If
'判断是否新增的SQL语句
txtSql = "select * from limit where Id='" & txtId.Text & "' and Program='" & Trim(findProgramId(ComboProgram.Text)) & "'"
Set mrc = Nothing
Set mrc = ExecuteSQL(txtSql)
If mrc.EOF = False Then '修改
For i = 0 To 2
If OptionLimit(i).Value Then
mrc.Fields(2) = i
Exit For
End If
Next i
mrc.Update
Else '新增
txtSql = "select * from limit"
Set mrc = Nothing
Set mrc = ExecuteSQL(txtSql)
mrc.AddNew
mrc.Fields(0) = txtId.Text
mrc.Fields(1) = findProgramId(ComboProgram.Text)
For i = 0 To 2
If OptionLimit(i).Value Then
mrc.Fields(2) = i
Exit For
End If
Next i
mrc.Update
End If
Set mrc = Nothing
ShowListLimit ' 刷新数据
Cleartxt '清除文本中的数据
End Sub
Private Sub Cleartxt()
Dim i As Integer
ComboProgram.Text = ""
For i = 0 To 2
OptionLimit(i).Value = False
Next i
End Sub
Private Sub Form_Load()
Dim FlagEnabled As Boolean
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
FlagEnabled = CheckProgramLimit("hrd403")
cmdSave.Enabled = FlagEnabled
cmdDelete.Enabled = FlagEnabled
Call Init
End Sub
Private Sub Init()
Dim i As Integer
Dim TvHead As ColumnHeader
Set TvHead = LViewLimit.ColumnHeaders.Add(, "h01", "序号", 0)
Set TvHead = LViewLimit.ColumnHeaders.Add(, "h02", "程序名称", 3000)
Set TvHead = LViewLimit.ColumnHeaders.Add(, "h03", "权限", 2000)
arrayLimit(0, 0) = "0"
arrayLimit(0, 1) = "查询"
arrayLimit(1, 0) = "1"
arrayLimit(1, 1) = "维护"
arrayLimit(2, 0) = "2"
arrayLimit(2, 1) = "管理"
txtSql = "select * from program"
Set mrc = Nothing
Set mrc = ExecuteSQL(txtSql)
ReDim arrayProgram(mrc.RecordCount - 1, 1)
ProgramCount = mrc.RecordCount
i = 0
Do While Not mrc.EOF
ComboProgram.AddItem mrc.Fields(1).Value, i
arrayProgram(i, 0) = mrc.Fields(0).Value
arrayProgram(i, 1) = mrc.Fields(1).Value
i = i + 1
mrc.MoveNext
Loop
End Sub
Private Sub ShowListLimit()
Dim i As Integer
Dim LvDate As ListItem
LViewLimit.ListItems.Clear
txtSql = "select * from limit where Id='" & txtId.Text & "'"
Set mrc = Nothing
Set mrc = ExecuteSQL(txtSql)
i = 1
Do While Not mrc.EOF
Set LvData = LViewLimit.ListItems.Add(, "d" & i, i, 1, 1)
LvData.SubItems(1) = findProgramName(mrc.Fields(1).Value)
LvData.SubItems(2) = findLimitName(mrc.Fields(2).Value)
i = i + 1
mrc.MoveNext
Loop
mrc.Close
End Sub
Private Function findLimitName(vbtxt As String) As String
Dim i As Integer
findLimitName = ""
For i = 0 To 2
If Trim(arrayLimit(i, 0)) = Trim(vbtxt) Then
findLimitName = arrayLimit(i, 1)
Exit For
End If
Next i
End Function
Private Function findProgramName(vbtxt As String) As String
Dim i As Integer
findProgramName = ""
For i = 0 To ProgramCount - 1
If Trim(arrayProgram(i, 0)) = Trim(vbtxt) Then
findProgramName = arrayProgram(i, 1)
Exit For
End If
Next i
End Function
Private Function findLimitId(vbtxt As String) As String
Dim i As Integer
findLimitId = ""
For i = 0 To 2
If Trim(arrayLimit(i, 1)) = Trim(vbtxt) Then
findLimitId = arrayLimit(i, 0)
Exit For
End If
Next i
End Function
Private Function findProgramId(vbtxt As String) As String
Dim i As Integer
findProgramId = ""
For i = 0 To ProgramCount - 1
If Trim(arrayProgram(i, 1)) = Trim(vbtxt) Then
findProgramId = arrayProgram(i, 0)
Exit For
End If
Next i
End Function
Private Sub LViewLimit_BeforeLabelEdit(Cancel As Integer)
Cancel = 1
End Sub
Private Sub LViewLimit_ItemClick(ByVal Item As MSComctlLib.ListItem)
ComboProgram.Text = Item.SubItems(1)
OptionLimit(Val(findLimitId(Item.SubItems(2)))).Value = True
End Sub
Private Sub txtId_Change()
Call ShowListLimit
End Sub
Private Sub txtId_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
ComboProgram.SetFocus
End If
End Sub
Private Function check_Limit() As Boolean
Dim str As String
Dim i As Integer
check_Limit = True
If txtId.Text = "" Then
MsgBox "输入的数据不能为空", vbCritical + vbOKOnly, "错误提示:"
check_Limit = False
txtId.SetFocus
Exit Function
End If
If ComboProgram.Text = "" Then
MsgBox "输入的数据不能为空", vbCritical + vbOKOnly, "错误提示:"
check_Limit = False
ComboProgram.SetFocus
Exit Function
Else
str = ""
str = findProgramId(ComboProgram.Text)
If str = "" Then
MsgBox "程序名称不存在", vbCritical + vbOKOnly, "错误提示:"
check_Limit = False
ComboProgram.SetFocus
Exit Function
End If
End If
For i = 0 To 2
If OptionLimit(i).Value = True Then
Exit For
End If
Next i
If i > 2 Then
MsgBox "权限没有选择", vbCritical + vbOKOnly, "错误提示:"
check_Limit = False
OptionLimit(0).SetFocus
Exit Function
End If
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -