www.pudn.com > Pepsi_five.rar > FrmSetDep.frm
VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form FrmSetDep
Caption = "部门设置"
ClientHeight = 5895
ClientLeft = 60
ClientTop = 345
ClientWidth = 5205
Icon = "FrmSetDep.frx":0000
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 5895
ScaleWidth = 5205
Begin VB.Frame Frame2
Height = 2595
Left = 0
TabIndex = 8
Top = 3300
Width = 5180
Begin VB.CommandButton CmdAct
Caption = "恢复(&U)"
Enabled = 0 'False
Height = 315
Index = 1
Left = 2880
TabIndex = 14
Top = 1680
Width = 1275
End
Begin VB.CommandButton CmdAct
Caption = "保存(&S)"
Enabled = 0 'False
Height = 315
Index = 0
Left = 960
TabIndex = 13
Top = 1680
Width = 1275
End
Begin VB.TextBox txtdepartment_name
DataField = "department_name"
DataMember = "ComDepartment"
DataSource = "DEjxc"
Enabled = 0 'False
Height = 285
Left = 1425
TabIndex = 12
Top = 990
Width = 3300
End
Begin VB.TextBox txtdepartment_id
DataField = "department_id"
DataMember = "ComDepartment"
DataSource = "DEjxc"
Enabled = 0 'False
Height = 285
Left = 1425
MaxLength = 8
TabIndex = 10
Top = 615
Width = 855
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "部门名称:"
Height = 180
Index = 1
Left = 585
TabIndex = 11
Top = 1035
Width = 810
End
Begin VB.Label lblFieldLabel
Alignment = 1 'Right Justify
AutoSize = -1 'True
Caption = "部门编号:"
Height = 180
Index = 0
Left = 585
TabIndex = 9
Top = 660
Width = 810
End
End
Begin VB.Frame Frame1
Height = 3375
Left = 0
TabIndex = 0
Top = -60
Width = 5175
Begin VB.CommandButton CmdDep
Caption = "退出(&X)"
Height = 315
Index = 5
Left = 3780
TabIndex = 7
Top = 2940
Width = 1275
End
Begin VB.CommandButton CmdDep
Caption = "列表(&P)"
Height = 315
Index = 4
Left = 3780
TabIndex = 6
Top = 2388
Width = 1275
End
Begin VB.CommandButton CmdDep
Caption = "删除(&D)"
Height = 315
Index = 3
Left = 3780
TabIndex = 5
Top = 1836
Width = 1275
End
Begin VB.CommandButton CmdDep
Caption = "查询(&F)"
Height = 315
Index = 2
Left = 3780
TabIndex = 4
Top = 1284
Width = 1275
End
Begin VB.CommandButton CmdDep
Caption = "编辑(&E)"
Height = 315
Index = 1
Left = 3780
TabIndex = 3
Top = 732
Width = 1275
End
Begin VB.CommandButton CmdDep
Caption = "增加(&N)"
Height = 315
Index = 0
Left = 3780
TabIndex = 2
Top = 180
Width = 1275
End
Begin MSDataGridLib.DataGrid DataGrid1
Bindings = "FrmSetDep.frx":0442
Height = 3075
Left = 60
TabIndex = 1
Top = 180
Width = 3615
_ExtentX = 6376
_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 = "ComDepartment"
ColumnCount = 2
BeginProperty Column00
DataField = "department_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 = "department_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
WrapText = -1 'True
ColumnWidth = 1184.882
EndProperty
BeginProperty Column01
ColumnAllowSizing= 0 'False
WrapText = -1 'True
ColumnWidth = 2085.166
EndProperty
EndProperty
End
End
End
Attribute VB_Name = "FrmSetDep"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private rsDepartment As ADODB.Recordset
Private strMaxNum As String
Private blnIsSQL As Boolean
Private Sub CmdAct_Click(Index As Integer)
On Error GoTo Err:
With rsDepartment
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 DepAddNew
Case 1
Call IsEdit(True)
Me.txtdepartment_id.SetFocus
Case 2
FrmSql.intNumField = 2
FrmSql.Show vbModal
Select Case FrmSql.intNumField
Case -1
blnIsSQL = False
CmdDep(0).Enabled = True
CmdDep(3).Enabled = True
rsDepartment.Filter = Me.DataGrid1.Columns.Item(0).DataField & _
"<>''"
Case -2
Case Else
blnIsSQL = True
CmdDep(0).Enabled = False
CmdDep(3).Enabled = False
rsDepartment.Filter = Me.DataGrid1.Columns.Item(FrmSql.intNumField).DataField & _
" like '*" & FrmSql.strSqlField & "*'"
End Select
Case 3
intAnswer = MsgBox("确认删除当前记录吗?", vbYesNo + vbQuestion, "删除确认")
If intAnswer = vbYes Then
With rsDepartment
.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 Form_Load()
intNumWindows = OpenWindow(intNumWindows)
Me.Height = 6300
Me.Width = 5325
Call SetFormStu(Me, frmMain)
Set rsDepartment = DEjxc.rsComDepartment
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)
rsDepartment.Filter = Me.DataGrid1.Columns.Item(0).DataField & "<>''"
rsDepartment.Close
Set rsDepartment = Nothing
End Sub
Private Sub DepAddNew()
Dim strSQL As String
With rsDepartment
' If .RecordCount = 0 Then
' strMaxNum = 0
' Else
' .MoveLast
' strMaxNum = !department_id
' End If
.AddNew "department_id", ""
' Me.txtdepartment_id.Text = Format(CLng(strMaxNum) + 1, "0##")
Call IsEdit(True)
Me.txtdepartment_id.SetFocus
End With
End Sub
Private Sub IsEdit(blnIsEdit As Boolean)
Dim intNum As Integer
Me.txtdepartment_id.Enabled = blnIsEdit
Me.txtdepartment_name.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 rsDepartment.RecordCount = 0 Then
For intNum = 1 To 4
Me.CmdDep(intNum).Enabled = False
Next
End If
End Sub
Private Sub txtdepartment_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 txtdepartment_name.SetFocus
End Sub