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

📄 frmdocmodify.frm

📁 学生信息管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmDocModify 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "登记档案"
   ClientHeight    =   4335
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7350
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   4335
   ScaleWidth      =   7350
   Begin VB.TextBox txtDocument 
      Appearance      =   0  'Flat
      BackColor       =   &H80000018&
      ForeColor       =   &H00000000&
      Height          =   300
      Index           =   2
      Left            =   1200
      TabIndex        =   11
      Text            =   "Text1"
      Top             =   2160
      Width           =   2295
   End
   Begin VB.ComboBox comDocument 
      BackColor       =   &H80000018&
      ForeColor       =   &H00000000&
      Height          =   300
      Index           =   1
      Left            =   1200
      TabIndex        =   10
      TabStop         =   0   'False
      Text            =   "Combo1"
      Top             =   720
      Width           =   2295
   End
   Begin VB.TextBox txtDocument 
      Appearance      =   0  'Flat
      BackColor       =   &H80000018&
      ForeColor       =   &H00000000&
      Height          =   1740
      Index           =   7
      Left            =   4800
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   9
      Top             =   1680
      Width           =   2295
   End
   Begin VB.TextBox txtDocument 
      Appearance      =   0  'Flat
      BackColor       =   &H80000018&
      ForeColor       =   &H00000000&
      Height          =   300
      Index           =   6
      Left            =   1200
      TabIndex        =   8
      Text            =   "Text1"
      Top             =   2640
      Width           =   2295
   End
   Begin VB.TextBox txtDocument 
      Appearance      =   0  'Flat
      BackColor       =   &H80000018&
      ForeColor       =   &H00000000&
      Height          =   300
      Index           =   5
      Left            =   1200
      MaxLength       =   12
      TabIndex        =   7
      Text            =   "Text1"
      Top             =   3120
      Width           =   2295
   End
   Begin VB.TextBox txtDocument 
      Appearance      =   0  'Flat
      BackColor       =   &H80000018&
      ForeColor       =   &H00000000&
      Height          =   300
      Index           =   4
      Left            =   4800
      MaxLength       =   6
      TabIndex        =   6
      Text            =   "Text1"
      Top             =   1200
      Width           =   2295
   End
   Begin VB.TextBox txtDocument 
      Appearance      =   0  'Flat
      BackColor       =   &H80000018&
      ForeColor       =   &H00000000&
      Height          =   780
      Index           =   3
      Left            =   4800
      MaxLength       =   30
      TabIndex        =   5
      Text            =   "Text1"
      Top             =   240
      Width           =   2295
   End
   Begin VB.TextBox txtDocument 
      Appearance      =   0  'Flat
      BackColor       =   &H80000018&
      ForeColor       =   &H00000000&
      Height          =   300
      Index           =   1
      Left            =   1200
      MaxLength       =   8
      TabIndex        =   4
      Text            =   "Text1"
      Top             =   1200
      Width           =   2295
   End
   Begin VB.TextBox txtDocument 
      Appearance      =   0  'Flat
      BackColor       =   &H80000018&
      ForeColor       =   &H00000000&
      Height          =   300
      Index           =   0
      Left            =   1200
      MaxLength       =   5
      TabIndex        =   3
      Text            =   "Text1"
      Top             =   240
      Width           =   2295
   End
   Begin VB.ComboBox comDocument 
      BackColor       =   &H80000018&
      ForeColor       =   &H00000000&
      Height          =   300
      Index           =   0
      Left            =   1200
      TabIndex        =   2
      TabStop         =   0   'False
      Text            =   "Combo1"
      Top             =   1680
      Width           =   2295
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "取消"
      Height          =   390
      Left            =   4080
      TabIndex        =   1
      TabStop         =   0   'False
      Top             =   3720
      Width           =   1095
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "确定"
      Height          =   390
      Left            =   2760
      TabIndex        =   0
      TabStop         =   0   'False
      Top             =   3720
      Width           =   1095
   End
   Begin VB.Label lblDocument 
      AutoSize        =   -1  'True
      Caption         =   "备注:"
      Height          =   180
      Index           =   7
      Left            =   4080
      TabIndex        =   21
      Top             =   1740
      Width           =   540
   End
   Begin VB.Label lblDocument 
      AutoSize        =   -1  'True
      Caption         =   "入学时间:"
      Height          =   180
      Index           =   6
      Left            =   240
      TabIndex        =   20
      Top             =   2700
      Width           =   900
   End
   Begin VB.Label lblDocument 
      AutoSize        =   -1  'True
      Caption         =   "联系电话:"
      Height          =   180
      Index           =   5
      Left            =   240
      TabIndex        =   19
      Top             =   3180
      Width           =   900
   End
   Begin VB.Label lblDocument 
      AutoSize        =   -1  'True
      Caption         =   "邮政编码:"
      Height          =   180
      Index           =   4
      Left            =   3840
      TabIndex        =   18
      Top             =   1260
      Width           =   900
   End
   Begin VB.Label lblDocument 
      AutoSize        =   -1  'True
      Caption         =   "家庭住址:"
      Height          =   180
      Index           =   3
      Left            =   3840
      TabIndex        =   17
      Top             =   300
      Width           =   900
   End
   Begin VB.Label lblDocument 
      AutoSize        =   -1  'True
      Caption         =   "出生年月:"
      Height          =   180
      Index           =   2
      Left            =   240
      TabIndex        =   16
      Top             =   2220
      Width           =   900
   End
   Begin VB.Label lblDocument 
      AutoSize        =   -1  'True
      Caption         =   "姓名:"
      Height          =   180
      Index           =   1
      Left            =   600
      TabIndex        =   15
      Top             =   1260
      Width           =   540
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "班级:"
      Height          =   180
      Left            =   600
      TabIndex        =   14
      Top             =   780
      Width           =   540
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "性别:"
      Height          =   180
      Left            =   600
      TabIndex        =   13
      Top             =   1740
      Width           =   540
   End
   Begin VB.Label lblDocument 
      AutoSize        =   -1  'True
      Caption         =   "学号:"
      Height          =   180
      Index           =   0
      Left            =   600
      TabIndex        =   12
      Top             =   300
      Width           =   540
   End
End
Attribute VB_Name = "frmDocModify"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'----------------------------------frmDocModify.frm----------------------------------
Option Explicit

Dim strSQL As String

Private Sub comDocument_Click(Index As Integer)
    Dim objRecordset As ADODB.Recordset
    
    strSQL = "select 专业,年制 from Classes where 班级='" & Trim(comDocument(1).Text) & "'"
    Set objRecordset = ExecuteSQL(strSQL)
    objRecordset.Close
End Sub

Private Sub cmdOK_Click()
    Dim i As Integer
    Dim objRecordset As ADODB.Recordset
    
    '输入学生信息
    For i = 0 To 7
        If txtDocument(i) = "" Then
            MsgBox lblDocument(i).Caption & "不能为空!", vbExclamation + vbOKOnly, "警告"
            txtDocument(i).SetFocus
            txtDocument(i).SelStart = 0
            txtDocument(i).SelLength = Len(txtDocument(i).Text)
            Exit Sub
        End If
    Next
    
    '查找输入的学生信息是否存在
    strSQL = "select * from Documents where 学号='" & Trim(txtDocument(0).Text) & "'"
    Set objRecordset = ExecuteSQL(strSQL)
    '如果是登记新的学生信息,则该数据库中必须不存在该信息
    If blnModifyDoc = False Then
        If objRecordset.EOF = False Then
            MsgBox "已经存在该学号的记录,学号不能重复!", vbExclamation + vbOKOnly, "警告"
            txtDocument(0).SetFocus
            txtDocument(0).SelStart = 0
            txtDocument(0).SelLength = Len(txtDocument(0).Text)
            objRecordset.Close
            Exit Sub
        End If
    End If
    
    '判断是否日期格式
    If Not IsDate(txtDocument(2).Text) Then
        MsgBox "请输入日期 mm-dd-yy", vbInformation + vbOKOnly, "警告"
        txtDocument(2).SetFocus
        txtDocument(2).SelStart = 0
        txtDocument(2).SelLength = Len(txtDocument(2).Text)
        Exit Sub
    End If
    
    If Not IsDate(txtDocument(6).Text) Then
        MsgBox "请输入日期 mm-dd-yy", vbInformation + vbOKOnly, "警告"
        txtDocument(6).SetFocus
        txtDocument(6).SelStart = 0
        txtDocument(6).SelLength = Len(txtDocument(6).Text)
        Exit Sub
    End If
    
    '如果是修改新的学生信息
    If blnModifyDoc = True Then
        strSQL = "update Documents set 学号='" & Trim(txtDocument(0).Text) & "',姓名='" & Trim(txtDocument(1).Text) & "',性别='" & Trim(comDocument(0).Text) & "',班级='" & Trim(comDocument(1).Text) & "',出生年月=#" & Trim(txtDocument(2).Text) & "# ,家庭住址='" & Trim(txtDocument(3).Text) & "' ,邮政编码='" & Trim(txtDocument(4).Text) & "' ,联系电话='" & Trim(txtDocument(5).Text) & "' ,入学时间=#" & Trim(txtDocument(6).Text) & "# ,备注='" & Trim(txtDocument(7).Text) & "'where 学号='" & Trim(frmDocBrowse.flgDocData.TextMatrix(frmDocBrowse.flgDocData.Row, 1)) & "'"
        Set objRecordset = ExecuteSQL(strSQL)
        strSQL = "update Scores set 学号='" & Trim(txtDocument(0).Text) & "' where 学号='" & Trim(frmDocBrowse.flgDocData.TextMatrix(frmDocBrowse.flgDocData.Row, 1)) & "'"
        Set objRecordset = ExecuteSQL(strSQL)
        strSQL = "update jf set 学号='" & Trim(txtDocument(0).Text) & "' where 学号='" & Trim(frmDocBrowse.flgDocData.TextMatrix(frmDocBrowse.flgDocData.Row, 1)) & "'" 'Set objRecordset = ExecuteSQL(strSQL)
        
        Unload Me
        Exit Sub
    End If
    
    '将新的学生信息登记到数据库
    strSQL = "select * from Documents "
    Set objRecordset = ExecuteSQL(strSQL)
    objRecordset.AddNew
    
    For i = 4 To 9
        objRecordset.Fields(i) = txtDocument(i - 2).Text
    Next i
    objRecordset.Fields(0) = Trim(txtDocument(0).Text)
    objRecordset.Fields(1) = Trim(txtDocument(1).Text)
    objRecordset.Fields(2) = Trim(comDocument(0).Text)
    objRecordset.Fields(3) = Trim(comDocument(1).Text)
    objRecordset.Update
    Set objRecordset = Nothing
    
    For i = 0 To 7
        txtDocument(i) = ""
    Next
End Sub

Private Sub cmdCancel_Click()
    Unload Me
End Sub

Private Sub Form_Activate()
    txtDocument(0).SetFocus
    Me.DocModifyLoad
End Sub

Public Sub DocModifyLoad()
    Dim i As Integer
    Dim objRecordset As ADODB.Recordset
    
    strSQL = "select DISTINCT 班级 from Classes order by 班级"
    Set objRecordset = ExecuteSQL(strSQL)
    If objRecordset.EOF Then
        MsgBox "请先设置班级部署!", "警告"
        objRecordset.Close
        Exit Sub
    End If
    
    comDocument(1).Clear
    objRecordset.MoveFirst
    Do While Not objRecordset.EOF
        comDocument(1).AddItem objRecordset.Fields(0)
        objRecordset.MoveNext
    Loop
    comDocument(1).ListIndex = 0
    
    '如果是修改档案
    If blnModifyDoc Then
        Me.Caption = "修改档案"
        strSQL = "select * from Documents where 学号='" & Trim(frmDocBrowse.flgDocData.TextMatrix(frmDocBrowse.flgDocData.Row, 1)) & "'"
        Set objRecordset = ExecuteSQL(strSQL)
        objRecordset.MoveFirst
        For i = 4 To 9
            txtDocument(i - 2).Text = objRecordset.Fields(i)
        Next i
        txtDocument(0).Text = objRecordset.Fields(0)
        txtDocument(1).Text = objRecordset.Fields(1)
        comDocument(0).Text = objRecordset.Fields(2)
        comDocument(1).Text = objRecordset.Fields(3)
        objRecordset.Close
    Else
        Me.Caption = "登记档案"
        For i = 2 To 7
            txtDocument(i).Text = ""
        Next i
        txtDocument(6).Text = Date
        txtDocument(0).Text = ""
        txtDocument(1).Text = ""
    End If
End Sub

Private Sub txtDocument_GotFocus(Index As Integer)
    If Index = 6 Then
        txtDocument(6).SelStart = 0
        txtDocument(6).SelLength = Len(txtDocument(6).Text)
    End If
End Sub



⌨️ 快捷键说明

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