frmemployee.frm
来自「通用书店管理系统」· FRM 代码 · 共 271 行
FRM
271 行
VERSION 5.00
Begin VB.Form frmEmployee
Appearance = 0 'Flat
BackColor = &H00C0E0FF&
Caption = "员工资料管理"
ClientHeight = 2610
ClientLeft = 60
ClientTop = 345
ClientWidth = 3210
KeyPreview = -1 'True
LinkTopic = "Form1"
ScaleHeight = 2610
ScaleWidth = 3210
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Txtfields
Appearance = 0 'Flat
BackColor = &H00FFFFFF&
Height = 375
Index = 3
Left = 1080
TabIndex = 3
Top = 1380
Width = 1815
End
Begin VB.TextBox Txtfields
Appearance = 0 'Flat
BackColor = &H00FFFFFF&
Height = 375
Index = 2
Left = 1080
TabIndex = 2
Top = 960
Width = 1815
End
Begin VB.TextBox Txtfields
Appearance = 0 'Flat
BackColor = &H00FFFFFF&
Height = 375
Index = 0
Left = 1080
TabIndex = 0
Top = 120
Width = 1815
End
Begin VB.TextBox Txtfields
Appearance = 0 'Flat
BackColor = &H00FFFFFF&
Height = 375
Index = 1
Left = 1080
TabIndex = 1
Top = 540
Width = 1815
End
Begin VB.CommandButton cmdSave
Appearance = 0 'Flat
Height = 435
Left = 480
Picture = "frmEmployee.frx":0000
Style = 1 'Graphical
TabIndex = 4
Top = 1980
Width = 945
End
Begin VB.CommandButton cmdExit
Appearance = 0 'Flat
Height = 435
Left = 1740
Picture = "frmEmployee.frx":14E4
Style = 1 'Graphical
TabIndex = 5
Top = 1980
Width = 960
End
Begin VB.Label Label4
Alignment = 2 'Center
BackColor = &H00E0E0E0&
BackStyle = 0 'Transparent
Caption = "性别"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 0
TabIndex = 9
Top = 1500
Width = 975
End
Begin VB.Label Label3
Alignment = 2 'Center
BackColor = &H00E0E0E0&
BackStyle = 0 'Transparent
Caption = "部门"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 0
TabIndex = 8
Top = 1080
Width = 975
End
Begin VB.Label Label1
Alignment = 2 'Center
BackColor = &H00E0E0E0&
BackStyle = 0 'Transparent
Caption = "工号"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 60
TabIndex = 7
Top = 240
Width = 870
End
Begin VB.Label Label2
Alignment = 2 'Center
BackColor = &H00E0E0E0&
BackStyle = 0 'Transparent
Caption = "姓名"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 0
TabIndex = 6
Top = 660
Width = 975
End
End
Attribute VB_Name = "frmEmployee"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public blnAddNew As Boolean
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub CmdSave_Click()
Dim sqlstring As String
Dim rstmp As New ADODB.Recordset
On Error GoTo SaveErr
If blnAddNew Then
If Trim(txtFields(0).Text) = "" Or Trim(txtFields(1).Text) = "" Then
MsgBox "编码、名称不能为空!", vbInformation
Exit Sub
End If
' If Trim(Txtfields(2).Text) = "" Then
' MsgBox "请输入税率!", vbInformation
' Exit Sub
' End If
'
If CheckExist Then
MsgBox "此员工记录已存在,请修改。", vbInformation + vbOKOnly
Call setselect(txtFields(0))
Exit Sub
End If
sqlstring = "Insert into tper_basEmployee (chrEmployeeId,ChrEmployee,chrDepartment,chrSex) values " & _
"('" & txtFields(0).Text & "','" & txtFields(1).Text & "','" & txtFields(2).Text & "'" & _
",'" & txtFields(3).Text & "')"
cN.BeginTrans
cN.Execute (sqlstring)
cN.CommitTrans
Unload Me
Call frmFields.cmdRefresh_Click
Else
If Trim(txtFields(0).Text) = "" Or Trim(txtFields(1).Text) = "" Then
MsgBox "编码、名称不能为空!", vbInformation
Exit Sub
End If
sqlstring = "Update tper_basEmployee set ChrEmployee='" & txtFields(1).Text & "', " & _
"chrDepartment='" & txtFields(2).Text & "',chrSex='" & txtFields(3).Text & _
"' where chrEmployeeId='" & Trim(txtFields(0).Text) & "'"
cN.BeginTrans
cN.Execute (sqlstring)
cN.CommitTrans
Unload Me
Call frmFields.cmdRefresh_Click
End If
Exit Sub
SaveErr:
cN.RollbackTrans
MsgBox "保存记录失败:" & err.Description, vbInformation
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
' Call autoreturn(KeyCode)
If KeyCode = vbKeyReturn Then
SendKeys "{TAB}"
Exit Sub
End If
End Sub
Private Function CheckExist() As Boolean
Dim sqlstring As String
Dim rstmp As New ADODB.Recordset
On Error GoTo err
sqlstring = "select * from tper_basEmployee where chrEmployeeId='" & Trim(txtFields(0).Text) & "'"
rstmp.Open sqlstring, cN, adOpenKeyset, adLockReadOnly
If rstmp.EOF Then
CheckExist = False
Else
CheckExist = True
End If
Exit Function
err:
MsgBox "打开记录失败:" & err.Description, vbInformation
End Function
Private Sub txtFields_KeyPress(Index As Integer, KeyAscii As Integer)
Select Case Index
Case 0
KeyAscii = ValiText(KeyAscii, vbExpChar, "0123456789", txtFields(Index).Text, 5)
Case 3
KeyAscii = ValiText(KeyAscii, vbExpDefault, "男女", txtFields(Index).Text)
' Case 4
' KeyAscii = ValiText(KeyAscii, vbExpInteger, "", TxtFields(Index).Text)
' Case 5
' KeyAscii = ValiText(KeyAscii, vbExpDecimal, "", TxtFields(Index).Text)
End Select
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?