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

📄 frminvoiceselect.frm

📁 金算盘软件代码
💻 FRM
📖 第 1 页 / 共 5 页
字号:
        End If
    End With
End Sub

Private Sub mclsGrid_DataValid(blnCancel As Boolean)
    Dim dblFactor As Double
    Dim strTmp As String
        
    GetLngColNO
    If GrdCol.col = xlngColNo(9) Then
        strTmp = curInput.Text
        dblFactor = DataofGrid(GrdCol.RowData(GrdCol.Row)).dblFactor
        strTmp = DisplayData(Me.hWnd, strTmp, dblFactor)
        If C2Dbl(curInput.Text) - (C2Dbl(curInput.Text) \ 1) <> 0 And C2Dbl(strTmp) - (C2Dbl(strTmp) \ 1) = 0 Then
            blnCancel = True
        End If
        curInput.Text = strTmp
        If C2Dbl(curInput.Text) > 0 And C2Dbl(GrdCol.TextMatrix(GrdCol.Row, xlngColNo(7))) < 0 Then
            cMsgBox "本次开票数量不能大于0!"
            blnCancel = True
        ElseIf C2Dbl(curInput.Text) < 0 And C2Dbl(GrdCol.TextMatrix(GrdCol.Row, xlngColNo(7))) > 0 Then
            cMsgBox "本次开票数量不能小于0!"
            blnCancel = True
        Else
            If Abs(C2Dbl(curInput.Text)) > Abs(C2Dbl(GrdCol.TextMatrix(GrdCol.Row, xlngColNo(7)))) Then
                cMsgBox "本次开票数量不能" & IIf(C2Dbl(GrdCol.TextMatrix(GrdCol.Row, xlngColNo(7))) >= 0, "大", "小") & "于" & GrdCol.TextMatrix(GrdCol.Row, xlngColNo(7)) & "!"
                blnCancel = True
            End If
        End If
    ElseIf GrdCol.col = xlngColNo(10) Then
        If C2Dbl(curInput.Text) > 0 And C2Dbl(GrdCol.TextMatrix(GrdCol.Row, xlngColNo(8))) < 0 Then
            cMsgBox "本次开票金额不能大于0!"
            blnCancel = True
        ElseIf C2Dbl(curInput.Text) < 0 And C2Dbl(GrdCol.TextMatrix(GrdCol.Row, xlngColNo(8))) > 0 Then
            cMsgBox "本次开票金额不能小于0!"
            blnCancel = True
        Else
            If Abs(C2Dbl(curInput.Text)) > Abs(C2Dbl(GrdCol.TextMatrix(GrdCol.Row, xlngColNo(8)))) Then
                cMsgBox "本次开票金额不能" & IIf(C2Dbl(GrdCol.TextMatrix(GrdCol.Row, xlngColNo(8))) > 0, "大", "小") & "于" & GrdCol.TextMatrix(GrdCol.Row, xlngColNo(8)) & "!"
                blnCancel = True
            End If
        End If
    End If
    blnCancelOK = blnCancel
End Sub

Private Sub SetSelectRow(ByVal lngRowno As Long, ByVal blnSelect As Boolean)
    Dim i As Long
    Dim dblTotalQuantity As Double
    Dim dblTotalAmount As Double
    
    If DataofGrid(GrdCol.RowData(GrdCol.Row)).blnNoChange Then GoTo EndProc
    If mblnBillCanNotChange Then
        GoTo EndProc
    End If
    GetLngColNO
    If blnSelect Then
        GrdCol.TextMatrix(lngRowno, 1) = "√"
        If mlngRowNO < 1 Then
            GrdCol.TextMatrix(lngRowno, xlngColNo(9)) = GrdCol.TextMatrix(lngRowno, xlngColNo(7))
            GrdCol.TextMatrix(lngRowno, xlngColNo(10)) = GrdCol.TextMatrix(lngRowno, xlngColNo(8))
            SetCloseRow lngRowno, True
        Else
            For i = 1 To GrdCol.Rows - 1
                If i <> lngRowno And GrdCol.RowHeight(i) <> 0 Then
                    dblTotalQuantity = dblTotalQuantity + C2Dbl(NumberConvert(GrdCol.TextMatrix(i, xlngColNo(9)), DataofGrid(GrdCol.RowData(i)).dblFactor))
                    dblTotalAmount = dblTotalAmount + C2Dbl(GrdCol.TextMatrix(i, xlngColNo(10)))
                End If
            Next
            dblTotalQuantity = C2Dbl(frmName.TextOfGrid(mlngRowNO, 41)) - dblTotalQuantity
            dblTotalAmount = C2Dbl(frmName.TextOfGrid(mlngRowNO, 14)) - dblTotalAmount
            If dblTotalQuantity * C2Dbl(GrdCol.TextMatrix(lngRowno, xlngColNo(7))) <= 0 Then
                dblTotalQuantity = 0
            ElseIf Abs(dblTotalQuantity) > Abs(C2Dbl(NumberConvert(GrdCol.TextMatrix(lngRowno, xlngColNo(7)), DataofGrid(GrdCol.RowData(lngRowno)).dblFactor))) Then
                dblTotalQuantity = C2Dbl(NumberConvert(GrdCol.TextMatrix(lngRowno, xlngColNo(7)), DataofGrid(GrdCol.RowData(lngRowno)).dblFactor))
            End If
            If dblTotalAmount * C2Dbl(GrdCol.TextMatrix(lngRowno, xlngColNo(8))) <= 0 Then
                dblTotalAmount = 0
            ElseIf Abs(dblTotalAmount) > Abs(C2Dbl(GrdCol.TextMatrix(lngRowno, xlngColNo(8)))) Then
                dblTotalAmount = C2Dbl(GrdCol.TextMatrix(lngRowno, xlngColNo(8)))
                SetCloseRow lngRowno, True
            End If
            GrdCol.TextMatrix(lngRowno, xlngColNo(9)) = DisplayData(Me.hWnd, NumberConvert(dblTotalQuantity, DataofGrid(GrdCol.RowData(lngRowno)).dblFactor, False), DataofGrid(GrdCol.RowData(lngRowno)).dblFactor)
            GrdCol.TextMatrix(lngRowno, xlngColNo(10)) = Format(dblTotalAmount, strCurrDec)
            If C2Dbl(GrdCol.TextMatrix(lngRowno, xlngColNo(8))) = C2Dbl(GrdCol.TextMatrix(lngRowno, xlngColNo(10))) Then
                SetCloseRow lngRowno, True
            Else
                SetCloseRow lngRowno, False
            End If
        End If
    Else
        GrdCol.TextMatrix(lngRowno, 1) = ""
        GrdCol.TextMatrix(lngRowno, xlngColNo(9)) = ""
        GrdCol.TextMatrix(lngRowno, xlngColNo(10)) = ""
        SetCloseRow lngRowno, False
    End If
EndProc:
    For i = 1 To GrdCol.Rows - 1
        If C2Dbl(GrdCol.TextMatrix(i, xlngColNo(9))) = 0 And C2Dbl(GrdCol.TextMatrix(i, xlngColNo(10))) = 0 Then
            GrdCol.TextMatrix(i, 1) = ""
        End If
    Next
    CalcCanSettleAmount
End Sub
Private Sub SetCloseRow(ByVal lngRowno As Long, ByVal blnClose As Boolean)
    If DataofGrid(GrdCol.RowData(GrdCol.Row)).blnNoChange Then Exit Sub
    GetLngColNO
    
    If _
        C2Dbl(GrdCol.TextMatrix(lngRowno, xlngColNo(10))) = C2Dbl(GrdCol.TextMatrix(lngRowno, xlngColNo(8))) Then
        GrdCol.TextMatrix(lngRowno, xlngColNo(11)) = "√"
    Else
        If blnClose Then
            GrdCol.TextMatrix(lngRowno, xlngColNo(11)) = "√"
        Else
            GrdCol.TextMatrix(lngRowno, xlngColNo(11)) = ""
        End If
    End If
End Sub

Private Sub cMsgBox(ByVal strText As String, Optional ByVal strTitle As String = "提示信息")
    ShowMsg Me.hWnd, strText, MB_OK + MB_ICONEXCLAMATION + MB_SYSTEMMODAL, strTitle
End Sub

Private Sub SetSelectedBills()
    Dim i As Long
    
    With GrdCol
        For i = 1 To .Rows - 1
            If C2Dbl(.TextMatrix(i, 9)) <> 0 Or C2Dbl(.TextMatrix(i, 10)) <> 0 Then
'                If mblnBillCanNotChange Then
                    GrdCol.TextMatrix(i, 1) = "√"
'               Else
'                    SetSelectRow i, True
'                End If
                If C2Dbl(.TextMatrix(i, 9)) = 0 Then
                    .TextMatrix(i, 9) = ""
                Else
                    .TextMatrix(i, 9) = DisplayData(Me.hWnd, _
                        NumberConvert(.TextMatrix(i, 9), DataofGrid(i).dblFactor, False), _
                        DataofGrid(i).dblFactor)
                End If
                If C2Dbl(.TextMatrix(i, 10)) = 0 Then
                    .TextMatrix(i, 10) = ""
                Else
                    .TextMatrix(i, 10) = Format(C2Dbl(.TextMatrix(i, 10)), strCurrDec)
                End If
            Else
                If mblnBillCanNotChange Then
                    GrdCol.TextMatrix(i, 1) = ""
                    .RowHeight(i) = 0
                Else
                    GrdCol.TextMatrix(i, 1) = ""
                End If
                .TextMatrix(i, 9) = ""
                .TextMatrix(i, 10) = ""
            End If
        Next
    End With
End Sub

Private Function OldBillClearSelect(ByVal blnResetRow As Boolean, ByVal blnDoTrans As Boolean) As Boolean
    Dim i As Long
    Dim strSql As String
    Dim strTmp As String
    
    OldBillClearSelect = False
    If blnDoTrans Then
        gclsBase.BaseWorkSpace.BeginTrans
    End If
    
    If blnResetRow Then
        If lngReceiptTypeID = 8 Then
        Else
        End If
        If gclsBase.ExecSQL(strSql) = False Then
            If blnDoTrans Then
                gclsBase.BaseWorkSpace.RollBacktrans
            End If
            cMsgBox "清除开票信息失败!", "错误信息"
            GoTo EndProc
        End If
    End If
    
    If mlngRowNO = 0 Then
        strTmp = " ItemActivityDetail_1.lngActivityID = " & frmName.getID
    Else
        strTmp = " ItemActivityDetail_1.lngActivityDetailID = " & C2lng(frmName.TextOfGrid(mlngRowNO, 0))
    End If
    
    If lngReceiptTypeID = 8 Then
        strSql = "UPDATE ItemActivityDetail SET ItemActivityDetail.dblInvoiceQuantity=(SELECT ItemActivityDetail.dblInvoiceQuantity-NVL(SUM(PurchaseToInvoice.dblQuantity),0) " & _
            " FROM PurchaseToInvoice,ItemActivityDetail ItemActivityDetail_1 " & _
            " WHERE PurchaseToInvoice.lngInvoiceDetailID = ItemActivityDetail_1.lngActivityDetailID " & _
            " AND PurchaseToInvoice.lngReceiptDetailID = ItemActivityDetail.lngActivityDetailID " & _
            " AND " & strTmp & "),"
        strSql = strSql & _
            " ItemActivityDetail.dblCurrInvoiceAmount=(SELECT ItemActivityDetail.dblCurrInvoiceAmount-NVL(SUM(PurchaseToInvoice.dblCurrAmount),0) " & _
            " FROM PurchaseToInvoice,ItemActivityDetail ItemActivityDetail_1 " & _
            " WHERE PurchaseToInvoice.lngInvoiceDetailID = ItemActivityDetail_1.lngActivityDetailID " & _
            " AND PurchaseToInvoice.lngReceiptDetailID = ItemActivityDetail.lngActivityDetailID " & _
            " AND " & strTmp & "),ItemActivityDetail.blnCloseInvoice=0 "
        strSql = strSql & _
            " WHERE EXISTS (SELECT ItemActivityDetail_1.lngActivityDetailID " & _
            " FROM PurchaseToInvoice,ItemActivityDetail ItemActivityDetail_1 " & _
            " WHERE PurchaseToInvoice.lngInvoiceDetailID = ItemActivityDetail_1.lngActivityDetailID " & _
            " AND PurchaseToInvoice.lngReceiptDetailID = ItemActivityDetail.lngActivityDetailID " & _
            " AND " & strTmp & ") "
    Else
        strSql = "UPDATE ItemActivityDetail SET ItemActivityDetail.dblInvoiceQuantity=(SELECT ItemActivityDetail.dblInvoiceQuantity-NVL(SUM(SaleToInvoice.dblQuantity),0) " & _
            " FROM SaleToInvoice,ItemActivityDetail ItemActivityDetail_1 " & _
            " WHERE SaleToInvoice.lngInvoiceDetailID = ItemActivityDetail_1.lngActivityDetailID " & _
            " AND SaleToInvoice.lngReceiptDetailID = ItemActivityDetail.lngActivityDetailID " & _
            " AND " & strTmp & "),"
        strSql = strSql & _
            " ItemActivityDetail.dblCurrInvoiceAmount=(SELECT ItemActivityDetail.dblCurrInvoiceAmount-NVL(SUM(SaleToInvoice.dblCurrAmount),0) " & _
            " FROM SaleToInvoice,ItemActivityDetail ItemActivityDetail_1 " & _
            " WHERE SaleToInvoice.lngInvoiceDetailID = ItemActivityDetail_1.lngActivityDetailID " & _
            " AND SaleToInvoice.lngReceiptDetailID = ItemActivityDetail.lngActivityDetailID " & _
            " AND " & strTmp & "),ItemActivityDetail.blnCloseInvoice=0 "
        strSql = strSql & _
            " WHERE EXISTS (SELECT ItemActivityDetail_1.lngActivityDetailID " & _
            " FROM SaleToInvoice,ItemActivityDetail ItemActivityDetail_1 " & _
            " WHERE SaleToInvoice.lngInvoiceDetailID = ItemActivityDetail_1.lngActivityDetailID " & _
            " AND SaleToInvoice.lngReceiptDetailID = ItemActivityDetail.lngActivityDetailID " & _
            " AND " & strTmp & ") "
    End If
    If gclsBase.ExecSQL(strSql) = False Then
        If blnDoTrans Then
            gclsBase.BaseWorkSpace.RollBacktrans
        End If
        cMsgBox "清除开票信息失败!", "错误信息"
        GoTo EndProc
    End If

    strSql = "UPDATE ItemActivityDetail SET dblInvoiceQuantity=0,dblCurrInvoiceAmount=0 "
    If mlngRowNO = 0 Then
        strSql = strSql & " WHERE ItemActivityDetail.lngActivityID = " & frmName.getID
    Else
        strSql = strSql & " WHERE ItemActivityDetail.lngActivityDetailID = " & C2lng(frmName.TextOfGrid(mlngRowNO, 0))
    End If
    If gclsBase.ExecSQL(strSql) = False Then
        If blnDoTrans Then
            gclsBase.BaseWorkSpace.RollBacktrans
        End If
        cMsgBox "清除开票信息失败!", "错误信息"
        GoTo EndProc
    End If
    
    If lngReceiptTypeID = 8 Then
        strSql = "DELETE FROM PurchaseToInvoice WHERE EXISTS (SELECT ItemActivityDetail_1.lngActivityDetailID FROM ItemActivityDetail ItemActivityDetail_1 " & _
            " WHERE ItemActivityDetail_1.lngActivityDetailID= PurchaseToInvoice.lngInvoiceDetailID AND " & strTmp & ")"
    Else
        strSql = "DELETE FROM SaleToInvoice WHERE EXISTS (SELECT ItemActivityDetail_1.lngActivityDetailID FROM ItemActivityDetail ItemActivityDetail_1 " & _
            " WHERE ItemActivityDetail_1.lngActivityDetailID= SaleToInvoice.lngInvoiceDetailID AND " & strTmp & ")"
    End If
    If gclsBase.ExecSQL(strSql) = False Then
        If blnDoTrans Then
            gclsBase.BaseWorkSpace.RollBacktrans
        End If
        cMsgBox "清除开票信息失败!", "错误信息"
        GoTo EndProc
    End If
    '写核销标志blnInvoiceClose
    strSql = "UPDATE ItemActivity SET blnInvoiceClose=0 WHERE lngActivityID=" & frmName.getID
    If gclsBase.ExecSQL(strSql) = False Then
        If blnDoTrans Then
            gclsBase.BaseWorkSpace.RollBacktrans
        End If
        cMsgBox "清除开票信息失败!", "错误信息"
        GoTo EndProc
    End If
    
    If blnDoTrans Then
        gclsBase.BaseWorkSpace.CommitTrans
    End If
    OldBillClearSelect = True
EndProc:
End Function

Private Function WriteObtendToBase()
    Dim i As Long
    Dim strSql As String
    Dim strTmp As String
    
    For i = 1 To GrdCol.Rows - 1
        If GrdCol.TextMatrix(i, 1) <> "" Then
            If lngReceiptTypeID = 8 Then
                strSql = "INSERT INTO PurchaseToInvoice (lngReceiptDetailID,lngInvoiceDetailID,dblQuantity, dblCurrAmount,lngVoucherID) " & _
                    " VALUES (" & ObtendData(i).lngActivityDetailID & "," & _
                    C2lng(frmName.TextOfGrid(ObtendData(i).lngTheRowNO, 0)) & "," & _
                    ObtendData(i).dblQuantity & " ," & _
     

⌨️ 快捷键说明

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