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

📄 frm_setcourse.frm

📁 学生信息的管理是学校经常遇到的问题。学生数量的积聚增加和学生认识制度的改革
💻 FRM
📖 第 1 页 / 共 2 页
字号:
   End
   Begin VB.Image imgleftwindow 
      Height          =   3495
      Left            =   0
      Picture         =   "frm_setcourse.frx":CD7A
      Stretch         =   -1  'True
      Top             =   405
      Width           =   465
   End
   Begin VB.Image imgclose 
      Height          =   240
      Left            =   6510
      Picture         =   "frm_setcourse.frx":1032C
      Top             =   120
      Width           =   240
   End
   Begin VB.Image imgrighttitle 
      Height          =   525
      Left            =   6495
      Picture         =   "frm_setcourse.frx":1066E
      Top             =   0
      Width           =   375
   End
   Begin VB.Image imgtop 
      Height          =   450
      Left            =   270
      Picture         =   "frm_setcourse.frx":11114
      Stretch         =   -1  'True
      Top             =   0
      Width           =   6225
   End
End
Attribute VB_Name = "frm_setcourse"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim mycourse As Cls_Course
Dim mysem As Cls_Sem



Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii <> 13 Then KeyAscii = 0
End Sub

Private Sub Combo2_KeyPress(KeyAscii As Integer)
If KeyAscii <> 13 Then KeyAscii = 0
End Sub

Private Sub Form_Load()
    Dim i As Integer
    SetWindow Me
    AlwaysOnTop Me, False
    Set mycourse = New Cls_Course
    Set mysem = New Cls_Sem
    Text1(2).Enabled = False
    Move (frm_main.Width - Me.Width) / 2, (frm_main.Height - Me.Height) / 2 - 800
    
    '显示学年名称在combo1中
    mysem.QuerySemOnlyYearName
    If mysem.GetQrySemOnlyYearNameRs.EOF = False Then
       Do Until mysem.GetQrySemOnlyYearNameRs.EOF
          Combo1.AddItem mysem.GetQrySemOnlyYearNameRs.Fields(0)
          mysem.GetQrySemOnlyYearNameRs.MoveNext
       Loop
    End If
    '设置窗体加载时各控件的默认状态
    State "cencel"
    Combo2.Enabled = False
    For i = 0 To 3
        command1(i).DragMode = 1
    Next
End Sub

Private Sub Combo2_Click()
    List1.Clear
    State "cencel"
    mycourse.PrcCourseById Trim(Combo2)
    If mycourse.GetPrcCourseByIdRs.EOF = False Then
       Do Until mycourse.GetPrcCourseByIdRs.EOF
          List1.AddItem mycourse.GetPrcCourseByIdRs.Fields(0)
          mycourse.GetPrcCourseByIdRs.MoveNext
       Loop
    End If
    command1(0).DragMode = 0
End Sub


Private Sub Combo1_Click()
Combo2.Enabled = True
Combo2.Clear
List1.Clear
State "cencel"
'按combo1的值查询,将符合的记录显示在combo2中
mysem.PrcSemByYearName Trim(Combo1)
If mysem.GetPrcSemByYearNameRs.EOF = False Then
   Do Until mysem.GetPrcSemByYearNameRs.EOF
      Combo2.AddItem mysem.GetPrcSemByYearNameRs.Fields(1)
      mysem.GetPrcSemByYearNameRs.MoveNext
   Loop
End If
command1(0).DragMode = 1
End Sub

Private Sub List1_Click()
Dim i As Integer
'按选中的学费编号将详细信息显示在文本框中
mycourse.QueryCourseById Trim(List1)
If mycourse.GetQryCourseByIdRs.EOF = False Then
   For i = 0 To 2
     Text1(i) = Trim(mycourse.GetQryCourseByIdRs.Fields(i))
   Next
End If
For i = 0 To List1.ListCount - 1
    List1.Selected(i) = False
Next
State "selected"
End Sub


Private Sub command1_Click(Index As Integer)
Dim i As Integer
Select Case Index
'增加
Case 0
    If command1(0).Caption = "增加" Then
       If Combo2 = "" Then
          command1(0).DragMode = 1
          Exit Sub
       End If
       State "add"
       '按combo2的值查询,将对应学期名称的学期编号显示在text1(2)中
       mysem.PrcSemBySemName (Combo2)
       If mysem.GetPrcSemBySemNameRs.EOF = False Then
          Text1(2) = Trim(mysem.GetPrcSemBySemNameRs.Fields(0))
       End If
    Else
       '调用Cls_Course类,添加数据
       If Text1(0) <> "" And Text1(1) <> "" And Text1(2) <> "" Then
           mycourse.QueryCourseById Trim(Text1(0))
           If mycourse.GetQryCourseByIdRs.EOF Then
                frm_ProgressBar.Show 1
                mycourse.OpenCourse
                mycourse.GetCourseRs.AddNew
                For i = 0 To 2
                   mycourse.GetCourseRs.Fields(i) = Trim(Text1(i))
                Next
                mycourse.GetCourseRs.Update
                mycourse.GetCourseRs.Requery
                '调用combo2的click 事件刷新list1
                Combo2_Click
                State "cencel"
           Else
                MsgBox "该课程已存在,请重新输入!"
                Exit Sub
           End If
        Else
           MsgBox " 请先输入数据!"
           Text1(0).SetFocus
        End If
    End If
'修改
Case 1
    If command1(1).Caption = "修改" Then
       State "edit"
    Else
       frm_ProgressBar.Show 1
       mycourse.QueryCourseById Trim(Text1(0))
       If mycourse.GetQryCourseByIdRs.EOF = False Then
          For i = 0 To 2
             mycourse.GetQryCourseByIdRs.Fields(i) = Trim(Text1(i))
          Next
          mycourse.GetQryCourseByIdRs.Update
          mycourse.GetQryCourseByIdRs.Requery
       End If
       State "cencel"
    End If
'删除
Case 2
    Dim yn As String
    yn = MsgBox("真的删除吗?", vbYesNo, "删除")
    If yn = vbYes Then
      frm_ProgressBar.Show 1
      mycourse.QueryCourseById Trim(Text1(0))
      If mycourse.GetQryCourseByIdRs.EOF = False Then
         mycourse.GetQryCourseByIdRs.Delete
         mycourse.GetQryCourseByIdRs.Requery
      End If
       Combo2_Click
       State "delete"
    Else
      State "cencel"
    End If
'取消
Case 3
       State "cencel"
'退出
Case 4
       Unload Me
End Select
End Sub

Public Sub State(kind As String)
'各种操作时各个控件的状态
Dim i As Integer
Select Case kind
Case "add"
 For i = 0 To 1
     Text1(i) = ""
     Text1(i).Enabled = True
 Next
    Text1(0).SetFocus
    command1(0).Caption = "提交"
    command1(0).DragMode = 0
    command1(1).DragMode = 1
    command1(2).DragMode = 1
    command1(3).DragMode = 0
    command1(4).DragMode = 1
    
Case "edit"
 Text1(1).Enabled = True
 Text1(1).SetFocus
 command1(1).Caption = "更新"
 command1(0).DragMode = 1
 command1(1).DragMode = 0
 command1(2).DragMode = 1
 command1(3).DragMode = 0
 command1(4).DragMode = 1
 
Case "cencel"
 For i = 0 To 2
     Text1(i) = ""
     Text1(i).Enabled = False
 Next
 
 command1(0).Caption = "增加"
 command1(1).Caption = "修改"
 command1(0).DragMode = 0
 command1(1).DragMode = 1
 command1(2).DragMode = 1
 command1(3).DragMode = 1
 command1(4).DragMode = 0
Case "delete"
 For i = 0 To 1
     Text1(i) = ""
     Text1(i).Enabled = False
 Next
 command1(0).Caption = "增加"
 command1(1).Caption = "修改"
 command1(0).DragMode = 0
 command1(1).DragMode = 1
 command1(2).DragMode = 1
 command1(3).DragMode = 1
 command1(4).DragMode = 0

Case "selected"
 For i = 0 To 1
     Text1(i).Enabled = False
 Next
 command1(0).Caption = "增加"
 command1(1).Caption = "修改"
 command1(0).DragMode = 0
 command1(1).DragMode = 0
 command1(2).DragMode = 0
 command1(3).DragMode = 1
 command1(4).DragMode = 0
End Select
End Sub


Private Sub Text1_GotFocus(Index As Integer)
'设定文本框获得焦点时处于全部被选中状态
Text1(Index).SelLength = Len(Text1(Index).Text)
Select Case Index
Case 1
   If Text1(0) = "" Then Text1(0).SetFocus
End Select
End Sub

Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
'传递焦点
Select Case Index
Case 0
    If KeyAscii = 13 Then Text1(1).SetFocus
Case 1
    If KeyAscii = 13 And Text1(2).Enabled = False And command1(0).DragMode = 0 Then
       command1(0).SetFocus
    ElseIf KeyAscii = 13 And Text1(2).Enabled = False And command1(0).DragMode = 1 Then
       command1(1).SetFocus
    End If
End Select
End Sub

Private Sub imgclose_Click()
    Unload Me
End Sub


Private Sub imglefttitle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    DrawForms Me
End Sub

Private Sub imgtop_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    DrawForms Me
End Sub


Private Sub imgrighttitle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
   DrawForms Me
End Sub

⌨️ 快捷键说明

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