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

📄 form1.frm

📁 VB学生信息管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmModifysinfo 
   Caption         =   "修改学籍信息"
   ClientHeight    =   7935
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8610
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   7935
   ScaleWidth      =   8610
   Begin VB.Frame Frame2 
      Caption         =   "修改学籍信息"
      Height          =   735
      Left            =   120
      TabIndex        =   19
      Top             =   6720
      Width           =   8295
      Begin VB.CommandButton cmdDel 
         Caption         =   "删除记录"
         Height          =   375
         Left            =   6240
         TabIndex        =   27
         Top             =   240
         Width           =   1455
      End
      Begin VB.CommandButton cmdCancel 
         Caption         =   "取消修改记录"
         Height          =   375
         Left            =   4200
         TabIndex        =   26
         Top             =   240
         Width           =   1455
      End
      Begin VB.CommandButton cmdUpt 
         Caption         =   "更新数据"
         Height          =   375
         Left            =   2520
         TabIndex        =   25
         Top             =   240
         Width           =   1095
      End
      Begin VB.CommandButton cmdEdit 
         Caption         =   "修改记录"
         Height          =   375
         Left            =   480
         TabIndex        =   24
         Top             =   240
         Width           =   1335
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "查看学籍信息"
      Height          =   735
      Left            =   120
      TabIndex        =   18
      Top             =   5520
      Width           =   8295
      Begin VB.CommandButton cmdLast 
         Caption         =   "最后一条记录"
         Height          =   375
         Left            =   6240
         TabIndex        =   23
         Top             =   240
         Width           =   1455
      End
      Begin VB.CommandButton cmdNext 
         Caption         =   "下一条记录"
         Height          =   375
         Left            =   4200
         TabIndex        =   22
         Top             =   240
         Width           =   1335
      End
      Begin VB.CommandButton cmdPre 
         Caption         =   "上一条记录"
         Height          =   375
         Left            =   2520
         TabIndex        =   21
         Top             =   240
         Width           =   1095
      End
      Begin VB.CommandButton cmdFrist 
         Caption         =   "第一条记录"
         Height          =   375
         Left            =   480
         TabIndex        =   20
         Top             =   240
         Width           =   1215
      End
   End
   Begin VB.TextBox txtAddress 
      Height          =   1695
      Left            =   5640
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   17
      Top             =   2400
      Width           =   2295
   End
   Begin VB.TextBox txtTel 
      Height          =   375
      Left            =   5640
      TabIndex        =   16
      Top             =   1560
      Width           =   1455
   End
   Begin VB.TextBox txtBrith 
      Height          =   375
      Left            =   5640
      TabIndex        =   15
      Top             =   840
      Width           =   1455
   End
   Begin VB.TextBox txtName 
      Height          =   375
      Left            =   5640
      TabIndex        =   14
      Top             =   120
      Width           =   1455
   End
   Begin VB.TextBox txtBZ 
      Height          =   1455
      Left            =   960
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   9
      Top             =   3480
      Width           =   2535
   End
   Begin VB.TextBox txtRuData 
      Height          =   375
      Left            =   960
      TabIndex        =   8
      Top             =   2400
      Width           =   1575
   End
   Begin VB.ComboBox comClassNo 
      Height          =   300
      Left            =   960
      TabIndex        =   7
      Top             =   1680
      Width           =   975
   End
   Begin VB.ComboBox comGender 
      Height          =   300
      Left            =   960
      TabIndex        =   6
      Top             =   1080
      Width           =   975
   End
   Begin VB.TextBox txtSid 
      Height          =   375
      Left            =   960
      TabIndex        =   5
      Top             =   240
      Width           =   1575
   End
   Begin VB.Label Label9 
      AutoSize        =   -1  'True
      Caption         =   "家庭住址"
      Height          =   180
      Left            =   4680
      TabIndex        =   13
      Top             =   2280
      Width           =   720
   End
   Begin VB.Label Label8 
      AutoSize        =   -1  'True
      Caption         =   "联系电话"
      Height          =   180
      Left            =   4680
      TabIndex        =   12
      Top             =   1680
      Width           =   720
   End
   Begin VB.Label Label7 
      Caption         =   "出生日期"
      Height          =   375
      Left            =   4680
      TabIndex        =   11
      Top             =   840
      Width           =   855
   End
   Begin VB.Label Label6 
      Caption         =   "姓名"
      Height          =   375
      Left            =   4680
      TabIndex        =   10
      Top             =   120
      Width           =   495
   End
   Begin VB.Label Label5 
      Caption         =   "备注"
      Height          =   375
      Left            =   120
      TabIndex        =   4
      Top             =   3600
      Width           =   735
   End
   Begin VB.Label Label4 
      Caption         =   "入校日期"
      Height          =   375
      Left            =   0
      TabIndex        =   3
      Top             =   2520
      Width           =   855
   End
   Begin VB.Label Label3 
      Caption         =   "班号"
      Height          =   255
      Left            =   120
      TabIndex        =   2
      Top             =   1800
      Width           =   615
   End
   Begin VB.Label Label2 
      Caption         =   "性别"
      Height          =   375
      Left            =   120
      TabIndex        =   1
      Top             =   1080
      Width           =   615
   End
   Begin VB.Label Label1 
      Caption         =   "学号"
      Height          =   255
      Left            =   120
      TabIndex        =   0
      Top             =   240
      Width           =   495
   End
End
Attribute VB_Name = "frmModifysinfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim mrc As ADODB.Recordset

'定义书签,记录当前记录位置
Dim MYBookmark As Variant

'定义标志,确定记录是否被修改
Dim mc As Boolean

Private Sub cmdEdit_Click()
mc = False
Frame2.Enabled = False

'使移动按钮失效
cmdFrist.Enabled = False
cmdPre.Enabled = False
cmdNext.Enabled = False
cmdLast.Enabled = False

'使文本框有效

txtSid.Enabled = True
txtName.Enabled = True
comGender.Enabled = True
txtBrith.Enabled = True
comClassNo.Enabled = True
txtRuData.Enabled = True
txtTel.Enabled = True
txtAddress.Enabled = True
txtBZ.Enabled = True

MYBookmark = mrc.Bookmark

End Sub

Private Sub cmdFrist_Click()
mrc.MoveFirst
Call viewData

End Sub

Private Sub cmdLast_Click()
mrc.MoveLast
Call viewData

End Sub

Private Sub cmdNext_Click()
mrc.MoveNext
If mrc.EOF Then
    mrc.MoveFirst
End If
Call viewData
End Sub

Private Sub cmdPre_Click()
mrc.MovePrevious
If mrc.BOF Then
    mrc.MoveLast
End If
Call viewData
End Sub

Private Sub cmdUpt_Click()
Dim txtSQL As String
Dim MsgText As String
Dim res As ADODB.Recordset

'判断是否处于修改状态
 If mc Then
        MsgBox "请先修改学籍信息", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    
    '判断学号是否为空
    If Not Testtxt(txtSid.Text) Then
        MsgBox "请输入学号!", vbOKOnly + vbExclamation, "警告"
        txtSid.SetFocus
        Exit Sub
    End If
    
     '判断姓名是否为空
    If Not Testtxt(txtName.Text) Then
        MsgBox "请输入姓名!", vbOKOnly + vbExclamation, "警告"
        txtName.SetFocus
        Exit Sub
    End If
    
     '判断性别是否为空
    If Not Testtxt(comGender.Text) Then
        MsgBox "请选择性别!", vbOKOnly + vbExclamation, "警告"
        comGender.SetFocus
        Exit Sub
    End If
    
     '判断出生日期是否为空
    If Not Testtxt(txtBrith.Text) Then
        MsgBox "请输入出生日期!", vbOKOnly + vbExclamation, "警告"
        txtBrith.SetFocus
        Exit Sub
    End If
    
     '判断班号是否为空
    If Not Testtxt(comClassNo.Text) Then
        MsgBox "请选择班号!", vbOKOnly + vbExclamation, "警告"
        comClassNo.SetFocus
        Exit Sub
    End If
    
     '判断联系电话是否为空
    If Not Testtxt(txtTel.Text) Then
        MsgBox "请输入联系电话!", vbOKOnly + vbExclamation, "警告"
        txtTel.SetFocus
        Exit Sub
    End If
    
     '判断入校日期是否为空
    If Not Testtxt(txtRuData.Text) Then
        MsgBox "请输入入校日期!", vbOKOnly + vbExclamation, "警告"
        txtRuData.SetFocus
        Exit Sub
    End If
    
     '判断地址是否为空
    If Not Testtxt(txtAddress.Text) Then
        MsgBox "请输入家庭住址!", vbOKOnly + vbExclamation, "警告"
        txtAddress.SetFocus
        Exit Sub
    End If
    
     '判断输入是否为数字
    If Not IsNumeric(Trim(txtBZ.Text)) Then
        MsgBox "学号请输入数字!", vbOKOnly + vbExclamation, "警告"
        txtSid.SetFocus
        Exit Sub
        
    End If
    

   '判断是否有重复记录
   mrc.Delete
   txtSQL = "select*from student_info where student_id='" & Trim(txtSid.Text) & "'"
   Set res = ExecuteSQL(txtSQL, MsgText)
   If res.EOF = False Then
       MsgBox "学号重复,请重新输入!", vbOKOnly + vbExclamation, "警告"
       res.Close
       txtSid.SetFocus
   Else
       res.Close
       
    If Not txttest(txtBrith.Text) Then
        MsgBox "出生时间应输入日期格式(yyyy-mm-dd)!", vbOKOnly + vbInformation, "警告!"
        txtBrith.SetFocus
    Else
        

End Sub


Private Sub Form_Load()
Dim txtSQL As String
Dim MsgText As String

txtSQL = "select*from student_info"
Set mrc = ExecuteSQL(txtSQL, MsgText)

    mrc.MoveFirst


'显示数据
Call viewData

'记下当前位置
MYBookmark = mrc.Bookmark

'给标志赋初值
mc = True

End Sub


Public Sub viewData()
txtSid.Text = mrc.Fields(0)
txtName.Text = mrc.Fields(1)
comGender.Text = mrc.Fields(2)
txtBrith.Text = Format(mrc.Fields(3), "yyyy-mm-dd")
comClassNo.Text = mrc.Fields(4)
txtTel.Text = mrc.Fields(5)
txtRuData.Text = Format(mrc.Fields(6), "yyyy-mm-dd")
txtAddress.Text = mrc.Fields(7)
txtBZ.Text = mrc.Fields(8)


End Sub

⌨️ 快捷键说明

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