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

📄 form2.frm

📁 一个教学管理系统,可以满足一般课程设计的要求
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form2 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "学生基本情况"
   ClientHeight    =   4905
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   6450
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   4905
   ScaleWidth      =   6450
   ShowInTaskbar   =   0   'False
   Begin VB.Frame Frame1 
      Caption         =   "学生信息"
      Height          =   3015
      Left            =   480
      TabIndex        =   7
      Top             =   360
      Width           =   5415
      Begin VB.TextBox Text5 
         Enabled         =   0   'False
         Height          =   375
         Left            =   1320
         TabIndex        =   16
         Top             =   2040
         Width           =   3255
      End
      Begin VB.TextBox Text4 
         Enabled         =   0   'False
         Height          =   375
         Left            =   3480
         TabIndex        =   14
         Top             =   1320
         Width           =   1095
      End
      Begin VB.TextBox Text1 
         Enabled         =   0   'False
         Height          =   375
         Left            =   1320
         TabIndex        =   10
         Top             =   600
         Width           =   1095
      End
      Begin VB.TextBox Text2 
         Enabled         =   0   'False
         Height          =   375
         Left            =   3480
         TabIndex        =   9
         Top             =   600
         Width           =   1095
      End
      Begin VB.TextBox Text3 
         Enabled         =   0   'False
         Height          =   375
         Left            =   1320
         TabIndex        =   8
         Top             =   1320
         Width           =   1095
      End
      Begin VB.Label Label5 
         Caption         =   "专业:"
         Height          =   255
         Left            =   720
         TabIndex        =   17
         Top             =   2160
         Width           =   615
      End
      Begin VB.Label Label4 
         Caption         =   "年龄:"
         Height          =   255
         Left            =   2880
         TabIndex        =   15
         Top             =   1440
         Width           =   615
      End
      Begin VB.Label Label1 
         Caption         =   "学号:"
         Height          =   255
         Left            =   720
         TabIndex        =   13
         Top             =   720
         Width           =   615
      End
      Begin VB.Label Label2 
         Caption         =   "姓名:"
         Height          =   255
         Left            =   2880
         TabIndex        =   12
         Top             =   720
         Width           =   615
      End
      Begin VB.Label Label3 
         Caption         =   "性别:"
         Height          =   255
         Left            =   720
         TabIndex        =   11
         Top             =   1440
         Width           =   615
      End
   End
   Begin VB.CommandButton Command1 
      Caption         =   "首记录"
      Height          =   375
      Index           =   0
      Left            =   1200
      TabIndex        =   6
      Top             =   3720
      Width           =   975
   End
   Begin VB.CommandButton Command1 
      Caption         =   "上一记录"
      Height          =   375
      Index           =   1
      Left            =   2160
      TabIndex        =   5
      Top             =   3720
      Width           =   975
   End
   Begin VB.CommandButton Command1 
      Caption         =   "下一记录"
      Height          =   375
      Index           =   2
      Left            =   3120
      TabIndex        =   4
      Top             =   3720
      Width           =   975
   End
   Begin VB.CommandButton Command1 
      Caption         =   "尾记录"
      Height          =   375
      Index           =   3
      Left            =   4080
      TabIndex        =   3
      Top             =   3720
      Width           =   975
   End
   Begin VB.CommandButton Command1 
      Caption         =   "添加"
      Height          =   375
      Index           =   4
      Left            =   1200
      TabIndex        =   2
      Top             =   4080
      Width           =   1335
   End
   Begin VB.CommandButton Command1 
      Caption         =   "修改"
      Height          =   375
      Index           =   5
      Left            =   2520
      TabIndex        =   1
      Top             =   4080
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "删除"
      Height          =   375
      Index           =   6
      Left            =   3720
      TabIndex        =   0
      Top             =   4080
      Width           =   1335
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Dim rs_test As New ADODB.Recordset



Private Sub Form_Load()
  Dim sql As String
  If X = 0 Then
    Text1.Enabled = False
    Text2.Enabled = False
    Text3.Enabled = False
    Text4.Enabled = False
    Text5.Enabled = False
    Command1(4).Visible = False
    Command1(5).Visible = False
    Command1(6).Visible = False
  Else
    Text1.Enabled = True
    Text2.Enabled = True
    Text3.Enabled = True
    Text4.Enabled = True
    Text5.Enabled = True
    Command1(4).Visible = True
    Command1(5).Visible = True
    Command1(6).Visible = True
  End If
  sql = "select * from student"
  If Y = 3 Then
     sql = sql & " where s_id=" & id
     Command1(0).Visible = False
     Command1(1).Visible = False
     Command1(2).Visible = False
     Command1(3).Visible = False
  End If
  Call Conn
  rs_test.Open sql, Module1.conn_mdb, 3, 3
  rs_test.MoveFirst
  Call shows
  X = 0
End Sub

Private Sub Command1_Click(Index As Integer)
  
  Select Case Index
     Case 0   '首记录
        rs_test.MoveFirst
        Call shows
     
     Case 1   '上一记录
        If Not rs_test.BOF Then
           rs_test.MovePrevious
           Call shows
        End If
        
     Case 2   '下一记录
        If Not rs_test.EOF Then
           rs_test.MoveNext
           Call shows
        End If
        
     Case 3   '尾记录
        rs_test.MoveLast
        Call shows
     
     Case 4   '添加
                           
        rs_test.AddNew
        rs_test("s_id") = Text1.Text
        rs_test("s_name") = Text2.Text
        rs_test("sex") = Text3.Text
        rs_test("age") = Text4.Text
        rs_test("class") = Text5.Text
        rs_test.Update
        
     Case 5   '编辑
        rs_test("s_id") = Text1.Text
        rs_test("s_name") = Text2.Text
        rs_test("sex") = Text3.Text
        rs_test("age") = Text4.Text
        rs_test("class") = Text5.Text
        rs_test.Update
              
     Case 6  '删除
        rs_test.Delete
        rs_test.Update
        rs_test.MoveFirst
  End Select
  
End Sub
Private Sub shows()
     
   If Not rs_test.EOF And Not rs_test.BOF Then
      Text1.Text = rs_test("s_id")
      Text2.Text = rs_test("s_name")
      Text3.Text = rs_test("sex")
      Text4.Text = rs_test("age")
      Text5.Text = rs_test("class")
   End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
  Call conclose
End Sub

⌨️ 快捷键说明

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