📄 main_jbzl_rygl.frm
字号:
Width = 960
End
Begin VB.CommandButton cmdSave
BackColor = &H80000004&
Caption = "[S]保存"
Enabled = 0 'False
Height = 360
Left = 7440
Style = 1 'Graphical
TabIndex = 23
Top = 195
Width = 960
End
End
End
Attribute VB_Name = "main_jbzl_rygl"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'*************************************************************************
'**模 块 名:main_jbzl_rygl
'**版权说明:吉林省明日科技有限公司享有本软件的所有版权,如果本软件用于商
'** 业用途,必须经过吉林省明日科技有限公司授权。如果提供网上免费
'** 下载,必须经过吉林省明日科技有限公司授权,并保证程序的完整,
'** 不得修改代码、注释和相关内容,否则,我公司将追究其法律责任
'**网 址:www.mingrisoft.com 价值无限,服务无限
'**电 话:(0431)84978981,84978982
'**创 建 人:明日科技
'**日 期:2007-10-31
'**修 改 人:MRLBB
'**日 期:2007-10-31
'**描 述:
'*************************************************************************
Dim i As Integer '定义整型变量
Dim rs1 As New ADODB.Recordset '定义数据集对象
Sub view_data() '定义一个显示数据的过程
If Adodc1.Recordset.RecordCount > 0 Then
With Adodc1.Recordset
If .Fields("编号") <> "" Then lblbh.Caption = .Fields("编号")
If .Fields("姓名") <> "" Then Text1(1) = .Fields("姓名")
If .Fields("性别") <> "" Then Combo1.text = .Fields("性别")
If .Fields("出生日期") <> "" Then DTPicker1.Value = .Fields("出生日期")
For i = 2 To 9
If .Fields(i) <> "" Then Text1(i) = .Fields(i + 2)
Next i
If .Fields("聘用日期") <> "" Then DTPicker2.Value = .Fields("聘用日期")
If .Fields("入职底薪") <> "" Then Text1(10) = .Fields("入职底薪")
If .Fields("在职与否") = True Then Check1.Value = 1 Else Check1.Value = 0
If .Fields("离职日期") <> "" Then DTPicker3.Value = .Fields("离职日期")
If .Fields("备注") <> "" Then Text1(11) = .Fields("备注")
End With
End If
End Sub
Private Sub Form_Load()
Adodc1.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=db_JXC;Data Source=."
Ado_update.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=db_JXC;Data Source=."
Set DataGrid1.DataSource = Adodc1
'初始化性别
Combo1.AddItem ("男"): Combo1.AddItem ("女"): Combo1.ListIndex = 0
'初始化查询内容
Combo4.AddItem ("编号"): Combo4.AddItem ("姓名")
Combo4.AddItem ("身份证号"): Combo4.AddItem ("性别")
Combo4.ListIndex = 1
Dim f1 As StdDataFormat
Set f1 = DataGrid1.Columns(13).DataFormat
f1.Format = "¥##0.00"
If Not Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveFirst
view_data '调用显示数据的过程
End If
For i = 1 To 11
Text1(i).Enabled = False
Next i
Combo1.Enabled = False: DTPicker1.Enabled = False
DTPicker2.Enabled = False: DTPicker3.Enabled = False: Check1.Enabled = False
cmdSave.Enabled = False
RegInfo Me
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then DTPicker1.SetFocus '回车Text1(1)获得焦点
End Sub
Private Sub DTPicker1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Text1(2).SetFocus
Text1(2).SelStart = 0
Text1(2).SelLength = Len(Text1(2))
End If
End Sub
Private Sub DTPicker2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Text1(10).SetFocus '回车Text1(10)获得焦点
Text1(10).SelStart = 0
Text1(10).SelLength = Len(Text1(10))
End If
End Sub
Private Sub DTPicker3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Text1(11).SetFocus '回车Text1(10)获得焦点
Text1(11).SelStart = 0
Text1(11).SelLength = Len(Text1(11))
End If
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn And Index = 1 Then Combo1.SetFocus
If KeyCode = vbKeyReturn And Index > 1 And Index < 9 Then
Text1(Index + 1).SetFocus '回车获得焦点
Text1(Index + 1).SelStart = 0
Text1(Index + 1).SelLength = Len(Text1(Index + 1))
End If
If KeyCode = vbKeyReturn And Index = 9 Then DTPicker2.SetFocus
If KeyCode = vbKeyReturn And Index = 10 Then Check1.SetFocus
If KeyCode = vbKeyReturn And Index = 11 Then cmdSave.SetFocus
End Sub
Private Sub Check1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then DTPicker3.SetFocus
End Sub
Private Sub SSTab1_Click(PreviousTab As Integer)
Adodc1.RecordSource = "tb_employe order by 编号"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount <> 0 Then
If SSTab1.Tab = 1 And cmdAdd.Enabled = False Then
MsgBox "您正在处理数据,请取消数据处理,再执行本操作!", , "提示窗口"
SSTab1.Tab = 0
Else
view_data
End If
End If
End Sub
Private Sub cmdFind_Click() '查询员工信息
Adodc1.RecordSource = "tb_employe where tb_employe." & Combo4.text & " like + '" + Text2 + "'+'%'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
view_data
End If
End Sub
Private Sub CmdMD_Click(Index As Integer)
Select Case Index
Case Is = 0 '移到第一条记录
If Not Adodc1.Recordset.BOF Then Adodc1.Recordset.MoveFirst
Case Is = 1 '移到上一条记录
If Adodc1.Recordset.RecordCount <> 0 Then
If Adodc1.Recordset.BOF = False Then Adodc1.Recordset.MovePrevious
If Adodc1.Recordset.BOF = True Then Adodc1.Recordset.MoveFirst
End If
Case Is = 2 '移到下一条记录
If Adodc1.Recordset.RecordCount <> 0 Then
If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MoveLast
End If
Case Is = 3 '移到最后一条记录
If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveLast
End Select
view_data '调用显示数据的过程
End Sub
Private Sub cmdAdd_Click() '添加
Text1(1).Enabled = True
rs1.Open "select * from tb_employe order by 编号", Cnn, adOpenStatic
If rs1.RecordCount > 0 Then
rs1.MoveLast
lblbh.Caption = Format(Val(rs1.Fields("编号")) + 1, "0000")
Else
lblbh.Caption = "0001"
End If
rs1.Close
For i = 1 To 11
Text1(i).text = ""
Text1(i).Enabled = True
Next i
Combo1.Enabled = True: DTPicker1.Enabled = True
DTPicker2.Enabled = True: DTPicker3.Enabled = True: Check1.Enabled = True
cmdSave.Enabled = True: cmdEsc.Enabled = True: cmdAdd.Enabled = False
cmdModify.Enabled = False: cmdDelete.Enabled = False
For i = 0 To 3
CmdMD(i).Enabled = False
Next i
SSTab1.Tab = 0
Text1(1).SetFocus 'text1(1)获得焦点
End Sub
Private Sub cmdModify_Click() '允许修改员工信息
If Adodc1.Recordset.RecordCount > 0 Then
For i = 1 To 11
Text1(i).Enabled = True
Next i
Text1(1).SetFocus
Text1(1).SelStart = 0
Text1(1).SelLength = Len(Text1(1))
Combo1.Enabled = True: DTPicker1.Enabled = True
DTPicker2.Enabled = True: DTPicker3.Enabled = True: Check1.Enabled = True
cmdSave.Enabled = True: cmdEsc.Enabled = True: cmdAdd.Enabled = False
cmdModify.Enabled = False: cmdDelete.Enabled = False
For i = 0 To 3
CmdMD(i).Enabled = False
Next i
Else
MsgBox ("没有要修改的数据!")
End If
End Sub
Private Sub cmdDelete_Click() '删除员工信息
If Adodc1.Recordset.RecordCount > 0 Then
Dim a As Integer
a = MsgBox("您确实要删除这条数据吗?", vbYesNo)
If a = vbYes Then
Adodc1.Recordset.Delete
Adodc1.Recordset.Update
If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MovePrevious
view_data '调用显示数据的过程
cmdSave.Enabled = False: cmdEsc.Enabled = False: cmdAdd.Enabled = True
cmdModify.Enabled = True
For i = 0 To 3
CmdMD(i).Enabled = True
Next i
End If
Else
MsgBox ("没有要删除的数据!")
End If
End Sub
Private Sub cmdSave_Click() '保存员工信息
If Text1(1).text = "" Then
MsgBox "系统不允许〖姓名〗为空!"
Exit Sub
End If
If Combo1.text = "" Then
MsgBox "系统不允许〖性别〗为空!"
Exit Sub
End If
If Text1(2).text = "" Then
MsgBox "系统不允许〖身份证号〗为空!"
Exit Sub
End If
On Error GoTo ErrorSave
' rs1.Open "tb_employe where 编号='" + lblbh + "'order by 编号", Cnn, adOpenStatic
Ado_update.RecordSource = "tb_employe where 编号='" + lblbh + "'order by 编号"
Ado_update.Refresh
If Ado_update.Recordset.RecordCount > 0 Then
Dim myval As Integer
myval = MsgBox("您确实要修改这条数据吗?", vbYesNo)
If myval = vbYes Then
'修改员工信息
Ado_update.Recordset.Fields("姓名") = Text1(1)
Ado_update.Recordset.Fields("性别") = Combo1.text
Ado_update.Recordset.Fields("出生日期") = DTPicker1.Value
For i = 2 To 9
Ado_update.Recordset.Fields(i + 2) = Text1(i).text
Next i
Ado_update.Recordset.Fields("聘用日期") = DTPicker2.Value
Ado_update.Recordset.Fields("入职底薪") = Val(Text1(10))
Ado_update.Recordset.Fields("在职与否") = Check1.Value
Ado_update.Recordset.Fields("离职日期") = DTPicker3.Value
Ado_update.Recordset.Fields("备注") = Text1(11)
Ado_update.Recordset.Update '更新数据库
Adodc1.Refresh
End If
Else
'添加员工信息
Ado_update.Recordset.AddNew
Ado_update.Recordset.Fields("编号") = lblbh
Ado_update.Recordset.Fields("姓名") = Text1(1)
Ado_update.Recordset.Fields("性别") = Combo1.text
Ado_update.Recordset.Fields("出生日期") = DTPicker1.Value
For i = 2 To 9
Ado_update.Recordset.Fields(i + 2) = Text1(i).text
Next i
Ado_update.Recordset.Fields("聘用日期") = DTPicker2.Value
Ado_update.Recordset.Fields("入职底薪") = Val(Text1(10))
Ado_update.Recordset.Fields("在职与否") = Check1.Value
Ado_update.Recordset.Fields("离职日期") = DTPicker3.Value
Ado_update.Recordset.Fields("备注") = Text1(11)
Ado_update.Recordset.Update '更新数据库
Adodc1.Refresh
End If
' rs1.Close '关闭数据集对象
'设置控件状态
For i = 1 To 11
Text1(i).Enabled = False
Next i
Combo1.Enabled = False: DTPicker1.Enabled = False
DTPicker2.Enabled = False: DTPicker3.Enabled = False: Check1.Enabled = False
cmdSave.Enabled = False: cmdEsc.Enabled = False: cmdAdd.Enabled = True
cmdModify.Enabled = True: cmdDelete.Enabled = True
For i = 0 To 3
CmdMD(i).Enabled = True
Next i
Exit Sub
ErrorSave:
MsgBox Err.Description, vbCritical, "明日图书"
End Sub
Private Sub cmdEsc_Click() '取消操作
If Not Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveFirst
view_data '调用显示数据的过程
End If
For i = 1 To 11
Text1(i).Enabled = False
Next i
Combo1.Enabled = False: DTPicker1.Enabled = False
DTPicker2.Enabled = False: DTPicker3.Enabled = False: Check1.Enabled = False
cmdSave.Enabled = False: cmdEsc.Enabled = False: cmdAdd.Enabled = True
cmdModify.Enabled = True: cmdDelete.Enabled = True
For i = 0 To 3
CmdMD(i).Enabled = True
Next i
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -