📄 添加员工信息.frm
字号:
Begin VB.CommandButton CmdQuXiao
Caption = "取 消"
Height = 300
Left = 2760
TabIndex = 17
Top = 2340
Width = 800
End
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 2640
Top = 1320
Visible = 0 'False
Width = 1200
_ExtentX = 2117
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Bookdate;Data Source=127.0.0.1"
OLEDBString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Bookdate;Data Source=127.0.0.1"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = "sa"
Password = ""
RecordSource = "Employee"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Label LabEditId
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
ForeColor = &H000080FF&
Height = 255
Left = 1200
TabIndex = 30
Top = 360
Width = 1335
End
Begin VB.Label Label12
AutoSize = -1 'True
Caption = "员工电话:"
Height = 180
Left = 240
TabIndex = 24
Top = 2040
Width = 900
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "员工编号:"
Height = 180
Left = 240
TabIndex = 23
Top = 360
Width = 900
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "员工姓名:"
Height = 180
Left = 240
TabIndex = 22
Top = 780
Width = 900
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "员工工资:"
Height = 180
Left = 240
TabIndex = 21
Top = 1620
Width = 900
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "员工性别:"
Height = 180
Left = 240
TabIndex = 20
Top = 1200
Width = 900
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "证件号码:"
Height = 180
Left = 240
TabIndex = 19
Top = 2445
Width = 900
End
Begin VB.Image Image2
Height = 780
Left = 2760
Picture = "添加员工信息.frx":150F
Top = 480
Width = 780
End
End
Begin VB.Label LabId
Caption = "Label11"
Height = 375
Left = 1680
TabIndex = 15
Top = 3360
Width = 1215
End
End
Attribute VB_Name = "frmAddEmployee"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub CmdOk_Click()
If TxtAddEmpId = "" Then
MsgBox "请输员工编号", vbOKOnly + vbExclamation, "提示"
Else
frmEmployee.Adodc1.CommandType = adCmdText
frmEmployee.Adodc1.RecordSource = "select * from employee"
frmEmployee.Adodc1.Refresh
Dim n%
For n = 1 To frmEmployee.Adodc1.Recordset.RecordCount
If TxtAddEmpId = frmEmployee.Adodc1.Recordset.Fields("emp_id") Then
MsgBox "这个编号已经有人了,请重新输入", vbExclamation, "编号重复"
TxtAddEmpId = "": TxtAddEmpName = "": TxtAddEmpSalary = ""
TxtAddEmpTel = "": TxtAddEmpSid = ""
Exit Sub
Else
frmEmployee.Adodc1.Recordset.MoveNext
End If
Next n
frmEmployee.Adodc1.Recordset.AddNew
frmEmployee.Adodc1.Recordset.Fields("emp_id") = TxtAddEmpId
frmEmployee.Adodc1.Recordset.Fields("emp_name") = TxtAddEmpName
frmEmployee.Adodc1.Recordset.Fields("emp_sex") = CobAddEmpSex.Text
frmEmployee.Adodc1.Recordset.Fields("emp_salary") = TxtAddEmpSalary
frmEmployee.Adodc1.Recordset.Fields("emp_tel") = TxtAddEmpTel
frmEmployee.Adodc1.Recordset.Fields("emp_sid") = TxtAddEmpSid
AddorEdit = "添加"
' Adodc1.Recordset.Update
' Adodc1.Refresh
Unload Me
End If
End Sub
Private Sub CmdOkEd_Click()
frmEmployee.Adodc1.Recordset.Update
frmEmployee.Adodc1.Recordset.Fields("emp_id") = LabEditId
frmEmployee.Adodc1.Recordset.Fields("emp_name") = TxtEmpName
frmEmployee.Adodc1.Recordset.Fields("emp_sex") = CobEmpSex.Text
frmEmployee.Adodc1.Recordset.Fields("emp_salary") = TxtEmpSalary
frmEmployee.Adodc1.Recordset.Fields("emp_tel") = TxtEmpTel
frmEmployee.Adodc1.Recordset.Fields("emp_sid") = TxtEmpSid
AddorEdit = "修改"
Unload Me
End Sub
Private Sub CmdQuXiao_Click()
Call Command2_Click
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
frmAddEmployee.Height = 3645
frmAddEmployee.Width = 4185
frmAddEmployee.Top = 1500
frmAddEmployee.Left = 3800
LabEditId = frmEmployee.Adodc1.Recordset.Fields("emp_id")
TxtEmpName = frmEmployee.Adodc1.Recordset.Fields("emp_name")
CobEmpSex.Text = frmEmployee.Adodc1.Recordset.Fields("emp_sex")
TxtEmpSalary = frmEmployee.Adodc1.Recordset.Fields("emp_salary")
TxtEmpTel = frmEmployee.Adodc1.Recordset.Fields("emp_tel")
TxtEmpSid = frmEmployee.Adodc1.Recordset.Fields("emp_sid")
LabId = LabByIdEd
End Sub
Private Sub TxtById_KeyPress(KeyAscii As Integer)
Select Case Chr(KeyAscii)
Case "0" To "9", Chr(8), Chr(46)
Case Else
KeyAscii = 0
End Select
End Sub
Private Sub TxtByTel_KeyPress(KeyAscii As Integer)
Select Case Chr(KeyAscii)
Case "0" To "9", Chr(8), Chr(46) 'Chr(8):退格键, Chr(46):小数点
Case Else
KeyAscii = 0
End Select
End Sub
Private Sub TxtByTelEd_KeyPress(KeyAscii As Integer)
Select Case Chr(KeyAscii)
Case "0" To "9", Chr(8), Chr(46)
Case Else
KeyAscii = 0
End Select
End Sub
Private Sub TxtAddEmpSalary_Change()
Select Case Chr(KeyAscii)
Case "0" To "9", Chr(8), Chr(46)
Case Else
KeyAscii = 0
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -