📄 frm_smxx.frm
字号:
Left = 1110
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 6
Top = 1020
Width = 2775
End
Begin VB.TextBox Text1
Height = 300
Index = 1
Left = 1110
TabIndex = 5
Top = 645
Width = 2775
End
Begin VB.TextBox Text1
Height = 300
Index = 0
Left = 1110
TabIndex = 3
Top = 240
Width = 2775
End
Begin VB.Label Label8
Caption = "职务说明"
Height = 285
Left = 120
TabIndex = 7
Top = 1065
Width = 765
End
Begin VB.Label Label1
Caption = "职务名称"
Height = 255
Index = 1
Left = 120
TabIndex = 4
Top = 705
Width = 855
End
Begin VB.Label Label1
Caption = "编号"
Height = 255
Index = 0
Left = 120
TabIndex = 2
Top = 345
Width = 855
End
End
End
Attribute VB_Name = "Frm_Zwxx"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer
Dim c
Private Sub Dgr_bmzl_Click()
On Error Resume Next
If Adodc1.Recordset.RecordCount > 0 Then
Text1(0).Text = Adodc1.Recordset.Fields("zw_id")
Text1(1).Text = Adodc1.Recordset.Fields("zw_mc")
Text1(2).Text = Adodc1.Recordset.Fields("zw_sm")
End If
For i = 0 To 2
Text1(i).Locked = False
Next i
End Sub
Private Sub Form_Load()
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
Call LoadFile
For i = 0 To 2
Text1(i).Locked = True
Next i
Adodc1.ConnectionString = PublicStr
Adodc1.RecordSource = "select * from tb_zw order by zw_id"
Adodc1.Refresh
Call DBGCon
Call Tbr_cortrol(Tbr_xxcz, True)
End Sub
Private Sub Tbr_xxcz_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Index
Case 1
Call Tbr_cortrol(Tbr_xxcz, False)
For i = 1 To 2
Text1(i).Locked = False
Text1(i).Text = ""
Text1(0).SetFocus
Next i
AdoRs.Open "select * from tb_zw order by zw_id", Cnn, adOpenKeyset
If AdoRs.RecordCount > 0 Then
AdoRs.MoveLast
StrNum = AdoRs.Fields("zw_id")
Call Con_idNum '调用位数转换函数
Text1(0).Text = StrIn
Else
Text1(0).Text = "001"
End If
AdoRs.Close
Case 2 '删除信息
Call Deletes
Case 3 '修改信息
Call Edits
Case 4 '保存信息
Call Saves
Case 5
Call Tbr_cortrol(Tbr_xxcz, True)
For i = 1 To 2
Text1(i).Text = ""
Text1(1).SetFocus
Text1(i).Locked = True
Next i
Case 6
ConBs = "ZW"
Frm_Cx.Show 1
Case 7
Unload Me
End Select
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
On Error Resume Next
If KeyCode = 13 Then
If Index >= 0 Then Text1(Index + 1).SetFocus
If Index = 2 Then
Call Saves
End If
End If
If Index >= 0 And KeyCode = 40 Then Text1(Index + 1).SetFocus
If Index <= 2 And KeyCode = 38 Then Text1(Index - 1).SetFocus
End Sub
Private Sub Saves() '保存信息的事件过程
If Text1(1).Text = "" Then
MsgBox "职务名称不能为空", 48, "提示信息"
Else
AdoRs.Open "select * from tb_zw where zw_mc='" + Text1(1).Text + "'", Cnn, adOpenKeyset
If AdoRs.RecordCount > 0 Then
MsgBox "该职务信息已经存在", 48, "提示信息"
AdoRs.Close
Else
AdoRs.Close
c = MsgBox("确认保存信息吗", 33, "提示信息")
If c = vbOK Then
Set AdoRs = Cnn.Execute("insert into tb_zw values('" & Text1(0) & "','" & Text1(1) & "','" & Text1(2) & "')")
MsgBox "数据保存成功", 64, "提示信息"
Else
End If
Adodc1.RecordSource = "select * from tb_zw order by zw_id"
Adodc1.Refresh
Call DBGCon
End If
Call Tbr_cortrol(Tbr_xxcz, True)
End If
End Sub
Private Sub Edits() '修改信息的事件过程
On Error Resume Next
AdoRs.Open "select * from tb_ygxx where ygxx_zw='" + Text1(1) + "'", Cnn, adOpenKeyset
If AdoRs.RecordCount > 0 Then
MsgBox "该职务下有关联信息,不允许修改", 48, "提示信息"
Else
c = MsgBox("确认修改信息吗", 33, "提示信息")
If c = vbOK Then
Set AdoRs = Cnn.Execute("UPDATE tb_zw SET zw_id='" + Text1(0) + "',zw_mc='" + Text1(1) + "',zw_sm='" + Text1(2) + "' where zw_id='" + Text1(0).Text + "'")
MsgBox "数据修改成功", 64, "提示信息"
Adodc1.Refresh
StrId = Text1(0).Text
StrTitle = Text1(1).Text
Call joinRZ
Call DBGCon
End If
End If
AdoRs.Close
End Sub
Private Sub LoadFile()
AdoRs.Open "select * from tb_zw", Cnn, adOpenKeyset
If AdoRs.RecordCount > 0 Then
On Error Resume Next
Text1(0).Text = AdoRs.Fields("zw_id")
Text1(1).Text = AdoRs.Fields("zw_mc")
Text1(2).Text = AdoRs.Fields("zw_sm")
End If
AdoRs.Close
End Sub
Private Sub LTbrControl()
Tbr_Gsxx.Buttons(1).Enabled = True
Tbr_Gsxx.Buttons(2).Enabled = False
Tbr_Gsxx.Buttons(3).Enabled = True
End Sub
Private Sub CTbrControl() '单击编辑按钮
Tbr_Gsxx.Buttons(1).Enabled = False
Tbr_Gsxx.Buttons(2).Enabled = True
Tbr_Gsxx.Buttons(3).Enabled = True
End Sub
Private Sub Deletes() '删除信息
AdoRs.Open "select * from tb_ygxx where ygxx_zw='" + Text1(1) + "'", Cnn, adOpenKeyset
If AdoRs.RecordCount > 0 Then
MsgBox "该职务下有关联信息,不允许删除", 48, "提示信息"
Else
c = MsgBox("确认删除该信息吗", 17, "提示信息")
If c = vbOK Then
On Error Resume Next
Adodc1.Recordset.Delete
End If
For i = 0 To 2
Text1(i).Text = ""
Next i
End If
AdoRs.Close
End Sub
Private Sub DBGCon()
Dgr_bmzl.Columns(0).Caption = "编号"
Dgr_bmzl.Columns(1).Caption = "职务名称"
Dgr_bmzl.Columns(2).Visible = False
Dgr_bmzl.Columns(0).Width = 800
Dgr_bmzl.Columns(1).Width = 1380
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -