📄 frmworadd.frm
字号:
VERSION 5.00
Begin VB.Form FrmWoradd
BackColor = &H8000000D&
BorderStyle = 1 'Fixed Single
Caption = "添加工作量"
ClientHeight = 3825
ClientLeft = 45
ClientTop = 330
ClientWidth = 6510
Icon = "FrmWoradd.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MDIChild = -1 'True
ScaleHeight = 3825
ScaleWidth = 6510
Begin VB.Frame Frame2
BackColor = &H8000000D&
Height = 615
Left = 120
TabIndex = 14
Top = 3020
Width = 6255
Begin VB.CommandButton Cmdcancle
Caption = "取消"
Height = 375
Left = 4080
TabIndex = 16
Top = 170
Width = 1200
End
Begin VB.CommandButton Cmdok
Caption = "确定"
Default = -1 'True
Height = 375
Left = 960
TabIndex = 15
Top = 170
Width = 1200
End
End
Begin VB.Frame Frame1
BackColor = &H8000000D&
Height = 2895
Left = 120
TabIndex = 6
Top = 120
Width = 6255
Begin VB.TextBox renshu
BeginProperty DataFormat
Type = 1
Format = "0"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 1
EndProperty
Height = 330
Left = 4275
TabIndex = 8
Top = 2280
Width = 1600
End
Begin VB.ComboBox Comqi
Height = 300
ItemData = "FrmWoradd.frx":1E72
Left = 4275
List = "FrmWoradd.frx":1E7C
TabIndex = 3
Top = 1000
Width = 1600
End
Begin VB.ComboBox Comxue
BeginProperty DataFormat
Type = 1
Format = "0"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 1
EndProperty
Height = 300
ItemData = "FrmWoradd.frx":1E90
Left = 1200
List = "FrmWoradd.frx":1EC1
TabIndex = 2
Top = 1000
Width = 1600
End
Begin VB.ComboBox TxtName
Height = 300
Left = 4275
TabIndex = 1
Top = 360
Width = 1600
End
Begin VB.ComboBox txtbh
Height = 300
Left = 1200
TabIndex = 0
Top = 360
Width = 1600
End
Begin VB.TextBox txtrenshu
BeginProperty DataFormat
Type = 1
Format = "0"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 1
EndProperty
Height = 330
Left = 1200
TabIndex = 7
Top = 2300
Width = 1600
End
Begin VB.TextBox txtbanji
Height = 330
Left = 4275
TabIndex = 5
Top = 1650
Width = 1600
End
Begin VB.TextBox txtkech
Height = 330
Left = 1200
ScrollBars = 3 'Both
TabIndex = 4
Top = 1650
Width = 1600
End
Begin VB.Label Label6
BackColor = &H8000000D&
Caption = "人 数"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0080FFFF&
Height = 375
Left = 3285
TabIndex = 19
Top = 2295
Width = 1095
End
Begin VB.Label Label5
BackColor = &H8000000D&
Caption = "学 期"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0080FFFF&
Height = 375
Left = 3285
TabIndex = 18
Top = 1005
Width = 975
End
Begin VB.Label Label4
BackColor = &H8000000D&
Caption = "学 年"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0080FFFF&
Height = 375
Left = 240
TabIndex = 17
Top = 1000
Width = 1215
End
Begin VB.Label Label1
BackColor = &H8000000B&
BackStyle = 0 'Transparent
Caption = "教师编号"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0080FFFF&
Height = 375
Index = 5
Left = 240
TabIndex = 13
Top = 360
Width = 1095
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "教师姓名"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0080FFFF&
Height = 375
Index = 1
Left = 3285
TabIndex = 12
Top = 360
Width = 1095
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "课程名称"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0080FFFF&
Height = 375
Index = 1
Left = 240
TabIndex = 11
Top = 1650
Width = 1095
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "班 级 "
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0080FFFF&
Height = 375
Index = 4
Left = 3285
TabIndex = 10
Top = 1650
Width = 1095
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "课 时 "
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0080FFFF&
Height = 375
Index = 3
Left = 240
TabIndex = 9
Top = 2300
Width = 1095
End
End
End
Attribute VB_Name = "FrmWoradd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Cmdcancle_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim mrcc As ADODB.Recordset
Dim mrc As ADODB.Recordset
'定义字符串变量,表示查询语句
Dim txtSQL As String
'定义字符串变量,返回查询信息
Dim MsgText As String
'判断是否输入编号,编号是主键,不能为空
If Not Testtxt(txtbh.Text) Then
MsgBox "请输入教师编号!", vbOKOnly + vbExclamation, "警告"
txtbh.SetFocus
Exit Sub
End If
If Not Testtxt(txtName.Text) Then
MsgBox "请输入教师姓名!", vbOKOnly + vbExclamation, "警告"
txtName.SetFocus
Exit Sub
End If
'判断课时是否输入数字
If Testtxt(txtrenshu.Text) Then
If Not IsNumeric(Trim(txtrenshu.Text)) Then
MsgBox "课时请输入数字!", vbOKOnly + vbExclamation, "警告"
txtrenshu.SetFocus
Exit Sub
End If
End If
'判断是否有该教师的记录
txtSQL = "select * from personnel_infor where personnel_id = '" & Trim(txtbh.Text) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = True Then
str2$ = MsgBox("教师编号不正确或是新来教师!" & Chr(13) & " 添加人员信息?", vbOKCancel, "警告")
If str2$ = vbOK Then
Unload FrmWoradd
FrmRenadd.Show
Else
txtbh.SetFocus
Exit Sub
End If
Else
If Trim(mrc.Fields(1)) <> Trim(txtName) Then
MsgBox "教师编号与教师姓名不符!", vbOKOnly + vbExclamation, "警告"
txtbh.SetFocus
Exit Sub
Else
'判断教师工作量表中是否有重复记录
txtSQL = "select * from gongzuoliang where Personnel_id = '" & Trim(txtbh.Text) & "'"
Set mrcc = ExecuteSQL(txtSQL, MsgText)
'如果数据库中没有编号相同记录,则一定不重复
If mrcc.EOF = True Then
mrcc.Close
'如果有记录,就应该不能再添加既无课程名又班级数和课时数的记录
Else
If Trim(txtkech) = "" Or Trim(txtrenshu) = "" Then
MsgBox "教师工作量信息重复!", vbOKOnly + vbExclamation, "警告"
txtbh.Text = ""
txtName.Text = ""
txtkech.Text = ""
txtbanji.Text = ""
txtrenshu.Text = ""
mrcc.Close
Exit Sub
End If
mrcc.MoveFirst
Do While Not mrcc.EOF
If Trim(mrcc.Fields(0)) = Trim(txtbh.Text) And Trim(mrcc.Fields(1)) = Trim(txtName.Text) _
And Trim(mrcc.Fields(2)) = Trim(txtkech.Text) And Trim(mrcc.Fields(3)) = Trim(txtbanji.Text) _
And Trim(mrcc.Fields(4)) = Trim(txtrenshu.Text) Then
MsgBox "教师工作量信息重复!", vbOKOnly + vbExclamation, "警告"
txtbh.Text = ""
txtName.Text = ""
txtkech.Text = ""
txtbanji.Text = ""
txtrenshu.Text = ""
mrcc.Close
Exit Sub
End If
mrcc.MoveNext
Loop
mrcc.Close
End If
End If
mrc.Close
txtSQL = "select * from gongzuoliang"
'执行查询操作
Set mrc = ExecuteSQL(txtSQL, MsgText)
'添加记录
mrc.AddNew
mrc.Fields(0) = Trim(txtbh.Text)
mrc.Fields(1) = Trim(txtName.Text)
mrc.Fields(2) = Trim(txtkech.Text)
mrc.Fields(3) = Trim(txtbanji.Text)
mrc.Fields(4) = Trim(txtrenshu.Text)
mrc.Fields(5) = Trim(Comxue.Text)
mrc.Fields(6) = Trim(Comqi.Text)
mrc.Fields(7) = Trim(renshu.Text)
mrc.Update
MsgBox "添加信息成功", vbOKOnly + vbExclamation, "警告"
'关闭数据集对象
mrc.Close
txtbh.Text = ""
txtName.Text = ""
txtkech.Text = ""
txtbanji.Text = ""
txtrenshu.Text = ""
Comxue.Text = ""
Comqi.Text = ""
renshu.Text = ""
Me.Hide
End If
End Sub
Private Sub Form_Load()
Dim txtSQL As String
Dim MsgText As String
Dim mrcc As ADODB.Recordset
'数据库中如果没有信息,则询问添加
txtSQL = "select personnel_id ,name from personnel_infor"
Set mrcc = ExecuteSQL(txtSQL, MsgText)
If Not mrcc.EOF Then
mrcc.MoveFirst
Do While Not mrcc.EOF
txtbh.AddItem Trim(mrcc.Fields(0))
txtName.AddItem Trim(mrcc.Fields(1))
'移动到下一条记录
mrcc.MoveNext
Loop
End If
mrcc.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -