📄 部门信息添加.frm
字号:
VERSION 5.00
Begin VB.Form Form8
Caption = "Form8"
ClientHeight = 3915
ClientLeft = 60
ClientTop = 420
ClientWidth = 5415
LinkTopic = "Form8"
ScaleHeight = 3915
ScaleWidth = 5415
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame2
Caption = "操 作"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1095
Left = 840
TabIndex = 9
Top = 2640
Width = 3735
Begin VB.CommandButton Command2
Caption = "取 消"
Height = 375
Left = 2280
TabIndex = 11
Top = 360
Width = 975
End
Begin VB.CommandButton Command1
Caption = "添加部门信息"
Height = 375
Left = 480
TabIndex = 10
Top = 360
Width = 1335
End
End
Begin VB.Frame Frame1
Caption = "部门信息"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2175
Left = 240
TabIndex = 1
Top = 240
Width = 4935
Begin VB.TextBox Text4
Height = 375
Left = 1440
TabIndex = 8
Top = 1560
Width = 2535
End
Begin VB.TextBox Text3
Height = 375
Left = 1320
TabIndex = 6
Top = 960
Width = 2295
End
Begin VB.TextBox Text2
Height = 375
Left = 3480
TabIndex = 4
Top = 360
Width = 1095
End
Begin VB.TextBox Text1
Height = 390
Left = 1080
TabIndex = 0
Top = 360
Width = 975
End
Begin VB.Label Label4
Caption = "部门办公处"
Height = 255
Left = 240
TabIndex = 7
Top = 1680
Width = 975
End
Begin VB.Label Label3
Caption = "部门电话"
Height = 255
Left = 240
TabIndex = 5
Top = 1080
Width = 855
End
Begin VB.Label Label2
Caption = "部门名称"
Height = 255
Left = 2400
TabIndex = 3
Top = 480
Width = 855
End
Begin VB.Label Label1
Caption = "部门号"
Height = 255
Left = 240
TabIndex = 2
Top = 480
Width = 615
End
End
End
Attribute VB_Name = "Form8"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rst As New ADODB.Recordset '定义Recordset对象
Dim strSql As String
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "部门信息输入不完整,请输入部门号!", vbInformation + vbOKCancel + vbApplicationModal, "提示"
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "部门信息输入不完整,请输入部门名称!", vbInformation + vbOKCancel + vbApplicationModal, "提示"
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "部门信息输入不完整,请输入部门电话!", vbInformation + vbOKCancel + vbApplicationModal, "提示"
Exit Sub
End If
If Text4.Text = "" Then
MsgBox "部门信息输入不完整,请输入部门办公处!", vbInformation + vbOKCancel + vbApplicationModal, "提示"
Exit Sub
End If
If rst.State = adStateOpen Then
rst.Close
End If
strSql = "select * from bmxx where 部门号='" & Text1.Text & "'"
rst.Open strSql, cnn, 1, 1
If Not rst.EOF Then
MsgBox "该部门号已存在,请重新输入!", vbInformation + vbOKOnly + vbApplicationModal, "提示"
Text1.Text = ""
Text1.SetFocus
Exit Sub
Else
If rst.State = adStateOpen Then
rst.Close
End If
If IsNumeric(Text1.Text) = False Then
MsgBox "部门号必须是数值!请重新输入!", vbInformation + vbOKOnly + vbApplicationModal, "提示"
Text1.Text = ""
Text1.SetFocus
Exit Sub
End If
strSql = "insert into bmxx values('" & Text1.Text & "','" & Text2.Text & "','" & Text3.Text & "','" & Text4.Text & "')"
rst.Open strSql, cnn, 1, 1
MsgBox "成功增加部门信息!", vbInformation + vbOKOnly + vbApplicationModal, "提示"
Call Form6.Info
Form6.Show
Unload Me
End If
End Sub
Private Sub Command2_Click()
Unload Me
Form6.Show
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -