📄 frmhz.frm
字号:
Grid1.ColWidth(0) = 1200
Grid1.ColWidth(1) = 1800
Grid1.ColWidth(2) = 1800
Grid1.ColWidth(3) = 1400
Grid1.ColWidth(4) = 1400
Grid1.ColWidth(5) = 1200
Grid1.ColWidth(6) = 1600
Grid1.ColWidth(7) = 1500
On Error Resume Next
Set DB = OpenDatabase(ConData, False, False, Constr)
Set EF = DB.OpenRecordset("SellList", dbOpenTable)
'增加一个合计
Grid1.Rows = EF.RecordCount + 3
If Grid1.Rows < 29 Then
Grid1.Rows = 29
End If
Set EF = DB.OpenRecordset(StoreQueryString, dbOpenDynaset)
HH = 1
Do While Not EF.EOF()
Grid1.Row = HH
Grid1.Col = 0
Grid1.CellAlignment = 4
If Not IsNull(EF.Fields(0).Value) Then '物品类别 |^ 物品名称 |^ 物品代码|^ 单位 |^ 单价 |^ 数量 |^ 金额 |^ 购物日期
Grid1.Text = EF.Fields(0).Value
If CBranch = True Then
If Trim(Grid1.Text) <> MargeRowBN Then
tmpBN = Trim(Grid1.Text)
If CMerge = False Then
Grid1.MergeCells = 0
Grid1.MergeCol(0) = False
Grid1.MergeRow(HH - 1) = False
Grid1.MergeRow(HH) = False
End If
For X = 1 To 7
Grid1.Col = X
If CMerge = False Then
Grid1.CellBackColor = &H80C0FF
Else
Grid1.CellBackColor = RGB(0, 0, 0)
End If
Next
ElseIf CMerge = True Then
Grid1.MergeCells = 3
Grid1.MergeCol(0) = True
Grid1.MergeRow(HH - 1) = True
Grid1.MergeRow(HH) = True
Else
Grid1.MergeCells = 0
Grid1.MergeCol(0) = False
Grid1.MergeRow(HH - 1) = False
Grid1.MergeRow(HH) = False
End If
MargeRowBN = tmpBN
Else
Grid1.MergeCol(0) = False
End If
End If
Grid1.Col = 1
Grid1.CellAlignment = 1
If Not IsNull(EF.Fields(1).Value) Then
Grid1.Text = EF.Fields(1).Value
End If
Grid1.Col = 2
Grid1.CellAlignment = 1
If Not IsNull(EF.Fields(2).Value) Then
Grid1.Text = EF.Fields(2).Value
End If
Grid1.Col = 3
Grid1.CellAlignment = 1
If Not IsNull(EF.Fields(3).Value) Then
Grid1.Text = EF.Fields(3).Value '物品类别 |^ 物品名称 |^ 物品代码|^ 单位 |^ 单价 |^ 数量 |^ 金额 |^ 购物日期
End If
Grid1.Col = 4
Grid1.CellAlignment = 1
If Not IsNull(EF.Fields(4).Value) Then
Grid1.Text = Format(EF.Fields(4).Value, "Currency")
End If
Grid1.Col = 5
Grid1.CellAlignment = 1
If Not IsNull(EF.Fields(5).Value) Then
Grid1.Text = EF.Fields(5).Value
End If
Grid1.Col = 6
Grid1.CellAlignment = 1
If Not IsNull(EF.Fields(6).Value) Then
Grid1.Text = EF.Fields(6).Value
End If
Grid1.Col = 7
Grid1.CellAlignment = 1
If Not IsNull(EF.Fields(7).Value) Then
Grid1.Text = EF.Fields(7).Value
If CStyle = True Then
If Trim(Grid1.Text) <> MargeRow Then
tmpBN = Trim(Grid1.Text)
If CMerge = False Then
Grid1.MergeCells = 0
Grid1.MergeCol(7) = False
Grid1.MergeRow(HH - 1) = False
Grid1.MergeRow(HH) = False
End If
For X = 1 To 7
Grid1.Col = X
If CMerge = False Then
Grid1.CellBackColor = &H80C0FF
Else
Grid1.CellBackColor = RGB(0, 0, 0)
End If
Next
ElseIf CMerge = True Then
Grid1.MergeCells = 3
Grid1.MergeCol(7) = True
Grid1.MergeRow(HH - 1) = True
Grid1.MergeRow(HH) = True
Else
Grid1.MergeCells = flexMergeRestrictAll
End If
MargeRow = tmpBN
Else
Grid1.MergeCol(7) = False
End If
End If
EF.MoveNext
HH = HH + 1
Loop
EF.Close
DB.Close
Grid1.Row = HH + 1
For X = 1 To 8
Grid1.Col = X
Grid1.CellForeColor = RGB(255, 0, 0)
Next
'定义合计
Dim SumQTY As Long
Grid1.Col = 7
For X = 1 To HH - 1
Grid1.Row = X
SumQTY = SumQTY + Val(Grid1.Text)
Next
Grid1.Col = 1
Grid1.Row = HH + 1
Grid1.CellAlignment = 1
Grid1.CellFontBold = True
Grid1.CellFontSize = 10
Grid1.Text = "--合 计--"
Grid1.Col = 5
Grid1.CellAlignment = 1
Grid1.CellFontBold = True
Grid1.CellFontSize = 10
Grid1.Text = SumQTY
SumQTY = 0
Grid1.Col = 5 '合计第六行
For X = 1 To HH - 1
Grid1.Row = X
SumQTY = SumQTY + Val(Grid1.Text)
Next
Grid1.Col = 5 '写入
Grid1.Row = HH + 1
Grid1.CellAlignment = 1
Grid1.CellFontBold = True
Grid1.CellFontSize = 10
Grid1.Text = SumQTY
SumQTY = 0
Grid1.Col = 6 '合计第七行
For X = 1 To HH - 1
Grid1.Row = X
SumQTY = SumQTY + Val(Grid1.Text)
Next
Grid1.Col = 6 '写入
Grid1.Row = HH + 1
Grid1.CellAlignment = 1
Grid1.CellFontBold = True
Grid1.CellFontSize = 10
Grid1.Text = Format(SumQTY, "Currency")
'定义合计结束
Grid1.Col = 1
Grid1.Row = 20
Grid1.ColSel = 7
Grid1.Visible = True
Me.MousePointer = 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set frmHZ = Nothing
SCondStr = ""
End Sub
Private Sub Grid1_DblClick()
PopupMenu MnuStoreDisplay
End Sub
Private Sub Grid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
PopupMenu MnuStoreDisplay
End If
End Sub
Private Sub MnuDisplayAllStore_Click()
SCondStr = ""
Call QuerySell(optBranch.Value, optStyle.Value, MnuDisplayStoreMerge.Checked)
End Sub
Private Sub MnuDisplayStoreMerge_Click()
If MnuDisplayStoreMerge.Checked = True Then
MnuDisplayStoreMerge.Checked = False
Else
MnuDisplayStoreMerge.Checked = True
End If
'保存设置
SaveSetting App.EXEName, "MainOption", "库存合并归类的列", MnuDisplayStoreMerge.Checked
'刷新格式
Call QuerySell(optBranch, optStyle, MnuDisplayStoreMerge.Checked)
End Sub
Private Sub MnuPrint_Click()
cmdPrinter.Value = True
End Sub
Private Sub MnuReturn_Click()
Unload Me
End Sub
Private Sub MnuSearch_Click()
End Sub
Private Sub MnuStoreNameSort_Click()
optBranch.Value = True
End Sub
Private Sub MnuProductNameSort_Click()
optStyle.Value = True
End Sub
Private Sub MnuStorePrint_Click()
cmdPrinter.Value = True
End Sub
Private Sub MnuStoreSearch_Click()
cmdSearch.Value = True
End Sub
Private Sub optBranch_Click()
'与菜单同步
Call SortMethod(optBranch.Value, optStyle.Value)
If optBranch.Value = True Then
Call QuerySell(True, False, MnuDisplayStoreMerge.Checked)
End If
End Sub
Private Sub optStyle_Click()
'与菜单同步
Call SortMethod(optBranch.Value, optStyle.Value)
If optStyle.Value = True Then
Call QuerySell(False, True, MnuDisplayStoreMerge.Checked)
End If
End Sub
Private Sub SortMethod(SB As Boolean, SS As Boolean)
If SB = True Then
MnuStoreNameSort.Checked = True
MnuProductNameSort.Checked = False
Exit Sub
End If
If SS = True Then
MnuStoreNameSort.Checked = False
MnuProductNameSort.Checked = True
Exit Sub
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -