⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmwriteoffbill.frm

📁 金算盘软件代码
💻 FRM
📖 第 1 页 / 共 4 页
字号:
            If lngReceiptTypeID = 2 Then
                mstrName = "采购发票单据"
            ElseIf lngReceiptTypeID = 12 Then
                mstrName = "销售发票单据"
            Else
                mstrName = recTmp!strReceiptTypeName & "单据"
            End If
        #End If
        recTmp.Close
        Set recTmp = Nothing
    End Select
    Frame1.Caption = "选择需要" & mstrUse & "的" & mstrName
    If bytShowItems = 3 Then
        Dim lngAdjustHeight As Long
        
        lngAdjustHeight = lstNO.top - cmbSelect(2).top
        cmbSelect(2).Visible = False
        lstNO.top = lstNO.top - lngAdjustHeight
        LblName(3).top = LblName(3).top - lngAdjustHeight
        LblName(2).Visible = False
        Frame1.Height = Frame1.Height - lngAdjustHeight
        Me.Height = Me.Height - lngAdjustHeight
    End If
    
    If mblnStart Then GoTo EndProc
    If intYear = 0 Or bytPeriod = 0 Then
        Select Case lngReceiptTypeID
        Case 41
            strSql = "SELECT strDate FROM Voucher WHERE lngVoucherID=" & lngActivityID
        Case 34 To 40
            strSql = "SELECT strDate FROM Activity WHERE lngActivityID=" & lngActivityID
        Case Else
            strSql = "SELECT strDate FROM ItemActivity WHERE lngActivityID=" & lngActivityID
        End Select
        Set recTmp = gclsBase.BaseDB.OpenResultset(strSql, rdOpenForwardOnly)
        If Not (recTmp.BOF And recTmp.EOF) Then
            intYear = gclsBase.FYearOfDate(CDate(recTmp!strDate))
            bytPeriod = gclsBase.PeriodOfDate(CDate(recTmp!strDate))
        End If
        recTmp.Close
        Set recTmp = Nothing
        If my_lngReceiptTypeID = 8 Or my_lngReceiptTypeID = 20 Then
            If intYear < C2lng(Left(gclsBase.BeginDate, 4)) Then
                intYear = gclsBase.FYearOfDate(C2Date(gclsBase.BeginDate))
                bytPeriod = 0
            End If
        End If
        If intYear = 0 Then
            intYear = gclsBase.FYearOfDate(gclsBase.BaseDate)
            bytPeriod = gclsBase.PeriodOfDate(gclsBase.BaseDate)
        End If
        If my_intYear = 0 Then
            my_intYear = intYear
        End If
        If my_bytPeriod = 0 Then
            my_bytPeriod = bytPeriod
        End If
    End If
    
    On Error Resume Next
    cmbSelect(0).Text = Format(intYear, "0000")
    If cmbSelect(0).ListIndex < 0 And cmbSelect(0).ListCount > 0 Then
        cmbSelect(0).ListIndex = 0
        Do While C2lng(cmbSelect(0).list(cmbSelect(0).ListIndex)) <> intYear
            cmbSelect(0).ListIndex = cmbSelect(0).ListIndex + 1
        Loop
    End If
    
    SetPeriod
    If bytPeriod <> 0 Then
        cmbSelect(1).Text = Format(bytPeriod, "00")
    End If
    If cmbSelect(1).ListIndex < 0 And cmbSelect(1).ListCount > 0 Then
        cmbSelect(1).ListIndex = 0
    End If
EndProc:
    SetBillNO
End Sub
Private Sub SetPeriod()
    Dim strSql As String
    Dim recTmp As rdoResultset
    Dim strStartDate As String
    
    If cmbSelect(0).ListIndex < 0 Then
        Exit Sub
    End If
'    strSql = "SELECT strStartDate FROM Business"
'    Set recTmp = gclsBase.BaseDB.OpenResultset(strSql, rdOpenForwardOnly)
'    If recTmp.BOF And recTmp.EOF Then
'        strStartDate = "1900-01-01"
'    Else
'        strStartDate = recTmp!strStartDate
'    End If
'    recTmp.Close
'    Set recTmp = Nothing
    strStartDate = gclsBase.BeginDate
    cmbSelect(1).Clear
    If my_lngReceiptTypeID = 8 Or my_lngReceiptTypeID = 20 Then
        If gclsBase.FYearOfDate(C2Date(strStartDate)) = cmbSelect(0).Text Then
            cmbSelect(1).AddItem "00"
        End If
    End If
    strSql = "SELECT bytPeriod FROM AccountPeriod WHERE intYear=" & cmbSelect(0).Text & " AND strEndDate>='" & Format(C2Date(strStartDate), "yyyy-mm-dd") & "'"
    Set recTmp = gclsBase.BaseDB.OpenResultset(strSql, rdOpenForwardOnly)
    If Not (recTmp.BOF And recTmp.EOF) Then
        Do While Not recTmp.EOF
            cmbSelect(1).AddItem Format(recTmp!bytPeriod, "00")
            If my_bytPeriod = recTmp!bytPeriod Then
                cmbSelect(1).ListIndex = cmbSelect(1).NewIndex
            End If
            recTmp.MoveNext
        Loop
        If cmbSelect(1).ListIndex < 0 And cmbSelect(1).ListCount > 0 Then
            cmbSelect(1).ListIndex = 0
        End If
    End If
    recTmp.Close
    Set recTmp = Nothing
End Sub

Private Sub SetBillNO()
    Dim strSql As String
    Dim recTmp As rdoResultset
    Dim strStartDate As String
    Dim strEndDate As String
    
    If mblnStart = False Then
        If cmbSelect(0).ListIndex < 0 Then
            Exit Sub
        End If
        If cmbSelect(1).ListIndex < 0 Then
            Exit Sub
        End If
        If cmbSelect(2).ListCount > 0 Then
            If cmbSelect(2).ListIndex < 0 Then
                Exit Sub
            End If
        End If
        If (my_lngReceiptTypeID = 8 Or my_lngReceiptTypeID = 20) And C2lng(cmbSelect(1).Text) = 0 Then
            strStartDate = "0"
            strEndDate = Format(DateAdd("D", -1, CDate(gclsBase.BeginDate)), "yyyy-mm-dd")
        Else
            strSql = "SELECT strStartDate,strEndDate FROM AccountPeriod WHERE intYear=" & _
                C2lng(cmbSelect(0).Text) & " AND bytPeriod=" & C2lng(cmbSelect(1).Text)
            Set recTmp = gclsBase.BaseDB.OpenResultset(strSql, rdOpenForwardOnly)
            If recTmp.BOF And recTmp.EOF Then
                recTmp.Close
                Set recTmp = Nothing
                Exit Sub
            Else
                strStartDate = Format(CDate(recTmp!strStartDate), "yyyy-mm-dd")
                strEndDate = Format(CDate(recTmp!strEndDate), "yyyy-mm-dd")
            End If
            recTmp.Close
            Set recTmp = Nothing
        End If
    End If
    Select Case my_lngReceiptTypeID
    Case 41
        strSql = "SELECT lngVoucherID,LPAD(intVoucherNO,4,'0') FROM Voucher WHERE lngVoucherTypeID=" & cmbSelect(2).ItemData(cmbSelect(2).ListIndex)
        If mblnSeek = False Then
            strSql = strSql & " AND lngVoucherSourceID=1 AND lngSourceVoucherID=0 AND blnIsVoid=0 "
        End If
        strSql = strSql & " AND strDate>='" & strStartDate & "' and strDate<='" & strEndDate & "'"
        If mblnView = False Then strSql = strSql & " AND lngOperatorID=" & gclsBase.OperatorID & " "
        strSql = strSql & " ORDER BY intVoucherNO"
    Case 34 To 38
        strSql = "SELECT lngActivityID,LTrim(strReceiptNO||LPAD(lngReceiptNO,4,'0')) FROM Activity WHERE lngReceiptTypeID=" & cmbSelect(2).ItemData(cmbSelect(2).ListIndex)
        If mblnSeek = False Then
            strSql = strSql & " AND lngSourceActivityID=0 AND blnIsVoid=0 AND Activity.blnIsDiscount=0 "
        End If
        strSql = strSql & " AND strDate>='" & strStartDate & "' and strDate<='" & strEndDate & "'"
        If mblnView = False Then strSql = strSql & " AND lngOperatorID=" & gclsBase.OperatorID & " "
        strSql = strSql & " ORDER BY strReceiptNO,lngReceiptNO"
'    Case 38
'        strSql = "SELECT lngActivityID,LTrim(strReceiptNO||LPAD(lngReceiptNO,4,'0')) FROM Activity WHERE lngReceiptTypeID=" & my_lngReceiptTypeID
'        If mblnSeek = False Then
'            strSql = strSql & " AND lngSourceActivityID=0 AND blnIsVoid=0 AND Activity.blnIsDiscount=0 "
'        End If
'        strSql = strSql & " AND strDate>='" & strStartDate & "' and strDate<='" & strEndDate & "'"
'        If mblnView = False Then strSql = strSql & " AND lngOperatorID=" & gclsBase.OperatorID & " "
'        strSql = strSql & " ORDER BY strReceiptNO,lngReceiptNO"
    Case 39, 40
        strSql = "SELECT lngActivityID,LTrim(strReceiptNO||LPAD(lngReceiptNO,4,'0')) FROM Activity WHERE lngReceiptTypeID=" & my_lngReceiptTypeID
        If mblnSeek = False Then
            strSql = strSql & " AND lngSourceActivityID=0 AND blnIsVoid=0 AND Activity.blnIsDiscount=0 "
        End If
        strSql = strSql & " AND strDate>='" & strStartDate & "' and strDate<='" & strEndDate & "'"
        If mblnView = False Then strSql = strSql & " AND lngOperatorID=" & gclsBase.OperatorID & " "
        strSql = strSql & " AND blnIsSpecial=" & IIf(my_blnIsSpecial, 1, 0) & " ORDER BY strReceiptNO,lngReceiptNO"
    Case 22
        strSql = "SELECT lngActivityID,LTrim(strReceiptNO||LPAD(lngReceiptNO,4,'0')) FROM ItemActivity WHERE lngReceiptTypeID=" & my_lngReceiptTypeID
        If mblnSeek = False Then
            strSql = strSql & " AND UPPER(strReceiptNO)<>'CA' AND UPPER(strReceiptNO)<> 'CB' AND lngSourceActivityID=0 AND blnIsVoid=0 "
        End If
        strSql = strSql & " AND strDate>='" & strStartDate & "' and strDate<='" & strEndDate & "'"
        If mblnView = False Then strSql = strSql & " AND lngOperatorID=" & gclsBase.OperatorID & " "
        strSql = strSql & " ORDER BY strReceiptNO,lngReceiptNO"
    Case 1
        strSql = "SELECT lngPurchaseOrderID,LTrim(strReceiptNO||LPAD(lngReceiptNO,4,'0')) FROM PurchaseOrder "
        strSql = strSql & " WHERE strDate>='" & strStartDate & "' and strDate<='" & strEndDate & "'"
        If mblnView = False Then strSql = strSql & " AND lngOperatorID=" & gclsBase.OperatorID & " "
        strSql = strSql & " ORDER BY strReceiptNO,lngReceiptNO"
    Case 12
        strSql = "SELECT lngSaleOrderID,LTrim(strReceiptNO||LPAD(lngReceiptNO,4,'0')) FROM SaleOrder "
        strSql = strSql & " WHERE strDate>='" & strStartDate & "' and strDate<='" & strEndDate & "'"
        If mblnView = False Then strSql = strSql & " AND lngOperatorID=" & gclsBase.OperatorID & " "
        strSql = strSql & " ORDER BY strReceiptNO,lngReceiptNO"
    Case 32
        strSql = "SELECT lngCostPriceID,LTrim(strReceiptNO||LPAD(lngReceiptNO,4,'0')) FROM CostPrice "
        strSql = strSql & " WHERE strDate>='" & strStartDate & "' and strDate<='" & strEndDate & "'"
        If mblnView = False Then strSql = strSql & " AND lngOperatorID=" & gclsBase.OperatorID & " "
        strSql = strSql & " ORDER BY strReceiptNO,lngReceiptNO"
    Case 33
        strSql = "SELECT lngStockTakingID,LTrim(strReceiptNO||LPAD(lngReceiptNO,4,'0')) FROM StockTaking "
        strSql = strSql & " WHERE strDate>='" & strStartDate & "' and strDate<='" & strEndDate & "'"
        If mblnView = False Then strSql = strSql & " AND lngOperatorID=" & gclsBase.OperatorID & " "
        strSql = strSql & " ORDER BY strReceiptNO,lngReceiptNO"
    Case 26
        strSql = "SELECT lngActivityID,LTrim(strReceiptNO||LPAD(lngReceiptNO,4,'0')) FROM ItemActivity WHERE lngReceiptTypeID=" & my_lngReceiptTypeID
        strSql = strSql & " AND strDate>='" & strStartDate & "' and strDate<='" & strEndDate & "'"
        If mblnView = False Then strSql = strSql & " AND lngOperatorID=" & gclsBase.OperatorID & " "
        strSql = strSql & " AND lngActivityTypeID = 25 "
        strSql = strSql & " ORDER BY strReceiptNO,lngReceiptNO"
    Case 28
        strSql = "SELECT lngActivityID,LTrim(strReceiptNO||LPAD(lngReceiptNO,4,'0')) FROM ItemActivity WHERE lngReceiptTypeID=" & my_lngReceiptTypeID
        strSql = strSql & " AND strDate>='" & strStartDate & "' and strDate<='" & strEndDate & "'"
        If mblnView = False Then strSql = strSql & " AND lngOperatorID=" & gclsBase.OperatorID & " "
        strSql = strSql & " AND lngActivityTypeID = 28 "
        strSql = strSql & " ORDER BY strReceiptNO,lngReceiptNO"
    Case 30
        strSql = "SELECT lngActivityID,LTrim(strReceiptNO||LPAD(lngReceiptNO,4,'0')) FROM ItemActivity WHERE lngReceiptTypeID=" & my_lngReceiptTypeID
        strSql = strSql & " AND strDate>='" & strStartDate & "' and strDate<='" & strEndDate & "'"
        If mblnView = False Then strSql = strSql & " AND lngOperatorID=" & gclsBase.OperatorID & " "
        strSql = strSql & " AND lngActivityTypeID = 31 "
        strSql = strSql & " ORDER BY strReceiptNO,lngReceiptNO"
    Case 31
        strSql = "SELECT lngActivityID,LTrim(strReceiptNO||LPAD(lngReceiptNO,4,'0')) FROM ItemActivity WHERE lngReceiptTypeID=" & my_lngReceiptTypeID
        strSql = strSql & " AND strDate>='" & strStartDate & "' and strDate<='" & strEndDate & "'"
        If mblnView = False Then strSql = strSql & " AND lngOperatorID=" & gclsBase.OperatorID & " "
        strSql = strSql & " AND lngActivityTypeID = 33 "
        strSql = strSql & " ORDER BY strReceiptNO,lngReceiptNO"
    Case 42 To 47, 52
        strSql = "SELECT lngActivityID,LTrim(strReceiptNO||LPAD(lngReceiptNO,4,'0')) FROM ItemActivity WHERE lngReceiptTypeID=" & my_lngReceiptTypeID
        If mblnView = False Then strSql = strSql & " AND lngOperatorID=" & gclsBase.OperatorID & " "
        strSql = strSql & " ORDER BY strReceiptNO,lngReceiptNO"
    Case 99
        strSql = "SELECT lngTransVoucherID,strTransVoucherName FROM TransVoucher "
        If mblnView = False Then strSql = strSql & " WHERE lngOperatorID=" & gclsBase.OperatorID & " "
        strSql = strSql & " ORDER BY strTransVoucherName"
    Case Else
        strSql = "SELECT lngActivityID,LTrim(strReceiptNO||LPAD(lngReceiptNO,4,'0')) FROM ItemActivity WHERE lngReceiptTypeID=" & my_lngReceiptTypeID
        If mblnSeek = False Then
            strSql = strSql & " AND lngSourceActivityID=0 AND blnIsVoid=0 "
        End If
        strSql = strSql & " AND strDate>='" & strStartDate & "' and strDate<='" & strEndDate & "'"
        If mblnView = False Then strSql = strSql & " AND lngOperatorID=" & gclsBase.OperatorID & " "
        strSql = strSql & " ORDER BY strReceiptNO,lngReceiptNO"
    End Select
    lstNO.SQL = strSql
    Set recTmp = gclsBase.BaseDB.OpenResultset(strSql, rdOpenStatic)
    Set lstNO.Recordset = recTmp
    If Not recTmp.EOF Then
        lstNO.SeekId my_lngActivityID
        If lstNO.Text = "" Then
            lstNO.ReferRow = 0
        End If
    End If
    lstNO.ColWidth(2) = lstNO.width - 900

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -