📄 frm_finance.frm
字号:
Private Sub Chk_ByTime_Click()
Dim i As Integer
If Chk_ByTime.Value = 1 Then
Chk_ByTime.Caption = "按时间段从"
For i = 0 To 5
Txt_Date(i).Visible = True
Vscro_Date(i).Visible = True
Lbl_Date(i).Visible = True
Next i
Else
Chk_ByTime.Caption = "按时间段查询"
For i = 0 To 5
Txt_Date(i).Visible = False
Vscro_Date(i).Visible = False
Lbl_Date(i).Visible = False
Next i
End If
End Sub
Private Sub Cmd_Count_Click()
Dim intSum_No As Integer
Dim i As Integer
Dim cSum As Currency
Do Until Comb_Sum.Text = Grid_History.TextMatrix(0, intSum_No) Or intSum_No = Grid_History.Cols
intSum_No = intSum_No + 1
Loop
If Comb_Sum.Text = Grid_History.TextMatrix(0, intSum_No) Then
For i = 1 To Grid_History.Rows - 1
If Grid_History.TextMatrix(i, intSum_No) = "" Or Grid_History.TextMatrix(i, intSum_No) = Null Then Grid_History.TextMatrix(i, intSum_No) = "0"
cSum = cSum + CCur(Grid_History.TextMatrix(i, intSum_No))
Next i
Lbl_Sum = "总金额=" & CStr(cSum) & "元"
End If
End Sub
Private Sub Cmd_Exit_Click()
Unload Me
End Sub
Private Sub Cmd_Preview_Click()
Frm_PreView.strHeader = strTableName
Set Frm_PreView.MGrid = Grid_History
Frm_PreView.Show
End Sub
Private Sub Cmd_Print_Click()
Dim GPrinter As FlexPrinter
Printer.ScaleMode = vbPixels
Set GPrinter = New FlexPrinter
Set GPrinter.FlexName = Grid_History
GPrinter.CurPage = 1
GPrinter.Header = strTableName
GPrinter.Footer = STRGRGINFO
With GPrinter
.PosTop = 550
.PosLeft = 50
.HSpace = 0
.VSpace = 0
.RoundCorX = 10
.RoundCorY = 10
.GridPenStyle = 0
.bGridPrint = True
.bDrawBoarder = True
.BoarderColor = 0
.BoarderStyle = 0
.BoarderWidth = 1
.BoarderDistance = 5
Do
.PrintOut Printer
.CurPage = .CurPage + 1
Printer.EndDoc
Loop Until .CurPage = .TotalPages + 1
End With
End Sub
Private Sub Command1_Click()
Dim strSql As String
Select Case Frm_Login.Caption
Case "浏览维修记录登录"
strSql = "Select * From 维修记录表"
Case "浏览财务记录登录"
strSql = "select * From 财务登记表"
Case "浏览固定资产登录"
strSql = "select * From 设备表"
End Select
If Chk_ByTime.Value = 1 Then
'有时间条件
strSql = strSql & " Where ( " & Comb_DateField.Text & " between #" & DateBegin & "# and #" & dateEnd & "# )"
End If
If Chk_ByField.Value = 1 Then
If InStr(1, strSql, "where") > 0 Or InStr(1, strSql, "Where") > 0 Then
strSql = strSql & " And (" & Comb_Fields.Text & " like '*" & Txt_Condition.Text & "*')"
Else
strSql = strSql & " where " & Comb_Fields.Text & " like '*" & Txt_Condition.Text & "*'"
End If
End If
If Frm_Login.Caption = "浏览维修记录登录" Then
If Comb_Condition.Text <> "全部" Then
If InStr(1, strSql, "where") > 0 Or InStr(1, strSql, "Where") > 0 Then
strSql = strSql & " And ( 状态 = '" & Comb_Condition.Text & "')"
Else
strSql = strSql & " where 状态 = '" & Comb_Condition.Text & "'"
End If
End If
ElseIf Frm_Login.Caption = "浏览财务记录登录" Then
If Comb_Condition.Text <> "全部" Then
If InStr(1, strSql, "where") > 0 Or InStr(1, strSql, "Where") > 0 Then
strSql = strSql & " And ( 账目种类 = '" & Comb_Condition.Text & "')"
Else
strSql = strSql & " where 账目种类 = '" & Comb_Condition.Text & "'"
End If
End If
If Chk_Own.Value = 1 Then
If InStr(1, strSql, "where") > 0 Or InStr(1, strSql, "Where") > 0 Then
strSql = strSql & " And (实际金额 < 标的金额)"
Else
strSql = strSql & " where (实际金额 < 标的金额) "
End If
End If
End If
Set mrsHistory = dbHistory.OpenRecordset(strSql, dbOpenDynaset, dbReadOnly)
Call ShowRSByFlex(mrsHistory, Grid_History)
'qdfHistory.Close
mrsHistory.Close
Grid_Part.Rows = 1
Grid_Labor.Rows = 1
End Sub
Private Sub Form_Load()
Dim i As Integer
Dim strTitle As String
Dim mrsRepair As Recordset
Dim intFieldPoint As Integer
On Error GoTo ErrHandle
Txt_Date(3).Text = CStr(Year(Date))
Txt_Date(4).Text = CStr(Month(Date))
Txt_Date(5).Text = CStr(Day(Date))
If Txt_Date(4) = "1" Then
Txt_Date(0).Text = CStr(CInt(Year(Date)) - 1)
Txt_Date(2).Text = 12
Else
Txt_Date(0).Text = CStr(Year(Date))
Txt_Date(1).Text = CStr(Month(Date) - 1)
Txt_Date(2).Text = CStr(Day(Date))
End If
For i = 0 To 5
intPeriod(i) = CInt(Txt_Date(i).Text)
Txt_Date(i).Visible = False
Vscro_Date(i).Visible = False
Lbl_Date(i).Visible = False
Next i
Frm_Login.Txt_Name = ""
Frm_Login.Txt_PWD = ""
Frm_Login.Show vbModal
If strOkorEsc = "取消" Then
Unload Me
Exit Sub
End If
Set wksHistory = DBEngine.CreateWorkspace("History", Frm_Login.Txt_Name, Frm_Login.Txt_PWD, dbUseJet)
Set dbHistory = wksHistory.OpenDatabase(DBPATH, False, False)
If Frm_Login.Caption = "浏览维修记录登录" Then '浏览维修记录
strTableName = "维修记录表"
Comb_Condition.Clear
Comb_Condition.AddItem "全部"
Comb_Condition.AddItem "维修"
Comb_Condition.AddItem "返修"
Comb_Condition.ListIndex = 0
Set mrsHistory = dbHistory.OpenRecordset("维修记录表")
For i = 0 To mrsHistory.Fields.Count - 1
strTitle = strTitle & vbTab & mrsHistory.Fields(i).Name
If mrsHistory.Fields(i).Type = dbText Then Comb_Fields.AddItem mrsHistory.Fields(i).Name
Next i
'显示两个显示零配件和人工的Grid
With Grid_Part
.Cols = 6
.FixedCols = 0
.CellAlignment = flexAlignRightBottom
.ColWidth(0) = 400
.ColWidth(2) = 2000
.ColWidth(1) = 1000
.ColWidth(3) = 500
.ColWidth(4) = 700
.ColWidth(5) = 400
.SelectionMode = flexSelectionByRow
End With
Set mrsRepair = dbHistory.OpenRecordset("库存表", dbOpenSnapshot)
For intFieldPoint = 0 To 5
Grid_Part.TextMatrix(0, intFieldPoint) = mrsRepair.Fields(intFieldPoint).Name
Next intFieldPoint
mrsRepair.Close
With Grid_Labor
.Cols = 7
.FixedCols = 0
.CellAlignment = flexAlignRightBottom
.ColWidth(0) = 1000
.ColWidth(2) = 600
.ColWidth(1) = 1000
.ColWidth(3) = 1000
.ColWidth(4) = 800
.ColWidth(5) = 1000
.ColWidth(6) = 1000
.SelectionMode = flexSelectionByRow
End With
Set mrsRepair = dbHistory.OpenRecordset("人工价格表", dbOpenSnapshot)
For intFieldPoint = 1 To 7
Grid_Labor.TextMatrix(0, intFieldPoint - 1) = mrsRepair.Fields(intFieldPoint).Name
Next intFieldPoint
mrsRepair.Close
Grid_History.Height = 3015
Frame_Part.Visible = True
Frame_Labor.Visible = True
lbl_Custom.Visible = True
ElseIf Frm_Login.Caption = "浏览财务记录登录" Then '/0
'浏览财务记录
Chk_Own.Visible = True
lbl_Custom.Visible = False
strTableName = "财务登记表"
Set mrsHistory = dbHistory.OpenRecordset("账目种类表")
Comb_Condition.Clear
Comb_Condition.AddItem "全部"
If mrsHistory.RecordCount > 0 Then '/1
For i = 0 To mrsHistory.RecordCount - 1
Comb_Condition.AddItem mrsHistory.Fields("账目种类")
mrsHistory.MoveNext
Next i
Comb_Condition.ListIndex = 0
mrsHistory.Close
Set mrsHistory = dbHistory.OpenRecordset(strTableName)
For i = 0 To mrsHistory.Fields.Count - 1
strTitle = strTitle & vbTab & mrsHistory.Fields(i).Name
Next i
End If '/1
Grid_History.Height = 6100
ElseIf Frm_Login.Caption = "浏览固定资产登录" Then
lbl_Custom.Visible = False
strTableName = "设备表"
Comb_Condition.Visible = False
Comb_Condition.Text = ""
Set mrsHistory = dbHistory.OpenRecordset(strTableName)
For i = 0 To mrsHistory.Fields.Count - 1
strTitle = strTitle & vbTab & mrsHistory.Fields(i).Name
Next i
Grid_History.Height = 6100
End If
Grid_History.Cols = mrsHistory.Fields.Count
Grid_History.Rows = 0
strTitle = Mid(strTitle, 2)
Grid_History.AddItem strTitle
Comb_DateField.Clear
For i = 0 To mrsHistory.Fields.Count - 1
Select Case mrsHistory.Fields(i).Type
Case 8 '是date型
Comb_DateField.AddItem mrsHistory.Fields(i).Name
Case 5
Comb_Sum.AddItem mrsHistory.Fields(i).Name
If mrsHistory.Fields(i).Type = dbText Then Comb_Fields.AddItem mrsHistory.Fields(i).Name
Case Else
If mrsHistory.Fields(i).Type = dbText Then Comb_Fields.AddItem mrsHistory.Fields(i).Name
End Select
Next i
If Comb_DateField.ListCount > 0 Then Comb_DateField.ListIndex = 0
mrsHistory.Close
Comb_Fields.Visible = False
Lbl_Field.Visible = False
Txt_Condition.Visible = False
Comb_Fields.ListIndex = 0
Comb_DateField.ListIndex = 0
Comb_Sum.ListIndex = 0
Exit Sub
ErrHandle:
If strOkorEsc = "确定" Then MsgBox Err.Description, vbCritical + vbOKOnly, STRGARAGE
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
Frm_Login.Txt_Name = ""
Frm_Login.Txt_PWD = ""
End Sub
Private Sub Grid_History_Click()
Dim rsDetail As Recordset
If Grid_History.Row > 0 Then popMnu = True
If Me.Caption = "浏览维修记录" And Grid_History.Row > 0 Then
Set rsDetail = dbHistory.OpenRecordset("select 人工, 材料 from 维修记录表 Where ID= " _
& CLng(Grid_History.TextMatrix(Grid_History.Row, 0)), dbOpenSnapshot)
Call ReadFromTBLWait(rsDetail, Grid_Labor, "人工")
Call ReadFromTBLWait(rsDetail, Grid_Part, "材料")
rsDetail.Close
lbl_Custom.Caption = ShowCustomofCar(Grid_History.TextMatrix(Grid_History.Row, 1))
Else
Grid_History.ToolTipText = Grid_History.TextMatrix(Grid_History.Row, Grid_History.Col)
End If
End Sub
Private Sub Grid_History_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 And Me.Caption = "浏览维修记录" And popMnu Then
Me.PopupMenu mnuFedBack
End If
End Sub
Private Sub mnuReadFedBack_Click()
Set rsFedBack = dbHistory.OpenRecordset("Select 反馈意见 from 维修记录表 where ID = " _
& CLng(Grid_History.TextMatrix(Grid_History.Row, 0)), dbOpenDynaset)
frm_FedBack.Show
End Sub
Private Sub mnuWrite_Click()
Set rsFedBack = dbHistory.OpenRecordset("Select 反馈意见 from 维修记录表 where ID = " _
& CLng(Grid_History.TextMatrix(Grid_History.Row, 0)), dbOpenDynaset)
frm_FedBack.Show
End Sub
Private Sub Vscro_Date_Change(Index As Integer)
Dim intMaxDays As Integer
Select Case Index
Case 0, 3
Txt_Date(Index).Text = CStr(intPeriod(Index) + Vscro_Date(Index).Value)
Case 1, 4
If intPeriod(Index) + Vscro_Date(Index).Value <= 12 And intPeriod(Index) + Vscro_Date(Index).Value >= 1 Then
Txt_Date(Index).Text = CStr(intPeriod(Index) + Vscro_Date(Index).Value)
Else
If intPeriod(Index) + Vscro_Date(Index).Value > 12 Then Vscro_Date(Index).Value = 12 - intPeriod(Index)
If intPeriod(Index) + Vscro_Date(Index).Value < 1 Then Vscro_Date(Index).Value = 1 - intPeriod(Index)
End If
Case 2, 5
Select Case CInt(Txt_Date(Index - 1).Text)
Case 1, 3, 5, 7, 8, 10, 12
intMaxDays = 31
Case 2
If CInt(Txt_Date(Index - 2).Text) Mod 4 = 0 Then
intMaxDays = 29
Else
intMaxDays = 28
End If
Case Else
intMaxDays = 30
End Select
If intPeriod(Index) + Vscro_Date(Index).Value <= intMaxDays And intPeriod(Index) + Vscro_Date(Index).Value >= 1 Then
Txt_Date(Index).Text = CStr(CStr(intPeriod(Index) + Vscro_Date(Index).Value))
Else
If intPeriod(Index) + Vscro_Date(Index).Value > intMaxDays Then Vscro_Date(Index).Value = intMaxDays - intPeriod(Index)
If intPeriod(Index) + Vscro_Date(Index).Value < 1 Then Vscro_Date(Index).Value = 1 - intPeriod(Index)
End If
End Select
End Sub
Function DateBegin() As String
DateBegin = Txt_Date(1).Text & "/" & Txt_Date(2).Text & "/" & Txt_Date(0).Text
End Function
Function dateEnd() As String
dateEnd = Txt_Date(4).Text & "/" & Txt_Date(5).Text & "/" & Txt_Date(3).Text
End Function
Function ShowCustomofCar(CarNumber As String) As String
Dim i As Integer
Dim rsCar As Recordset
Dim pCarNum As Parameter
Set pCarNum = dbHistory.QueryDefs("用车牌查找车记录").Parameters![carnum]
pCarNum = CarNumber
Set rsCar = dbHistory.QueryDefs("用车牌查找车记录").OpenRecordset
If rsCar.RecordCount > 0 Then
With rsCar
ShowCustomofCar = "车辆基本情况:" & .Fields("颜色") & "色" & .Fields("型号") & ";" & .Fields("客户名称") & " " & " 联系人" & .Fields("联系人") & ";电话 :" & .Fields("电话") & " 手机:" & .Fields("手机")
End With
Else
ShowCustomofCar = "未登记"
End If
rsCar.Close
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -