Dim UserID_TP As String
Dim Name_TP As String
Dim Bewrite_TP As String
Dim Trem_TP As Date
Dim Password_TP As String
Dim Need_TP As Boolean
Dim Repeat_TP As Boolean
Dim UserGroup_TP As String
Dim Validate_TP As BooleanDim Add As BooleanPublic Property Let UserID(ByVal n As String)
       UserID_TP = n
End Property
Public Property Get UserID() As String
       UserID = UserID_TP
End Property
Public Property Get Name() As String
       Name = Name_TP
End Property
Public Property Let Name(ByVal n As String)
       Name_TP = n
End Property
Public Property Let Bewrite(ByVal b As String)
       Bewrite_TP = b
End Property
Public Property Get Bewrite() As String
       Bewrite = Bewrite_TP
End Property
Public Property Let Trem(ByVal d As Date)
       Trem_TP = d
End Property
Public Property Get Trem() As Date
       Trem = Trem_TP
End Property
Public Property Let Password(ByVal p As String)
       Password_TP = p
End Property
Public Property Get Password() As String
       Password = Password_TP
End Property
Public Property Let Need(ByVal n As Boolean)
       Need_TP = n
End Property
Public Property Get Need() As Boolean
       Need = Need_TP
End Property
Public Property Let Repeat(ByVal r As Boolean)
       Repeat_TP = r
End Property
Public Property Get Repeat() As Boolean
       Repeat = Repeat_TP
End Property
Public Property Get UserGroup() As String
       UserGroup = UserGroup_TP
End Property
Public Property Get Validate() As Boolean
       Validate = Validate_TP
End Property
Public Property Get See() As String
       See = See_TP
End Property
Public Sub AddNew()
       Add = True
End Sub
'检索客户帐号信息合法性的函数
Public Function Find(Optional ByVal n As String, Optional ByVal p As String) As Boolean
  If n <> "" Then
     UserID_TP = n
  End If
  If p <> "" Then
     Password_TP = p
  End If
  Connect    '连接数据库
  Dim xm As New ADODB.Recordset   '返回帐号的记录
  
  xm.Open "select UserID,Name,Bewrite,Password,Trem,Need,Repeat,UserGroup from UserManger where UserID='" & UserID_TP & "'", GcoMainDB, adOpenDynamic, adLockOptimistic
  If xm.EOF And xm.BOF Then
     '返回说明
     See_TP = "没有这个用户帐号!"
     Find = False
     Validate_TP = False
     xm.Close
     Set xm = Nothing
     CloseDB    '关闭数据库
  Else
     '检测是否需要密码
     If Not NeedPassword(xm![Need]) Then
        '检测密码
        If Pass(Password_TP) <> xm![Password] Then
           See_TP = "密码错误!"
           Find = False
           Exit Function
        End If
     End If
     
     If See_TP = "试用期已经到了,请购买钥匙文件!" Then
        '检测使用期
        MsgBox "" & DLock & "试用期已经到了,请购买钥匙文件!", vbSystemModal
        Find = False
        Exit Function
     End If
     
     
     '检测帐户有效期
     Dim sr As Date
     sr = "1976-05-21"
     If Format(xm![Trem], "yyyy-mm-dd") = sr Then
        Find = True
     ElseIf Format(xm![Trem], "yyyy-mm-dd") >= Date Then
        Find = True
     Else
        See_TP = "帐户超期,请联系管理员!"
        Find = False
        Exit Function
     End If
     See_TP = "帐号验证成功!"
     UserID_TP = xm![UserID]
     Name_TP = xm![Name]
     Bewrite_TP = xm![Bewrite]
     Trem_TP = xm![Trem]
     Password_TP = xm![Need]
     Need_TP = xm![Need]
     Repeat_TP = xm![Repeat]
     UserGroup_TP = xm![UserGroup]
     Validate_TP = True
     '返回成功
     Find = True
     xm.Close
     Set xm = Nothing
     CloseDB   '关闭数据库
  End IfEnd Function'保存新增加的用户帐号
Public Sub Update()
On Error GoTo er:
'检测用户帐号输入的合法性
If UserID_TP = "" Or Len(UserID_TP) > 20 Then
   MsgBox "没有输入用户的帐号或用户帐号超过有效数量!", vbSystemModal
   Exit Sub
ElseIf Not Back_Check(UserID_TP) Then
   MsgBox "用户帐号不能输入非法的“'”单引号!", vbSystemModal
   Exit Sub
End If'检测用户密码中是否有非法字符 “'“
If Not Back_Check(Pass(Password_TP)) Then
   MsgBox "用户密码只能使用《英文》或《数字》不能使用其他非法字符!", vbSystemModal
   Exit Sub
End IfIf Not Back_Check(Bewrite) Then
   MsgBox "用户描述不能使用其他非法字符!", vbSystemModal
   Exit Sub
End IfConnect
If Add Then
   GcoMainDB.Execute "insert into UserManger (UserID,Name,Bewrite,UserGroup,Trem,Password,Need,Repeat) values " _
   & "('" & UserID_TP & "','" & Name_TP & "','" & Bewrite_TP & "','User',#" & Trem_TP & "#,'" & Pass(Password_TP) & "'," & Need_TP & "," & Repeat_TP & ")" 'UserGroup  用户组   (属性)   //只读属性,显示属于的组名称
Else
   GcoMainDB.Execute "update UserManger  set" _
   & " Name='" & Name_TP & "',Bewrite='" & Bewrite_TP & "',UserGroup='" & UserGroup_TP & "',Trem=#" & Trem_TP & "#,Password='" & Pass(Password_TP) & "',need=" & Need_TP & ",repeat=" & Repeat_TP & "" _
   & " where UserID='" & UserID_TP & "'"
End If
CloseDBExit Sub
er:
  If Err.Number = -2147467259 Then
     MsgBox "用户帐号重复!", vbSystemModal
     Exit Sub
  Else
     MsgBox Err.Description
  End If
End Sub
Public Sub About()
   AboutMe.Show
End Sub