www.pudn.com > jxc001.rar > FrmSetEmp.frm
VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form FrmSetEmp
Caption = "员工设置"
ClientHeight = 5895
ClientLeft = 60
ClientTop = 345
ClientWidth = 5610
Icon = "FrmSetEmp.frx":0000
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 5895
ScaleWidth = 5610
Begin VB.Frame Frame2
Height = 2595
Left = 0
TabIndex = 8
Top = 3300
Width = 5595
Begin MSDataListLib.DataCombo DCboEmp
Bindings = "FrmSetEmp.frx":0442
DataField = "employee_depid"
DataMember = "ComEmployee"
DataSource = "DEjxc"
Height = 330
Left = 2460
TabIndex = 16
Top = 900
Width = 1215
_ExtentX = 2143
_ExtentY = 582
_Version = 393216
Enabled = 0 'False
Style = 2
ListField = "department_name"
BoundColumn = "department_id"
Text = "DataCombo1"
Object.DataMember = "ComDepartment"
End
Begin VB.TextBox txtemployee_name
DataField = "employee_name"
DataMember = "ComEmployee"
DataSource = "DEjxc"
Enabled = 0 'False
Height = 330
Left = 2445
TabIndex = 15
Top = 1365
Width = 1320
End
Begin VB.TextBox txtemployee_id
DataField = "employee_id"
DataMember = "ComEmployee"
DataSource = "DEjxc"
Enabled = 0 'False
Height = 330
Left = 2445
MaxLength = 4
TabIndex = 12
Top = 420
Width = 660
End
Begin VB.CommandButton CmdAct
Caption = "恢复(&U)"
Enabled = 0 'False
Height = 315
Index = 1
Left = 3060
TabIndex = 10
Top = 1980
Width = 1275
End
Begin VB.CommandButton CmdAct
Caption = "保存(&S)"
Enabled = 0 'False
Height = 315
Index = 0
Left = 1140
TabIndex = 9
Top = 1980
Width = 1275
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "员工姓名:"
Height = 180
Index = 2
Left = 1485
TabIndex = 14
Top = 1410
Width = 810
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "所属部门:"
Height = 180
Index = 1
Left = 1485
TabIndex = 13
Top = 960
Width = 810
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "员工编号:"
Height = 180
Index = 0
Left = 1545
TabIndex = 11
Top = 465
Width = 810
End
End
Begin VB.Frame Frame1
Height = 3375
Left = 0
TabIndex = 0
Top = -60
Width = 5595
Begin VB.CommandButton CmdDep
Caption = "退出(&X)"
Height = 315
Index = 5
Left = 4140
TabIndex = 7
Top = 2940
Width = 1275
End
Begin VB.CommandButton CmdDep
Caption = "列表(&P)"
Height = 315
Index = 4
Left = 4140
TabIndex = 6
Top = 2385
Width = 1275
End
Begin VB.CommandButton CmdDep
Caption = "删除(&D)"
Height = 315
Index = 3
Left = 4140
TabIndex = 5
Top = 1830
Width = 1275
End
Begin VB.CommandButton CmdDep
Caption = "查询(&F)"
Height = 315
Index = 2
Left = 4140
TabIndex = 4
Top = 1290
Width = 1275
End
Begin VB.CommandButton CmdDep
Caption = "编辑(&E)"
Height = 315
Index = 1
Left = 4140
TabIndex = 3
Top = 735
Width = 1275
End
Begin VB.CommandButton CmdDep
Caption = "增加(&N)"
Height = 315
Index = 0
Left = 4140
TabIndex = 2
Top = 180
Width = 1275
End
Begin MSDataGridLib.DataGrid DataGrid1
Bindings = "FrmSetEmp.frx":048F
Height = 3075
Left = 60
TabIndex = 1
Top = 180
Width = 3795
_ExtentX = 6694
_ExtentY = 5424
_Version = 393216
AllowUpdate = 0 'False
AllowArrows = -1 'True
HeadLines = 1
RowHeight = 15
TabAcrossSplits = -1 'True
TabAction = 2
WrapCellPointer = -1 'True
FormatLocked = -1 'True
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
DataMember = "ComEmployee"
ColumnCount = 3
BeginProperty Column00
DataField = "employee_id"
Caption = "员工编号"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = "employee_depid"
Caption = "所属部门"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column02
DataField = "employee_name"
Caption = "员工姓名"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
ColumnAllowSizing= 0 'False
ColumnWidth = 1005.165
EndProperty
BeginProperty Column01
ColumnAllowSizing= 0 'False
ColumnWidth = 1275.024
EndProperty
BeginProperty Column02
ColumnAllowSizing= 0 'False
ColumnWidth = 1184.882
EndProperty
EndProperty
End
End
End
Attribute VB_Name = "FrmSetEmp"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private rsEmployee As ADODB.Recordset
Private strMaxNum As String
Private blnIsSQL As Boolean
Private Sub CmdAct_Click(Index As Integer)
On Error GoTo Err:
With rsEmployee
Select Case Index
Case 0
.UpdateBatch
.MoveLast
Case 1
.CancelUpdate
If .RecordCount <> 0 Then
.MoveFirst
End If
End Select
End With
Call IsEdit(False)
Me.DataGrid1.Refresh
Exit Sub
Err:
If Err.Number = -2147467259 Then
MsgBox "员工编号重复!请重新录入新的员工编号!", vbCritical, "错误"
End If
End Sub
Private Sub CmdDep_Click(Index As Integer)
Dim intAnswer As Integer
Select Case Index
Case 0
Call EmpAddNew
Case 1
Call IsEdit(True)
Me.txtemployee_name.SetFocus
Case 2
FrmSql.intNumField = 3
FrmSql.Show vbModal
Select Case FrmSql.intNumField
Case -1
blnIsSQL = False
CmdDep(0).Enabled = True
CmdDep(3).Enabled = True
rsEmployee.Filter = Me.DataGrid1.Columns.Item(0).DataField & _
"<>''"
Case -2
Case Else
blnIsSQL = True
CmdDep(0).Enabled = False
CmdDep(3).Enabled = False
rsEmployee.Filter = Me.DataGrid1.Columns.Item(FrmSql.intNumField).DataField & _
" like '*" & FrmSql.strSqlField & "*'"
End Select
Case 3
intAnswer = MsgBox("确认删除当前记录吗?", vbYesNo + vbQuestion, "删除确认")
If intAnswer = vbYes Then
With rsEmployee
.Delete
.UpdateBatch
If .RecordCount <> 0 Then
.MoveFirst
Else
For intAnswer = 1 To 4
CmdDep(intAnswer).Enabled = False
Next
End If
End With
End If
Case 4
Case 5
Unload Me
End Select
End Sub
Private Sub DCboEmp_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Me.txtemployee_name.SetFocus
End Sub
Private Sub Form_Load()
intNumWindows = OpenWindow(intNumWindows)
Me.Height = 6300
Me.Width = 5730
Call SetFormStu(Me, frmMain)
Set rsEmployee = DEjxc.rsComEmployee
Call IsEdit(False)
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If CmdDep(5).Enabled = False Then
MsgBox "请先退出编辑状态后再退出该程序!", , "提示"
Cancel = True
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
intNumWindows = Closewindow(intNumWindows)
rsEmployee.Filter = Me.DataGrid1.Columns.Item(0).DataField & "<>''"
rsEmployee.Close
Set rsEmployee = Nothing
End Sub
Private Sub EmpAddNew()
Dim strSQL As String
With rsEmployee
' If .RecordCount = 0 Then
' strMaxNum = 0
' Else
' .MoveLast
' strMaxNum = !employee_id
' End If
.AddNew "employee_id", ""
' Me.txtemployee_id = Format(CLng(strMaxNum) + 1, "0###")
Call IsEdit(True)
Me.txtemployee_id.SetFocus
End With
End Sub
Private Sub IsEdit(blnIsEdit As Boolean)
Dim intNum As Integer
Me.txtemployee_id.Enabled = blnIsEdit
Me.txtemployee_name.Enabled = blnIsEdit
Me.DCboEmp.Enabled = blnIsEdit
For intNum = 0 To 1
Me.CmdAct(intNum).Enabled = blnIsEdit
Next
For intNum = 0 To 5
Me.CmdDep(intNum).Enabled = Not blnIsEdit
Next
If blnIsSQL = True Then
CmdDep(0).Enabled = False
CmdDep(3).Enabled = False
End If
If rsEmployee.RecordCount = 0 Then
For intNum = 1 To 4
Me.CmdDep(intNum).Enabled = False
Next
End If
End Sub
Private Sub txtemployee_id_KeyPress(KeyAscii As Integer)
Dim strValid As String
strValid = "0123456789"
If KeyAscii > 26 Then
If InStr(strValid, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
End If
End If
If KeyAscii = 13 Then Me.DCboEmp.SetFocus
End Sub