form1.frm

来自「本人课程设计做的一个简单的教务辅助管理系统,实现了数据库的一般操作,适合初学者学」· FRM 代码 · 共 381 行

FRM
381
字号
VERSION 5.00
Begin VB.Form 添加上课教师信息 
   Caption         =   "Form1"
   ClientHeight    =   7125
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7395
   LinkTopic       =   "Form1"
   ScaleHeight     =   7125
   ScaleWidth      =   7395
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox Text6 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1560
      TabIndex        =   19
      Top             =   3840
      Width           =   1095
   End
   Begin VB.ComboBox Combo2 
      Height          =   300
      Left            =   5040
      TabIndex        =   14
      Top             =   3000
      Width           =   735
   End
   Begin VB.ComboBox Combo1 
      Height          =   300
      Left            =   2640
      TabIndex        =   13
      Top             =   3000
      Width           =   1095
   End
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   3000
      TabIndex        =   12
      Top             =   4680
      Width           =   1335
   End
   Begin VB.CommandButton Command1 
      Caption         =   "添加"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   1200
      TabIndex        =   11
      Top             =   4680
      Width           =   1455
   End
   Begin VB.TextBox Text5 
      Height          =   375
      Left            =   5880
      TabIndex        =   10
      Top             =   2160
      Width           =   495
   End
   Begin VB.TextBox Text4 
      Height          =   375
      Left            =   3480
      TabIndex        =   7
      Top             =   2160
      Width           =   1455
   End
   Begin VB.TextBox Text3 
      Height          =   375
      Left            =   1320
      TabIndex        =   5
      Top             =   2160
      Width           =   975
   End
   Begin VB.TextBox Text2 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4560
      TabIndex        =   3
      Top             =   1320
      Width           =   1335
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1560
      TabIndex        =   0
      Top             =   1320
      Width           =   1095
   End
   Begin VB.Label Label10 
      Caption         =   "课程号"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   360
      TabIndex        =   18
      Top             =   2160
      Width           =   735
   End
   Begin VB.Label Label9 
      Caption         =   "   添加教师上课基本信息"
      BeginProperty Font 
         Name            =   "华文中宋"
         Size            =   24
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   600
      TabIndex        =   17
      Top             =   0
      Width           =   5295
   End
   Begin VB.Label Label7 
      Caption         =   "第几节"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3960
      TabIndex        =   16
      Top             =   3000
      Width           =   735
   End
   Begin VB.Label Label6 
      Caption         =   "星期"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   1680
      TabIndex        =   15
      Top             =   3000
      Width           =   855
   End
   Begin VB.Label Label8 
      Caption         =   "上课教室"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   240
      TabIndex        =   9
      Top             =   3840
      Width           =   975
   End
   Begin VB.Label Label5 
      Caption         =   "上课时间"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   240
      TabIndex        =   8
      Top             =   3000
      Width           =   1095
   End
   Begin VB.Label Label4 
      Caption         =   "学分"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   5160
      TabIndex        =   6
      Top             =   2160
      Width           =   615
   End
   Begin VB.Label Label3 
      Caption         =   "课程名"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2520
      TabIndex        =   4
      Top             =   2160
      Width           =   735
   End
   Begin VB.Label Label2 
      Caption         =   "教师姓名"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   3120
      TabIndex        =   2
      Top             =   1320
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "教师编号"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   360
      TabIndex        =   1
      Top             =   1320
      Width           =   1095
   End
End
Attribute VB_Name = "添加上课教师信息"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
Set qr = New ADODB.Recordset
Set pr = New ADODB.Recordset
Set sr = New ADODB.Recordset
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Then
  w = MsgBox("请输入完整记录", vbOKOnly, "提示")
  Text1.SetFocus
  Else
  con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\教务管理系统.mdb;Persist Security Info=False"
    rs.Open "SELECT * FROM 教师上课信息表 WHERE  上课教室='" & Trim(Text6.Text) & "'and 上课日期='" & Trim(Combo1.Text) & "and 上课节次=" & Trim(Combo2.Text) & "'", con, adOpenStatic, adLockOptimistic '检查上课时间冲突‘
    If rs.RecordCount > 0 Then
MsgBox "时间冲突", vbOKOnly + vbExclamation, "警告"
   Else
    qr.Open "SELECT * FROM 课程基本信息表 WHERE  课程号='" & Trim(Text3.Text) & "'and 课程名='" & Trim(Text4.Text) & "'", con, adOpenStatic, adLockOptimistic '检查课程是否存在‘
   If qr.EOF Then
   
   MsgBox "课程表里没有这门课或课程号和课程不对应", vbOKOnly + vbExclamation, "警告"
   Else
   pr.Open "SELECT * FROM 教师基本信息 WHERE  教师编号='" & Trim(Text1.Text) & "'and 教师姓名='" & Trim(Text2.Text) & "'", con, adOpenStatic, adLockOptimistic
   If pr.RecordCount = 0 Then
   MsgBox "没有这个教师或编号和教师不对应", vbOKOnly + vbExclamation, "警告"
   Else
 sr.Open "SELECT * FROM 教室基本信息表 WHERE  教室编号='" & Trim(Text6.Text) & "'", con, adOpenStatic, adLockOptimistic
 If sr.EOF Then
   
   MsgBox "教室基本信息表里没有这个教室", vbOKOnly + vbExclamation, "警告"
   Else
   rs.AddNew
  rs.Fields(0) = Text1.Text
 rs.Fields(1) = Text2.Text
rs.Fields(2) = Text3.Text
rs.Fields(3) = Text4.Text
rs.Fields(4) = Text5.Text
rs.Fields(6) = Combo2.Text
rs.Fields(5) = Text6.Text
rs.Fields(7) = Combo1.Text

                     rs.Update
                  MsgBox "添加成功!"
                  Text1.Text = ""
                  Text2.Text = ""
                  Text3.Text = ""
                  Text4.Text = ""
                  Text5.Text = ""
                  Text6.Text = ""
                Combo1.Text = ""
                Combo2.Text = ""
                
                  End If
                  End If
       End If
End If
       End If
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Form_Load()
Combo1.AddItem "星期一"
Combo1.AddItem "星期二"
Combo1.AddItem "星期三"
Combo1.AddItem "星期四"
Combo1.AddItem "星期五"
Combo1.AddItem "星期六"
Combo1.AddItem "星期天"
Combo2.AddItem "1"
Combo2.AddItem "2"
Combo2.AddItem "3"
Combo2.AddItem "4"
Combo2.AddItem "5"
End Sub

⌨️ 快捷键说明

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