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

📄 frmcj2.frm

📁 用VB连接ORalce数据库的学生管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmcj2 
   BackColor       =   &H00FFC0FF&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "成绩添加"
   ClientHeight    =   4605
   ClientLeft      =   2640
   ClientTop       =   1485
   ClientWidth     =   5670
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   4605
   ScaleWidth      =   5670
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   4200
      Top             =   240
      Visible         =   0   'False
      Width           =   1215
      _ExtentX        =   2143
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   "he"
      Password        =   "he"
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.TextBox Text2 
      Height          =   390
      Left            =   3000
      TabIndex        =   6
      Top             =   2040
      Width           =   1095
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00FFC0FF&
      Caption         =   "成绩设置"
      Height          =   3495
      Left            =   480
      TabIndex        =   0
      Top             =   840
      Width           =   4575
      Begin VB.CommandButton Command1 
         Caption         =   "确定"
         Height          =   390
         Left            =   1080
         TabIndex        =   9
         Top             =   2640
         Width           =   1095
      End
      Begin VB.CommandButton Command2 
         Caption         =   "取消"
         Height          =   390
         Left            =   2520
         TabIndex        =   8
         Top             =   2640
         Width           =   1095
      End
      Begin VB.TextBox Text3 
         Height          =   390
         Left            =   2520
         TabIndex        =   7
         Top             =   1920
         Width           =   1095
      End
      Begin VB.TextBox Text1 
         Height          =   390
         Left            =   2520
         TabIndex        =   5
         Top             =   480
         Width           =   1095
      End
      Begin VB.Label Label3 
         BackColor       =   &H00FFC0FF&
         Caption         =   "学号:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1200
         TabIndex        =   4
         Top             =   480
         Width           =   855
      End
      Begin VB.Label Label2 
         BackColor       =   &H00FFC0FF&
         Caption         =   "课程号:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1200
         TabIndex        =   3
         Top             =   1200
         Width           =   855
      End
      Begin VB.Label Label7 
         BackColor       =   &H00FFC0FF&
         Caption         =   "分数:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1200
         TabIndex        =   2
         Top             =   1920
         Width           =   855
      End
   End
   Begin VB.Image Image4 
      Height          =   480
      Left            =   720
      Picture         =   "frmcj2.frx":0000
      Top             =   120
      Width           =   480
   End
   Begin VB.Label Label6 
      Caption         =   "成绩添加"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   21.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   495
      Left            =   1920
      TabIndex        =   1
      Top             =   120
      Width           =   2055
   End
End
Attribute VB_Name = "frmcj2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
If Trim(Text1.Text) = "" Then
 MsgBox "学号不能为空!", vbExclamation + vbOKOnly, "警告"
 Text1.SetFocus
 Exit Sub
End If
If Trim(Text2.Text) = "" Then
 MsgBox "课程号不能为空!", vbExclamation + vbOKOnly, "警告"
 Text2.SetFocus
 Exit Sub
End If
If Trim(Text3.Text) = "" Then
 MsgBox "成绩不能为空!", vbExclamation + vbOKOnly, "警告"
 Text3.SetFocus
 Exit Sub
End If
    Adodc1.ConnectionString = "Provider=MSDAORA.1;User ID=he;Persist Security Info=False"
    sql = "select * from student where sno='" & Trim(Text1.Text) & "'"
    Adodc1.CommandType = adCmdText
    Adodc1.RecordSource = sql
    Adodc1.Refresh
    If Adodc1.Recordset.EOF = True Then
        MsgBox " 并不存在学号为" & Trim(Text1.Text) & "的学生!不可以添加成绩!", vbExclamation + vbOKOnly, "警告"
        Text1.SetFocus
        Exit Sub
    End If
    Adodc1.ConnectionString = "Provider=MSDAORA.1;User ID=he;Persist Security Info=False"
    sql = "select * from course where cno='" & Trim(Text2.Text) & "'"
    Adodc1.CommandType = adCmdText
    Adodc1.RecordSource = sql
    Adodc1.Refresh
    If Adodc1.Recordset.EOF = True Then
        MsgBox " 并不存在课程号为" & Trim(Text2.Text) & "的课程!不可以添加成绩!", vbExclamation + vbOKOnly, "警告"
        Text2.SetFocus
        Exit Sub
    End If

    Adodc1.ConnectionString = "Provider=MSDAORA.1;User ID=he;Persist Security Info=False"
    sql = "select * from course where cno='" & Trim(Text2.Text) & "'"
    Adodc1.CommandType = adCmdText
    Adodc1.RecordSource = sql
    Adodc1.Refresh
    If Adodc1.Recordset.EOF = True Then
        MsgBox " 并不存在课程号为" & Trim(Text2.Text) & "的学生!不可以添加成绩!", vbExclamation + vbOKOnly, "警告"
        Text2.SetFocus
        Exit Sub
    End If
        Adodc1.ConnectionString = "Provider=MSDAORA.1;User ID=he;Persist Security Info=False"
        sql = "select * from choose where sno='" & Trim(Text1.Text) & "' and cno='" & Trim(Text2.Text) & "'"
        Adodc1.CommandType = adCmdText
        Adodc1.RecordSource = sql
        Adodc1.Refresh
    If Adodc1.Recordset.EOF = False Then
        MsgBox " 该学生已经选过此课程!", vbExclamation + vbOKOnly, "警告"
        Text1.SetFocus
        Text1.SelStart = 0
        Text1.SelLength = Len(Text1.Text)
        Exit Sub
    End If

Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("sno").Value = Trim(Text1.Text)
Adodc1.Recordset.Fields("cno").Value = Trim(Text2.Text)
Adodc1.Recordset.Fields("grade").Value = Trim(Text3.Text)
Adodc1.Recordset.Update
Adodc1.Refresh
MsgBox " 成绩添加成功!", vbInformation + vbOKOnly, "警告"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

⌨️ 快捷键说明

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