📄 frm_group_add.frm
字号:
VERSION 5.00
Begin VB.Form Frm_Group_Add
BorderStyle = 1 'Fixed Single
Caption = "添加部门"
ClientHeight = 1755
ClientLeft = 3315
ClientTop = 4980
ClientWidth = 6600
Icon = "Frm_Group_Add.frx":0000
LinkTopic = "Form2"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1755
ScaleWidth = 6600
Begin VB.TextBox Txt_Fields
Height = 300
Index = 1
Left = 1793
TabIndex = 1
Text = "Text2"
Top = 600
Width = 4455
End
Begin VB.TextBox Txt_Fields
Height = 300
Index = 0
Left = 1793
TabIndex = 0
Text = "Text2"
Top = 180
Width = 4455
End
Begin VB.CommandButton Cmd_Creat
Caption = "创建(&E)"
Height = 375
Left = 3570
TabIndex = 2
Top = 1200
Width = 1095
End
Begin VB.CommandButton Cmd_Close
Caption = "关闭(&O)"
Height = 375
Left = 4890
TabIndex = 4
Top = 1200
Width = 1095
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "部门描述(&D):"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 180
Left = 353
TabIndex = 5
Top = 660
Width = 1290
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "部门名称(&G):"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 180
Left = 353
TabIndex = 3
Top = 240
Width = 1290
End
End
Attribute VB_Name = "Frm_Group_Add"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Cmd_Close_Click()
Unload Me
End Sub
Private Sub Cmd_Creat_Click()
On Error GoTo err
If Group_Add = True And Group_Edit = False Then
Set Cn_Common = New ADODB.Connection
Cn_Common.Open Cs
Set Rs_Common = New ADODB.Recordset
Rs_Common.Open "select * from department", Cn_Common, adOpenKeyset, adLockOptimistic, adCmdText
If Rs_Common.RecordCount <> 0 Then
Rs_Common.MoveLast
Rs_Common.AddNew
Rs_Common!部门名称 = Trim(Me.txt_Fields(0).text)
Rs_Common!部门描述 = Trim(Me.txt_Fields(1).text)
Rs_Common.Update
Rs_Common.Close
Rs_Common.Open "select 部门名称, 部门描述 from department", Cn_Common, adOpenKeyset, adLockOptimistic, adCmdText
Set Frm_Group_User.DataGrd_Group_User.DataSource = Rs_Common
' Cn_Common.Close
Else
Rs_Common.AddNew
Rs_Common!部门名称 = Trim(Me.txt_Fields(0).text)
Rs_Common!部门描述 = Trim(Me.txt_Fields(1).text)
Rs_Common.Update
Rs_Common.Close
Rs_Common.Open "select 部门名称, 部门描述 from department", Cn_Common, adOpenKeyset, adLockOptimistic, adCmdText
Set Frm_Group_User.DataGrd_Group_User.DataSource = Rs_Common
' Cn_Common.Close
End If
Me.txt_Fields(0).text = ""
Me.txt_Fields(1).text = ""
End If
If Group_Add = False And Group_Edit = True Then
Rs_Common!部门名称 = Me.txt_Fields(0).text
Rs_Common!部门描述 = Me.txt_Fields(1).text
Rs_Common.Update
Unload Me
End If
Exit Sub
err:
MsgBox err.Description, vbCritical
End Sub
Private Sub Form_Load()
On Error GoTo err
If Group_Add = True And Group_Edit = False Then
Me.txt_Fields(0).text = ""
Me.txt_Fields(1).text = ""
ElseIf Group_Add = False And Group_Edit = True Then
If IsNull(Rs_Common!部门名称) = False Then Me.txt_Fields(0).text = Rs_Common!部门名称 Else Me.txt_Fields(0).text = ""
If IsNull(Rs_Common!部门描述) = False Then Me.txt_Fields(1).text = Rs_Common!部门描述 Else Me.txt_Fields(1).text = ""
Me.Cmd_Creat.Caption = "保存(&Save)"
End If
Exit Sub
err:
MsgBox err.Description, vbCritical
End Sub
Private Sub Txt_Fields_KeyPress(Index As Integer, KeyAscii As Integer)
On Error GoTo err
Call ENTER(KeyAscii)
Exit Sub
err:
MsgBox err.Description, vbCritical
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -