📄 main_bmgl_addmodify.frm
字号:
VERSION 5.00
Begin VB.Form main_bmgl_addmodify
BorderStyle = 1 'Fixed Single
ClientHeight = 3375
ClientLeft = 45
ClientTop = 330
ClientWidth = 5655
Icon = "main_bmgl_addmodify.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 3375
ScaleWidth = 5655
Begin VB.CommandButton CmdSave
BackColor = &H00FFC0C0&
Caption = "保存"
Height = 420
Left = 1065
TabIndex = 11
Top = 2760
Width = 1710
End
Begin VB.CommandButton CmdEnd
BackColor = &H00FFC0C0&
Caption = "取消"
Height = 420
Left = 2895
TabIndex = 10
Top = 2760
Width = 1710
End
Begin VB.TextBox Text1
Height = 645
Index = 3
Left = 1065
ScrollBars = 2 'Vertical
TabIndex = 9
Top = 1455
Width = 4425
End
Begin VB.TextBox Text1
Enabled = 0 'False
Height = 330
Index = 0
Left = 1065
TabIndex = 3
Top = 195
Width = 1695
End
Begin VB.TextBox Text1
Height = 330
Index = 1
Left = 1065
TabIndex = 2
Top = 600
Width = 4425
End
Begin VB.TextBox Text1
Height = 330
Index = 2
Left = 1065
TabIndex = 1
Top = 1035
Width = 4425
End
Begin VB.TextBox Text1
Height = 330
Index = 4
Left = 1065
TabIndex = 0
Top = 2190
Width = 4425
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "部门编号:"
Height = 270
Index = 0
Left = 180
TabIndex = 8
Top = 255
Width = 1380
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "部门名称:"
Height = 270
Index = 1
Left = 180
TabIndex = 7
Top = 690
Width = 1380
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "部门经理:"
Height = 270
Index = 2
Left = 180
TabIndex = 6
Top = 1095
Width = 1380
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "部门地址:"
Height = 270
Index = 3
Left = 180
TabIndex = 5
Top = 1515
Width = 1380
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "部门电话:"
Height = 270
Index = 4
Left = 135
TabIndex = 4
Top = 2250
Width = 1380
End
End
Attribute VB_Name = "main_bmgl_addmodify"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs1 As New ADODB.Recordset
Dim i As Integer
Dim blnTJ, blnAdd As Boolean
Dim bmjc As Integer
Dim bmbh As String
Public lngOL As Long
Sub tlbState(state As Boolean)
With Toolbar1
If state = True Then
.Buttons(1).Enabled = False
.Buttons(2).Enabled = False
For i = 4 To 11
.Buttons(i).Enabled = True
Next i
For i = 0 To Text1.UBound
Text1(i).Locked = True
Next i
Else
.Buttons(1).Enabled = True
.Buttons(2).Enabled = True
For i = 4 To 11
.Buttons(i).Enabled = False
Next i
For i = 0 To Text1.UBound
Text1(i).Locked = False
Next i
End If
End With
End Sub
Private Sub CmdEnd_Click()
Unload Me
End Sub
Private Sub CmdSave_Click()
If Len(Text1(0)) > 10 Then
MsgBox "部门编号超长!"
Exit Sub
End If
If blnAddBM = True Then
rs1.Open "select * from 部门表", cnn, adOpenKeyset, adLockOptimistic
rs1.AddNew
For i = 0 To 4
rs1.Fields(i) = Text1(i)
Next i
rs1.Update
rs1.Close
Else
rs1.Open "select * from 部门表 where 部门编号='" + Text1(0) + "'", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
For i = 0 To 4
rs1.Fields(i) = Text1(i)
Next i
rs1.Update
End If
rs1.Close
main_bmgl_cx.Adodc1.Refresh
End If
Unload Me
End Sub
Private Sub Form_Activate()
Text1(1).SetFocus
End Sub
Private Sub Form_Load()
If blnAddBM = True Then
Me.Caption = "部门信息添加"
rs1.Open "select * from 部门表 order by 部门编号", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
rs1.MoveLast
Text1(0) = Format(Val(rs1.Fields("部门编号")) + 1, "00")
Else
Text1(0) = "01"
End If
rs1.Close
Else
Me.Caption = "部门信息修改"
For i = 0 To Text1.UBound
Text1(i) = main_bmgl_cx.Adodc1.Recordset.Fields(i)
Next i
End If
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn And Index > 0 And Index < 4 Then Text1(Index + 1).SetFocus
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -