?? frmsq.frm
字號:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmsq
BackColor = &H00C0E0FF&
BorderStyle = 3 'Fixed Dialog
Caption = "操作員管理"
ClientHeight = 4230
ClientLeft = 45
ClientTop = 330
ClientWidth = 5910
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 4230
ScaleWidth = 5910
ShowInTaskbar = 0 'False
Begin MSComctlLib.ImageList ImageList1
Left = 2160
Top = 2730
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 2
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "FRMSQ.frx":0000
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "FRMSQ.frx":059C
Key = ""
EndProperty
EndProperty
End
Begin VB.PictureBox Picture1
BackColor = &H00C0E0FF&
Height = 3705
Left = 180
ScaleHeight = 3645
ScaleWidth = 5445
TabIndex = 0
Top = 210
Width = 5505
Begin MSComctlLib.TreeView tvwdb
Height = 3285
Left = 210
TabIndex = 6
Top = 120
Width = 3105
_ExtentX = 5477
_ExtentY = 5794
_Version = 393217
Sorted = -1 'True
Style = 7
ImageList = "ImageList1"
Appearance = 1
MousePointer = 99
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Frame Frame1
BackColor = &H00C0E0FF&
Height = 3345
Left = 3450
TabIndex = 1
Top = 60
Width = 1785
Begin VB.CommandButton Command5
Cancel = -1 'True
Caption = "關閉(&E)"
Height = 585
Left = 270
TabIndex = 5
Top = 2520
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "刪除(&D)"
Height = 585
Left = 270
TabIndex = 4
Top = 1170
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "新增(&A)"
Height = 585
Left = 270
TabIndex = 3
Top = 420
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "授權(&S)"
Height = 585
Left = 240
TabIndex = 2
Top = 1860
Width = 1215
End
End
End
End
Attribute VB_Name = "frmsq"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rsdel As ADODB.Recordset
Dim mnode As Node
Private Sub Command1_Click()
frmadduser.Caption = "新增操作員信息"
isxg = False
frmadduser.Show vbModal
tvwdb.Nodes.Clear
Call loadtreeview
End Sub
Private Sub Command2_Click()
frmczql.Show vbModal
End Sub
Private Sub Command3_Click() '刪除操作人員的命令按鈕
'顯示對話框,是否刪除操作人員
t = MsgBox("你是否確定刪除該操作員!", vbOKCancel, "確定嗎?")
If t = 1 Then '如果返回1,則進行刪除操作
'判斷是否有記錄,如果沒有紀錄,則提示選擇操作人員
If rsdel.BOF = True Or rsdel.EOF = True Then
t = MsgBox("請選擇操作員姓名!", vbOKOnly, "無記錄")
Else '否則進行刪除,并顯示成功刪除操作人員對話框
rsdel.Delete
t = MsgBox("成功刪除操作員姓名!", vbOKOnly, "成功")
End If
tvwdb.Nodes.Clear '清除TreeView中節點的內容
tvwdb.Sorted = True '設置sorted屬性為真
Set mnode = tvwdb.Nodes.Add()
mnode.Text = "操作員姓名" '節點顯示“操作員姓名”
mnode.Image = 2 '設置節點的圖表為imagelist1中的圖2
Set rspsw = New ADODB.Recordset
rspsw.Open "select * from user_load", cn, adOpenStatic, adLockPessimistic
Do Until rspsw.EOF '用rspsw中的記錄對treeview進行加載
Set mnode = tvwdb.Nodes.Add(1, tvwChild) '添加treeview的孩子
mnode.Text = rspsw.Fields("user_name") '使其文本為rspsw字段中的用戶名
mnode.Image = 1 '設置節點的圖表為imagelist1中的圖1
rspsw.MoveNext '記錄往后移動一條
Loop
Else
Exit Sub
End If
End Sub
Private Sub Command5_Click()
Call close_condatabase '關閉數據庫連接
Unload Me '釋放該窗體
End Sub
Private Sub loadtreeview() '將用戶數據表中的用戶名加載到treeview控件中
tvwdb.Sorted = True '將treeview的排序設為真
Set mnode = tvwdb.Nodes.Add()
mnode.Text = "操作員姓名" '節點顯示“操作員姓名”
mnode.Image = 2 '設置節點的圖表為imagelist1中的圖2
If cn.State = 1 Then
Else
Call condatabase ' 連接數據庫
End If
Set rspsw = New ADODB.Recordset
'打開rspsw記錄集
rspsw.Open "select * from user_load", cn, adOpenStatic, adLockPessimistic
Do Until rspsw.EOF '用rspsw中的記錄對treeview進行加載
Set mnode = tvwdb.Nodes.Add(1, tvwChild) '添加treeview的孩子
mnode.Text = rspsw.Fields("user_name") '使其文本為rspsw字段中的用戶名
mnode.Image = 1 '設置節點的圖表為imagelist1中的圖1
rspsw.MoveNext '記錄往后移動一條
Loop
End Sub
Private Sub Form_Load() '窗體加載過程
Call loadtreeview '調用loadtreeview過程
End Sub
Private Sub Form_Unload(Cancel As Integer)
MainForm.StatusBar1.Panels(1).Text = "狀態: 無"
End Sub
Private Sub tvwdb_NodeClick(ByVal Node As MSComctlLib.Node) '處理nodeclick事件
If Node.Index = 1 Then '如果只有一個根節點,則退出程序
Exit Sub
End If
Call check_condatabase '檢查是否連接數據庫,如果連接了則放棄,否則連接
If Node.Parent.Index = 1 Then '是根節點
nodename = Node.Text '將刪除的變量賦值給nodename
Set rsdel = New ADODB.Recordset
'獲得該節點的用戶名的所有資料
rsdel.Open "select * from user_load where user_name='" & nodename & "'", cn, _
adOpenStatic, adLockPessimistic
End If
End Sub
'Download by http://www.codefans.net
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -