?? formc2.frm
字號(hào):
MyRs0.Open StrSQL, cnnTce, adOpenKeyset, adLockOptimistic
N0 = MyRs0.RecordCount
If N0 > 0 Then
N0 = MyRs0.RecordCount: ReDim arrXm(N0, 2)
With Combo1
.Clear
.AddItem " "
For i = 1 To N0
.AddItem " " & MyRs0![Mc]
arrXm(i, 1) = MyRs0![dm]
arrXm(i, 2) = MyRs0![Mc]
MyRs0.MoveNext
Next
End With
MyRs0.Close
End If
End Sub
Private Sub P_init()
strFs = "0"
For i = 0 To 3
Text1(i) = "": Text1(i).Enabled = False
Next
Label3 = "備注:"
Combo1.Text = ""
End Sub
Private Sub P_grd1()
Set MyRs3 = New Recordset ' T_yf 表
StrSQL = "SELECT * FROM " & StrT3 & " Order By Bh Desc"
MyRs3.Open StrSQL, cnnTce, adOpenKeyset, adLockOptimistic
N3 = MyRs3.RecordCount ' N3: 條數(shù)
ReDim arrBh(N3 + 10, 3)
If N3 = 0 Then
Bh = 0 ' T_yf( Bh,Xm,Sj,Je,Sl,Bx,Rq,Bz)
Else
MyRs3.MoveLast
Bh = MyRs3![Bh] ' 最后的編號(hào)
End If
With MSFlexGrid1
.Clear
.Rows = IIf(N3 + 2 < intRs1, intRs1, N3 + 2) + 1
.Cols = 8
.Height = 225 * (intRs1 + 1) + 90
.Row = 0: .Col = 0: .Text = "編號(hào)": .ColWidth(0) = 500
.Col = 1: .Text = " 姓 名 ": .ColWidth(1) = 1050
.Col = 2: .Text = " 起 止 時(shí) 間": .ColWidth(2) = 2250
.Col = 3: .Text = " 金 額 ": .ColWidth(3) = 980
.Col = 4: .Text = " 單據(jù) ": .ColWidth(4) = 640
.Col = 5: .Text = " 報(bào)銷 ": .ColWidth(5) = 640
.Col = 6: .Text = " 報(bào)銷日期 ": .ColWidth(6) = 1160
.Col = 7: .Text = " 備 注": .ColWidth(7) = 1160 - IIf(.Rows > intRs1 + 1, 270, 0)
If N3 > 0 Then
MyRs3.MoveFirst
Jep = 0: Dsp = 0
For i = 1 To N3
arrBh(i, 0) = MyRs3![Bh]
arrBh(i, 1) = MyRs3![Bx]
arrBh(i, 2) = MyRs3![Rq]
Rq = MyRs3![Rq]
.TextMatrix(i, 0) = MyRs3![Bh] & " "
.TextMatrix(i, 1) = " " & MyRs3![Xm]
.TextMatrix(i, 2) = " " & MyRs3![Sj]
.TextMatrix(i, 3) = Format(MyRs3![Je], "0.00 ")
.TextMatrix(i, 4) = MyRs3![Sl] & " "
.TextMatrix(i, 5) = IIf(MyRs3![Bx] = "B", " √", "")
.TextMatrix(i, 6) = " " & MyRs3![Rq]
.TextMatrix(i, 7) = " " & MyRs3![Bz]
Jep = Jep + MyRs3![Je]
Dsp = Dsp + MyRs3![Sl]
MyRs3.MoveNext
Next
.TextMatrix(i + 1, 1) = " 累計(jì)"
.TextMatrix(i + 1, 3) = Format(Jep, "0.00 ")
.TextMatrix(i + 1, 4) = Dsp & " "
End If
' .MergeCol(1) = True
' .MergeCells = flexMergeRestrictColumns ' 單元格合并
.Visible = True
End With
End Sub
Private Sub P_grd2() ' 顯示 T_zm 表
Set MyRs2 = New Recordset
StrSQL = "SELECT * FROM " & StrT2 & strTj & " Order By Bh Desc,Rq Desc,Xh Desc"
MyRs2.Open StrSQL, cnnTce, adOpenKeyset, adLockOptimistic
N2 = MyRs2.RecordCount ' n2: 條數(shù)
With MSFlexGrid2
.Clear
.Top = MSFlexGrid1.Top + MSFlexGrid1.Height + 400
.Rows = IIf(N2 + 2 < intRs2, intRs2, N2 + 2) + 1
.Cols = 9
.Height = 225 * (intRs2 + 1) + 90
.Row = 0: .Col = 0: .Text = "序號(hào)": .ColWidth(0) = 500
.Col = 1: .Text = "編號(hào)": .ColWidth(1) = 500
.Col = 2: .Text = " 日期": .ColWidth(2) = 1150
.Col = 3: .Text = " 名 稱": .ColWidth(3) = 1690
.Col = 4: .Text = " 單價(jià) ": .ColWidth(4) = 860
.Col = 5: .Text = "數(shù)量": .ColWidth(5) = 560
.Col = 6: .Text = " 收 入 ": .ColWidth(6) = 980
.Col = 7: .Text = " 支 出 ": .ColWidth(7) = 980
.Col = 8: .Text = " 備 注": .ColWidth(8) = 1160 - IIf(.Rows > intRs2 + 1, 270, 0)
If N2 > 0 Then
ReDim arrZm(N2, 2)
MyRs2.MoveFirst
Srp = 0: Zcp = 0
Bhp = 0: m = 1
For i = 1 To N2
Rq = MyRs2![Rq]
Sz = MyRs2![Sz]
arrZm(i, 0) = MyRs2![Xh] ' 暫存記錄
arrZm(i, 1) = MyRs2![Sz]
arrZm(i, 2) = MyRs2![Lb]
If Bhp = MyRs2![Bh] Then
If m = 2 Then
.Row = i
For j = 1 To .Cols - 1
.Col = j: .CellBackColor = intCy2 ' 設(shè)置顏色
Next
End If
Else
Bhp = MyRs2![Bh]
m = IIf(m = 1, 2, 1)
If m = 2 Then
.Row = i
For j = 1 To .Cols - 1
.Col = j: .CellBackColor = intCx2 ' 設(shè)置顏色
Next
End If
End If
.TextMatrix(i, 0) = i & " "
.TextMatrix(i, 1) = MyRs2![Bh] & " "
.TextMatrix(i, 2) = " " & Rq
.TextMatrix(i, 3) = " " & MyRs2![Mc]
.TextMatrix(i, 4) = IIf(MyRs2![Dj] > 0, Format(MyRs2![Dj], "0.00 "), "")
.TextMatrix(i, 5) = IIf(MyRs2![Sl] > 0, MyRs2![Sl] & " ", "")
.TextMatrix(i, 6) = IIf(Sz = "s", Format(MyRs2![Sr], "0.00 "), "")
.TextMatrix(i, 7) = IIf(Sz = "z", Format(MyRs2![Zc], "0.00 "), "")
.TextMatrix(i, 8) = " " & MyRs2![Bz]
Srp = Srp + MyRs2![Sr]
Zcp = Zcp + MyRs2![Zc]
MyRs2.MoveNext
Next
.TextMatrix(i + 1, 2) = " 累計(jì)"
.TextMatrix(i + 1, 6) = IIf(Srp > 0, Format(Srp, "0.00 "), "")
.TextMatrix(i + 1, 7) = Format(Zcp, "0.00 ")
Else
MsgBox " 很抱歉,暫無(wú)相關(guān)記錄 ... ", 48, " 請(qǐng)注意"
End If
.MergeCol(1) = True
.MergeCells = flexMergeRestrictColumns ' 單元格合并
.Visible = True
End With
End Sub
Private Sub MSFlexGrid2_Click() ' 匯總報(bào)銷單
If strFs <> "3" Then Exit Sub
With MSFlexGrid2
'MsgBox .TextMatrix(.Row, 1)
If Trim(.TextMatrix(.Row, 1)) = "" Then Exit Sub
If Val(.TextMatrix(.Row, 1)) > 0 Then Exit Sub
If Trim(.TextMatrix(.Row, 7)) = "" Then Exit Sub
.Col = 1
If .TextMatrix(.Row, 8) Like "*√*" Then
.TextMatrix(.Row, 8) = ""
For j = 1 To .Cols - 1
.Col = j: .CellBackColor = intCy2 ' 顏色復(fù)原
Next
Text1(0) = " " & Val(Text1(0)) - 1
Text1(1) = " " & Format(Val(Text1(1)) - Val(.TextMatrix(.Row, 7)), "0.00")
Else
.TextMatrix(.Row, 8) = " √"
For j = 1 To .Cols - 1
.Col = j: .CellBackColor = intCx2 ' 設(shè)置顏色
Next
Text1(0) = " " & Val(Text1(0)) + 1
Text1(1) = " " & Format(Val(Text1(1)) + Val(.TextMatrix(.Row, 7)), "0.00")
End If
Command4.Enabled = True
Command5.Enabled = True
End With
End Sub
Private Sub Combo1_Click() ' 選中一人
strFs = "3"
dm = arrXm(Combo1.ListIndex, 1) ' 代碼 Dm
Xm = arrXm(Combo1.ListIndex, 2)
If Xm = "" Then
strTj = strYf ' 全部
Else
strTj = strYf & " And Mc Like '%" & Xm & "%'"
End If
Call P_grd2
Command4.Enabled = True
Command5.Enabled = False
Call P_qtxt
Text1(2).Enabled = True
Text1(3).Enabled = True
End Sub
Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer) ' 選中一筆報(bào)銷單
If KeyAscii = 13 Then Call MSFlexGrid1_Click
End Sub
Private Sub MSFlexGrid1_Click() ' 選中一單
With MSFlexGrid1
If .Row > N3 Then Exit Sub
strFs = "2"
k = .Row
Bhp = arrBh(k, 0)
Bxp = arrBh(k, 1)
Xmp = Trim(.TextMatrix(k, 1))
Sjp = Trim(.TextMatrix(k, 2))
Jep = Val(.TextMatrix(k, 3))
Combo1.Text = " " & Xmp
.Row = intRo1
For j = 1 To .Cols - 1
.Col = j: .CellBackColor = intCy1 ' 顏色復(fù)原
Next
intRo1 = k
.Row = k
For j = 1 To .Cols - 1
.Col = j: .CellBackColor = intCx1 ' 設(shè)置顏色
Next
Text1(0) = " " & Trim(.TextMatrix(k, 4))
Text1(1) = " " & Trim(.TextMatrix(k, 3))
Text1(2) = " " & Trim(.TextMatrix(k, 6))
Text1(3) = " " & Trim(.TextMatrix(k, 7))
Label3 = IIf(.TextMatrix(.Row, 5) Like "*√*", "返款日期:", "備注:")
Command4.Enabled = True
Command5.Enabled = True
strTj = strYf & " And Bh=" & Bhp & " And Mc Like '%" & Xmp & "%'"
Call P_grd2
Label4 = IIf(Bxp = "B", "已報(bào)銷返款", "已匯總送交") & "的醫(yī)藥費(fèi)單據(jù):"
If Trim(.TextMatrix(k, 5)) = "" Then
strTj = strYd & " And Bh=0 And Mc Like '%" & Xmp & "%'"
m = 0: Call P_grd3
End If
End With
End Sub
Private Sub P_grd3()
Set MyRs0 = New Recordset ' T_zm 表
StrSQL = "SELECT * FROM " & StrT2 & strTj & _
" Order By Rq Desc,Xh Desc"
'MsgBox StrSQL
MyRs0.Open StrSQL, cnnTce, adOpenKeyset, adLockOptimistic
N0 = MyRs0.RecordCount ' n0: 條數(shù)
If N0 < 1 Then
Exit Sub
End If
With MSFlexGrid2
.Height = 225 * (intRs1 + 1) + 90
.ColWidth(8) = 1160 - IIf(.Rows > intRs1 + 1, 270, 0)
End With
With MSFlexGrid3
.Clear
.Rows = IIf(N0 + 2 < intRs3, intRs3, N0 + 2) + 1
.Cols = 8
.Height = 225 * (intRs3 + 1) + 90
.Row = 0: .Col = 0: .Text = "序號(hào)": .ColWidth(0) = 500
.Col = 1: .Text = " 日期": .ColWidth(1) = 1150
.Col = 2: .Text = " 名 稱": .ColWidth(2) = 2130
.Col = 3: .Text = " 單價(jià) ": .ColWidth(3) = 860
.Col = 4: .Text = " 數(shù)量 ": .ColWidth(4) = 620
.Col = 5: .Text = " 收 入 ": .ColWidth(5) = 980
.Col = 6: .Text = " 支 出 ": .ColWidth(6) = 980
.Col = 7: .Text = " 備 注": .ColWidth(7) = 1160 - IIf(.Rows > intRs3 + 1, 270, 0)
If N0 > 0 Then
ReDim arrZm(N0, 3)
MyRs0.MoveFirst
Srp = 0: Zcp = 0
For i = 1 To N0
Rq = MyRs0![Rq]
Sz = MyRs0![Sz]
arrZm(i, 0) = MyRs0![Xh] ' 暫存記錄
arrZm(i, 1) = MyRs0![Sz]
arrZm(i, 2) = MyRs0![Lb]
arrZm(i, 3) = MyRs0![Rq]
.TextMatrix(i, 0) = i & " "
.TextMatrix(i, 1) = " " & Rq
.TextMatrix(i, 2) = " " & MyRs0![Mc]
.TextMatrix(i, 3) = IIf(MyRs0![Dj] > 0, Format(MyRs0![Dj], "0.00 "), "")
.TextMatrix(i, 4) = IIf(MyRs0![Sl] > 0, MyRs0![Sl] & " ", "")
.TextMatrix(i, 5) = IIf(Sz = "s", Format(MyRs0![Sr], "0.00 "), "")
.TextMatrix(i, 6) = IIf(Sz = "z", Format(MyRs0![Zc], "0.00 "), "")
.TextMatrix(i, 7) = " " & MyRs0![Bz]
Srp = Srp + MyRs0![Sr]
Zcp = Zcp + MyRs0![Zc]
MyRs0.MoveNext
Next
.TextMatrix(i + 1, 2) = " 累計(jì)"
.TextMatrix(i + 1, 5) = IIf(Srp > 0, Format(Srp, "0.00 "), "")
.TextMatrix(i + 1, 6) = Format(Zcp, "0.00 ")
End If
.MergeCol(1) = True
.MergeCells = flexMergeRestrictColumns ' 單元格合并
.Visible = True
End With
Text1(2).Enabled = True
Text1(3).Enabled = True
End Sub
Private Sub MSFlexGrid3_Click()
With MSFlexGrid3
If Trim(.TextMatrix(.Row, 1)) = "" Then Exit Sub
.Col = 1
If .TextMatrix(.Row, 7) Like "*√*" Then
m = m - 1
.TextMatrix(.Row, 7) = ""
For j = 1 To .Cols - 1
.Col = j: .CellBackColor = intCy3 ' 顏色復(fù)原
Next
Text1(0) = " " & Val(Text1(0)) - 1
Text1(1) = " " & Format(Val(Text1(1)) - Val(.TextMatrix(.Row, 6)), "0.00")
Else
m = m + 1
.TextMatrix(.Row, 7) = " √"
For j = 1 To .Cols - 1
.Col = j: .CellBackColor = intCx3 ' 設(shè)置顏色
Next
Text1(0) = " " & Val(Text1(0)) + 1
Text1(1) = " " & Format(Val(Text1(1)) + Val(.TextMatrix(.Row, 6)), "0.00")
End If
End With
End Sub
Private Sub Command4_Click() ' 待報(bào) ??
strTj = strYd
Xm = Trim(Combo1.Text)
If Xm <> "" Then
strTj = strTj & " And Mc Like '%" & Xm & "%'"
End If
Call P_qtxt
Call P_grd2
Label3 = "備注:"
Command4.Enabled = False
Command5.Enabled = True
End Sub
Private Sub P_qtxt()
For i = 0 To 3: Text1(i) = "": Next
Text1(2) = " " & StrCrq
End Sub
Private Sub Command5_Click() ' 全部
strTj = strYf
Xm = Trim(Combo1.Text)
If Xm <> "" Then
strTj = strTj & " And Mc Like '%" & Xm & "%'"
End If
Call P_qtxt
Call P_grd2
Label3 = "備注:"
MSFlexGrid1.Visible = True
MSFlexGrid3.Visible = False
Command4.Enabled = True
Command5.Enabled = False
End Sub
Private Sub Command6_Click() ' 退出
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next ' 關(guān)閉記錄集,釋放對(duì)象
MyRs0.Close: Set MyRs0 = Nothing
MyRs1.Close: Set MyRs1 = Nothing
MyRs2.Close: Set MyRs2 = Nothing
MyRs3.Close: Set MyRs3 = Nothing
End Sub
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -