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

📄 form1.frm

📁 要解决三个冲突:1.同一老师任两门以上课程的在同一时间内安排在不同的班讲课 2.不同的课程在相同时间内安排在同一教室 3 .教室容量与学生人数的冲突 数据库:班级表(班级名称,人数) 教师表(教师
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   BackColor       =   &H8000000A&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "教员入库"
   ClientHeight    =   5310
   ClientLeft      =   420
   ClientTop       =   4275
   ClientWidth     =   7170
   Icon            =   "Form1.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   5310
   ScaleWidth      =   7170
   Begin VB.CommandButton queryComm 
      BackColor       =   &H8000000A&
      Caption         =   "查询"
      Height          =   350
      Left            =   1440
      Style           =   1  'Graphical
      TabIndex        =   19
      Top             =   4680
      Width           =   945
   End
   Begin VB.TextBox Text1 
      Height          =   390
      Index           =   3
      Left            =   240
      TabIndex        =   18
      Top             =   4680
      Width           =   1095
   End
   Begin VB.Frame Frame3 
      BackColor       =   &H8000000A&
      Caption         =   "浏览"
      ForeColor       =   &H00000000&
      Height          =   3735
      Left            =   240
      TabIndex        =   14
      Top             =   120
      Width           =   6735
      Begin VB.TextBox Text1 
         Height          =   390
         Index           =   0
         Left            =   1920
         TabIndex        =   0
         Top             =   360
         Width           =   1815
      End
      Begin VB.TextBox Text1 
         BeginProperty DataFormat 
            Type            =   1
            Format          =   "0"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   1
         EndProperty
         Height          =   375
         Index           =   1
         Left            =   1920
         TabIndex        =   1
         Top             =   960
         Width           =   1455
      End
      Begin VB.TextBox Text1 
         Height          =   1935
         Index           =   2
         Left            =   1920
         MultiLine       =   -1  'True
         TabIndex        =   2
         Top             =   1560
         Width           =   4335
      End
      Begin VB.Label Label1 
         BackStyle       =   0  'Transparent
         Caption         =   "教职员姓名:"
         ForeColor       =   &H00000000&
         Height          =   255
         Index           =   0
         Left            =   600
         TabIndex        =   17
         Top             =   480
         Width           =   1095
      End
      Begin VB.Label Label1 
         BackStyle       =   0  'Transparent
         Caption         =   "年龄:"
         ForeColor       =   &H00000000&
         Height          =   255
         Index           =   1
         Left            =   600
         TabIndex        =   16
         Top             =   1080
         Width           =   975
      End
      Begin VB.Label Label1 
         BackStyle       =   0  'Transparent
         Caption         =   "详细信息:"
         ForeColor       =   &H00000000&
         Height          =   255
         Index           =   2
         Left            =   600
         TabIndex        =   15
         Top             =   1680
         Width           =   1095
      End
   End
   Begin VB.Frame Frame2 
      BackColor       =   &H8000000A&
      Caption         =   "编辑"
      ForeColor       =   &H00000000&
      Height          =   1215
      Left            =   2640
      TabIndex        =   8
      Top             =   3960
      Width           =   4335
      Begin VB.CommandButton Command2 
         BackColor       =   &H8000000A&
         Caption         =   "取消"
         Height          =   350
         Index           =   4
         Left            =   3120
         Style           =   1  'Graphical
         TabIndex        =   13
         Top             =   240
         Width           =   1065
      End
      Begin VB.CommandButton Command2 
         BackColor       =   &H8000000A&
         Caption         =   "保存"
         Height          =   350
         Index           =   3
         Left            =   1680
         Style           =   1  'Graphical
         TabIndex        =   12
         Top             =   720
         Width           =   1305
      End
      Begin VB.CommandButton Command2 
         BackColor       =   &H8000000A&
         Caption         =   "修改"
         Height          =   350
         Index           =   2
         Left            =   120
         Style           =   1  'Graphical
         TabIndex        =   11
         Top             =   720
         Width           =   1425
      End
      Begin VB.CommandButton Command2 
         BackColor       =   &H8000000A&
         Caption         =   "删除"
         Height          =   350
         Index           =   1
         Left            =   1680
         Style           =   1  'Graphical
         TabIndex        =   10
         Top             =   240
         Width           =   1305
      End
      Begin VB.CommandButton Command2 
         BackColor       =   &H8000000A&
         Caption         =   "添加"
         Height          =   350
         Index           =   0
         Left            =   120
         Style           =   1  'Graphical
         TabIndex        =   9
         Top             =   240
         Width           =   1425
      End
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H8000000A&
      Caption         =   "导航"
      Enabled         =   0   'False
      ForeColor       =   &H00000000&
      Height          =   1215
      Left            =   120
      TabIndex        =   3
      Top             =   3960
      Width           =   2415
      Begin VB.CommandButton Command1 
         BackColor       =   &H8000000A&
         Caption         =   ">>"
         Height          =   375
         Index           =   3
         Left            =   1920
         Style           =   1  'Graphical
         TabIndex        =   7
         Top             =   240
         Width           =   375
      End
      Begin VB.CommandButton Command1 
         BackColor       =   &H8000000A&
         Caption         =   ">"
         Height          =   375
         Index           =   2
         Left            =   1320
         Style           =   1  'Graphical
         TabIndex        =   6
         Top             =   240
         Width           =   375
      End
      Begin VB.CommandButton Command1 
         BackColor       =   &H8000000A&
         Caption         =   "<"
         Height          =   375
         Index           =   1
         Left            =   720
         Style           =   1  'Graphical
         TabIndex        =   5
         Top             =   240
         Width           =   375
      End
      Begin VB.CommandButton Command1 
         BackColor       =   &H8000000A&
         Caption         =   "<<"
         Height          =   375
         Index           =   0
         Left            =   120
         Style           =   1  'Graphical
         TabIndex        =   4
         Top             =   240
         Width           =   375
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim qrs As ADODB.Recordset
Dim slSql As String
Dim i, j As Integer
Dim strBak(2) As String
Dim sqlStr As String


Private Sub Command1_Click(Index As Integer)
On Error GoTo Err:
Dim cn As Integer
For cn = 0 To 2
    Text1(cn).Text = ""
Next cn


If rs.RecordCount > 0 Then
    Select Case Index
    Case 0:
        rs.MoveFirst
        
    Case 1:
        rs.MovePrevious
        Command1(2).Enabled = True
        Command1(3).Enabled = True
        
    Case 2:
        rs.MoveNext
        Command1(0).Enabled = True
        Command1(1).Enabled = True
        
    Case 3:
        rs.MoveLast
    End Select
    displayInfo
End If
GoTo ok:
Err:
Call dataOver

ok:
End Sub
Private Sub dataOver()
If rs.BOF Then
    Command1(0).Enabled = False
    Command1(1).Enabled = False
    Command1(2).Enabled = True
    Command1(3).Enabled = True
    rs.MoveFirst
    
Else
    If rs.EOF Then
    rs.MoveLast
    
        Command1(0).Enabled = True
        Command1(1).Enabled = True
        Command1(2).Enabled = False
        Command1(3).Enabled = False
    Else
        MsgBox "Database Error", vbExclamation + vbOKOnly, "Error unknown"
    End If
End If



End Sub

Private Sub Command2_Click(Index As Integer)
On Error GoTo errDeal
If Index = 0 Or Index = 2 Then
    CanSave (True)
Else
    CanSave (False)
End If

Select Case Index
Case 0:
    rs.AddNew
    Call toNull
    
Case 1:
    j = MsgBox("你确定要删除本记录吗?", vbYesNo + vbQuestion, "删除")
    If j = vbYes Then
        rs.Delete
        Call toNull
    End If
    
Case 2:
rs.Delete
rs.AddNew

Case 3:
    If Len(LTrim$(RTrim$(Text1(0).Text))) > 0 Then
        'rs.AddNew
        For i = 0 To 2
            If Len(LTrim$(RTrim$(Text1(i).Text))) > 0 Then
            
                rs.Fields(i) = Text1(i).Text
            End If
            
        Next i
        rs.Update
    Else
        MsgBox "姓名不得为空", vbOKOnly + vbExclamation, "Error"
    End If
Case 4:
    For i = 0 To 2
        Text1(i).Text = strBak(i)
    Next i
    Call Command2_Click(3)
    
End Select
Exit Sub


errDeal:
MsgBox "database Error", vbExclamation + vbOKOnly, "error"
'okEnd:
End Sub
Private Sub CanSave(ok As Boolean)
Frame1.Enabled = Not ok
Frame3.Enabled = ok

    For i = 0 To 4
        If i < 3 Then
            Command2(i).Enabled = Not ok
        Else
            Command2(i).Enabled = ok
        End If
    Next i
    
        
End Sub
Private Sub Form_Load()
Dim cnt As Integer

Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
Set qrs = New ADODB.Recordset
'"Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=C:\WINDOWS\Desktop\dataUse.mdb"
con.Open "provider=Microsoft.Jet.OLEDB.4.0; data source= " & App.Path & "\dataUse.mdb"
rs.Open "select * from teacher", con, adOpenStatic, adLockOptimistic
If rs.RecordCount > 0 Then
    rs.MoveFirst
    displayInfo
    CanSave (False)
    
Else
    'new data
    CanSave (True)
    Call Command2_Click(0)
    
End If
End Sub
Private Sub displayInfo()
    i = j = 0
    For i = 0 To 2
        'Text1(i).Text = ""
        
        If Len(rs.Fields(i)) > 0 Then
        
        Text1(i).Text = rs.Fields(i)
        
        strBak(i) = Text1(i).Text
        End If
        
    Next i
    
End Sub
Private Sub toNull()
    For i = 0 To 2
        Text1(i).Text = ""
        strBak(i) = ""
    Next i
    
End Sub



Private Sub Form_Unload(Cancel As Integer)
On Error GoTo KK
rs.Close
Set rs = Nothing
qrs.Close
Set qrs = noting
con.Close
Set con = Nothing
KK:

End Sub

Private Sub queryComm_Click()
    slSql = "select * from Teacher where cTrname = '" + Text1(3).Text + "'"
    qrs.Open slSql, con, adOpenStatic
    If Not qrs.EOF Then
        qrs.MoveFirst
            i = j = 0
        For i = 0 To 2
        'Text1(i).Text = ""
        
        If Len(qrs.Fields(i)) > 0 Then
        
        Text1(i).Text = qrs.Fields(i)
        
        strBak(i) = Text1(i).Text
        End If
        Next i
    End If
    qrs.Close
End Sub

⌨️ 快捷键说明

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