📄 frmcourseinfo.frm
字号:
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Caption = "关闭(&E)"
CaptionMouseOverColor= 16711680
PictureBackColor= 15790320
PictureSmoothBackColor= 15790320
ButtonPicture = "FrmCourseInfo.frx":4CB0
End
End
Attribute VB_Name = "FrmCourse"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'***************************************************
'* 学生系统管理系统 V1.0 *
'* 开发者:覃能华 *
'* 窗 体:课程基本信息管理窗体 *
'* 日 期:2003.12.26 *
'***************************************************
Dim myCourse As OpenRs
Private Sub AutoCourseNo() '窗体启动时自动检测课程编号
myCourse.rsDK2 "select * from course_info"
If myCourse.rs2.EOF = True Then
TxtcouNo.Text = "1"
Exit Sub
Else
myCourse.rs2.MoveLast
TxtcouNo.Text = Trim(myCourse.rs2!course_no) + 1
If TxtcouNo.Text > 2000 Then
MsgBox "系统超出负荷!建议尽快升级!", vbOKOnly + vbInformation, "提示"
End If
End If
End Sub
Private Sub CboCouType_KeyPress(KeyAscii As Integer)
If KeyAscii = 39 Then KeyAscii = 0
End Sub
Private Sub CboFinNo_dropdown()
CboFinNo.Clear
myCourse.rsDK2 "select * from course_info"
myCourse.rs2.MoveFirst
While myCourse.rs2.EOF = False
CboFinNo.AddItem myCourse.rs2!course_no
myCourse.rs2.MoveNext
Wend
End Sub
Private Sub CboFinNo_KeyPress(KeyAscii As Integer)
If Not (Chr(KeyAscii) <= "9" And Chr(KeyAscii) >= "0" Or KeyAscii = 8) Then
KeyAscii = 0
End If
End Sub
Private Sub cmdAdd_Click()
If cmdAdd.Caption = "添加(&A)" Then
Call ClearText
cmdAdd.Caption = "取消(&C)"
Frame1.Enabled = True
Call AutoCourseNo
TxtcouName.SetFocus
cmdSave.Caption = "保存(&S)"
cmdSave.Enabled = True
cmdDel.Enabled = False
Else
Call ClearText
cmdAdd.Caption = "添加(&A)"
Frame1.Enabled = False
cmdSave.Caption = "保存(&S)"
cmdSave.Enabled = False
cmdDel.Enabled = False
End If
End Sub
Private Sub cmdDel_Click()
If TxtcouNo.Text <> "" Then
myCourse.rsDK1 "select * from course_info where course_no='" & TxtcouNo.Text & "'"
If MsgBox("确定要删除该记录吗?", vbQuestion + vbOKCancel, "删除记录") = vbOK Then
myCourse.rs1.Delete
Call ClearText
Else
Exit Sub
End If
myCourse.rsDK1 "select * from course_info"
If myCourse.rs1.EOF Then
Frame2.Enabled = False
Course_Grid.Clear
Course_Grid.FormatString = " | 课程编号| 课程名称| 课程类型| 课程描述"
Else
Set Course_Grid.DataSource = myCourse.rs1
Course_Grid.FormatString = " | 课程编号| 课程名称| 课程类型| 课程描述"
End If
Frame1.Enabled = False
cmdAdd.Caption = "添加(&A)"
cmdSave.Caption = "保存(&S)"
cmdSave.Enabled = False
cmdDel.Enabled = False
End If
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub Cmdfind_Click()
If CboFinNo.Text = "" Then
MsgBox "请输入课程编号!", vbOKOnly + vbInformation, "提示"
Else
myCourse.rsDK1 "select * from course_info where course_no='" & CboFinNo.Text & "'"
If myCourse.rs1.EOF Then
Course_Grid.Clear
Call ClearText
Course_Grid.FormatString = " | 课程编号| 课程名称| 课程类型| 课程描述"
MsgBox "没有找到符合条件的记录!", vbOKOnly + vbInformation, "提示"
myCourse.rsDK1 "select * from course_info"
Set Course_Grid.DataSource = myCourse.rs1
Course_Grid.FormatString = " | 课程编号| 课程名称| 课程类型| 课程描述"
CboFinNo.Text = ""
Frame1.Enabled = False
cmdAdd.Caption = "添加(&A)"
cmdSave.Enabled = False
cmdSave.Caption = "保存(&S)"
cmdDel.Enabled = False
Else
Set Course_Grid.DataSource = myCourse.rs1
Course_Grid.FormatString = " | 课程编号| 课程名称| 课程类型| 课程描述"
TxtcouNo.Text = myCourse.rs1!course_no
TxtcouName.Text = myCourse.rs1!course_name
CboCouType.Text = myCourse.rs1!course_type
TxtcouDes.Text = myCourse.rs1!course_des
cmdDel.Enabled = True
Frame1.Enabled = True
TxtcouName.SetFocus
cmdAdd.Caption = "添加(&A)"
cmdSave.Enabled = True
cmdSave.Caption = "更新(&U)"
End If
End If
End Sub
Private Sub Cmdsave_Click()
If TxtcouName.Text = Empty Then
MsgBox "请输入课程名称!", vbOKOnly + vbInformation, "提示"
TxtcouName.SetFocus
Exit Sub
End If
If CboCouType.Text = Empty Then
MsgBox "请输入课程类型!", vbOKOnly + vbInformation, "提示"
CboCouType.SetFocus
Exit Sub
End If
If cmdSave.Caption = "保存(&S)" Then
myCourse.rsDK1 "select * from course_info"
With myCourse.rs1
.AddNew
!course_no = TxtcouNo.Text
!course_name = TxtcouName.Text
!course_type = CboCouType.Text
!course_des = TxtcouDes.Text
.Update
End With
myCourse.rsDK1 "select * from course_info"
Set Course_Grid.DataSource = myCourse.rs1
Course_Grid.FormatString = " | 课程编号| 课程名称| 课程类型| 课程描述"
MsgBox "课程信息已成功添加!", vbOKOnly + vbInformation, "提示"
Frame1.Enabled = False
Frame2.Enabled = True
cmdAdd.Caption = "添加(&A)"
cmdSave.Caption = "保存(&S)"
cmdSave.Enabled = False
cmdDel.Enabled = False
Else
myCourse.rsDK1 "select * from course_info where course_no='" & TxtcouNo.Text & "'"
With myCourse.rs1
!course_name = TxtcouName.Text
!course_type = CboCouType.Text
!course_des = TxtcouDes.Text
.Update
End With
Set Course_Grid.DataSource = myCourse.rs1
Course_Grid.FormatString = " | 课程编号| 课程名称| 课程类型| 课程描述"
MsgBox "课程信息已成功更新!", vbOKOnly + vbInformation, "提示"
myCourse.rsDK1 "select * from course_info"
Set Course_Grid.DataSource = myCourse.rs1
Course_Grid.FormatString = " | 课程编号| 课程名称| 课程类型| 课程描述"
Frame1.Enabled = False
cmdAdd.Caption = "添加(&A)"
cmdSave.Caption = "保存(&S)"
cmdSave.Enabled = False
cmdDel.Enabled = False
End If
End Sub
Private Sub Course_Grid_Click()
myCourse.rsDK1 "select * from course_info"
If Not myCourse.rs1.EOF Then
TxtcouNo.Text = Course_Grid.TextMatrix(Course_Grid.Row, 1)
TxtcouName.Text = Course_Grid.TextMatrix(Course_Grid.Row, 2)
CboCouType.Text = Course_Grid.TextMatrix(Course_Grid.Row, 3)
TxtcouDes.Text = Course_Grid.TextMatrix(Course_Grid.Row, 4)
cmdDel.Enabled = True
Frame1.Enabled = True
cmdAdd.Caption = "添加(&A)"
cmdSave.Enabled = True
cmdSave.Caption = "更新(&U)"
End If
End Sub
Private Sub Form_Load()
Set myCourse = New OpenRs
Course_Grid.FormatString = " | 课程编号| 课程名称| 课程类型| 课程描述"
myCourse.rsDK1 "select * from course_info"
If Not myCourse.rs1.EOF Then
Frame2.Enabled = True
Set Course_Grid.DataSource = myCourse.rs1
Course_Grid.FormatString = " | 课程编号| 课程名称| 课程类型| 课程描述"
End If
CboCouType.AddItem "程序设计"
CboCouType.AddItem "数据库设计"
CboCouType.AddItem "网络"
CboCouType.AddItem "网页设计"
CboCouType.AddItem "其它"
End Sub
Public Sub ClearText()
TxtcouNo.Text = ""
TxtcouName.Text = ""
CboCouType.Text = ""
TxtcouDes.Text = ""
End Sub
Private Sub TxtcouDes_KeyPress(KeyAscii As Integer)
If KeyAscii = 39 Then KeyAscii = 0
End Sub
Private Sub TxtcouName_KeyPress(KeyAscii As Integer)
If KeyAscii = 39 Then KeyAscii = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -