📄 ware_compose_information1.frm
字号:
VERSION 5.00
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form ware_compose_information1
Caption = "department"
ClientHeight = 7665
ClientLeft = 1125
ClientTop = 360
ClientWidth = 6675
FillStyle = 0 'Solid
KeyPreview = -1 'True
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 7665
ScaleWidth = 6675
WindowState = 2 'Maximized
Begin VB.CommandButton Command1
Caption = "生成报表"
Height = 615
Left = 4320
TabIndex = 6
Top = 4800
Width = 2055
End
Begin MSDataListLib.DataCombo DataCombo1
Bindings = "ware_compose_information1.frx":0000
DataField = "blong_to"
DataMember = "Command3"
DataSource = "DataEnvironment1"
Height = 330
Left = 2160
TabIndex = 5
Top = 5280
Width = 1335
_ExtentX = 2355
_ExtentY = 582
_Version = 393216
ListField = "blong_to"
Text = "DataCombo1"
Object.DataMember = "Command1"
End
Begin VB.TextBox Text1
DataField = "blong_to"
DataMember = "Command3"
DataSource = "DataEnvironment1"
Height = 375
Left = 1920
TabIndex = 3
Text = "Text1"
Top = 4800
Width = 1215
End
Begin VB.CommandButton cmdClose
Cancel = -1 'True
Caption = "关闭(&C)"
Height = 300
Left = 5340
TabIndex = 0
Top = 3960
Width = 1080
End
Begin MSHierarchicalFlexGridLib.MSHFlexGrid MSHFlexGrid1
DragIcon = "ware_compose_information1.frx":0057
Height = 3840
Left = 60
TabIndex = 1
Top = 60
Width = 6360
_ExtentX = 11218
_ExtentY = 6773
_Version = 393216
BackColor = 16777215
ForeColor = 0
Rows = 19
Cols = 4
FixedCols = 0
BackColorFixed = 0
ForeColorFixed = 16777215
GridColor = 12632256
GridColorFixed = 0
WordWrap = -1 'True
AllowBigSelection= 0 'False
FocusRect = 0
HighLight = 0
MergeCells = 4
AllowUserResizing= 1
FormatString = " |||"
_NumberOfBands = 1
_Band(0).Cols = 4
_Band(0).GridLineWidthBand= 1
_Band(0).TextStyleBand= 0
End
Begin VB.Label Label2
Caption = "划分"
BeginProperty Font
Name = "黑体"
Size = 9.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 3360
TabIndex = 4
Top = 4800
Width = 615
End
Begin VB.Label Label1
Caption = "按"
Height = 255
Left = 1560
TabIndex = 2
Top = 4800
Width = 255
End
End
Attribute VB_Name = "ware_compose_information1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Const MARGIN_SIZE = 60 ' 单位为缇
' 数据绑定变量
Private datPrimaryRS As ADODB.Recordset
' 列拖拽变量
Private m_bDragOK As Boolean
Private m_iDragCol As Integer
Private xdn As Integer, ydn As Integer
Private Sub Command1_Click()
'sconi = Text1.Text
'sconi = DataCombo1.SelectedItem
Dim f As New index_blong
f.Show
End Sub
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
sconi = DataCombo1.SelectedItem
End Sub
Private Sub Form_Load()
Dim sConnect As String
Dim sSQL As String
Dim dfwConn As ADODB.Connection
Dim ii As Integer
Dim a As String
Dim b As String
Dim c As String
Dim d As String
Dim j As Integer
Dim strtotal As Variant
'设置字符串
a = "select distinct temp0.ware_layer_id as '零件编号',temp0.warename as '零件名称',temp0.quantity as '数量'"
b = ""
c = " temp0"
d = " from "
For j = 1 To i - 1
b = b & ",temp" & CStr(j) & ".ware_id as '零件编号'," & "temp" & CStr(j) & ".warename as '零件名称'," & "temp" & CStr(j) & ".quantity as '数量'"
c = c & " LEFT JOIN temp" & CStr(j) & " ON temp" & CStr(j - 1) & ".ware_layer_id = temp" & CStr(j) & ".war_ware_id)"
d = d & "("
strtotal = a & b & d
strtotal = strtotal & c
Next
strtotal = a & b & d & c
sConnect = "Provider=MSDASQL.1;Connect Timeout=15;Extended Properties='DRIVER=SQL Server;SERVER=ht;UID=sa;PWD=;APP=Visual Basic;WSID=HT;DATABASE=warehouse';Locale Identifier=2052"
' sSQL = "SELECT DISTINCT temp0.ware_layer_id, temp0.quantity, temp1.ware_id, temp1.warename, temp1.quantity, temp2.ware_id, temp2.warename, temp2.quantity, temp3.ware_id, temp3.warename, temp3.quantity, temp4.ware_id, temp4.warename, temp4.quantity FROM (((temp0 LEFT JOIN temp1 ON temp0.ware_layer_id = temp1.war_ware_id) LEFT JOIN temp2 ON temp1.ware_layer_id = temp2.war_ware_id) LEFT JOIN temp3 ON temp2.ware_layer_id = temp3.war_ware_id) LEFT JOIN temp4 ON temp3.ware_layer_id = temp4.war_ware_id"
sSQL = strtotal
' 打开连接
Set dfwConn = New Connection
dfwConn.Open sConnect
' 使用提供的集合创建 recordset
Set datPrimaryRS = New Recordset
datPrimaryRS.CursorLocation = adUseClient
datPrimaryRS.Open sSQL, dfwConn, adOpenForwardOnly, adLockReadOnly
Set MSHFlexGrid1.DataSource = datPrimaryRS
With MSHFlexGrid1
.Redraw = False
' 设置网格列宽度
.ColWidth(0) = 1215
.ColWidth(1) = 1440
.ColWidth(2) = 1530
.ColWidth(3) = 2220
' 设置网格列合并和排序
For ii = 0 To .Cols - 1
''' If .Col = 0 Then
''' If MsgBox("没有生成零件", vbOKOnly, "没有生成零件") = vbOK Then Exit Sub
''' End If
'''''''''' .MergeCol(ii) = True
Next ii
.Sort = flexSortGenericAscending
' 设置网格样式
.AllowBigSelection = True
.FillStyle = flexFillRepeat
' 将标头作成粗体
.Row = 0
.Col = 0
.RowSel = .FixedRows - 1
'''''''''' .ColSel = .Cols - 1
.CellFontBold = True
.AllowBigSelection = False
.FillStyle = flexFillSingle
.Redraw = True
End With
End Sub
Private Sub MSHFlexGrid1_DragDrop(Source As Control, X As Single, Y As Single)
'-------------------------------------------------------------------------------------------
' 网格中 DragDrop, MouseDown, MouseMove, 和 MouseUp 事件代码能进行列拖拽
'-------------------------------------------------------------------------------------------
If m_iDragCol = -1 Then Exit Sub ' 现在不能拖拽
If MSHFlexGrid1.MouseRow <> 0 Then Exit Sub
With MSHFlexGrid1
.Redraw = False
.ColPosition(m_iDragCol) = .MouseCol
DoSort
.Redraw = True
End With
End Sub
Private Sub MSHFlexGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'-------------------------------------------------------------------------------------------
' 网格中 DragDrop, MouseDown, MouseMove, 和 MouseUp 事件代码能进行列拖拽
'-------------------------------------------------------------------------------------------
If MSHFlexGrid1.MouseRow <> 0 Then Exit Sub
xdn = X
ydn = Y
m_iDragCol = -1 ' 清除拖拽标志
m_bDragOK = True
End Sub
Private Sub MSHFlexGrid1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'-------------------------------------------------------------------------------------------
' 网格中 DragDrop, MouseDown, MouseMove, 和 MouseUp 事件代码能进行列拖拽
'-------------------------------------------------------------------------------------------
' 测试是否能够开始拖拽
If Not m_bDragOK Then Exit Sub
If Button <> 1 Then Exit Sub ' 错误按钮
If m_iDragCol <> -1 Then Exit Sub ' 已经开始拖拽
If Abs(xdn - X) + Abs(ydn - Y) < 50 Then Exit Sub ' 移得不够
If MSHFlexGrid1.MouseRow <> 0 Then Exit Sub ' 必须拖拽标头
' 如果到达这则开始拖拽
m_iDragCol = MSHFlexGrid1.MouseCol
MSHFlexGrid1.Drag vbBeginDrag
End Sub
Private Sub MSHFlexGrid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
'-------------------------------------------------------------------------------------------
' 网格中 DragDrop, MouseDown, MouseMove, 和 MouseUp 事件代码能进行列拖拽
'-------------------------------------------------------------------------------------------
m_bDragOK = False
End Sub
Sub DoSort()
With MSHFlexGrid1
.Redraw = False
.Col = 0
.Row = 1
.RowSel = .Rows - 1
.Sort = flexSortGenericAscending
.Redraw = True
End With
End Sub
Private Sub Form_Resize()
Dim sngButtonTop As Single
Dim sngScaleWidth As Single
Dim sngScaleHeight As Single
On Error GoTo Form_Resize_Error
With Me
sngScaleWidth = .ScaleWidth
sngScaleHeight = .ScaleHeight
' 移动“关闭”按钮到右下角
With .cmdClose
sngButtonTop = sngScaleHeight - (.Height + MARGIN_SIZE)
.Move sngScaleWidth - (.Width + MARGIN_SIZE), sngButtonTop
End With
.MSHFlexGrid1.Move MARGIN_SIZE, _
MARGIN_SIZE, _
sngScaleWidth - (2 * MARGIN_SIZE), _
sngButtonTop - (2 * MARGIN_SIZE)
End With
Exit Sub
Form_Resize_Error:
' 避免负值错误
Resume Next
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -