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

📄 frminput.frm

📁 目 录 前 言 1 第一章 概述 1 1.1课题来源 1 1.2 开发工具的选用 2 1.2.1 Visual Basic的使用 2 1.2.2 Microsoft Access的使用
💻 FRM
📖 第 1 页 / 共 4 页
字号:
      Adodc2.Recordset.Fields("民族").Value = Text5.Text
      Adodc2.Recordset.Fields("父母姓名").Value = Text6.Text
      Adodc2.Recordset.Fields("地址").Value = Text7.Text
      Adodc2.Recordset.Fields("邮政编码").Value = Text8.Text
      Adodc2.Recordset.Fields("电话号码").Value = Text9.Text
      Adodc2.Recordset.Fields("院系").Value = Text10.Text
      Adodc2.Recordset.Fields("专业").Value = DataCombo1.Text
      Adodc2.Recordset.Fields("附注").Value = Text12.Text
      Adodc2.Recordset.Update
      'Adodc2.Recordset.Close
      MsgBox "修改学籍信息成功!", vbOKOnly + vbExclamation, "修改学籍信息"
     ' Adodc2.Recordset.Bookmark = mybookmark
      Command2.Enabled = True
      Command3.Enabled = True
      Command4.Enabled = True
      Command5.Enabled = True
      Command10.Enabled = True
      mcclean = True
End If
    Exit Sub
AddErr:
    MsgBox Err.Description
End Sub

Private Sub Command10_Click()
    
    On Error GoTo AddErr
        If MsgBox("你确信吗?", vbOKCancel, "警告") = vbOK Then
        Adodc2.Recordset.Delete
        Adodc2.Recordset.MoveNext
        If Adodc2.Recordset.EOF Then
            Adodc2.Recordset.MoveLast
            
        End If
                GradeRefresh
        End If
        Exit Sub
AddErr:
    MsgBox Err.Description
End Sub




Private Sub Command2_Click()
    On Error GoTo AddErr
        Adodc2.Recordset.MoveFirst
        GradeRefresh
        Exit Sub
AddErr:
    MsgBox Err.Description
End Sub

Private Sub Command3_Click()
    On Error GoTo AddErr
        Adodc2.Recordset.MoveLast
        GradeRefresh
        Exit Sub
        
AddErr:
    MsgBox Err.Description
End Sub

Private Sub Command4_Click()
    On Error GoTo AddErr
        If Adodc2.Recordset.EOF Then Adodc2.Recordset.MoveFirst
        Adodc2.Recordset.MoveNext
                GradeRefresh
        Exit Sub
AddErr:
    MsgBox Err.Description
End Sub

Private Sub Command5_Click()
    On Error GoTo AddErr
        If Adodc2.Recordset.BOF Then Adodc2.Recordset.MoveLast
        Adodc2.Recordset.MovePrevious
        GradeRefresh
        Exit Sub
AddErr:
    MsgBox Err.Description
End Sub

Private Sub Command6_Click()
On Error GoTo AditErr
mcclean = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command10.Enabled = False
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text5.Enabled = True
Text6.Enabled = True
Text7.Enabled = True
Text8.Enabled = True
Text9.Enabled = True
Combo1.Enabled = True
DataCombo1.Enabled = True
Text10.Enabled = True
Text12.Enabled = True
Exit Sub
'mybookmark = Adodc2.Recordset.Bookmark
AditErr:
    MsgBox Err.Description
End Sub

Private Sub Command7_Click()
  On Error GoTo errh
    If Text1.Text <> "" Then
       If Text13.Text <> "" Then
          If Combo4.Text <> "" Then
             If Combo2.Text <> "" Then
               If Combo3.Text <> "" Then
                 If checkclass = False Then
                   If match Then
                'Set rs = cn.Execute("select 成绩 from 学生与课程 where 课程号='" & Trim(Combo1.Text) & "' and 课程名称='" & Trim(Combo2.Text) & "' and 学号='" & Trim(Text2.Text) & "' ")
                'If rs.EOF Then
                    'rs.Close
                    'Exit Sub
               ' End If
                'rs.Close
                       rs.LockType = adLockOptimistic
                       rs.CursorType = adOpenKeyset
                       rs.Open "select * from 学生与课程 where 课程号='" & Trim(Combo4.Text) & "' and 课程名称='" & Trim(Combo2.Text) & "' and 学号='" & Trim(Text1.Text) & "' ", cn, , , adCmdText
                'rs.Find ("UserName=" & "'" & Text1.Text & "'")
                'If rs.Fields("Password").Value = Text2.Text Then
                    'rs.Fields(0).Value = Text3.Text
                    'rs.Fields(1).Value = Combo3.Text
                    'rs.Update
                    'rs.Update "成绩", Text3.Text
                        rs.Fields("成绩").Value = Text13.Text
                        rs.Fields("备注").Value = Combo3.Text
                        rs.Update
                        rs.Close
                        MsgBox "修改成功!"
                        Combo4.Text = ""
                        Combo2.Text = ""
                        Combo3.Text = ""
                        Text13.Text = ""
                        Combo4.SetFocus
                    Else
                         MsgBox "成绩和备注不匹配,请核对!"
                    End If
                 Else
                    MsgBox "没有该课程成绩,不能修改!"
                 End If
               Else
                  MsgBox "该项不能为空,请输入备注!"
               End If
            Else
                MsgBox "该项不能为空,请输入课程名称!"
            End If
         Else
            MsgBox "该项不能为空,请输入课程号!"
         End If
       Else
          MsgBox "该项不能为空,请输入成绩!"
       End If
    Else
       MsgBox "该项不能为空,请输入学号!"
    End If
    Exit Sub
errh:
    
    MsgBox Err.Description
    'rs.Close

End Sub

Private Sub Command8_Click()
On Error GoTo errh
    
    If MsgBox("你的操作将会删除当前的纪录,你确信吗?", vbOKCancel, "警告") = vbOK Then
    If Combo4.Text <> "" Then
       If Combo2.Text <> "" Then
         
     Set rs1 = New ADODB.Recordset
        
        rs1.CursorType = adOpenDynamic
        rs1.LockType = adLockOptimistic
        rs1.Open "SELECT * FROM 学生与课程 WHERE 课程名称='" & Trim(Combo2.Text) & "'AND 课程号='" & Trim(Combo4.Text) & "' and  学号='" & Trim(Text1.Text) & "'", cn, adOpenDynamic, adLockOptimistic, adCmdText
       
       If rs1.EOF Then
          'Adodc2.Recordset.Close
          rs1.Close
          MsgBox "没有这条记录,无法删除!"
          Exit Sub
       End If
       rs1.Delete
       rs1.Update
       rs1.Close
       MsgBox "删除成功!"
       Text2.Text = ""
       Text3.Text = ""
       Combo1.Text = ""
       Combo2.Text = ""
       Combo3.Text = ""
    End If
    End If
    End If
    Exit Sub
errh:
    rs.Close
    MsgBox Err.Description
End Sub

Private Sub Command9_Click()
    Unload Me
End Sub

Private Sub DataCombo1_Click(Area As Integer)
'datacombo1.
End Sub

Private Sub Form_Load()
    MakeCenter FrmInput
    If UserType = False Then
     Command6.Enabled = False
     'Command7.Enabled = False
     'Command8.Enabled = False
     CmdUpdata.Enabled = False
     CmdBolish.Enabled = False
    ' CmdBolish.Enabled = False
    'CmdUpdata.Enabled = False
    Command10.Enabled = False
    End If
    mcclean = True
     
    Set rs = cn.Execute("select distinct 课程名称,课程号 from 课程")
    rs.MoveFirst
    Do
        Combo4.AddItem rs.Fields(1).Value
        Combo2.AddItem rs.Fields(0).Value
        rs.MoveNext
    Loop Until rs.EOF
    rs.Close
    Set rs = Nothing
    Combo1.AddItem "男"
    Combo1.AddItem "女"
    Combo3.AddItem "优异"
    Combo3.AddItem "良好"
    Combo3.AddItem "中等"
    Combo3.AddItem "及格"
    Combo3.AddItem "不及格"
   
'    Adodc1.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
'                   "DBQ=db5.MDB;" & _
'                   "DefaultDir=" & CheckPath(App.path) & ";" & _
'                   "UID=;PWD=;"
'    Adodc1.RecordSource = "SELECT * FROM 学生与课程"
    'txtSQL = "select * from 学生"
    'Set mrc = cn.Execute(txtSQL)
    
    'Data1.RecordSource = "SELECT 课程号,课程名称,成绩,备注  FROM 学生与课程 where 学号=text1.text"
    Adodc2.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
                   "DBQ=db5.MDB;" & _
                   "DefaultDir=" & CheckPath(App.path) & ";" & _
                   "UID=;PWD=;"
    Adodc2.RecordSource = "SELECT * FROM 学生"
    Text1.DataField = "学号"
    Text2.DataField = "名字"
    'Combo1.Text = Adodc2.Recordset.Fields("性别").Value
    Text3.DataField = "班级"
    Text4.DataField = "出生年月"
    Text5.DataField = "民族"
    Text6.DataField = "父母姓名"
    Text7.DataField = "地址"
    Text8.DataField = "邮政编码"
    Text9.DataField = "电话号码"
    Text10.DataField = "院系"
   ' Text11.DataField = "专业"
    Text12.DataField = "附注"
'    Label3.DataField = "学生ID"
GradeRefresh

End Sub


'Private Sub Form_Unload(Cancel As Integer)
'On Error Resume Next
   ' Adodc2.Recordset.Close
'End Sub

Private Function check1() As Boolean  '检测添加的课程是否重复
On Error GoTo errh
     
    Set rs = cn.Execute("SELECT 学号 FROM 学生 WHERE 学号='" & Trim(Text1.Text) & "'")
    ' Adodc2.RecordSource = "select * from 课程 where 课程号='" & Trim(Text1.Text) & "' and 课程名称='" & Trim(Text2.Text) & "' "
        If rs.EOF Then
            rs.Close
            check1 = True
            Exit Function
        End If
    check1 = False
    rs.Close
    Exit Function
errh:
    rs.Close
    MsgBox Err.Description
End Function






Private Sub GradeRefresh()
    Adodc1.RecordSource = "Select * from 学生与课程 where  学号 = '" & Trim(Text1.Text) & "'"
    Adodc1.Refresh
End Sub

Private Function checkcourse() As Boolean
On Error GoTo errh
 Set rs = cn.Execute("select * from 课程 where  课程名称='" & Trim(Combo2.Text) & "' and 课程号='" & Trim(Combo4.Text) & "'")
 'If Adodc2.Recordset.EOF Then
    'Adodc2.Recordset.Close
    If rs.EOF Then
       rs.Close
       checkcourse = False
    Exit Function
End If
checkcourse = True
rs.Close
Exit Function
errh:
    rs.Close
    MsgBox Err.Description
End Function
Private Function checkclass() As Boolean '检测添加的课程是否重复
On Error GoTo errh
     ' Adodc2.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
                   "DBQ=db5.MDB;" & _
                   "DefaultDir=" & CheckPath(App.path) & ";" & _
                   "UID=;PWD=;"
    Set rs = cn.Execute("SELECT 课程名称 FROM 学生与课程 WHERE 课程名称='" & Trim(Combo2.Text) & "'  and  学号='" & Trim(Text1.Text) & "' And 成绩 Is Not Null ")
    ' Adodc2.RecordSource = "select * from 课程 where 课程号='" & Trim(Text1.Text) & "' and 课程名称='" & Trim(Text2.Text) & "' "
        If rs.EOF Then
            rs.Close
            checkclass = True
            Exit Function
        End If
    checkclass = False
    rs.Close
    Exit Function
errh:
    rs.Close
    MsgBox Err.Description
End Function
Private Function match() As Boolean
On Error GoTo error
If Text13.Text < 60 Then
    If Combo3.Text = "不及格" Then
       match = True
    Else
       match = False
    End If
End If
If Text13.Text < 70 And Text13.Text >= 60 Then
    If Combo3.Text = "及格" Then
        match = True
    Else
        match = False
    End If
End If
If Text13.Text < 80 And Text13.Text >= 70 Then
    If Combo3.Text = "中等" Then
          match = True
    Else
          match = False
    End If
End If
If Text13.Text < 90 And Text13.Text >= 80 Then
    If Combo3.Text = "良好" Then
          match = True
    Else
          match = False
    End If
End If
If Text13.Text <= 100 And Text13.Text >= 90 Then
    If Combo3.Text = "优异" Then
          match = True
    Else
          match = False
    End If
End If
Exit Function
error:
  MsgBox Err.descirption
End Function



Private Sub Timer1_Timer()
If Combo4.Text <> "" Then
   Set rs = cn.Execute("SELECT distinct 课程名称 ,课程号 FROM 课程 where 课程号='" & Trim(Combo4.Text) & "'")
   If Not rs.EOF Then
      Combo2.Text = rs.Fields(0).Value
      rs.Close
      
   End If
  
      
End If
End Sub

⌨️ 快捷键说明

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