📄 frmexportquery.frm
字号:
ShowDateRef txtStartDate
End Sub
Private Sub cmdRef1_LostFocus()
cmdRef1.Visible = False
End Sub
Private Sub cmdRef2_Click()
ShowDateRef txtEndDate
End Sub
Private Sub cmdRef2_LostFocus()
cmdRef2.Visible = False
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF1 Then
SendKeys "{F1}"
ElseIf KeyCode = vbKeySeparator Or KeyCode = vbKeyReturn Then
SendKeys "{tab}"
ElseIf KeyCode = vbKeyF2 Then
If Me.ActiveControl.Name = "txtStartDate" Then
cmdRef1_Click
ElseIf Me.ActiveControl.Name = "txtEndDate" Then
cmdRef2_Click
End If
End If
End Sub
Private Sub Form_Load()
cmdRef1.Picture = LoadResPicture(1108, vbResBitmap)
cmdRef2.Picture = LoadResPicture(1108, vbResBitmap)
Me.Icon = LoadResPicture(109, vbResIcon)
FillUser
FillVchStyle
FillUnitName
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set unitID = Nothing
End Sub
Private Sub txtEndDate_GotFocus()
cmdRef2.Visible = True
End Sub
Private Sub txtStartDate_GotFocus()
cmdRef1.Visible = True
End Sub
Private Sub txtStartDate_LostFocus()
Dim tmp As String
If Me.ActiveControl.Name <> "cmdRef1" And Trim(txtStartDate.Text) = "" Then
cmdRef1.Visible = False
Exit Sub
End If
If Me.ActiveControl.Name = "cmdRef1" Then
Exit Sub
End If
tmp = txtStartDate.Text
If tmp = "" Then
ElseIf tmp <> "" And m_objAid.bCheckDate(tmp) Then
txtStartDate.Text = tmp
Else
txtStartDate.SelStart = 0
txtStartDate.SelLength = Len(txtStartDate.Text)
iShowMsg "日期格式错误!"
txtStartDate.SetFocus
End If
txtStartDate.Text = tmp
cmdRef1.Visible = False
End Sub
Private Sub txtEndDate_LostFocus()
Dim tmp As String
If Me.ActiveControl.Name <> "cmdRef2" And Trim(txtEndDate.Text) = "" Then
cmdRef2.Visible = False
Exit Sub
End If
If Me.ActiveControl.Name = "cmdRef2" Then
Exit Sub
End If
tmp = txtEndDate.Text
If tmp = "" Then
ElseIf tmp <> "" And m_objAid.bCheckDate(tmp) Then
txtEndDate.Text = tmp
Else
txtEndDate.SelStart = 0
txtEndDate.SelLength = Len(txtEndDate.Text)
iShowMsg "日期格式错误!"
txtEndDate.SetFocus
End If
txtEndDate.Text = tmp
cmdRef2.Visible = False
End Sub
'载入操作员列表
Public Sub FillUser()
Dim rs As ADODB.Recordset
If zjLogInfo.GetAccInfo(120, rs) Then
While Not rs.EOF
cboCheck.AddItem rs!cUser_Name
cboBill.AddItem rs!cUser_Name
rs.MoveNext
Wend
rs.Close
End If
End Sub
'载入单据类型
Private Sub FillVchStyle()
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
Dim cnt As Integer
con.CursorLocation = adUseClient
con.ConnectionString = g_sDataSourceName
con.Open
cnt = 0
sql = "select scaption,iid from fd_entities where ibitype=27 or ibitype=28 or iBIType=25"
Set rs = con.Execute(sql)
While Not rs.EOF
cboVchStyle.AddItem rs!sCaption
cboVchStyle.ItemData(cnt) = rs!iid
cnt = cnt + 1
rs.MoveNext
Wend
If cnt <> 0 Then
cboVchStyle.ListIndex = 0
End If
rs.Close
con.Close
End Sub
'载入
Private Sub FillUnitName()
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
Dim cnt As Integer
con.CursorLocation = adUseClient
con.ConnectionString = g_sDataSourceName
con.Open
cnt = 0
sql = "SELECT accunit_id, cUnitName FROM FD_AccUnit"
Set rs = con.Execute(sql)
While Not rs.EOF
cboUnitName.AddItem rs!cunitName
unitID.Add "" & rs!accunit_id, "" & cnt
cnt = cnt + 1
rs.MoveNext
Wend
rs.Close
con.Close
End Sub
'检查完整性
Private Function GetQuery() As String
Dim tmp As String
'单据类型
GetQuery = ""
If Trim(cboVchStyle.Text) <> "" Then
GetQuery = " (t5.iBIType=" & cboVchStyle.ItemData(cboVchStyle.ListIndex) & " or t5.iDeriveBIType=" & cboVchStyle.ItemData(cboVchStyle.ListIndex) & ")"
End If
'单据编号
tmp = Trim(txtStartID.Text)
If tmp <> "" Then
If GetQuery <> "" Then
GetQuery = GetQuery & " and fd_transactions.transactions_code>='" & tmp & "' "
Else
GetQuery = " fd_transactions.transactions_code>='" & tmp & "' "
End If
End If
tmp = Trim(txtEndID.Text)
If tmp <> "" Then
If GetQuery <> "" Then
GetQuery = GetQuery & " and fd_transactions.transactions_code<='" & tmp & "' "
Else
GetQuery = " fd_transactions.transactions_code<='" & tmp & "' "
End If
End If
'单位名称
If Trim(cboUnitName.Text) <> "" Then
If GetQuery <> "" Then
GetQuery = GetQuery & " and (t3.accunit_id='" & unitID(cboUnitName.ListIndex + 1) & "' or t4.accunit_id='" & unitID(cboUnitName.ListIndex + 1) & "')"
Else
GetQuery = " t3.accunit_id='" & unitID(cboUnitName.ListIndex + 1) & "' or t4.accunit_id='" & unitID(cboUnitName.ListIndex + 1) & "'"
End If
End If
'日期
tmp = Trim(txtStartDate.Text)
If tmp <> "" Then
If GetQuery <> "" Then
GetQuery = GetQuery & " and fd_transactions.bill_date>='" & tmp & "' "
Else
GetQuery = " fd_transactions.bill_date>='" & tmp & "' "
End If
End If
tmp = Trim(txtEndDate.Text)
If tmp <> "" Then
If GetQuery <> "" Then
GetQuery = GetQuery & " and fd_transactions.bill_date<='" & tmp & "' "
Else
GetQuery = " fd_transactions.bill_date<='" & tmp & "' "
End If
End If
'制单人
tmp = Trim(cboBill.Text)
If tmp <> "" Then
If GetQuery <> "" Then
GetQuery = GetQuery & " and fd_transactions.bill_name='" & tmp & "' "
Else
GetQuery = " fd_transactions.bill_name='" & tmp & "' "
End If
End If
'审核人
tmp = Trim(cboCheck.Text)
If tmp <> "" Then
If GetQuery <> "" Then
GetQuery = GetQuery & " and fd_transactions.check_name='" & tmp & "' "
Else
GetQuery = " fd_transactions.check_name='" & tmp & "' "
End If
End If
'
If GetQuery <> "" Then
GetQuery = "where fd_transactions.check_name is not null and fd_transactions.pz_code is null and fd_transactions.book_name is null and " & GetQuery
Else
GetQuery = "where fd_transactions.check_name is not null and fd_transactions.pz_code is null and fd_transactions.book_name is null "
End If
End Function
'检查日期
Private Function bCheckField() As Boolean
If txtEndDate <> "" And txtStartDate <> "" And txtEndDate <> txtStartDate Then
If DateDiff("d", CDate(txtEndDate.Text), CDate(txtStartDate)) >= 0 Then
iShowMsg "结束日期不应小于起始日期!!"
txtEndDate.SelStart = 0
txtEndDate.SelLength = Len(txtEndDate.Text)
txtEndDate.SetFocus
Exit Function
End If
End If
bCheckField = True
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -