📄 frmuser.frm
字号:
VERSION 5.00
Object = "{D76D7128-4A96-11D3-BD95-D296DC2DD072}#1.0#0"; "Vsflex7.ocx"
Begin VB.Form Frm_用户管理
BorderStyle = 3 'Fixed Dialog
Caption = "用户管理"
ClientHeight = 2655
ClientLeft = 45
ClientTop = 330
ClientWidth = 5325
Icon = "FrmUSER.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 2655
ScaleWidth = 5325
ShowInTaskbar = 0 'False
Begin VB.PictureBox Picture2
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 2625
Left = 3255
ScaleHeight = 2595
ScaleWidth = 2040
TabIndex = 1
Top = 30
Width = 2070
Begin VB.CommandButton Command1
Caption = "退 出"
Height = 495
Left = 360
TabIndex = 14
Top = 1920
Width = 1335
End
Begin VB.CommandButton SNXpButtonSAVE
Caption = "保 存"
Height = 495
Left = 360
TabIndex = 13
Top = 1320
Width = 1335
End
Begin VB.CommandButton SNXpButtonDEL
Caption = "删 除"
Height = 495
Left = 360
TabIndex = 12
Top = 720
Width = 1335
End
Begin VB.CommandButton SNXpButtonVIEW
Caption = "浏 览"
Height = 495
Left = 360
TabIndex = 11
Top = 120
Width = 1335
End
End
Begin VB.PictureBox Picture1
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 2625
Left = 15
ScaleHeight = 2595
ScaleWidth = 3210
TabIndex = 0
Top = 30
Width = 3240
Begin VSFlex7Ctl.VSFlexGrid VFG
Height = 2595
Left = 30
TabIndex = 10
Top = 0
Width = 3210
_cx = 5662
_cy = 4577
_ConvInfo = -1
Appearance = 1
BorderStyle = 1
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
MousePointer = 0
BackColor = -2147483643
ForeColor = -2147483640
BackColorFixed = -2147483633
ForeColorFixed = -2147483630
BackColorSel = -2147483635
ForeColorSel = -2147483634
BackColorBkg = -2147483636
BackColorAlternate= 16777152
GridColor = -2147483633
GridColorFixed = -2147483632
TreeColor = -2147483632
FloodColor = 192
SheetBorder = -2147483642
FocusRect = 1
HighLight = 1
AllowSelection = -1 'True
AllowBigSelection= -1 'True
AllowUserResizing= 0
SelectionMode = 0
GridLines = 1
GridLinesFixed = 2
GridLineWidth = 1
Rows = 50
Cols = 10
FixedRows = 1
FixedCols = 0
RowHeightMin = 0
RowHeightMax = 0
ColWidthMin = 0
ColWidthMax = 0
ExtendLastCol = 0 'False
FormatString = ""
ScrollTrack = 0 'False
ScrollBars = 3
ScrollTips = 0 'False
MergeCells = 0
MergeCompare = 0
AutoResize = -1 'True
AutoSizeMode = 0
AutoSearch = 0
AutoSearchDelay = 2
MultiTotals = -1 'True
SubtotalPosition= 1
OutlineBar = 0
OutlineCol = 0
Ellipsis = 0
ExplorerBar = 0
PicturesOver = 0 'False
FillStyle = 0
RightToLeft = 0 'False
PictureType = 0
TabBehavior = 0
OwnerDraw = 0
Editable = 0
ShowComboButton = 1
WordWrap = 0 'False
TextStyle = 0
TextStyleFixed = 0
OleDragMode = 0
OleDropMode = 0
DataMode = 0
VirtualData = -1 'True
DataMember = ""
ComboSearch = 3
AutoSizeMouse = -1 'True
FrozenRows = 0
FrozenCols = 0
AllowUserFreezing= 0
BackColorFrozen = 0
ForeColorFrozen = 0
WallPaperAlignment= 9
End
Begin VB.TextBox TxtQX
Height = 320
Left = 1170
TabIndex = 9
Top = 2025
Width = 1800
End
Begin VB.TextBox TxtPass
Height = 320
Left = 1170
TabIndex = 8
Top = 1410
Width = 1800
End
Begin VB.TextBox TxtName
Height = 320
Left = 1170
TabIndex = 7
Top = 780
Width = 1800
End
Begin VB.TextBox TxtNum
Height = 320
Left = 1170
TabIndex = 6
Top = 165
Width = 1800
End
Begin VB.Label Label4
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
Caption = "用户权限"
ForeColor = &H80000008&
Height = 180
Left = 300
TabIndex = 5
Top = 2145
Width = 720
End
Begin VB.Label Label3
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
Caption = "用户口令"
ForeColor = &H80000008&
Height = 180
Left = 300
TabIndex = 4
Top = 1500
Width = 720
End
Begin VB.Label Label2
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
Caption = "用户名称"
ForeColor = &H80000008&
Height = 180
Left = 300
TabIndex = 3
Top = 855
Width = 720
End
Begin VB.Label Label1
Appearance = 0 'Flat
AutoSize = -1 'True
BackColor = &H80000005&
Caption = "用户编号"
ForeColor = &H80000008&
Height = 180
Left = 300
TabIndex = 2
Top = 210
Width = 720
End
Begin VB.Shape Shape2
BorderColor = &H00FF8080&
Height = 2490
Left = 45
Top = 45
Width = 3105
End
Begin VB.Shape Shape1
BorderColor = &H00FF8080&
Height = 2565
Left = 15
Top = 15
Width = 3165
End
End
End
Attribute VB_Name = "Frm_用户管理"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs As New ADODB.Recordset
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Activate()
TxtNum.SetFocus
End Sub
Private Sub Form_Load()
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) * (1 - 0.618)
Call txtkong
TxtNum.Enabled = True
TxtName.Enabled = True
TxtPass.Enabled = True
TxtQX.Enabled = True
End Sub
Private Sub SNXpButtonEXIT_Click()
Unload Me
End Sub
Private Sub SNXpButtonDEL_Click()
If Trim(TxtNum.Text) <> "" Then
If MsgBox("你确定要删除编号为 '" & TxtNum.Text & "'的记录吗?", vbYesNo) = vbYes Then
Conn.Execute "delete from users where bh='" & Trim(TxtNum.Text) & "'"
MsgBox "删除成功", 64
Call txtkong
SNXpButtonVIEW.Caption = "浏览"
Else
Exit Sub
End If
Else
MsgBox "请指定要删除的用户编号", 48
End If
End Sub
Private Sub SNXpButtonSAVE_Click()
If TxtNum.Text = "" Then
MsgBox "用户编号不能为空,请重新输入", , "远望提示"
TxtNum.SetFocus
Exit Sub
End If
If TxtName.Text = "" Then
MsgBox "用户名不能为空,请重新输入", , "远望提示"
TxtName.SetFocus
Exit Sub
End If
If TxtPass.Text = "" Then
MsgBox "用户口令不能为空,请重新输入", , "远望提示"
TxtPass.SetFocus
Exit Sub
End If
If rs.State = 1 Then rs.Close
rs.Open "select * from users where bh='" & Trim(TxtNum.Text) & "'", Conn, adOpenKeyset, adLockOptimistic
If rs.EOF = False Then
If Trim(rs!Bh) = Trim(TxtNum.Text) Then
If MsgBox("您输入的部门编号已经存在,当前操作为修改操作,是否继续?", vbOKCancel, "远望提示") = vbOK Then
Conn.Execute "delete * from users where bh='" & Trim(TxtNum.Text) & "'"
rs.AddNew
rs!Bh = Trim(TxtNum.Text)
rs!Mc = Trim(TxtName.Text)
rs!kl = Trim(TxtPass.Text)
'rs!qx = Trim(TxtQX.Text)
rs.UpdateBatch
MsgBox "已经成功修改!", , "远望提示"
Call txtkong
SNXpButtonVIEW.Caption = "浏览"
Exit Sub
Else
Exit Sub
End If
End If
End If
If rs.State = 1 Then
rs.Close
rs.CursorLocation = adUseClient
rs.Open "select * from users", Conn, adOpenKeyset, adLockOptimistic
rs.AddNew
rs!Bh = Trim(TxtNum.Text)
rs!Mc = Trim(TxtName.Text)
rs!kl = Trim(TxtPass.Text)
'rs!qx = Val(Trim(TxtQX.Text))
rs.Update
MsgBox "已经成功保存", , "远望提示"
Call txtkong
SNXpButtonVIEW.Caption = "浏览"
End If
End Sub
Sub txtkong()
TxtNum.Text = ""
TxtName.Text = ""
TxtPass.Text = ""
TxtQX.Text = ""
VFG.Visible = False
End Sub
Private Sub SNXpButtonVIEW_Click()
If rs.State = 1 Then rs.Close
rs.CursorLocation = adUseClient
rs.Open "select bh as 用户编号,mc as 用户名,kl as 密码,qx as 权限 from users", Conn
If rs.EOF = False Then
VFG.Visible = True
Set VFG.DataSource = rs
If SNXpButtonVIEW.Caption = "浏览" Then
SNXpButtonVIEW.Caption = "取消浏览"
ElseIf SNXpButtonVIEW.Caption = "取消浏览" Then
SNXpButtonVIEW.Caption = "浏览"
Call txtkong
End If
Else
MsgBox "库中无记录", , "远望提示"
SNXpButtonVIEW.Caption = "浏览"
Exit Sub
End If
End Sub
Private Sub TxtName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
End If
End Sub
Private Sub TxtNum_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
End If
End Sub
Private Sub TxtPass_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
End If
End Sub
Private Sub TxtQX_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
End If
End Sub
Private Sub VFG_DblClick()
Call txtkong
TxtNum.Text = VFG.TextMatrix(VFG.RowSel, 0)
TxtName.Text = VFG.TextMatrix(VFG.RowSel, 1)
TxtPass.Text = VFG.TextMatrix(VFG.RowSel, 2)
TxtQX.Text = VFG.TextMatrix(VFG.RowSel, 3)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -