📄
字号:
Private Sub BanlGrid2_LeaveCell() '离开单元格
If Changelock Then
Exit Sub
End If
'记录刚刚离开网格单元的行列值
Dqlkwgh = BanlGrid2.Row
Dqlkwgl = BanlGrid2.Col
'判断是否需要录入数据回写
If Not (Ydtext.Visible Or YdCombo.Visible) Then
Exit Sub
End If
Call Lrsjhx
End Sub
Private Sub BanlGrid2_RowColChange() '网格录入行列发生变化时,进行有效性判断
Valilock = True '屏蔽文本框失去焦点进行有效性判断
With BanlGrid2
If Changelock Then
Exit Sub
End If
If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
Exit Sub
End If
If .Row <> Dqlkwgh Then
If Not Sjhzyxxpd(Dqlkwgh) Then
Exit Sub
End If
End If
End With
Call fhyxh
Call Xldql
End Sub
Private Sub BanlGrid2_DblClick() '鼠标双击网格显示文本框
With BanlGrid2
Call xswbk
End With
End Sub
Private Sub Ycwbk() '隐藏文本框,帮助按钮,列表组合框
Valilock = True
Ydtext.Visible = False
YdCombo.Visible = False
Ydcommand.Visible = False
End Sub
Private Sub SzToolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
If Trim(Ydtext) = "" Then
Call Ycwbk
End If
Select Case Button.Key
Case "ymsz" '页面设置
Dyymctbl.Show 1
Case "yl" '预 览
Call bbyl(True)
Case "dy" '打 印
Call bbyl(False)
Case "gl"
Balance_KF_Query.Show 1
Case "fp"
Balance_KF_Invoice.Now_FilterCondition = FilterInvoice
Balance_KF_Invoice.Show 1
Case "rkd"
Balance_KF_InOut.Now_FilterCondition = FilterInOut
Balance_KF_InOut.Show 1
Case "js"
If Fun_Drfrmyxxpd Then Call Sub_HandBalance
Case "bz" '帮 助
Call F1bz
Case "fh" '退 出
Unload Me
End Select
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
Dim jsqte As Integer
FilterInvoice = " where 1=1 "
FilterInOut = " where 1=1 "
With Balance_KF_Query
For jsqte = 1 To 5
Select Case jsqte
Case 1 '查询日期范围(起始)
If Trim(.LrText(0).Text) <> "" Then
FilterInvoice = FilterInvoice & " And InvoiceDate>=convert(datetime,'" & Trim(.LrText(0).Text) & "')"
FilterInOut = FilterInOut & " And BillDate>=convert(datetime,'" & Trim(.LrText(0).Text) & "')"
End If
Case 2 '查询日期范围(终止)
If Trim(.LrText(1).Text) <> "" Then
FilterInvoice = FilterInvoice & " And InvoiceDate<= convert(datetime,'" & Trim(.LrText(1).Text) & "')"
FilterInOut = FilterInOut & " And BillDate<= convert(datetime,'" & Trim(.LrText(1).Text) & "')"
End If
Case 3 '供应商(Like)
If Trim(.LrText(2).Text) <> "" Then
FilterInvoice = FilterInvoice & " And ( SupplierCode like '%" & Trim(.LrText(2).Text) & "%' or SupplierName like '%" & Trim(.LrText(2).Text) & "%')"
FilterInOut = FilterInOut & " And ( SupplierCode like '%" & Trim(.LrText(2).Text) & "%' or SupplierName like '%" & Trim(.LrText(2).Text) & "%')"
End If
Case 4 '物料分类
If Trim(.LrText(3).Text) <> "" Then
FilterInvoice = FilterInvoice & " and InvSortcode like '" & Trim(.LrText(3).Tag) & "%'"
FilterInOut = FilterInOut & " and InvSortcode like '" & Trim(.LrText(3).Tag) & "%'"
End If
Case 5 '物料
If Trim(.LrText(4).Text) <> "" Then
FilterInvoice = FilterInvoice & " and MNumber like '%" & Trim(.LrText(4).Text) & "%'"
FilterInOut = FilterInOut & " and MNumber like '%" & Trim(.LrText(4).Text) & "%'"
End If
End Select
Next
End With
FilterInOut = FilterInOut & " And WhCode in (select whcode from KF_V_WhLimit where ltrim(rtrim(Czybm))='" & Xtczybm & "')"
End Sub
Private Sub Timer2_Timer()
Timer2.Enabled = False
Dim int_temp As Integer
Dim rst_temp As New ADODB.Recordset
Dim str_sqlTemp As String
Dim Jsqte1 As Integer
Dim Jsqte2 As Integer
BanlGrid1.Rows = BanlGrid1.FixedRows
BanlGrid2.Rows = BanlGrid2.FixedRows
str_sqlTemp = "SELECT 0 as IsInvoice, InOutMainId as Mainid, InOutSubId as SubId, MNumber, MName, Model, PrimaryUnitName, BillNum, " & _
" '' AS InvoiceNum, FactReceiptQuan, 0 AS InvoiceQuan, Price, 0 AS InvoicePriceBb, " & _
" EMoney, 0 AS InvoiceTotalMoneyBb, 0 AS Ischarge ,'' as SupplierCode,'' as SupplierName " & _
" From KF_V_BalanceInOut " & "Where " & Me.InOut_FilterCondition & _
" Union " & _
" SELECT 1 as IsInvoice,InvoiceMainID as Mainid, InvoiceSubID as Subid , MNumber, MName, Model, PrimaryUnitName, " & _
" '' AS InoutNum, InvoiceNum, 0 AS InOutQuan, Quantity, 0 AS InoutPrice, PriceBb, " & _
" 0 AS InOutMoney, TotalMoneyBb, IsCharge ,SupplierCode, SupplierName" & _
" From KF_V_BalanceInvoice where " & Me.Invoice_FilterCondition & _
" ORDER BY MNumber, IsInvoice "
Set rst_temp = Cw_DataEnvi.DataConnect.Execute(str_sqlTemp)
Jsqte1 = BanlGrid1.FixedRows
Jsqte2 = BanlGrid2.FixedRows
If rst_temp.RecordCount <> 0 Then
rst_temp.MoveFirst
For int_temp = 1 To rst_temp.RecordCount
If rst_temp.Fields("IsCharge") = False Then '是否费用
With BanlGrid1
If Jsqte1 >= .Rows Then
.AddItem ""
End If
.TextMatrix(Jsqte1, 0) = Trim("" & rst_temp.Fields("MNumber"))
.TextMatrix(Jsqte1, 1) = rst_temp.Fields("IsInvoice")
.TextMatrix(Jsqte1, 2) = rst_temp.Fields("Mainid") '主表ID
.TextMatrix(Jsqte1, 3) = rst_temp.Fields("SubId") '子表ID
.TextMatrix(Jsqte1, Sydz("001", GridStr1(), Szzls1)) = Trim("" & rst_temp.Fields("MNumber"))
.TextMatrix(Jsqte1, Sydz("002", GridStr1(), Szzls1)) = Trim("" & rst_temp.Fields("MName"))
.TextMatrix(Jsqte1, Sydz("003", GridStr1(), Szzls1)) = Trim(rst_temp.Fields("Model") & "")
.TextMatrix(Jsqte1, Sydz("004", GridStr1(), Szzls1)) = Trim(rst_temp.Fields("PrimaryUnitName") & "")
.TextMatrix(Jsqte1, Sydz("005", GridStr1(), Szzls1)) = Trim(rst_temp.Fields("BillNum") & "")
.TextMatrix(Jsqte1, Sydz("006", GridStr1(), Szzls1)) = Trim("" & rst_temp.Fields("InvoiceNum"))
.TextMatrix(Jsqte1, Sydz("007", GridStr1(), Szzls1)) = IIf(IsNull(rst_temp.Fields("FactReceiptQuan")) Or rst_temp.Fields("FactReceiptQuan") = 0, "", rst_temp.Fields("FactReceiptQuan"))
.TextMatrix(Jsqte1, Sydz("008", GridStr1(), Szzls1)) = IIf(IsNull(rst_temp.Fields("InvoiceQuan")) Or rst_temp.Fields("InvoiceQuan") = 0, "", rst_temp.Fields("InvoiceQuan"))
.TextMatrix(Jsqte1, Sydz("009", GridStr1(), Szzls1)) = IIf(IsNull(rst_temp.Fields("Price")) Or rst_temp.Fields("Price") = 0, "", rst_temp.Fields("Price"))
.TextMatrix(Jsqte1, Sydz("010", GridStr1(), Szzls1)) = IIf(IsNull(rst_temp.Fields("InvoicePriceBb")) Or rst_temp.Fields("InvoicePriceBb") = 0, "", rst_temp.Fields("InvoicePriceBb"))
.TextMatrix(Jsqte1, Sydz("011", GridStr1(), Szzls1)) = IIf(IsNull(rst_temp.Fields("EMoney")) Or rst_temp.Fields("EMoney") = 0, "", rst_temp.Fields("EMoney"))
.TextMatrix(Jsqte1, Sydz("012", GridStr1(), Szzls1)) = IIf(IsNull(rst_temp.Fields("InvoiceTotalMoneyBb")) Or rst_temp.Fields("InvoiceTotalMoneyBb") = 0, "", rst_temp.Fields("InvoiceTotalMoneyBb"))
.RowHeight(Jsqte1) = Sjhgd1
Jsqte1 = Jsqte1 + 1
End With
ElseIf rst_temp.Fields("IsCharge") = 1 And rst_temp.Fields("IsInvoice") = 1 Then
With BanlGrid2
If Jsqte2 >= .Rows Then
.AddItem ""
End If
.TextMatrix(Jsqte2, 1) = rst_temp.Fields("IsInvoice")
.TextMatrix(Jsqte2, 2) = rst_temp.Fields("Mainid") '主表ID
.TextMatrix(Jsqte2, 3) = rst_temp.Fields("SubId") '子表ID
.TextMatrix(Jsqte2, Sydz("001", GridStr(), Szzls)) = Trim("" & rst_temp.Fields("MNumber")) '
.TextMatrix(Jsqte2, Sydz("002", GridStr(), Szzls)) = Trim("" & rst_temp.Fields("MName"))
.TextMatrix(Jsqte2, Sydz("003", GridStr(), Szzls)) = Trim(rst_temp.Fields("Model") & "")
.TextMatrix(Jsqte2, Sydz("004", GridStr(), Szzls)) = Trim(rst_temp.Fields("PrimaryUnitName") & "")
.TextMatrix(Jsqte2, Sydz("005", GridStr(), Szzls)) = Trim(rst_temp.Fields("InvoiceNum") & "")
.TextMatrix(Jsqte2, Sydz("006", GridStr(), Szzls)) = IIf(IsNull(rst_temp.Fields("InvoiceQuan")) Or rst_temp.Fields("InvoiceQuan") = 0, "", rst_temp.Fields("InvoiceQuan"))
.TextMatrix(Jsqte2, Sydz("007", GridStr(), Szzls)) = IIf(IsNull(rst_temp.Fields("InvoiceTotalMoneyBb")) Or rst_temp.Fields("InvoiceTotalMoneyBb") = 0, "", rst_temp.Fields("InvoiceTotalMoneyBb"))
.TextMatrix(Jsqte2, Sydz("008", GridStr(), Szzls)) = Trim("" & rst_temp.Fields("SupplierName"))
.RowHeight(Jsqte2) = Sjhgd
Jsqte2 = Jsqte2 + 1
End With
End If
rst_temp.MoveNext
Next int_temp
End If
rst_temp.Close
Set rst_temp = Nothing
Call SubTotal '加入小合计
'''''''''''''''
For int_temp = BanlGrid1.FixedRows To BanlGrid1.Rows - 1
If BanlGrid1.IsSubtotal(int_temp) = True Then
BanlGrid1.TextMatrix(int_temp, Sydz("001", GridStr1(), Szzls1)) = "合 计"
End If
Next int_temp
''''''''''''''''
End Sub
Private Sub SubTotal()
Dim int_temp As Integer
If BanlGrid1.Rows <> BanlGrid1.FixedRows Then
BanlGrid1.BackColorAlternate = &H80000005
BanlGrid1.SubTotal flexSTSum, 0, Sydz("007", GridStr1(), Szzls1), , &HF7F3EC, , , "合计"
BanlGrid1.SubTotal flexSTSum, 0, Sydz("008", GridStr1(), Szzls1), , &HF7F3EC, , , "合计"
BanlGrid1.SubTotal flexSTSum, 0, Sydz("011", GridStr1(), Szzls1), , &HF7F3EC, , , "合计"
BanlGrid1.SubTotal flexSTSum, 0, Sydz("012", GridStr1(), Szzls1), , &HF7F3EC, , , "合计"
BanlGrid1.SubTotal flexSTSum, 0, Sydz("013", GridStr1(), Szzls1), , &HF7F3EC, , , "合计"
BanlGrid1.SubTotal flexSTSum, 0, Sydz("014", GridStr1(), Szzls1), , &HF7F3EC, , , "合计"
BanlGrid1.SubTotal flexSTSum, 0, Sydz("015", GridStr1(), Szzls1), , &HF7F3EC, , , "合计"
For int_temp = BanlGrid1.FixedRows To BanlGrid1.Rows - 1
If BanlGrid1.IsSubtotal(int_temp) = True Then
If BanlGrid1.ValueMatrix(int_temp, Sydz("007", GridStr1(), Szzls1)) = 0 Then
BanlGrid1.TextMatrix(int_temp, Sydz("007", GridStr1(), Szzls1)) = ""
End If
If BanlGrid1.ValueMatrix(int_temp, Sydz("008", GridStr1(), Szzls1)) = 0 Then
BanlGrid1.TextMatrix(int_temp, Sydz("008", GridStr1(), Szzls1)) = ""
End If
If BanlGrid1.ValueMatrix(int_temp, Sydz("011", GridStr1(), Szzls1)) = 0 Then
BanlGrid1.TextMatrix(int_temp, Sydz("011", GridStr1(), Szzls1)) = ""
End If
If BanlGrid1.ValueMatrix(int_temp, Sydz("012", GridStr1(), Szzls1)) = 0 Then
BanlGrid1.TextMatrix(int_temp, Sydz("012", GridStr1(), Szzls1)) = ""
End If
If BanlGrid1.ValueMatrix(int_temp, Sydz("013", GridStr1(), Szzls1)) = 0 Then
BanlGrid1.TextMatrix(int_temp, Sydz("013", GridStr1(), Szzls1)) = ""
End If
If BanlGrid1.ValueMatrix(int_temp, Sydz("014", GridStr1(), Szzls1)) = 0 Then
BanlGrid1.TextMatrix(int_temp, Sydz("014", GridStr1(), Szzls1)) = ""
End If
If BanlGrid1.ValueMatrix(int_temp, Sydz("015", GridStr1(), Szzls1)) = 0 Then
BanlGrid1.TextMatrix(int_temp, Sydz("015", GridStr1(), Szzls1)) = ""
End If
End If
Next int_temp
End If
End Sub
Private Sub YdCombo_KeyDown(KeyCode As Integer, Shift As Integer) '列表框移动
With BanlGrid2
Select Case KeyCode
Case vbKeyEscape 'ESC 键放弃录入
Valilock = True
.SetFocus
Call Ycwbk
Valilock = False
Case vbKeyReturn '回 车 键 =13
KeyCode = 0
.SetFocus
Call Lrsjhx
Rowjsq = .Row
Coljsq = .Col + 1
If Coljsq > .Cols - 1 Then
If Rowjsq < .Rows - 1 Then
Rowjsq = Rowjsq + 1
End If
Coljsq = Qslz
End If
Do While Rowjsq <= .Rows - 1
If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
Coljsq = Coljsq + 1
If Coljsq > .Cols - 1 Then
Rowjsq = Rowjsq + 1
Coljsq = Qslz
End If
Else
Exit Do
End If
Loop
.Select Rowjsq, Coljsq
Case vbKeyLeft '左 箭 头 =37
If .Col - 1 = Qslz Then
If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
GoTo jzzx
End If
End If
If .Col > Qslz Then
KeyCode = 0
.SetFocus
Call Lrsjhx
Coljsq = .Col - 1
Do While Coljsq > Qslz
If Coljsq - 1 = Qslz Then
If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
GoTo jzzx
End If
End If
If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
Coljsq = Coljsq - 1
Else
Exit Do
End If
Loop
.Select .Row, Coljsq
End If
Case vbKeyRight '右 箭 头 =39
KeyCode = 0
.SetFocus
Call Lrsjhx
Rowjsq = .Row
Coljsq = .Col + 1
If Coljsq > .Cols - 1 Then
If Rowjsq < .Rows - 1 Then
Rowjsq = Rowjsq + 1
End If
Coljsq = Qslz
End If
Do While Rowjsq <= .Rows - 1
If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
Coljsq = Coljsq + 1
If Coljsq > .Cols - 1 Then
Rowjsq = Rowjsq + 1
Coljsq = Qslz
End If
Else
Exit Do
End If
Loop
.Select Rowjsq, Coljsq
Case Else
End Select
jzzx:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -