📄 frmdept.frm
字号:
'Dim pic() As Byte
Dim Filename As String
Private Sub Command1_Click()
Dim strYYY As String
Dim rs As New ADODB.Recordset
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Then
MsgBox "工号,姓名,身份证号不能为空!", vbInformation, "系统提示"
Exit Sub
End If
If rs.State = 1 Then rs.Close
rs.Open "select 工号 from T_员工表 where 工号='" & Text1.Text & "'", gCnn, adOpenStatic, adLockReadOnly
If rs.RecordCount > 0 Then
' strYYY = "update T_员工表 set 姓名='" & Text2 & "',身份证号='" & Text3 & "',出生年月='" & Format(Text5, "yyyy-mm-dd") & "',性别='" & Text4 & "',电话='" & Text6 & "',"
' strYYY = strYYY & "手机='" & Text7 & "',电子邮箱='" & Text8 & "',住址='" & Text9 & "',民族='" & Text10 & "',毕业院校='" & Text11 & "',所学专业='" & Text12 & "',上班日期='" & Format(DTPicker1, "yyyy-mm-dd") & "',"
' strYYY = strYYY & "学历='" & Combo1 & "',职务='" & Combo2 & "',职称='" & Combo3 & "',部门='" & Combo4 & "',员工状态='" & Combo5 & "' where 工号='" & Text1 & "'"
MsgBox "员工工号重复,请核对!", vbInformation, "系统提示"
Exit Sub
Else
strYYY = "insert into T_员工表(工号,姓名,身份证号,性别,出生年月,电话,手机,电子邮箱,住址,民族,毕业院校,所学专业,上班日期,学历,职务,职称,部门,员工状态) "
strYYY = strYYY & " values('" & Text1 & "','" & Text2 & "','" & Text3 & "','" & Text4 & "','" & Format(Text5, "yyyy-mm-dd") & "','" & Text6 & "','" & Text7 & "',"
strYYY = strYYY & "'" & Text8 & "','" & Text9 & "','" & Text10 & "','" & Text11 & "','" & Text12 & "','" & Format(DTPicker1, "yyyy-mm-dd") & "','" & Combo1 & "',"
strYYY = strYYY & "'" & Combo2 & "','" & Combo3 & "','" & Combo4 & "','" & Combo5 & "')"
End If
gCnn.Execute strYYY
MsgBox "保存成功!", vbInformation, "系统提示"
Call Form_Load
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Command4_Click()
Call Form_Load
End Sub
Private Sub Form_Load()
'ID,工号,姓名,性别,出生年月,身份证号,电话,手机,电子邮箱,住址,学历,民族,毕业院校,所学专业,上班日期,职务,职称,部门,员工状态,奖惩记录,培训记录,照片 T_员工表
Dim rs As New ADODB.Recordset
If Me.WindowState = 0 Then Me.Move 0, 0
Call ShowHead
If rs.State = 1 Then rs.Close
MSFlexGrid1.Rows = 1
gSQL = "select 工号,姓名,身份证号,性别,出生年月,电话,手机,电子邮箱,住址,民族,毕业院校,所学专业,上班日期,学历,职务,职称,部门,员工状态 from T_员工表 "
rs.Open gSQL, gCnn, adOpenStatic, adLockReadOnly
If rs.RecordCount >= 1 Then
rs.MoveFirst
Do While Not rs.EOF
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
MSFlexGrid1.Row = MSFlexGrid1.Rows - 1
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 0) = rs.Fields(0).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1) = rs.Fields(1).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 2) = rs.Fields(2).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 3) = rs.Fields(3).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 4) = rs.Fields(4).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 5) = rs.Fields(5).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 6) = rs.Fields(6).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 7) = rs.Fields(7).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 8) = rs.Fields(8).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 9) = rs.Fields(9).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 10) = rs.Fields(10).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 11) = rs.Fields(11).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 12) = rs.Fields(12).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 13) = rs.Fields(13).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 14) = rs.Fields(14).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 15) = rs.Fields(15).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 16) = rs.Fields(16).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 17) = rs.Fields(17).Value
rs.MoveNext
Loop
End If
If rs.State = 1 Then rs.Close
rs.Open "select VALUEID,VALUE from PARAMETERS where PARATYPE=2 order by VALUEID", gCnn, adOpenKeyset, adLockReadOnly, adCmdText
strMsg = AddListItem(Combo1, rs)
If strMsg <> "0" Then MsgBox strMsg, vbCritical, "系统提示"
Combo1.Text = Combo1.List(0)
If rs.State = 1 Then rs.Close
rs.Open "select VALUEID,VALUE from PARAMETERS where PARATYPE=3 order by VALUEID", gCnn, adOpenKeyset, adLockReadOnly, adCmdText
strMsg = AddListItem(Combo2, rs)
If strMsg <> "0" Then MsgBox strMsg, vbCritical, "系统提示"
Combo2.Text = Combo2.List(0)
If rs.State = 1 Then rs.Close
rs.Open "select VALUEID,VALUE from PARAMETERS where PARATYPE=1 order by VALUEID", gCnn, adOpenKeyset, adLockReadOnly, adCmdText
strMsg = AddListItem(Combo3, rs)
If strMsg <> "0" Then MsgBox strMsg, vbCritical, "系统提示"
Combo3.Text = Combo3.List(0)
If rs.State = 1 Then rs.Close
rs.Open "select VALUEID,VALUE from PARAMETERS where PARATYPE=4 order by VALUEID", gCnn, adOpenKeyset, adLockReadOnly, adCmdText
strMsg = AddListItem(Combo4, rs)
If strMsg <> "0" Then MsgBox strMsg, vbCritical, "系统提示"
Combo4.Text = Combo4.List(0)
If rs.State = 1 Then rs.Close
rs.Open "select VALUEID,VALUE from PARAMETERS where PARATYPE=5 order by VALUEID", gCnn, adOpenKeyset, adLockReadOnly, adCmdText
strMsg = AddListItem(Combo5, rs)
If strMsg <> "0" Then MsgBox strMsg, vbCritical, "系统提示"
Combo5.Text = Combo5.List(0)
gtxtclear
End Sub
Private Sub ShowHead()
'MSFlexGrid1设置
strHead = "工号,姓名,性别,出生年月,身份证号,电话,手机,电子邮箱,住址,民族,毕业院校,所学专业,上班日期,学历,职务,职称,部门,员工状态"
strWid = "800,1100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
FillGridHead MSFlexGrid1, strHead, strWid
End Sub
Private Sub MSFlexGrid1_Click()
If MSFlexGrid1.Rows = 1 Then Exit Sub
If MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1) = "" Then Exit Sub
Text1.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 0)
Text1.Enabled = False
Text2.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1)
Text3.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 2)
Text4.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 3)
Text5.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 4)
Text6.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 5)
Text7.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 6)
Text8.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 7)
Text9.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 8)
Text10.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 9)
Text11.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 10)
Text12.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 11)
DTPicker1 = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 12)
Combo1.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 13)
Combo2.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 14)
Combo3.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 15)
Combo4.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 16)
Combo5.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 17)
End Sub
Public Sub gtxtclear()
Text1.Enabled = True
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
Text6 = ""
Text7 = ""
Text8 = ""
Text9 = ""
Text10 = ""
Text11 = ""
Text12 = ""
DTPicker1 = Date
' Combo1 = ""
' Combo2 = ""
' Combo3 = ""
' Combo4 = ""
' Combo5 = ""
' Image1.Picture = LoadPicture("")
' Label1.Visible = True
End Sub
Private Sub Text3_LostFocus()
On Error GoTo Err_Handle
If Trim(Text3) = "" Then
MsgBox "请输入身份证号!", vbCritical, "系统提示"
Text3.SetFocus
Exit Sub
Else
If Len(Trim(Text3)) <> 15 And Len(Trim(Text3)) <> 18 Then
MsgBox "身份证号为15位或者18位!", vbCritical, "系统提示 "
Text3.SetFocus
Exit Sub
Else
If Len(Trim(Text3)) = 18 Then
Text5 = Format(DateSerial(Mid(Trim(Text3), 7, 4), Mid(Trim(Text3), 11, 2), Mid(Trim(Text3), 13, 2)), "yyyy-MM-dd")
If Mid(Trim(Text3), 17, 1) Mod 2 = 0 Then
Text4.Text = "女"
Else
Text4.Text = "男"
End If
Else
Text5 = Format(DateSerial(Mid(Trim(Text3), 7, 2), Mid(Trim(Text3), 9, 2), Mid(Trim(Text3), 11, 2)), "yyyy-MM-dd")
If Right(Trim(Text3), 1) Mod 2 = 0 Then
Text4.Text = "女"
Else
Text4.Text = "男"
End If
End If
End If
End If
Exit Sub
Err_Handle:
If Err.Number = 13 Then
MsgBox "确认身份证号是否正确!", vbInformation, "系统提示"
Text3.SetFocus
Else
MsgBox Err.Description, vbInformation, "系统提示"
End If
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
Private Sub Text10_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
Private Sub Text11_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
Private Sub Text12_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
Private Sub Text3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
Private Sub Text4_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
Private Sub Text5_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
Private Sub Text6_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
Private Sub Text7_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
Private Sub Text8_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
Private Sub Text9_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
Private Sub Combo2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
Private Sub Combo3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
Private Sub Combo4_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
Private Sub Combo5_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
Private Sub DTPicker1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then SendKeys "{tab}"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -