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

📄 frmmodifysinfo.frm

📁 学生信息管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      EndProperty
      Height          =   210
      Left            =   4650
      TabIndex        =   14
      Top             =   1041
      Width           =   915
   End
   Begin VB.Label Label5 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      Caption         =   "班    号"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   210
      Left            =   195
      TabIndex        =   13
      Top             =   1635
      Width           =   945
   End
   Begin VB.Label Label6 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      Caption         =   "联系电话"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   210
      Left            =   4650
      TabIndex        =   12
      Top             =   1641
      Width           =   915
   End
   Begin VB.Label Label7 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      Caption         =   "入校日期"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   210
      Left            =   210
      TabIndex        =   11
      Top             =   2160
      Width           =   915
   End
   Begin VB.Label Label8 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      Caption         =   "家庭住址"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   210
      Left            =   4650
      TabIndex        =   10
      Top             =   2160
      Width           =   915
   End
   Begin VB.Label Label9 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      Caption         =   "备    注"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   210
      Left            =   195
      TabIndex        =   9
      Top             =   2760
      Width           =   945
   End
End
Attribute VB_Name = "frmModifysinfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim mrc As ADODB.Recordset
Dim myBookmark As Variant
Dim mcclean As Boolean

Private Sub editCommand_Click()
    mcclean = False
    Frame2.Enabled = False
    firstCommand.Enabled = False
    previousCommand.Enabled = False
    nextCommand.Enabled = False
    lastCommand.Enabled = False
    
    editCommand.Enabled = False
    updateCommand.Enabled = True
    cancelCommand.Enabled = True
    deleteCommand.Enabled = False

        
'    txtSID.Enabled = True
    txtName.Enabled = True
    comboSex.Enabled = True
    txtBorndate.Enabled = True
    comboClassno.Enabled = True
    txtRudate.Enabled = True
    txtTel.Enabled = True
    txtAddress.Enabled = True
    txtComment.Enabled = True
    
    myBookmark = mrc.Bookmark
End Sub

Private Sub cancelCommand_Click()
    If Not mcclean Then
        Frame2.Enabled = True
        firstCommand.Enabled = True
        previousCommand.Enabled = True
        nextCommand.Enabled = True
        lastCommand.Enabled = True
    
        editCommand.Enabled = True
        updateCommand.Enabled = False
        cancelCommand.Enabled = False
        deleteCommand.Enabled = True
            
        txtSID.Enabled = False
        txtName.Enabled = False
        comboSex.Enabled = False
        txtBorndate.Enabled = False
        comboClassno.Enabled = False
        txtRudate.Enabled = False
        txtTel.Enabled = False
        txtAddress.Enabled = False
        txtComment.Enabled = False
        
        mrc.Bookmark = myBookmark
        Call viewData
    Else
        MsgBox "什么都没有修改,有什么好取消的!", vbOKOnly + vbExclamation, "警告"
    End If
        
End Sub

Private Sub deleteCommand_Click()
    'Call Form_Load
    If mrc.RecordCount <> 1 Then
        myBookmark = mrc.Bookmark
        str2$ = MsgBox("是否删除当前记录?", vbOKCancel, "删除当前记录")
        If str2$ = vbOK Then
            mrc.MoveNext
            If mrc.EOF Then
                mrc.MoveFirst
                myBookmark = mrc.Bookmark
                mrc.MoveLast
                mrc.Delete
                mrc.Bookmark = myBookmark
                Call viewData
            Else
                myBookmark = mrc.Bookmark
                mrc.MovePrevious
                mrc.Delete
                mrc.Bookmark = myBookmark
                Call viewData
            End If
        Else
            mrc.Bookmark = myBookmark
            Call viewData
        End If
        Frame2.Enabled = True
        firstCommand.Enabled = True
        previousCommand.Enabled = True
        nextCommand.Enabled = True
        lastCommand.Enabled = True
    
        editCommand.Enabled = True
        updateCommand.Enabled = False
        cancelCommand.Enabled = False
        deleteCommand.Enabled = True
    Else
        mrc.Delete
        MsgBox "最后一条纪录已被删除!", vbOKOnly + vbExclamation, "警告"
        Unload Me
    End If
End Sub

Private Sub firstCommand_Click()
    mrc.MoveFirst
    Call viewData
End Sub

Private Sub Form_Load()
    
    Dim txtSQL As String
    Dim MsgText As String
    
    txtSQL = "select * from student_Info "
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    If mrc.EOF = False Then
        mrc.MoveFirst
        Call viewData
        myBookmark = mrc.Bookmark
        mcclean = True
    End If
    '显示列表信息
    Dim mrclist As ADODB.Recordset
    Dim i As Integer
    txtSQL = "select * from class_Info "
    Set mrclist = ExecuteSQL(txtSQL, MsgText)
    
    For i = 1 To mrclist.RecordCount
        comboClassno.AddItem mrclist.Fields(0)
        mrclist.MoveNext
    Next i
    mrclist.Close
    comboSex.AddItem "男"
    comboSex.AddItem "女"

    Frame2.Enabled = True
    firstCommand.Enabled = True
    previousCommand.Enabled = True
    nextCommand.Enabled = True
    lastCommand.Enabled = True
    
    editCommand.Enabled = True
    updateCommand.Enabled = False
    cancelCommand.Enabled = False
    deleteCommand.Enabled = True

End Sub

Public Sub viewData()
    txtSID.Text = mrc.Fields(0)
    txtName.Text = mrc.Fields(1)
    comboSex.Text = mrc.Fields(2)
    txtBorndate.Text = Format(mrc.Fields(3), "yyyy-mm-dd")
    comboClassno.Text = mrc.Fields(4)
    txtTel.Text = mrc.Fields(5)
    txtRudate.Text = Format(mrc.Fields(6), "yyyy-mm-dd")
    txtAddress.Text = mrc.Fields(7)
    txtComment.Text = mrc.Fields(8)
End Sub

Private Sub lastCommand_Click()
    mrc.MoveLast
    Call viewData
End Sub

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

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

Private Sub updateCommand_Click()
    Dim txtSQL As String
    Dim MsgText As String
    
    If mcclean 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(comboSex.Text) Then
        MsgBox "请选择性别!", vbOKOnly + vbExclamation, "警告"
        comboSex.SetFocus
        Exit Sub
    End If
    
    If Not Testtxt(txtBorndate.Text) Then
        MsgBox "请输入出生日期!", vbOKOnly + vbExclamation, "警告"
        txtBorndate.SetFocus
        Exit Sub
    End If
    
    If Not Testtxt(comboClassno.Text) Then
        MsgBox "请选择班号!", vbOKOnly + vbExclamation, "警告"
        comboClassno.SetFocus
        Exit Sub
    End If
    
    If Not Testtxt(txtTel.Text) Then
        MsgBox "请输入联系电话!", vbOKOnly + vbExclamation, "警告"
        txtTel.SetFocus
        Exit Sub
    End If
    
    If Not Testtxt(txtRudate.Text) Then
        MsgBox "请输入入校日期!", vbOKOnly + vbExclamation, "警告"
        txtRudate.SetFocus
        Exit Sub
    End If
    
    If Not Testtxt(txtAddress.Text) Then
        MsgBox "请输入家庭住址!", vbOKOnly + vbExclamation, "警告"
        txtAddress.SetFocus
        Exit Sub
    End If
    
    If Not IsNumeric(Trim(txtSID.Text)) Then
        MsgBox "学号请输入数字!", vbOKOnly + vbExclamation, "警告"
        txtSID.SetFocus
        Exit Sub
        
    End If

    
    If Not IsDate(txtBorndate.Text) Then
        MsgBox "出生时间应输入日期格式(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
        txtBorndate.SetFocus
    Else
        txtBorndate = Format(txtBorndate, "yyyy-mm-dd")
        If Not IsDate(txtRudate.Text) Then
            MsgBox "入校时间应输入日期格式(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
            txtRudate.SetFocus
        Else
            txtRudate = Format(txtRudate, "yyyy-mm-dd")
        End If
    End If
'            mrc.Delete
'            mrc.AddNew
            mrc.Fields(0) = Trim(txtSID.Text)
            mrc.Fields(1) = Trim(txtName.Text)
            mrc.Fields(2) = Trim(comboSex.Text)
            mrc.Fields(3) = Trim(txtBorndate.Text)
            mrc.Fields(4) = Trim(comboClassno.Text)
            mrc.Fields(5) = Trim(txtTel.Text)
            mrc.Fields(6) = Trim(txtRudate.Text)
            mrc.Fields(7) = Trim(txtAddress.Text)
            mrc.Fields(8) = Trim(txtComment.Text)
            mrc.Update
            MsgBox "修改学籍信息成功!", vbOKOnly + vbExclamation, "修改学籍信息"
                
'            mrc.Bookmark = myBookmark
            Call viewData
            Frame2.Enabled = True
            firstCommand.Enabled = True
            previousCommand.Enabled = True
            nextCommand.Enabled = True
            lastCommand.Enabled = True
    
            editCommand.Enabled = True
            updateCommand.Enabled = False
            cancelCommand.Enabled = False
            deleteCommand.Enabled = True
        
            txtSID.Enabled = False
            txtName.Enabled = False
            comboSex.Enabled = False
            txtBorndate.Enabled = False
            comboClassno.Enabled = False
            txtRudate.Enabled = False
            txtTel.Enabled = False
            txtAddress.Enabled = False
            txtComment.Enabled = False
                
            mcclean = True
        
End Sub

⌨️ 快捷键说明

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