📄 deluserfrm.frm
字号:
VERSION 5.00
Begin VB.Form deluserfrm
Caption = "删除用户"
ClientHeight = 3225
ClientLeft = 60
ClientTop = 345
ClientWidth = 6960
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 3225
ScaleMode = 0 'User
ScaleWidth = 7304.865
Begin VB.CommandButton cmdexit
Caption = "退出"
Height = 495
Left = 4680
TabIndex = 7
Top = 2400
Width = 1215
End
Begin VB.CommandButton cmdcancel
Caption = "取消操作"
Height = 495
Left = 2760
TabIndex = 6
Top = 2400
Width = 1215
End
Begin VB.CommandButton cmddel
Caption = "删除用户"
Height = 495
Left = 840
TabIndex = 5
Top = 2400
Width = 1215
End
Begin VB.Frame Frame1
Caption = "用户信息"
Height = 1335
Left = 480
TabIndex = 0
Top = 480
Width = 5655
Begin VB.TextBox txtgonghao
Height = 375
Left = 3720
TabIndex = 4
Top = 360
Width = 1335
End
Begin VB.TextBox txtuser
Height = 375
Left = 960
TabIndex = 2
Top = 360
Width = 1335
End
Begin VB.Label Label2
Caption = "工号"
Height = 375
Left = 3000
TabIndex = 3
Top = 480
Width = 975
End
Begin VB.Label Label1
Caption = "姓名"
Height = 375
Left = 360
TabIndex = 1
Top = 480
Width = 735
End
End
End
Attribute VB_Name = "deluserfrm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdcancel_Click()
txtuser.Text = ""
txtgonghao.Text = ""
End Sub
Private Sub cmddel_Click()
Dim conuser As New ADODB.Connection
Dim cmduser As New ADODB.Command
Dim rstuser As New ADODB.Recordset
Dim cnnstr As String
'输入数据进行验证
If Len(Trim(txtuser.Text)) = 0 Then
MsgBox "用户名没有输入,请输入!", vbOKOnly
Exit Sub
Else
txtuser.Text = CStr(Trim(txtuser.Text))
End If
If Len(Trim(txtgonghao.Text)) = 0 Then
MsgBox "工号没有输入,请输入!", vbOKOnly
Exit Sub
Else
txtgonghao.Text = CStr(Trim(txtgonghao.Text))
End If
cnnstr = "delete from userinfo where username='" & txtuser & "' and userid=" & CLng(txtgonghao) & ""
With conuser
If .State = adStateOpen Then
.Close
End If
.Provider = "microsoft.jet.oledb.4.0"
.ConnectionString = App.Path & "\jinbin.mdb"
.ConnectionTimeout = 10
.Open
End With
With cmduser
.ActiveConnection = conuser
.CommandType = adCmdText
.CommandText = cnnstr
.Execute
End With
MsgBox "删除用户成功!", vbOKOnly
txtuser.Text = ""
txtgonghao.Text = ""
With rstuser
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.ActiveConnection = conuser
End With
End Sub
Private Sub cmdexit_Click()
deluserfrm.Hide
Unload Me
End Sub
Private Sub Form_Load()
With deluserfrm
.ScaleWidth = 6800
.Width = 6900
.ScaleHeight = 4000
.Height = 3800
End With
Dim conuser As New ADODB.Connection
Dim cmduser As New ADODB.Command
Dim rstuser As New ADODB.Recordset
Dim cnnstr As String
With conuser
If .State = adStateOpen Then
.Close
End If
.Provider = "microsoft.jet.oledb.4.0"
.ConnectionString = App.Path & "\jinbin.mdb"
.ConnectionTimeout = 10
.Open
End With
With rstuser
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.ActiveConnection = conuser
End With
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -