📄 main_bmgl_update.frm
字号:
VERSION 5.00
Begin VB.Form main_bmgl_update
BackColor = &H00D0E8EE&
BorderStyle = 1 'Fixed Single
Caption = "修改部门"
ClientHeight = 3570
ClientLeft = 45
ClientTop = 330
ClientWidth = 6180
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3570
ScaleWidth = 6180
StartUpPosition = 1 '所有者中心
Begin VB.Frame Frame1
BackColor = &H00D0E8EE&
Height = 2250
Left = 15
TabIndex = 0
Top = 495
Width = 6165
Begin VB.TextBox Text1
Height = 285
Index = 2
Left = 960
TabIndex = 6
Top = 945
Width = 2055
End
Begin VB.TextBox Text1
Height = 285
Index = 3
Left = 3945
TabIndex = 5
Top = 945
Width = 2055
End
Begin VB.TextBox Text1
BeginProperty DataFormat
Type = 1
Format = """¥""#,##0.00;(""¥""#,##0.00)"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 2
EndProperty
Height = 285
Index = 4
Left = 960
TabIndex = 4
Top = 1350
Width = 5040
End
Begin VB.TextBox Text1
Height = 285
Index = 5
Left = 960
TabIndex = 3
Top = 1755
Width = 5040
End
Begin VB.TextBox Text1
Height = 285
Index = 1
Left = 960
TabIndex = 2
Top = 555
Width = 5040
End
Begin VB.TextBox Text1
BackColor = &H00FFFFFF&
Height = 285
Index = 0
Left = 960
Locked = -1 'True
TabIndex = 1
Top = 180
Width = 2055
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "备 注 "
Height = 240
Left = 120
TabIndex = 12
Top = 1830
Width = 765
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "部门电话 基础工资 "
Height = 330
Left = 120
TabIndex = 11
Top = 1410
Width = 765
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "部门主管 基础工资 "
Height = 225
Left = 3180
TabIndex = 10
Top = 1005
Width = 765
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "部门级别 基础工资 "
Height = 330
Left = 120
TabIndex = 9
Top = 975
Width = 765
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "部门编号 "
Height = 330
Left = 120
TabIndex = 8
Top = 240
Width = 870
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "部门名称 基础工资 "
Height = 330
Left = 120
TabIndex = 7
Top = 615
Width = 765
End
End
Begin VB.Frame Frame2
BackColor = &H00D0E8EE&
Height = 735
Left = 15
TabIndex = 13
Top = 2685
Width = 6165
Begin VB.CommandButton CmdCancel
BackColor = &H00FFC0C0&
Caption = "取消"
Height = 375
Left = 4500
Style = 1 'Graphical
TabIndex = 15
Top = 225
Width = 1395
End
Begin VB.CommandButton CmdModify
BackColor = &H00FFC0C0&
Caption = "修改"
Height = 375
Left = 3120
Style = 1 'Graphical
TabIndex = 14
Top = 225
Width = 1395
End
End
Begin VB.Label Label10
Appearance = 0 'Flat
BackColor = &H00FFC0C0&
BorderStyle = 1 'Fixed Single
Caption = " 部门信息修改"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0080FF80&
Height = 375
Left = 1455
TabIndex = 16
Top = 90
Width = 3270
End
End
Attribute VB_Name = "main_bmgl_update"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer
Dim sql As String
Dim mycnn As New ADODB.Connection
Private Sub Form_Activate()
For i = 0 To 5
'对应列
main_bmgl.DataGrid1.Col = i
Text1(i) = main_bmgl.DataGrid1.Text
Next i
End Sub
Private Sub Form_Unload(Cancel As Integer)
main_bmgl.Enabled = True
End Sub
Private Sub Text1_GotFocus(Index As Integer)
Text1(Index).BackColor = &HFFFF00
End Sub
Private Sub Text1_LostFocus(Index As Integer)
Text1(Index).BackColor = &HFFFFFF
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If Index < 5 And KeyCode = vbKeyReturn Then Text1(Index + 1).SetFocus
If Index = 5 And KeyCode = vbKeyReturn Then CmdModify.SetFocus
If Index <> 0 And KeyCode = vbKeyUp Then Text1(Index - 1).SetFocus
End Sub
Private Sub CmdModify_Click()
mycnn.Open Cnn
'生成SQL语句
sql = "UPDATE 部门信息表 SET 部门编号 ='" + Text1(0).Text + "',部门名称 = '" + Text1(1).Text + "',部门级别 = '" + Text1(2).Text + "',部门主管 = '" + Text1(3).Text + "',部门电话 = '" + Text1(4).Text + "',备注= '" + Text1(5).Text + "' WHERE 部门编号='" + Text1(0).Text + "'"
'执行SQL
mycnn.Execute sql
mycnn.Close
main_bmgl.Adodc1.Refresh
main_bmgl.Enabled = True
Unload Me
End Sub
Private Sub CmdCancel_Click()
main_bmgl.Enabled = True
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -