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

📄 classmodi.frm

📁 学生信息管理系统2.0,增加了数据库的恢复和备份
💻 FRM
字号:
VERSION 5.00
Object = "{CE671F01-259E-40DA-92FE-95803E2ECBB5}#1.0#0"; "SmartXPButton.ocx"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form classmodi 
   BackColor       =   &H00E7DFE7&
   Caption         =   "班级修改"
   ClientHeight    =   5130
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   8370
   Icon            =   "classmodi.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   5130
   ScaleWidth      =   8370
   StartUpPosition =   2  '屏幕中心
   Begin VB.TextBox Text3 
      Height          =   375
      Left            =   1320
      TabIndex        =   2
      Top             =   2520
      Width           =   1455
   End
   Begin VB.TextBox Text2 
      Height          =   375
      Left            =   1320
      TabIndex        =   1
      Top             =   1680
      Width           =   1695
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   1320
      TabIndex        =   0
      Top             =   960
      Width           =   1215
   End
   Begin MSDataGridLib.DataGrid DataGrid1 
      Height          =   2610
      Left            =   3360
      TabIndex        =   3
      Top             =   840
      Width           =   4575
      _ExtentX        =   8070
      _ExtentY        =   4604
      _Version        =   393216
      AllowUpdate     =   0   'False
      BackColor       =   16777215
      ForeColor       =   -2147483642
      HeadLines       =   1
      RowHeight       =   18
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         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     =   2
      BeginProperty Column00 
         DataField       =   ""
         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       =   ""
         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 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin SmartXPButton.XpButton XpButton6 
      Height          =   495
      Left            =   480
      TabIndex        =   5
      Top             =   3360
      Width           =   1215
      _ExtentX        =   2143
      _ExtentY        =   873
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "修改"
      PictureSmoothBackColor=   15460844
      ButtonPicture   =   "classmodi.frx":0A02
   End
   Begin SmartXPButton.XpButton XpButton5 
      Height          =   495
      Left            =   480
      TabIndex        =   6
      Top             =   4200
      Width           =   1215
      _ExtentX        =   2143
      _ExtentY        =   873
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "关闭"
      PictureSmoothBackColor=   15460844
      ButtonPicture   =   "classmodi.frx":1414
   End
   Begin SmartXPButton.XpButton XpButton4 
      Height          =   495
      Left            =   6600
      TabIndex        =   7
      Top             =   4200
      Width           =   1335
      _ExtentX        =   2355
      _ExtentY        =   873
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "最后一条"
      PictureSmoothBackColor=   15460844
      ButtonPicture   =   "classmodi.frx":1E26
   End
   Begin SmartXPButton.XpButton XpButton3 
      Height          =   495
      Left            =   5040
      TabIndex        =   8
      Top             =   4200
      Width           =   1215
      _ExtentX        =   2143
      _ExtentY        =   873
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "下一条"
      PictureSmoothBackColor=   15460844
      ButtonPicture   =   "classmodi.frx":2838
   End
   Begin SmartXPButton.XpButton XpButton2 
      Height          =   495
      Left            =   3480
      TabIndex        =   9
      Top             =   4200
      Width           =   1215
      _ExtentX        =   2143
      _ExtentY        =   873
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "上一条"
      PictureSmoothBackColor=   15460844
      ButtonPicture   =   "classmodi.frx":324A
   End
   Begin SmartXPButton.XpButton XpButton1 
      Height          =   495
      Left            =   1920
      TabIndex        =   10
      Top             =   4200
      Width           =   1215
      _ExtentX        =   2143
      _ExtentY        =   873
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "第一条"
      PictureSmoothBackColor=   15460844
      ButtonPicture   =   "classmodi.frx":3C5C
   End
   Begin VB.Label Label4 
      BackStyle       =   0  'Transparent
      Caption         =   "班长学号:"
      Height          =   495
      Left            =   360
      TabIndex        =   14
      Top             =   2640
      Width           =   1215
   End
   Begin VB.Label Label3 
      BackStyle       =   0  'Transparent
      Caption         =   "班级名称"
      Height          =   495
      Left            =   360
      TabIndex        =   13
      Top             =   1800
      Width           =   855
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "班级编号:"
      Height          =   495
      Left            =   360
      TabIndex        =   12
      Top             =   1080
      Width           =   855
   End
   Begin VB.Label Label9 
      BackStyle       =   0  'Transparent
      Caption         =   "Label9"
      Height          =   375
      Left            =   3360
      TabIndex        =   11
      Top             =   3600
      Width           =   4935
   End
   Begin VB.Label label1 
      BackStyle       =   0  'Transparent
      Caption         =   "班级信息修改"
      BeginProperty Font 
         Name            =   "隶书"
         Size            =   21.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000002&
      Height          =   495
      Left            =   2760
      TabIndex        =   4
      Top             =   0
      Width           =   2895
   End
End
Attribute VB_Name = "classmodi"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim WithEvents MyRs As ADODB.Recordset
Attribute MyRs.VB_VarHelpID = -1
Dim myrs1 As ADODB.Recordset
Dim myrs2 As ADODB.Recordset
Dim str As String
Dim myconn As ADODB.Connection
Private Sub Form_Load()
Set myconn = New ADODB.Connection
myconn.ConnectionString = "driver={SQL Server};" & _
      "server=(local);uid=sa;pwd=;database=student_info"
myconn.Open
'***** 使用Recordset对象的Open方法创建记录集 *****
'myrs.Open "student", myconn, adOpenStatic, adLockOptimistic, adCmdTable
Set MyRs = New ADODB.Recordset
MyRs.ActiveConnection = myconn
MyRs.Source = "class"
MyRs.CursorLocation = adUseClient
MyRs.CursorType = adOpenStatic
MyRs.Open , , , adLockOptimistic
Set DataGrid1.DataSource = MyRs
DataGrid1.Columns(0).Caption = "班级编号"
DataGrid1.Columns(1).Caption = "班级名称"
DataGrid1.Columns(2).Caption = "班长学号"
DataGrid1.Columns(0).Width = 800
DataGrid1.Columns(1).Width = 1400
DataGrid1.Columns(2).Width = 1200
End Sub

Private Sub XpButton1_Click()
MyRs.MoveFirst
End Sub

Private Sub XpButton2_Click()
MyRs.MovePrevious
   If MyRs.BOF = True Then
     MyRs.MoveFirst
   End If
End Sub

Private Sub XpButton3_Click()
MyRs.MoveNext
   If MyRs.EOF = True Then
     MyRs.MoveLast
   End If
End Sub

Private Sub XpButton4_Click()
MyRs.MoveLast
End Sub

Private Sub XpButton5_Click()
MyRs.Close

myconn.Close

Unload Me
End Sub
Private Sub MyRs_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
Label9.Caption = "当前记录/记录总数:" & MyRs.AbsolutePosition & "/" & MyRs.RecordCount
If MyRs.EOF = True Then
     MyRs.MoveLast
Else
   If MyRs.BOF = True Then
       MyRs.MoveFirst
   Else
      Text1.Text = MyRs.Fields(0)
      Text2.Text = MyRs.Fields(1)
      Text3.Text = MyRs.Fields(2)
      
   End If
End If
End Sub
Private Sub XpButton6_Click()
On Error GoTo DbnotOpen
If Trim(Text1.Text) <> "" And Trim(Text2.Text) <> "" And Trim(Text3.Text) <> "" Then
   With MyRs
      .Fields(0) = Trim(Text1.Text)
      .Fields(1) = Trim(Text2.Text)
      .Fields(2) = Trim(Text3.Text)
      .Update
   End With
   MsgBox "班级信息修改成功!", vbOKOnly + vbInformation, "提示信息"
Else
   MsgBox "班级编号或班级名称或班长学号不能为空!", vbOKOnly + vbExclamation, "错误提示"
End If
DbnotOpen:
    If Err = -2147217900 Then
      MsgBox "该班级不能被修改!" & vbCrLf & vbCrLf & "班级修改失败!", vbOKOnly + vbExclamation, "错误提示"
      Set MyRs = New ADODB.Recordset
      MyRs.ActiveConnection = myconn
      MyRs.Source = "class"
      MyRs.CursorLocation = adUseClient
      MyRs.CursorType = adOpenStatic
      MyRs.Open , , , adLockOptimistic
      Set DataGrid1.DataSource = MyRs
      DataGrid1.Columns(0).Caption = "班级编号"
      DataGrid1.Columns(1).Caption = "班级名称"
      DataGrid1.Columns(2).Caption = "班长学号"
      DataGrid1.Columns(0).Width = 800
      DataGrid1.Columns(1).Width = 1400
     DataGrid1.Columns(2).Width = 1200
    End If
    If Err = -2147217887 Then
        MsgBox "输入的班级编号或班级名称或者班长学号长度越界" & vbCrLf & "请重新输入!", vbInformation, "提示信息"
        Text1.SetFocus
        Text1.Text = ""
        Text2.Text = ""
        Text3.Text = ""
        Set MyRs = New ADODB.Recordset
    With MyRs
     .Source = "class"
     .ActiveConnection = myconn
     .CursorType = adOpenKeyset
     .LockType = adLockOptimistic
     .Open , , , , adCmdTable
    End With
    Set DataGrid1.DataSource = MyRs
    DataGrid1.Columns(0).Caption = "班级编号"
    DataGrid1.Columns(1).Caption = "班级名称"
    DataGrid1.Columns(2).Caption = "班长学号"
    DataGrid1.Columns(0).Width = 800
    DataGrid1.Columns(1).Width = 1400
    DataGrid1.Columns(2).Width = 1200
    Exit Sub
    End If
End Sub


⌨️ 快捷键说明

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