📄 frmcostfind.frm
字号:
VERSION 5.00
Begin VB.Form frmcostfind
BorderStyle = 1 'Fixed Single
Caption = "费用查询"
ClientHeight = 2655
ClientLeft = 5730
ClientTop = 2220
ClientWidth = 4680
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 2655
ScaleWidth = 4680
Begin VB.CommandButton cmdcancel
Caption = "取 消"
Height = 375
Left = 2880
TabIndex = 15
Top = 2160
Width = 1095
End
Begin VB.CommandButton cmdok
Caption = "确 定"
Height = 375
Left = 1560
TabIndex = 14
Top = 2160
Width = 1095
End
Begin VB.TextBox txtitem
Height = 375
Left = 1440
TabIndex = 3
Top = 240
Width = 3015
End
Begin VB.Frame Frame1
Height = 1335
Left = 1440
TabIndex = 2
Top = 720
Width = 3015
Begin VB.ComboBox cbomonth
Height = 300
Index = 1
Left = 1800
TabIndex = 12
Top = 840
Width = 615
End
Begin VB.ComboBox cboyear
Height = 300
Index = 1
Left = 480
TabIndex = 10
Top = 840
Width = 735
End
Begin VB.ComboBox cbomonth
Height = 300
Index = 0
Left = 1800
TabIndex = 7
Top = 240
Width = 615
End
Begin VB.ComboBox cboyear
Height = 300
Index = 0
Left = 480
TabIndex = 5
Top = 240
Width = 735
End
Begin VB.Label Label6
Caption = "月"
Height = 255
Left = 2640
TabIndex = 13
Top = 840
Width = 255
End
Begin VB.Label Label5
Caption = "年"
Height = 255
Left = 1440
TabIndex = 11
Top = 840
Width = 495
End
Begin VB.Label Label4
Caption = "到"
Height = 255
Left = 120
TabIndex = 9
Top = 840
Width = 495
End
Begin VB.Label Label3
Caption = "月"
Height = 255
Left = 2640
TabIndex = 8
Top = 240
Width = 255
End
Begin VB.Label Label2
Caption = "年"
Height = 255
Left = 1440
TabIndex = 6
Top = 240
Width = 255
End
Begin VB.Label Label1
Caption = "从"
Height = 255
Left = 120
TabIndex = 4
Top = 240
Width = 375
End
End
Begin VB.CheckBox chkitem
Caption = "时间查询:"
Height = 375
Index = 1
Left = 120
TabIndex = 1
Top = 720
Width = 1215
End
Begin VB.CheckBox chkitem
Caption = "车牌查询:"
Height = 375
Index = 0
Left = 120
TabIndex = 0
Top = 240
Value = 1 'Checked
Width = 1335
End
End
Attribute VB_Name = "frmcostfind"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cbomonth_Click(Index As Integer)
If cbomonth(0) <> "" And cbomonth(1) <> "" Then
If CInt(cboyear(0)) = CInt(cboyear(1)) Then
Select Case Index
Case 0
If CInt(cbomonth(Index)) > CInt(cbomonth(1)) Then
cbomonth(Index) = cbomonth(1)
End If
Case 1
If CInt(cbomonth(Index)) < CInt(cbomonth(0)) Then
cbomonth(Index) = cbomonth(0)
End If
End Select
End If
End If
End Sub
Private Sub cboyear_Click(Index As Integer)
If cboyear(0) <> "" And cboyear(1) <> "" Then
Select Case Index
Case 0
If CInt(cboyear(Index)) > CInt(cboyear(1)) Then
cboyear(Index) = cboyear(1)
End If
Case 1
If CInt(cboyear(Index)) < CInt(cboyear(1)) Then
cboyear(Index) = cboyear(0)
End If
End Select
Call cbomonth_Click(Index)
End If
End Sub
Private Sub chkitem_Click(Index As Integer)
If Index = 1 Then
cboyear(0).SetFocus
Else
txtitem.SetFocus
End If
End Sub
Private Sub cmdcancel_Click()
Me.Hide
End Sub
Private Sub cmdok_Click()
Dim txtsql As String
Dim dBeginDate As String
Dim dEndDateTemp As Date
Dim dEndDate As String
If chkitem(0).Value = vbChecked Then
txtsql = " fy_id ='" & Trim(txtitem.Text & " ") & "'"
End If
If chkitem(1).Value = vbChecked Then
dBeginDate = Format(CDate(cboyear(0) & "-" & cbomonth(0) & "-1"), "yyyy-mm-dd")
dEndDateTemp = DateAdd("d", -1, DateAdd("m", 1, DateSerial(CInt(cboyear(1)), CInt(cbomonth(1)), 1)))
dEndDate = Format(dEndDateTemp, "yyyy-mm-dd")
If Trim(txtsql & " ") = "" Then
txtsql = " fy_date>='" & dBeginDate & "' and fy_date<='" & dEndDate & "'"
Else
txtsql = txtsql & " and (fy_date>='" & dBeginDate & "' and fy_date<='" & dEndDate & "')"
End If
Else
End If
If Trim(txtsql) = "" Then
MsgBox "请设置查询方式!", vbOKOnly + vbExclamation, "警告"
Exit Sub
Else
If flagrEdit Then
Unload frmcost
End If
frmcostlist.txtsql = "select * from cost where" & txtsql
frmcostlist.Show
End If
Me.Hide
End Sub
Private Sub Form_Load()
Dim i As Integer
Dim j As Integer
Dim txtsql As String
Dim mrc As ADODB.Recordset
Dim msgtext As String
Me.Left = 5685
Me.Top = 1890
txtsql = "select distinct datepart(yy,fy_date) from cost"
Set mrc = ExecuteSQL(txtsql, msgtext)
If mrc.EOF = False Then
With mrc
Do While Not .EOF
cboyear(0).AddItem .Fields(0)
cboyear(1).AddItem .Fields(0)
.MoveNext
Loop
End With
For i = 0 To 1
cboyear(i).ListIndex = 0
Next i
For i = 0 To 1
For j = 1 To 12
cbomonth(i).AddItem j
Next j
Next i
For i = 0 To 1
cbomonth(i).Text = Month(Now())
Next i
Else
CmdOK.Enabled = False
End If
mrc.Close
End Sub
Private Sub txtitem_GotFocus()
txtitem.SelStart = 0
txtitem.SelLength = Len(txtitem)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -