www.pudn.com > chap07.rar > frmUser.frm


VERSION 5.00 
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX" 
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX" 
Begin VB.Form frmUser  
   BorderStyle     =   3  'Fixed Dialog 
   Caption         =   "用户管理" 
   ClientHeight    =   3795 
   ClientLeft      =   2760 
   ClientTop       =   3750 
   ClientWidth     =   5130 
   Icon            =   "frmUser.frx":0000 
   LinkTopic       =   "Form1" 
   LockControls    =   -1  'True 
   MaxButton       =   0   'False 
   MinButton       =   0   'False 
   ScaleHeight     =   3795 
   ScaleWidth      =   5130 
   ShowInTaskbar   =   0   'False 
   StartUpPosition =   1  '所有者中心 
   Begin VB.PictureBox Picture1  
      Height          =   2865 
      Left            =   -15 
      ScaleHeight     =   2805 
      ScaleWidth      =   5070 
      TabIndex        =   5 
      Top             =   0 
      Width           =   5130 
      Begin MSDataGridLib.DataGrid DataGrid1  
         Bindings        =   "frmUser.frx":000C 
         Height          =   2790 
         Left            =   0 
         TabIndex        =   6 
         Top             =   0 
         Width           =   5070 
         _ExtentX        =   8943 
         _ExtentY        =   4921 
         _Version        =   393216 
         AllowUpdate     =   0   'False 
         AllowArrows     =   -1  'True 
         BackColor       =   -2147483634 
         BorderStyle     =   0 
         HeadLines       =   2 
         RowHeight       =   15 
         FormatLocked    =   -1  'True 
         BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}  
            Name            =   "宋体" 
            Size            =   9 
            Charset         =   134 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}  
            Name            =   "宋体" 
            Size            =   9 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ColumnCount     =   3 
         BeginProperty Column00  
            DataField       =   "zh" 
            Caption         =   "帐号" 
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}  
               Type            =   0 
               Format          =   "" 
               HaveTrueFalseNull=   0 
               FirstDayOfWeek  =   0 
               FirstWeekOfYear =   0 
               LCID            =   2052 
               SubFormatType   =   0 
            EndProperty 
         EndProperty 
         BeginProperty Column01  
            DataField       =   "mc" 
            Caption         =   "名称" 
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}  
               Type            =   0 
               Format          =   "" 
               HaveTrueFalseNull=   0 
               FirstDayOfWeek  =   0 
               FirstWeekOfYear =   0 
               LCID            =   2052 
               SubFormatType   =   0 
            EndProperty 
         EndProperty 
         BeginProperty Column02  
            DataField       =   "lx" 
            Caption         =   "帐号类别" 
            BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}  
               Type            =   0 
               Format          =   "" 
               HaveTrueFalseNull=   0 
               FirstDayOfWeek  =   0 
               FirstWeekOfYear =   0 
               LCID            =   2052 
               SubFormatType   =   0 
            EndProperty 
         EndProperty 
         SplitCount      =   1 
         BeginProperty Split0  
            MarqueeStyle    =   3 
            AllowRowSizing  =   0   'False 
            Locked          =   -1  'True 
            BeginProperty Column00  
               ColumnWidth     =   1574.929 
            EndProperty 
            BeginProperty Column01  
               ColumnWidth     =   1695.118 
            EndProperty 
            BeginProperty Column02  
               Alignment       =   2 
               ColumnWidth     =   915.024 
            EndProperty 
         EndProperty 
      End 
   End 
   Begin VB.CommandButton cmdEdit  
      Caption         =   "修改(&E)..." 
      Height          =   375 
      Left            =   2580 
      TabIndex        =   3 
      Top             =   3300 
      Width           =   1215 
   End 
   Begin VB.CommandButton cmdDel  
      Caption         =   "删除(&D)" 
      Height          =   375 
      Left            =   1320 
      TabIndex        =   2 
      Top             =   3300 
      Width           =   1215 
   End 
   Begin VB.CommandButton CancelButton  
      Cancel          =   -1  'True 
      Caption         =   "关闭(&C)" 
      Height          =   375 
      Left            =   3870 
      TabIndex        =   1 
      Top             =   3300 
      Width           =   1215 
   End 
   Begin VB.CommandButton cmdAdd  
      Caption         =   "添加(&A)..." 
      Height          =   375 
      Left            =   45 
      TabIndex        =   0 
      Top             =   3300 
      Width           =   1215 
   End 
   Begin MSAdodcLib.Adodc Adodc1  
      Height          =   330 
      Left            =   3120 
      Top             =   3330 
      Visible         =   0   'False 
      Width           =   1200 
      _ExtentX        =   2117 
      _ExtentY        =   582 
      ConnectMode     =   0 
      CursorLocation  =   3 
      IsolationLevel  =   -1 
      ConnectionTimeout=   15 
      CommandTimeout  =   30 
      CursorType      =   3 
      LockType        =   3 
      CommandType     =   8 
      CursorOptions   =   0 
      CacheSize       =   50 
      MaxRecords      =   0 
      BOFAction       =   0 
      EOFAction       =   0 
      ConnectStringType=   1 
      Appearance      =   1 
      BackColor       =   -2147483643 
      ForeColor       =   -2147483640 
      Orientation     =   0 
      Enabled         =   -1 
      Connect         =   "" 
      OLEDBString     =   "" 
      OLEDBFile       =   "" 
      DataSourceName  =   "" 
      OtherAttributes =   "" 
      UserName        =   "" 
      Password        =   "" 
      RecordSource    =   "" 
      Caption         =   "Adodc1" 
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}  
         Name            =   "宋体" 
         Size            =   9 
         Charset         =   134 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      _Version        =   393216 
   End 
   Begin VB.Label Label1  
      AutoSize        =   -1  'True 
      Caption         =   "注:帐号类别:0 - 系统管理员;1 - 考生" 
      ForeColor       =   &H00FF0000& 
      Height          =   180 
      Left            =   75 
      TabIndex        =   4 
      Top             =   3000 
      Width           =   3420 
   End 
End 
Attribute VB_Name = "frmUser" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Option Explicit 
Private mUserRS As ADODB.Recordset 
Private Sub CancelButton_Click() 
    Unload Me 
End Sub 
 
Private Sub cmdAdd_Click() 
    Dim frm As New frmUserAddEdit 
     
    On Error Resume Next 
     
    Adodc1.Recordset.AddNew 
    frm.UserADORecordset = Adodc1.Recordset 
     
    Load frm 
     
    frm.Show vbModal 
End Sub 
Private Sub cmdDel_Click() 
    Dim zh As String 
     
    If Adodc1.Recordset.RecordCount > 0 Then 
        zh = "" & Adodc1.Recordset("zh") 
        '系统管理员不能删除 
        If zh = "administrator" Then 
            MsgBox "系统管理员帐号administrator不能删除!", vbOKOnly + vbInformation, Me.Caption 
            Exit Sub 
        End If 
        '缺省用户不能删除 
        If zh = "public" Then 
            MsgBox "缺省用户帐号public不能删除!", vbOKOnly + vbInformation, Me.Caption 
            Exit Sub 
        End If 
        '--------------------------- 
        If MsgBox("真的要删除当前记录吗?", vbQuestion + vbYesNo, "提示") = vbYes Then 
            Adodc1.Recordset.Delete adAffectCurrent 
            'save the data 
            Adodc1.Recordset.Update 
        End If 
    End If 
End Sub 
 
Private Sub cmdEdit_Click() 
    Dim frm As New frmUserAddEdit 
     
    On Error Resume Next 
     
    frm.UserADORecordset = Adodc1.Recordset 
    Load frm 
     
    frm.Show vbModal 
End Sub 
Private Sub DataGrid1_DblClick() 
    Call cmdEdit_Click 
End Sub 
 
Private Sub Form_Load() 
    On Error Resume Next 
    '打开记录集 
    Set mUserRS = New ADODB.Recordset 
    mUserRS.Open "SELECT * FROM tbUser", gadoCONN, adOpenKeyset, adLockPessimistic, adCmdText 
    Set Adodc1.Recordset = mUserRS 
End Sub 
Private Sub Form_Unload(Cancel As Integer) 
    On Error Resume Next 
     
    If Not mUserRS Is Nothing Then 
        If mUserRS.State = adStateOpen Then 
            mUserRS.Close 
        End If 
        Set mUserRS = Nothing 
    End If 
End Sub