📄 frmcx.frm
字号:
Height = 165
Left = 585
TabIndex = 15
Top = 690
Width = 720
End
End
Begin VB.Frame Frame2
Caption = "查询条件"
ForeColor = &H00FF0000&
Height = 1335
Left = 270
TabIndex = 7
Top = 285
Width = 4230
Begin VB.ComboBox Combo2
Height = 300
Left = 1335
TabIndex = 1
Top = 540
Width = 1905
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1335
TabIndex = 0
Top = 210
Width = 1905
End
Begin VB.Label Label2
Caption = "供应商:"
Height = 225
Left = 540
TabIndex = 12
Top = 585
Width = 765
End
Begin VB.Label Label1
Caption = "商品名称:"
Height = 195
Left = 375
TabIndex = 11
Top = 270
Width = 930
End
End
Begin ComctlLib.TreeView Treeview
Height = 3510
Left = 240
TabIndex = 17
Top = 1635
Width = 2685
_ExtentX = 4736
_ExtentY = 6191
_Version = 327682
Indentation = 317
LabelEdit = 1
LineStyle = 1
Style = 7
ImageList = "imlSmallIcons"
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
OLEDropMode = 1
End
Begin ComctlLib.ImageList imlSmallIcons
Left = 90
Top = 1575
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 13
ImageHeight = 13
MaskColor = 12632256
UseMaskColor = 0 'False
_Version = 327682
BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7}
NumListImages = 5
BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "frmcx.frx":030A
Key = "SClosed"
EndProperty
BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "frmcx.frx":082C
Key = "Open"
EndProperty
BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "frmcx.frx":0D4E
Key = "File"
EndProperty
BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "frmcx.frx":1270
Key = "SOpen"
EndProperty
BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "frmcx.frx":1792
Key = "Closed"
EndProperty
EndProperty
End
End
Begin MSComctlLib.TabStrip TabStrip1
Height = 5580
Left = 75
TabIndex = 5
Top = 60
Width = 10905
_ExtentX = 19235
_ExtentY = 9843
_Version = 393216
BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628}
NumTabs = 1
BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628}
Caption = "查询"
ImageVarType = 2
EndProperty
EndProperty
End
End
Attribute VB_Name = "frmcx"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs As ADODB.Recordset
Dim mNode As ComctlLib.Node
Dim adoGRs As ADODB.Recordset
Dim adoSRs As ADODB.Recordset '
Dim adoZRs As ADODB.Recordset '子公司
Private Sub Combo1_KeyPress(KeyAscii As Integer)
Call IfEnterKeyMoveNext(KeyAscii)
End Sub
Private Sub Combo2_KeyPress(KeyAscii As Integer)
Call IfEnterKeyMoveNext(KeyAscii)
End Sub
Private Sub Command1_Click()
Dim strSQL As String
If Trim(Combo1.Text) = "" And Trim(Combo2.Text) = "" Then
MsgBox "请输入或选择项目!", vbExclamation, "上海华盟电讯科技公司"
Combo1.SetFocus
Exit Sub
End If
If Trim(txtStart.Text) <> "" And Trim(txtEnd.Text) <> "" Then
strSQL = "select * from stock_info where stock_product_name like '%" & Trim(Combo1.Text) & "%' and stock_provider_name like '%" & Trim(Me.Combo2.Text) & "%' and stock_date >='" & Trim(txtStart.Text) & "' and stock_date<='" & Trim(Me.txtEnd.Text) & "'"
ElseIf Trim(txtStart.Text) = "" And Trim(txtEnd.Text) = "" Then
strSQL = "select * from stock_info where stock_product_name like '%" & Trim(Combo1.Text) & "%' and stock_provider_name like '%" & Trim(Me.Combo2.Text) & "%'"
End If
Set adoSRs = New ADODB.Recordset
Set adoSRs.ActiveConnection = DB
adoSRs.CursorLocation = adUseClient
adoSRs.CursorType = adOpenForwardOnly
adoSRs.LockType = adLockOptimistic
adoSRs.Open strSQL
Set DataGrid1.DataSource = adoSRs
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub DTPicker1_CloseUp()
txtStart.Text = Format(DTPicker1.value, "yyyy-mm-dd")
End Sub
Private Sub DTPicker2_CloseUp()
txtEnd.Text = Format(DTPicker2.value, "yyyy-mm-dd")
End Sub
Private Sub Form_Load()
MoveToCenter gMainFormRefer, Me
DTPicker1.value = Format(Date, "yyyy-mm-dd")
DTPicker2.value = Format(Date, "yyyy-mm-dd")
Set rs = New ADODB.Recordset
Set rs.ActiveConnection = DB
rs.CursorLocation = adUseClient
rs.CursorType = adOpenForwardOnly
rs.LockType = adLockOptimistic
rs.Open "select product_name from product"
Set adoGRs = New ADODB.Recordset
Set adoGRs.ActiveConnection = DB
adoGRs.CursorLocation = adUseClient
adoGRs.CursorType = adOpenForwardOnly
adoGRs.LockType = adLockOptimistic
adoGRs.Open "select provider_name from provider"
Set adoZRs = New ADODB.Recordset
Set adoZRs.ActiveConnection = DB
adoZRs.CursorLocation = adUseClient
adoZRs.CursorType = adOpenForwardOnly
adoZRs.LockType = adLockOptimistic
adoZRs.Open "select corporation_Name from Filiale"
'----------------------------------------------------------------
'读入产品名称
Do While Not rs.EOF
Combo1.AddItem Trim(rs!Product_Name)
rs.MoveNext
Loop
'----------------------------------------------------------------
'读入供应商名称
Do While Not adoGRs.EOF
Combo2.AddItem Trim(adoGRs!Provider_Name)
adoGRs.MoveNext
Loop
'-----------------------------------------------------------
'读出在Treeview显示
Call Init_Tree(Treeview)
End Sub
Private Sub Form_Unload(Cancel As Integer)
rs.Close
adoGRs.Close
Set adoGRs = Nothing
Set rs = Nothing
End Sub
Private Sub TabStrip1_Click()
End Sub
Private Sub TreeView_Collapse(ByVal Node As ComctlLib.Node)
If Node.Tag = "FileManager" Then Node.Image = "Closed"
If Node.Tag = "File" Then Node.Image = "SClosed"
End Sub
Private Sub TreeView_Expand(ByVal Node As ComctlLib.Node)
If Node.Tag = "FileManager" Then Node.Image = "Open"
If Node.Tag = "File" Then Node.Image = "SOpen"
End Sub
Private Sub TreeView_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
PopupMenu MnuControl
End If
End Sub
Private Sub Init_Tree(ByRef Tree As ComctlLib.Treeview)
Dim Pre_LEN As Integer
Dim Self_LEN As Integer
Dim Depth As Integer
Dim New_Node As ComctlLib.Node
Dim Root_Node As ComctlLib.Node
Dim Last_Node As ComctlLib.Node
Dim Father_Node As ComctlLib.Node
Pre_LEN = 0
Tree.Nodes.Clear
Set rs = New ADODB.Recordset
rs.CursorType = adOpenDynamic
rs.CursorLocation = adUseClient
rs.LockType = adLockOptimistic
rs.ActiveConnection = DB
rs.Open "SELECT * FROM CLASS ORDER BY Class_Code"
Set New_Node = Tree.Nodes.Add(, , "Root", "产品信息", "Closed")
Set Root_Node = Tree.Nodes(1)
Dim num As Integer
num = 1
While rs.EOF = False
num = num + 1
Set Last_Node = New_Node
Self_LEN = Len(rs.Fields("Class_Code").value)
Depth = (Pre_LEN - Self_LEN) / 3
If Depth > 0 Then
Set Father_Node = Last_Node
For i = 0 To Depth
Set Father_Node = Father_Node.Parent
Next i
End If
If Depth > 0 Then Set New_Node = Tree.Nodes.Add(Father_Node, tvwChild, "AD" & rs.Fields("Class_Code").value, rs.Fields("class_Name").value, "SClosed")
If Depth = 0 Then Set New_Node = Tree.Nodes.Add(Last_Node, tvwNext, "AD" & rs.Fields("Class_Code").value, rs.Fields("class_Name").value, "SClosed")
If Depth < 0 Then Set New_Node = Tree.Nodes.Add(Last_Node, tvwChild, "AD" & rs.Fields("Class_Code").value, rs.Fields("class_Name").value, "SClosed")
Pre_LEN = Self_LEN
Set Last_Node = New_Node
rs.MoveNext
Wend
End Sub
Private Sub Treeview_NodeClick(ByVal Node As ComctlLib.Node)
Dim strKey As String
Dim strSQL As String
Set rs = New ADODB.Recordset
Set rs.ActiveConnection = DB
rs.CursorLocation = adUseClient
rs.CursorType = adOpenForwardOnly
rs.LockType = adLockOptimistic
If (Node.Key = "Root") Then
strSQL = "select * from stock_info"
Else
strKey = Right(Node.Key, Len(Node.Key) - 2)
strSQL = "select * from stock_info where left(stock_product_class,'" & Len(strKey) & "')='" & strKey & "'"
End If
rs.Open strSQL
Set DataGrid1.DataSource = rs
End Sub
Private Sub txtEnd_GotFocus()
Call AutoSelectText(txtEnd)
End Sub
Private Sub txtStart_GotFocus()
Call AutoSelectText(txtStart)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -