📄 frmclassinfo.frm
字号:
cmdReturn.Enabled = False
txtproj.Text = ClassGrid.TextMatrix(ClassGrid.Row, 1)
Txttime.Text = ClassGrid.TextMatrix(ClassGrid.Row, 2)
Txtplace.Text = ClassGrid.TextMatrix(ClassGrid.Row, 3)
cmdDel.Enabled = True
If txtproj.Text <> "" Then
cmdSave.Caption = "更新(&U)"
cmdSave.Enabled = True
cmdAdd.Caption = "添加(&A)"
txtproj.Enabled = False
Txttime.Enabled = True
Txtplace.Enabled = True
End If
End Sub
Private Sub cmdAdd_Click()
If cmdAdd.Caption = "添加(&A)" Then
cmdAdd.Caption = "取消(&C)"
cmdSave.Caption = "保存(&S)"
txtproj.Text = ""
Txttime.Text = "____-__-__"
Txtplace.Text = ""
cmdSave.Enabled = True
cmdDel.Enabled = False
txtproj.Enabled = True
Txttime.Enabled = True
Txtplace.Enabled = True
txtproj.SetFocus
ElseIf cmdAdd.Caption = "取消(&C)" Then
cmdAdd.Caption = "添加(&A)"
txtproj.Text = ""
Txttime.Text = "____-__-__"
Txtplace.Text = ""
cmdSave.Enabled = False
cmdDel.Enabled = False
txtproj.Enabled = False
Txttime.Enabled = False
Txtplace.Enabled = False
End If
End Sub
Private Sub cmdDel_Click()
On Error Resume Next
If txtproj.Text = "" Then
MsgBox "请选择要删除的记录!", vbOKOnly + vbInformation, "删除记录"
Exit Sub
End If
If MsgBox("确定要删除项目为 " & txtproj.Text & " 的记录吗?", vbOKCancel + vbQuestion, "删除记录") = vbOK Then
myModiproj.rsDK1 "select * from plan_info where project='" & txtproj.Text & "'"
myModiproj.rs1.Delete
cmdDel.Enabled = False
cmdSave.Enabled = False
txtproj.Text = ""
Txttime.Text = "____-__-__"
Txtplace.Text = ""
ClassGrid.Clear
ClassGrid.FormatString = " | 培训项目 | 培训时间 | 培训地点 "
myModiproj.rsDK1 "select * from plan_info"
If Not myModiproj.rs1.EOF Then
Set ClassGrid.DataSource = myModiproj.rs1
ClassGrid.FormatString = " | 培训项目 | 培训时间 | 培训地点 "
End If
End If
myModiproj.rsDK1 "select * from plan_info"
Set ClassGrid.DataSource = myModiproj.rs1
ClassGrid.FormatString = " | 培训项目 | 培训时间 | 培训地点 "
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub Cmdfind_Click()
On Error Resume Next
cmdReturn.Enabled = True
myModiproj.rsDK1 "select * from plan_info where project='" & txtFind.Text & "'"
If Not myModiproj.rs1.EOF Then
Set ClassGrid.DataSource = myModiproj.rs1
ClassGrid.FormatString = " | 培训项目 | 培训时间 | 培训地点 "
txtproj.Text = myModiproj.rs1!project
Txttime.Text = myModiproj.rs1!Time
Txtplace.Text = myModiproj.rs1!place
txtproj.Enabled = False
Txttime.Enabled = True
Txtplace.Enabled = True
cmdSave.Caption = "更新(&U)"
cmdAdd.Caption = "添加(&A)"
cmdSave.Enabled = True
cmdDel.Enabled = True
myModiproj.rsDK1 "select * from plan_info where project='" & txtFind.Text & "'"
Set ClassGrid.DataSource = myModiproj.rs1
ClassGrid.FormatString = " | 培训项目 | 培训时间 | 培训地点 "
Else
ClassGrid.Clear
ClassGrid.FormatString = " | 培训项目 | 培训时间 | 培训地点 "
txtFind.Text = ""
MsgBox "没有找到符合条件的记录!", vbOKOnly + vbInformation, "提示"
ClassGrid.FormatString = " | 培训项目 | 培训时间 | 培训地点 "
End If
End Sub
Private Sub cmdReturn_Click()
On Error Resume Next
myModiproj.rsDK1 "select * from plan_info"
Set ClassGrid.DataSource = myModiproj.rs1
ClassGrid.FormatString = " | 培训项目 | 培训时间 | 培训地点 "
End Sub
Private Sub Cmdsave_Click()
On Error Resume Next
If cmdSave.Caption = "保存(&S)" Then
If txtproj.Text = "" Then
MsgBox "请输入培训项目!", vbOKOnly + vbInformation, "培训信息添加"
txtproj.SetFocus
Exit Sub
End If
If Txttime.Text = "" Then
MsgBox "请输入培训时间!", vbOKOnly + vbInformation, "培训信息添加"
Txttime.SetFocus
Exit Sub
End If
If Txtplace.Text = "" Then
MsgBox "请输入培训地点!", vbOKOnly + vbInformation, "培训信息添加"
Txtplace.SetFocus
Exit Sub
End If
If RightProject() = True Then
MsgBox "您输入的项目已存在!", vbOKOnly + vbInformation, "培训信息添加"
txtproj.Text = ""
txtproj.SetFocus
Exit Sub
End If
If Txttime.Text = Empty Then
MsgBox "请输入培训日期!", vbInformation, "提示"
Txttime.SetFocus
Exit Sub
ElseIf Not IsDate(Txttime) Then
MsgBox "培训日期不是有效日期,请重新输入.", vbInformation, "提示"
Txttime.SetFocus
Txttime.Text = "____-__-__"
Exit Sub
ElseIf Format(Txttime.Text, "yyyy/mm/dd") < Format(#1/1/1900#, "yyyy/mm/dd") Then
MsgBox "培训日期不能小于1900年,请重新输入!", vbInformation, "提示"
Txttime.SetFocus
ttxttime.Text = "____-__-__"
Exit Sub
End If
myModiproj.rsDK1 "select * from plan_info"
With myModiproj.rs1
.AddNew
!project = Trim(txtproj.Text)
!Time = Trim(Txttime.Text)
!place = Trim(Txtplace.Text)
.Update
End With
Set ClassGrid.DataSource = myModiproj.rs1
ClassGrid.FormatString = " | 培训项目 | 培训时间 | 培训地点 "
MsgBox "信息已成功添加!", vbOKOnly + vbInformation, "培训信息添加"
txtproj.Enabled = False
Txttime.Enabled = False
Txtplace.Enabled = False
cmdSave.Caption = "保存(&S)"
cmdAdd.Caption = "添加(&A)"
cmdSave.Enabled = False
cmdDel.Enabled = False
myModiproj.rsDK1 "select * from plan_info"
Set ClassGrid.DataSource = myModiproj.rs1
ClassGrid.FormatString = " | 培训项目 | 培训时间 | 培训地点 "
Exit Sub
End If
If cmdSave.Caption = "更新(&U)" Then
If Txttime.Text = "" Then
MsgBox "培训时间不能为空,请输入!", vbOKOnly + vbInformation, "培训信息添加"
Txttime.SetFocus
Exit Sub
End If
If Txtplace.Text = "" Then
MsgBox "培训地点不能为空,请输入!", vbOKOnly + vbInformation, "培训信息添加"
Txtplace.SetFocus
Exit Sub
End If
myModiproj.rsDK1 "select * from plan_info where project='" & txtproj.Text & "'"
myModiproj.rs1!Time = Trim(Txttime.Text)
myModiproj.rs1!place = Trim(Txtplace.Text)
myModiproj.rs1.Update
Set ClassGrid.DataSource = myModiproj.rs1
ClassGrid.FormatString = " | 培训项目 | 培训时间 | 培训地点 "
MsgBox "培训信息已成功更新!", vbOKOnly + vbInformation, "培训信息添加"
txtproj.Enabled = False
Txttime.Enabled = False
Txtplace.Enabled = False
cmdSave.Caption = "保存(&S)"
cmdAdd.Caption = "添加(&A)"
cmdSave.Enabled = False
cmdDel.Enabled = False
End If
myModiproj.rsDK1 "select * from plan_info"
Set ClassGrid.DataSource = myModiproj.rs1
ClassGrid.FormatString = " | 培训项目 | 培训时间 | 培训地点 "
End Sub
Private Sub Form_Load()
On Error Resume Next
Set myModiproj = New OpenRs
ClassGrid.FormatString = " | 培训项目 | 培训时间 | 培训地点 "
myModiproj.rsDK1 "select * from plan_info"
Set ClassGrid.DataSource = myModiproj.rs1
ClassGrid.FormatString = " | 培训项目 | 培训时间 | 培训地点 "
cmdSave.Enabled = False
cmdDel.Enabled = False
End Sub
Private Sub txtFind_Change()
txtproj.Text = ""
Txttime.Text = "____-__-__"
Txtplace.Text = ""
cmdDel.Enabled = False
cmdSave.Enabled = False
If txtFind.Text = "" Then
cmdFind.Enabled = False
Else
cmdFind.Enabled = True
End If
End Sub
Private Sub txtFind_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If Not ((Chr(KeyAscii) <= "Z" And Chr(KeyAscii) >= "A") Or (Chr(KeyAscii) <= "9" And Chr(KeyAscii) >= "0") Or KeyAscii = 8) Then
KeyAscii = 0
End If
End Sub
Private Function RightProject() As Boolean
myModiproj.rsDK1 "select * from plan_info where project='" & txtproj.Text & "'"
If myModiproj.rs1.EOF Then
RightProject = False
Else
RightProject = True
End If
End Function
Private Sub txttime_GotFocus()
If cmdSave.Caption = "保存(&S)" Then
Txttime.Text = Format(Date, "yyyy/mm/dd")
End If
End Sub
Private Sub txttime_LostFocus()
Txttime.Text = Format(Txttime.Text, "yyyy/mm/dd")
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -