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

📄 useradd.frm

📁 一部酒店管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form useradd 
   Caption         =   "添加用户"
   ClientHeight    =   4485
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   3540
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4485
   ScaleWidth      =   3540
   StartUpPosition =   3  '窗口缺省
   Begin VB.PictureBox Picture1 
      BackColor       =   &H00404000&
      Height          =   4455
      Left            =   0
      ScaleHeight     =   4395
      ScaleWidth      =   3435
      TabIndex        =   0
      Top             =   0
      Width           =   3495
      Begin VB.CommandButton cmd_cansel 
         Caption         =   "退出"
         Height          =   375
         Left            =   1800
         TabIndex        =   6
         Top             =   3360
         Width           =   855
      End
      Begin VB.CommandButton cmd_ok 
         Caption         =   "确认"
         Height          =   375
         Left            =   480
         TabIndex        =   5
         Top             =   3360
         Width           =   855
      End
      Begin VB.TextBox txt_pwd2 
         BackColor       =   &H00FFFFC0&
         Height          =   270
         IMEMode         =   3  'DISABLE
         Left            =   1200
         PasswordChar    =   "*"
         TabIndex        =   4
         Top             =   2480
         Width           =   1455
      End
      Begin VB.TextBox txt_pwd1 
         BackColor       =   &H00FFFFC0&
         Height          =   270
         IMEMode         =   3  'DISABLE
         Left            =   1200
         PasswordChar    =   "*"
         TabIndex        =   3
         Top             =   1880
         Width           =   1455
      End
      Begin VB.ComboBox comb_shen 
         BackColor       =   &H00FFFFC0&
         Height          =   300
         Left            =   1200
         TabIndex        =   2
         Top             =   1160
         Width           =   1455
      End
      Begin VB.TextBox txt_name 
         BackColor       =   &H00FFFFC0&
         Height          =   270
         Left            =   1200
         TabIndex        =   1
         Top             =   320
         Width           =   1455
      End
      Begin VB.Label Label4 
         BackColor       =   &H00404000&
         Caption         =   "确认密码:"
         Height          =   195
         Left            =   240
         TabIndex        =   10
         Top             =   2520
         Width           =   855
      End
      Begin VB.Label Label3 
         BackColor       =   &H00404000&
         Caption         =   "密    码:"
         Height          =   195
         Left            =   240
         TabIndex        =   9
         Top             =   1920
         Width           =   855
      End
      Begin VB.Label Label2 
         BackColor       =   &H00404000&
         Caption         =   "用户身份:"
         Height          =   195
         Left            =   240
         TabIndex        =   8
         Top             =   1200
         Width           =   855
      End
      Begin VB.Label Label1 
         BackColor       =   &H00404000&
         Caption         =   "用户名:"
         Height          =   195
         Left            =   240
         TabIndex        =   7
         Top             =   360
         Width           =   735
      End
   End
End
Attribute VB_Name = "useradd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit

Dim m_index As Integer 'combox索引

Private Sub cmd_cansel_Click()

    Unload Me
    usermanager.Show vbModal

End Sub

Private Sub cmd_ok_Click()
    
    If RegGuest = True Then
    
        Unload Me
        usermanager.Show vbModal
        
    End If
End Sub

Private Sub comb_shen_Click()
    
    m_index = comb_shen.ListIndex

End Sub

Private Sub Form_Load()

    '窗口居中
    Me.Left = (Screen.Width - Me.Width) / 2
    Me.Top = (Screen.Height - Me.Height) / 2 - 550
    
    Call LoadShenFen
    
End Sub

'加载用户身份

Private Sub LoadShenFen()

    Dim str As String
    str = "select * from quan"
    
    Dim myrs As ADODB.Recordset
    Set myrs = New ADODB.Recordset
    
    myrs.CursorLocation = adUseClient
    myrs.LockType = adLockOptimistic
    myrs.CursorType = adOpenDynamic
    myrs.Open str, myCon
        
    While Not myrs.EOF
    
        comb_shen.AddItem (myrs("value"))
        myrs.MoveNext
        
    Wend
        
    comb_shen.ListIndex = 0
        

End Sub


'客人注册
Private Function RegGuest() As Boolean
    
    If txt_name.Text = "" Then
        MsgBox "名字不能为空!", vbExclamation
        txt_name.SetFocus
        RegGuest = False
        Exit Function
    End If
    
    If txt_pwd1.Text = "" Then
        MsgBox "密码不能为空!", vbExclamation
        txt_pwd1.SetFocus
        RegGuest = False
        Exit Function
    End If
    
    If txt_pwd2.Text = "" Then
        MsgBox "密码不能为空!", vbExclamation
        txt_pwd2.SetFocus
        RegGuest = False
        Exit Function
    End If
    
    If txt_pwd1.Text <> txt_pwd2.Text Then
    
        MsgBox "两次密码输入不相同!", vbExclamation
        txt_pwd1.SetFocus
        RegGuest = False
        Exit Function
    End If
        
    Dim str As String
    str = "select * from userinfo where uid='" & txt_name.Text & "'"
    
    Dim myrs As ADODB.Recordset
    Set myrs = New ADODB.Recordset
    
    myrs.CursorLocation = adUseClient
    myrs.LockType = adLockOptimistic
    myrs.CursorType = adOpenDynamic
    myrs.Open str, myCon
    
    If myrs.RecordCount <> 0 Then
        MsgBox "已有相同用户名,请更换!", vbExclamation
        txt_name.SetFocus
        RegGuest = False
        Exit Function
    End If
    
    Dim m_shenfen As String '用户身份
    m_shenfen = m_index + 1
    
    Dim strSQL As String
    
    strSQL = "insert into userinfo (uid,pass,quanxian) values ('" & txt_name.Text & "','" & txt_pwd1.Text & "','" & m_shenfen & "')"

    myCon.Execute (strSQL)
    MsgBox "注册成功!", vbExclamation
    RegGuest = True
    
End Function

⌨️ 快捷键说明

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