⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmadd_del_yh.frm

📁 图书简明管理系统源代码(VB),可作为软件工程课程设计用,也可以作为学习用。
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmadd_del_yh 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "增加删除用户"
   ClientHeight    =   5190
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   6480
   Icon            =   "frmadd_del_yh.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   5190
   ScaleWidth      =   6480
   Begin VB.TextBox txt用户名 
      Height          =   375
      Left            =   3960
      TabIndex        =   2
      Top             =   1080
      Width           =   1935
   End
   Begin VB.TextBox txt密码 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   3960
      PasswordChar    =   "*"
      TabIndex        =   3
      Top             =   2160
      Width           =   1935
   End
   Begin VB.TextBox txt确认密码 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   3960
      PasswordChar    =   "*"
      TabIndex        =   4
      Top             =   3240
      Width           =   1935
   End
   Begin VB.ListBox lst用户 
      Columns         =   1
      Height          =   3660
      ItemData        =   "frmadd_del_yh.frx":19862
      Left            =   240
      List            =   "frmadd_del_yh.frx":19864
      TabIndex        =   0
      Top             =   480
      Width           =   1935
   End
   Begin VB.CommandButton cmdexit 
      Cancel          =   -1  'True
      Caption         =   "退   出"
      Height          =   375
      Left            =   4800
      TabIndex        =   6
      Top             =   4560
      Width           =   1215
   End
   Begin VB.CommandButton cmdadd 
      Caption         =   "添 加 用 户"
      Default         =   -1  'True
      Height          =   375
      Left            =   2640
      TabIndex        =   5
      Top             =   4560
      Width           =   1215
   End
   Begin VB.CommandButton cmddel 
      Caption         =   "删 除 用 户"
      Height          =   375
      Left            =   480
      TabIndex        =   1
      Top             =   4560
      Width           =   1215
   End
   Begin VB.PictureBox Picbg1 
      Appearance      =   0  'Flat
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   1440
      Left            =   -840
      Picture         =   "frmadd_del_yh.frx":19866
      ScaleHeight     =   1440
      ScaleWidth      =   1440
      TabIndex        =   7
      Top             =   4440
      Width           =   1440
   End
   Begin VB.Label Label4 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "显 示 用 户"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   210
      Left            =   240
      TabIndex        =   9
      Top             =   240
      Width           =   1185
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "用  户  名:"
      Height          =   180
      Left            =   2760
      TabIndex        =   12
      Top             =   1177
      Width           =   1095
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "密      码:"
      Height          =   180
      Left            =   2760
      TabIndex        =   11
      Top             =   2250
      Width           =   1095
   End
   Begin VB.Label Label3 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "确 认 密 码:"
      Height          =   180
      Left            =   2760
      TabIndex        =   10
      Top             =   3330
      Width           =   1185
   End
   Begin VB.Label Label5 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "添加新用户"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   210
      Left            =   2400
      TabIndex        =   8
      Top             =   240
      Width           =   1065
   End
   Begin VB.Shape Shape1 
      BorderColor     =   &H8000000B&
      Height          =   3735
      Left            =   2400
      Top             =   480
      Width           =   3855
   End
End
Attribute VB_Name = "frmadd_del_yh"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub cmdadd_Click()
Dim name As String
Dim rs As New ADODB.Recordset
Dim sql, sql2 As String

name = LCase(Trim(txt用户名.Text))
sql = " insert into yhxxb values ('" & name & "','" & Trim(txt密码.Text) & "')"
sql2 = "select * from yhxxb where 用户名 = '" & Trim(txt用户名.Text) & "'"


If Trim(txt用户名.Text) = "" Then
       MsgBox "用户名不能为空!", vbOKOnly + vbExclamation, "错误"
        txt用户名.SetFocus
        txt用户名.Text = ""
ElseIf Len(Trim(txt密码.Text)) < 6 Or Len(Trim(txt密码.Text)) > 6 Then
        MsgBox "密码至少有6位,不能超过20位", vbOKOnly + vbExclamation, "错误"
        txt密码.SetFocus
        
ElseIf Trim(txt密码.Text) <> Trim(txt确认密码.Text) Then
        MsgBox "两次密码不一致", vbOKOnly + vbExclamation, "错误"
        txt密码.SetFocus
Else
    Set rs = TransactSQL(sql2)
    If Not rs.EOF Then
         MsgBox "已有这个用户", vbOKOnly + vbExclamation, "错误"
    Else
        TransactSQL (sql)
        lst用户.AddItem name
         'MsgBox "添加用户", vbOKOnly + vbExclamation
    End If
    
    rs.Close
    txt用户名.SetFocus
    txt用户名.Text = ""
End If
txt密码.Text = ""
txt确认密码.Text = ""

End Sub

Private Sub cmddel_Click()

Dim sql As String

sql = "delete from yhxxb where 用户名 = '" & Trim(lst用户.Text) & "'"
If Trim(lst用户.Text) = "Admin" Or Trim(lst用户.Text) = "System" Then
    MsgBox "不能删除此用户", vbOKOnly + vbExclamation, "错误"
ElseIf MsgBox("真的要删除该用户吗?", vbQuestion + vbYesNo, "询问") = vbYes Then
       TransactSQL (sql)
       lst用户.RemoveItem (lst用户.ListIndex)
       lst用户.Refresh
       cmddel.Enabled = False
End If
    
End Sub

Private Sub cmdexit_Click()
Unload Me
End Sub

Private Sub Form_Load()

Call fullpic(Me, Picbg1)
cmddel.Enabled = False
Me.Left = (frmmain.ScaleWidth - Me.Width) / 2
Me.Top = (frmmain.ScaleHeight - Me.Height) / 2

Dim rs1 As New ADODB.Recordset
Dim sql As String
sql = "select 用户名 from yhxxb"
Set rs1 = TransactSQL(sql)
While Not rs1.EOF
    lst用户.AddItem rs1(0)
    rs1.MoveNext
Wend
rs1.Close

End Sub

Private Sub lst用户_Click()
cmddel.Enabled = True
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -