www.pudn.com > vb71053453673553.rar > FormClear.frm


VERSION 5.00 
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX" 
Begin VB.Form FormClear  
   BorderStyle     =   1  'Fixed Single 
   Caption         =   "SV班级成绩管理 - 清空数据库" 
   ClientHeight    =   5295 
   ClientLeft      =   45 
   ClientTop       =   435 
   ClientWidth     =   4500 
   Icon            =   "FormClear.frx":0000 
   LinkTopic       =   "Form1" 
   MaxButton       =   0   'False 
   MinButton       =   0   'False 
   ScaleHeight     =   5295 
   ScaleWidth      =   4500 
   StartUpPosition =   2  '屏幕中心 
   Begin VB.CommandButton Command4  
      Caption         =   "更改权限码" 
      Height          =   405 
      Left            =   3000 
      TabIndex        =   5 
      Top             =   3870 
      Width           =   1335 
   End 
   Begin MSAdodcLib.Adodc AdoBJ  
      Height          =   375 
      Left            =   1680 
      Top             =   1680 
      Visible         =   0   'False 
      Width           =   2295 
      _ExtentX        =   4048 
      _ExtentY        =   661 
      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         =   "AdoBJ" 
      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 MSAdodcLib.Adodc AdoNJ  
      Height          =   405 
      Left            =   1740 
      Top             =   1290 
      Visible         =   0   'False 
      Width           =   2100 
      _ExtentX        =   3704 
      _ExtentY        =   714 
      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         =   "AdoNJ" 
      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 MSAdodcLib.Adodc Adodc1  
      Height          =   330 
      Left            =   1260 
      Top             =   390 
      Visible         =   0   'False 
      Width           =   2145 
      _ExtentX        =   3784 
      _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.ListBox List1  
      Height          =   4920 
      Left            =   0 
      TabIndex        =   3 
      Top             =   0 
      Width           =   2835 
   End 
   Begin VB.CommandButton Command3  
      Caption         =   "删除本班级" 
      Height          =   405 
      Left            =   3000 
      TabIndex        =   2 
      Top             =   90 
      Width           =   1335 
   End 
   Begin VB.CommandButton Command2  
      Caption         =   "关闭" 
      Default         =   -1  'True 
      Height          =   405 
      Left            =   3000 
      TabIndex        =   1 
      Top             =   4470 
      Width           =   1335 
   End 
   Begin VB.CommandButton Command1  
      Caption         =   "清空所有数据" 
      Height          =   405 
      Left            =   3000 
      TabIndex        =   0 
      TabStop         =   0   'False 
      Top             =   690 
      Width           =   1335 
   End 
   Begin VB.Label Label1  
      Alignment       =   2  'Center 
      BorderStyle     =   1  'Fixed Single 
      Height          =   285 
      Left            =   0 
      TabIndex        =   4 
      Top             =   5010 
      Width           =   4515 
   End 
End 
Attribute VB_Name = "FormClear" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Option Explicit 
 
Private Sub Command1_Click() 
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db\SVDB.mdb;Persist Security Info=False" 
Adodc1.RecordSource = "SELECT * FROM 成绩" 
Adodc1.Refresh 
On Error Resume Next 
If MsgBox("您是否确定要清空学生数据库中的学生记录(本操作不可逆,请谨慎操作)?" & Chr(10) & Chr(13) & "点击[是]清空;点击[否]返回", vbQuestion + vbYesNo, "确认") = vbYes Then 
    With Adodc1.Recordset 
    .MoveFirst 
    Do While Not .EOF 
      .Delete 
      .MoveNext 
    Loop 
    End With 
MsgBox ("数据已全部清除!") 
    Form_Load 
End If 
End Sub 
 
Private Sub Command2_Click() 
End 
End Sub 
 
Private Sub Command3_Click() 
On Error Resume Next 
If MsgBox("您是否确定要删除" & List1.Text & "班级学生数据库中的学生记录?" & Chr(10) & Chr(13) & "点击[是]删除;点击[否]返回", vbQuestion + vbYesNo, "确认") = vbYes Then 
 
    Adodc1.Recordset.MoveFirst 
    Do While Not Adodc1.Recordset.EOF 
     Adodc1.Recordset.Delete 
     Adodc1.Recordset.MoveNext 
    Loop 
    MsgBox List1.Text & "班的记录已经删除!" 
    DoEvents 
    Form_Load 
End If 
    Command3.Enabled = False 
End Sub 
 
Private Sub Command4_Click() 
frmLogin1.Show 1 
End Sub 
 
Private Sub Form_Load() 
On Error Resume Next 
List1.Clear 
    Dim I, J 
    AdoNJ.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\db\svdb.mdb;Persist Security Info=False" 
    AdoBJ.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\db\svdb.mdb;Persist Security Info=False" 
     
    AdoNJ.RecordSource = "SELECT DISTINCT 年级 FROM 成绩 ORDER BY 年级" 
    AdoNJ.Refresh 
On Error Resume Next 
If AdoNJ.Recordset.EOF Then 
    Command1.Enabled = False 
    Command3.Enabled = False 
    Exit Sub 
End If 
    AdoNJ.Recordset.MoveFirst 
    For I = 1 To AdoNJ.Recordset.RecordCount 
          AdoBJ.RecordSource = "SELECT DISTINCT 班级 FROM 成绩 WHERE 年级 = '" & AdoNJ.Recordset.Fields(0).Value & "' ORDER BY 班级" 
          AdoBJ.Refresh 
            For J = 1 To AdoBJ.Recordset.RecordCount 
                 
                List1.AddItem AdoNJ.Recordset.Fields(0).Value & AdoBJ.Recordset.Fields(0).Value 
                AdoBJ.Recordset.MoveNext 
            Next J 
          AdoNJ.Recordset.MoveNext 
    Next I 
On Error Resume Next 
 
 
End Sub 
 
Private Sub List1_Click() 
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db\SVDB.mdb;Persist Security Info=False" 
Adodc1.RecordSource = "SELECT ID FROM 成绩 WHERE 年级 ='" & Left(Trim(List1.Text), 4) & "' AND 班级='" & Right(Trim(List1.Text), 3) & "'" 
Adodc1.Refresh 
 
Label1.Caption = List1.Text & "班共有" & Adodc1.Recordset.RecordCount & "条记录" 
    Command3.Enabled = True 
End Sub