📄 frm_infoinput.frm
字号:
Begin VB.Label Label1
Caption = "家庭住址"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 7
Left = 4050
TabIndex = 28
Top = 1170
Width = 885
End
Begin VB.Label Label1
Caption = "专 业"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 6
Left = 4050
TabIndex = 27
Top = 780
Width = 885
End
Begin VB.Label Label1
Caption = "学 历"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 5
Left = 4050
TabIndex = 26
Top = 450
Width = 885
End
Begin VB.Label Label1
Caption = "年 龄"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 4
Left = 450
TabIndex = 25
Top = 2010
Width = 885
End
Begin VB.Label Label1
Caption = "出生日期"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 3
Left = 450
TabIndex = 24
Top = 1590
Width = 885
End
Begin VB.Label Label1
Caption = "性 别"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 2
Left = 450
TabIndex = 23
Top = 1200
Width = 885
End
Begin VB.Label Label1
Caption = "职工姓名"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 1
Left = 450
TabIndex = 22
Top = 810
Width = 885
End
Begin VB.Label Label1
Caption = "职工编号"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 0
Left = 450
TabIndex = 20
Top = 420
Width = 885
End
End
End
Attribute VB_Name = "Frm_InfoInput"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
End Sub
Private Sub BornDate_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub BSalaryDate_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Cmd_Cancel_Click()
Unload Me
End Sub
Private Sub Cmd_Save_Click()
Dim m_Rs As New ADODB.Recordset
Dim i As Integer
Dim strSql As String
''''''检查输入的正确性结束'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If iFlag = 0 Then
'''''''检查输入的正确性''''''''''''''''''''''''
If Text1.Text = "" Then
MsgBox "职工编号不能为空..."
Exit Sub
End If
strSql = "SELECT * FROM StuffInfo WHERE SID='" & Trim(Text1.Text) & "'"
If isRecordExist(strSql, "Person.mdb") Then
MsgBox "此职工编号的记录已经存在..."
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "职工姓名不能为空...", vbOKOnly + vbExclamation, "警告!"
Exit Sub
''Me.Text2.SetFocus
End If
If Combo1.Text = "" Then
MsgBox "职工出生日期不能为空...", vbOKOnly + vbExclamation, "警告!"
Exit Sub
End If
If Not IsDate(BornDate.Text) Then
MsgBox "职工出生日期格式错误,输入正确的日期格式...", vbOKOnly + vbExclamation, "警告!"
Exit Sub
End If
If Combo4.Text = "" Then
MsgBox "请输入部门名称...", vbOKOnly + vbExclamation, "警告!"
Exit Sub
End If
''''''进行存盘操作''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If MsgBox("确定是否存盘?", vbYesNo + vbQuestion, "存盘?") = vbYes Then
strSql = "INSERT INTO StuffInfo(SID,SName,SGender,SPlace,SAge,SBirthday,SDegree,SSpecial,SAddress,SCode,STel,SEmail"
strSql = strSql & ",SWorkTime,SInTime,SDept,SPayTime,SPosition,SRemark) VALUES('" & Trim(Text1.Text) & "','" & Trim(Text2.Text) & "','" & Trim(Combo1.Text) & "','" & Trim(Text9.Text) & "'," & Val(Text3.Text) & ",'"
strSql = strSql & Trim(BornDate.Text) & "','" & Trim(Combo2.Text) & "','" & Trim(Text4.Text) & "','" & Trim(Text5.Text) & "','"
strSql = strSql & Trim(Text6.Text) & "','" & Trim(Text7.Text) & "','" & Trim(Text8.Text) & "','" & Trim(WorkDate.Text) & "','" & Trim(InDate.Text) & "','"
strSql = strSql & Trim(Combo4.Text) & "','" & Trim(BSalaryDate.Text) & "','" & Trim(Combo3.Text) & "','" & Trim(Text10.Text) & "')"
MsgBox strSql
Set m_Rs = ExecuteSQL(strSql, "Person.mdb")
MsgBox "存盘成功..."
'''''''自动计算职工编号'''''''''''''''''''''
Dim i_RecordCount As Integer
strSql = "SELECT COUNT(*) FROM StuffInfo"
i_RecordCount = getRstCount(strSql, "Person.mdb") + 1 '''''得到记录个数,然后加1
Text1.Text = "P" + Trim(Str(1000000 + i_RecordCount))
'''''''初始化各个文本控件'''''''''''''''''
With Me
Text2.Text = ""
Combo1.Text = ""
Text9.Text = ""
Text3.Text = ""
''BornDate.Text = ""
Combo2.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
''WorkDate.Text = ""
''IDate.Text = ""
''BSalaryDate.Text = ""
Combo3.Text = ""
Text10.Text = ""
Combo4.Text = ""
End With
End If
ElseIf iFlag = 1 Then ''''''1代表修改记录''''''''''''''
''MsgBox sData(0)
If MsgBox("确定是否修改记录?", vbYesNo + vbQuestion, "修改?") = vbYes Then
strSql = "UPDATE StuffInfo Set SName='" & Trim(Text2.Text) & "',SGender='" & Trim(Combo1.Text) & "',SPlace='" & Trim(Text9.Text) & "',SBirthday='" & Trim(BornDate.Text) & "',SAge="
strSql = strSql & Trim(Text3.Text) & ",SDegree='" & Trim(Combo2.Text) & "',SSpecial='" & Trim(Text4.Text) & "',SAddress='" & Trim(Text5.Text) & "',SCode='" & Trim(Text6.Text) & "',STel='"
strSql = strSql & Trim(Text7.Text) & "',SEmail='" & Trim(Text8.Text) & "',SWorkTime='" & Trim(WorkDate.Text) & "',SInTime='" & Trim(InDate.Text) & "',SPayTime='" & Trim(BSalaryDate.Text)
strSql = strSql & "',SDept='" & Trim(Combo4.Text) & "',SPosition='" & Trim(Combo3.Text) & "',SRemark='" & Trim(Text10.Text) & "' WHERE SID='" & Trim(sData(0)) & "'"
'MsgBox strSql
Set m_Rs = ExecuteSQL(strSql, "Person.mdb")
MsgBox "修改成功..."
End If
ElseIf iFlag = 2 Then
If MsgBox("确定是否删除此记录?", vbYesNo + vbQuestion, "删除?") = vbYes Then
strSql = "DELETE * FROM StuffInfo WHERE SID='" & Trim(Text1.Text) & "'"
Set m_Rs = ExecuteSQL(strSql, "Person.mdb")
MsgBox "删除成功..."
End If
End If
End Sub
Private Sub Cmd_OK_Click()
End Sub
Private Sub Combo1_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Combo2_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Combo3_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Combo4_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Form_Load()
''''添加信息'''''''''
Combo1.AddItem "男"
Combo1.AddItem "女"
''''''
Combo2.AddItem "小学"
Combo2.AddItem "初中"
Combo2.AddItem "高中"
Combo2.AddItem "技校"
Combo2.AddItem "中专"
Combo2.AddItem "专科"
Combo2.AddItem "大专"
Combo2.AddItem "本科"
Combo2.AddItem "硕士"
Combo2.AddItem "研究生"
Combo2.AddItem "博士"
'''''自动计算职工的编号''''''''''''''''''''
Dim m_Rs As New ADODB.Recordset
Dim strSql As String
Dim i As Integer
Dim i_RecordCount As Integer
If iFlag = 0 Then
strSql = "SELECT COUNT(*) FROM StuffInfo"
i_RecordCount = getRstCount(strSql, "Person.mdb") + 1 '''''得到记录个数,然后加1
Text1.Text = "P" + Trim(Str(1000000 + i_RecordCount))
''''''''''''''''
WorkDate.Text = Format(Now, "yyyy年mm月dd日")
BSalaryDate.Text = Format(Now, "yyyy年mm月dd日")
InDate.Text = Format(Now, "yyyy年mm月dd日")
With Me
Text2.Text = ""
Combo1.Text = ""
Text9.Text = ""
Text3.Text = ""
''BornDate.Text = ""
Combo2.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
''WorkDate.Text = ""
''IDate.Text = ""
''BSalaryDate.Text = ""
Combo3.Text = ""
Text10.Text = ""
Combo4.Text = ""
End With
End If
'''iFlag = 0 ''''''0代表增加记录'''''''
'''''''''''iFlag=1代表是修改记录''''''''''
If iFlag = 1 Then
With Me
Text1.Text = Trim(sData(0))
Text2.Text = Trim(sData(1))
Combo4.Text = Trim(sData(2))
Combo1.Text = Trim(sData(3))
Text9.Text = Trim(sData(4))
Text3.Text = sData(5)
BornDate.Text = sData(6)
Combo2.Text = Trim(sData(7))
Text4.Text = Trim(sData(8))
Text5.Text = Trim(sData(9))
Text6.Text = Trim(sData(10))
Text7.Text = Trim(sData(11))
Text8.Text = Trim(sData(12))
WorkDate.Text = sData(13)
InDate.Text = sData(14)
BSalaryDate.Text = sData(15)
Combo3.Text = sData(16)
Text10.Text = sData(19)
End With
End If
''''''''iFlag=2是代表删除记录''''''''''
If iFlag = 2 Then
With Me
Text1.Text = Trim(sData(0))
Text2.Text = Trim(sData(1))
Combo4.Text = Trim(sData(2))
Combo1.Text = Trim(sData(3))
Text9.Text = Trim(sData(4))
Text3.Text = sData(5)
BornDate.Text = sData(6)
Combo2.Text = Trim(sData(7))
Text4.Text = Trim(sData(8))
Text5.Text = Trim(sData(9))
Text6.Text = Trim(sData(10))
Text7.Text = Trim(sData(11))
Text8.Text = Trim(sData(12))
WorkDate.Text = sData(13)
InDate.Text = sData(14)
BSalaryDate.Text = sData(15)
Combo3.Text = sData(16)
Text10.Text = sData(19)
End With
End If
End Sub
Private Sub InDate_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Text10_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Text3_GotFocus()
''''''根据出生日期自动计算年龄'''''''''''''
Dim iAge As Integer
If BornDate.Text = "" Then
MsgBox "出生日期输入错误...", vbOKOnly + vbExclamation, "警告!"
Combo1.SetFocus
End If
iAge = Val(Mid(Trim(Format(Now, "yyyy-mm-dd")), 1, 4)) - Val(Mid(Trim(Format(BornDate.Text, "yyyy-mm-dd")), 1, 4)) + 1
Text3.Text = Trim(Str(iAge))
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Text6_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Text7_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Text8_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub Text9_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
Private Sub WorkDate_KeyPress(KeyAscii As Integer)
TabToEnter (KeyAscii)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -