📄 frminvoiceselect.frm
字号:
GoTo EndProc
End If
End If
If SetRowClose = False Then
GoTo EndProc
End If
ReDim ObtendData(GrdCol.Rows - 1)
For i = 1 To GrdCol.Rows - 1
If GrdCol.TextMatrix(i, 1) <> "" Then
ObtendData(i).lngMeRowNO = i
ObtendData(i).lngActivityDetailID = DataofGrid(GrdCol.RowData(i)).lngActivityDetailID
ObtendData(i).lngVoucherID = DataofGrid(GrdCol.RowData(i)).lngVoucherID
ObtendData(i).lngItemID = DataofGrid(GrdCol.RowData(i)).lngItemID
ObtendData(i).dblQuantity = C2Dbl(NumberConvert(GrdCol.TextMatrix(i, xlngColNo(9)), DataofGrid(GrdCol.RowData(i)).dblFactor))
ObtendData(i).dblCurrAmount = C2Dbl(GrdCol.TextMatrix(i, xlngColNo(10)))
End If
Next
' .SetGridRows 1
' For i = .grdCol.Rows - 1 To 1 Step -1
' If UCase(.TextOfGrid(i, 47)) = "TRUE" Or C2lng(.TextOfGrid(i, 28)) = 0 Then
' If .grdCol.Rows = 2 Then
' .SetGridRows 1
' Else
' .blnDeleteARow i
' End If
' End If
' Next
.GrdCol.Redraw = False
.FormRefresh False
.chkPrint(0).Value = 1 - .chkPrint(0).Value
.chkPrint(0).Value = 1 - .chkPrint(0).Value
For i = 1 To GrdCol.Rows - 1
If GrdCol.TextMatrix(i, 1) <> "" Then
SetARow i
End If
Next
.setAllItemproperty
.GrdCol.Redraw = True
.FormRefresh True
If .SaveBill(True) = False Then
gclsBase.BaseWorkSpace.RollBacktrans
.SetGridRows 1
GoTo EndProc
End If
If WriteObtendToBase() = False Then
gclsBase.BaseWorkSpace.RollBacktrans
.SetGridRows 1
cMsgBox "更新开票信息失败,不能存盘!", "保存单据"
GoTo EndProc
End If
gclsBase.BaseWorkSpace.CommitTrans
End With
cmdOK_Click = True
blnSucceed = True
EndProc:
frmName.GrdCol.Redraw = True
frmName.FormRefresh True
End Function
Private Sub SetARow(ByVal lngRowno As Long)
Dim lngWriteRowNO As Long
Dim i As Long
Dim j As Long
Dim k As Long
Dim blnNew As Boolean
Dim dblAmount As Double
Dim dblQuantity As Double
k = GrdCol.RowData(lngRowno)
For i = 1 To lngRowno - 1
If GrdCol.TextMatrix(i, 1) <> "" Then
j = GrdCol.RowData(i)
If DataofGrid(k).lngItemID = DataofGrid(j).lngItemID _
And DataofGrid(k).lngUnitID = DataofGrid(j).lngUnitID _
And DataofGrid(k).lngTaxID = DataofGrid(j).lngTaxID _
And DataofGrid(k).lngJobID = DataofGrid(j).lngJobID _
And DataofGrid(k).lngCustomID0 = DataofGrid(j).lngCustomID0 _
And DataofGrid(k).lngCustomID1 = DataofGrid(j).lngCustomID1 _
And DataofGrid(k).lngCustomID2 = DataofGrid(j).lngCustomID2 _
And DataofGrid(k).lngCustomID3 = DataofGrid(j).lngCustomID3 _
And DataofGrid(k).lngCustomID4 = DataofGrid(j).lngCustomID4 _
And DataofGrid(k).lngCustomID5 = DataofGrid(j).lngCustomID5 _
And DataofGrid(k).strProduceNum = DataofGrid(j).strProduceNum _
And DataofGrid(k).strProduceDate = DataofGrid(j).strProduceDate _
And DataofGrid(k).strValidDate = DataofGrid(j).strValidDate _
And DataofGrid(k).intValidDay = DataofGrid(j).intValidDay _
And DataofGrid(k).dblPriceTax = DataofGrid(j).dblPriceTax Then
Exit For
End If
End If
Next
If i = lngRowno Then
frmName.InsertARow False
lngWriteRowNO = frmName.GrdCol.Rows - 1
ObtendData(lngRowno).lngTheRowNO = lngWriteRowNO
blnNew = True
Else
ObtendData(lngRowno).lngTheRowNO = ObtendData(i).lngTheRowNO
lngWriteRowNO = ObtendData(i).lngTheRowNO
blnNew = False
End If
With frmName
If blnNew Then
.TextOfGrid(lngWriteRowNO, 1) = GrdCol.TextMatrix(lngRowno, xlngColNo(5))
.TextOfGrid(lngWriteRowNO, 2) = "" 'strAccountYearPeriodOfDate(recTmp!strDate) & "-" & recTmp!ReceiptNo
.TextOfGrid(lngWriteRowNO, 4) = GrdCol.TextMatrix(lngRowno, xlngColNo(6))
' .TextOfGrid(lngWriteRowNO, 3) = IIf(IsNull(recTmp!strPosition), "", recTmp!strPosition)
.TextOfGrid(lngWriteRowNO, 8) = "100.00"
.TextOfGrid(lngWriteRowNO, 11) = DataofGrid(k).strTax
.TextOfGrid(lngWriteRowNO, 17) = DataofGrid(k).strProduceNum
.TextOfGrid(lngWriteRowNO, 18) = DataofGrid(k).strProduceDate
.TextOfGrid(lngWriteRowNO, 19) = DataofGrid(k).strValidDate
.TextOfGrid(lngWriteRowNO, 20) = IIf(DataofGrid(k).intValidDay = 0, "", DataofGrid(k).intValidDay)
.TextOfGrid(lngWriteRowNO, 21) = DataofGrid(k).strJob
.TextOfGrid(lngWriteRowNO, 22) = DataofGrid(k).strCustom0
.TextOfGrid(lngWriteRowNO, 23) = DataofGrid(k).strCustom1
.TextOfGrid(lngWriteRowNO, 24) = DataofGrid(k).strCustom2
.TextOfGrid(lngWriteRowNO, 25) = DataofGrid(k).strCustom3
.TextOfGrid(lngWriteRowNO, 26) = DataofGrid(k).strCustom4
.TextOfGrid(lngWriteRowNO, 27) = DataofGrid(k).strCustom5
.TextOfGrid(lngWriteRowNO, 28) = DataofGrid(k).lngItemID
.TextOfGrid(lngWriteRowNO, 29) = "" 'DataofGrid(GrdCol.RowData(i)).lngActivityDetailID
' .TextOfGrid(lngWriteRowNO, 30) = recTmp!lngPositionID
.TextOfGrid(lngWriteRowNO, 31) = DataofGrid(k).lngUnitID
.TextOfGrid(lngWriteRowNO, 32) = DataofGrid(k).lngTaxID
.TextOfGrid(lngWriteRowNO, 33) = DataofGrid(k).lngJobID
.TextOfGrid(lngWriteRowNO, 34) = DataofGrid(k).lngCustomID0
.TextOfGrid(lngWriteRowNO, 35) = DataofGrid(k).lngCustomID1
.TextOfGrid(lngWriteRowNO, 36) = DataofGrid(k).lngCustomID2
.TextOfGrid(lngWriteRowNO, 37) = DataofGrid(k).lngCustomID3
.TextOfGrid(lngWriteRowNO, 38) = DataofGrid(k).lngCustomID4
.TextOfGrid(lngWriteRowNO, 39) = DataofGrid(k).lngCustomID5
.TextOfGrid(lngWriteRowNO, 40) = DataofGrid(k).dblFactor
.TextOfGrid(lngWriteRowNO, 47) = "True"
.TextOfGrid(lngWriteRowNO, 50) = DataofGrid(k).dblTaxRate
dblAmount = C2Dbl(GrdCol.TextMatrix(lngRowno, xlngColNo(10)))
dblQuantity = 0
Else
dblAmount = C2Dbl(GrdCol.TextMatrix(lngRowno, xlngColNo(10))) + C2Dbl(.TextOfGrid(lngWriteRowNO, 14))
dblQuantity = C2Dbl(.TextOfGrid(lngWriteRowNO, 41))
End If
dblQuantity = dblQuantity + C2Dbl(NumberConvert(GrdCol.TextMatrix(lngRowno, xlngColNo(9)), DataofGrid(k).dblFactor))
.TextOfGrid(lngWriteRowNO, 41) = dblQuantity
.WriteGrd DisplayData(Me.hWnd, NumberConvert(dblQuantity, DataofGrid(k).dblFactor, False), DataofGrid(k).dblFactor), lngWriteRowNO, 5
.WriteGrd dblAmount, lngWriteRowNO, 14
.WriteGrd dblAmount * DataofGrid(k).dblAmount / DataofGrid(k).dblCurrAmount, lngWriteRowNO, 15
.WriteGrd dblAmount * DataofGrid(k).dblCurrAmount / (DataofGrid(k).dblCurrAmount + DataofGrid(k).dblTaxCurrAmount), lngWriteRowNO, 9
.WriteGrd dblAmount * DataofGrid(k).dblAmount / (DataofGrid(k).dblCurrAmount + DataofGrid(k).dblTaxCurrAmount), lngWriteRowNO, 10
.WriteGrd dblAmount * DataofGrid(k).dblTaxCurrAmount / (DataofGrid(k).dblCurrAmount + DataofGrid(k).dblTaxCurrAmount), lngWriteRowNO, 12
.WriteGrd dblAmount * DataofGrid(k).dblTaxAmount / (DataofGrid(k).dblCurrAmount + DataofGrid(k).dblTaxCurrAmount), lngWriteRowNO, 13
.WriteGrd dblAmount * DataofGrid(k).dblCurrAmount / (DataofGrid(k).dblCurrAmount + DataofGrid(k).dblTaxCurrAmount), lngWriteRowNO, 9
If dblQuantity = 0 Then
.WriteGrd DataofGrid(k).dblPriceTax * DataofGrid(k).dblFactor, lngWriteRowNO, 7
.WriteGrd DataofGrid(k).dblPrice * DataofGrid(k).dblFactor, lngWriteRowNO, 6
Else
.WriteGrd dblAmount * DataofGrid(k).dblFactor / dblQuantity, lngWriteRowNO, 7
.WriteGrd (dblAmount * DataofGrid(k).dblCurrAmount / (DataofGrid(k).dblCurrAmount + DataofGrid(k).dblTaxCurrAmount)) * DataofGrid(k).dblFactor / dblQuantity, lngWriteRowNO, 6
End If
End With
End Sub
Private Function strAccountYearPeriodOfDate(ByVal strDate As String) As String
If Not IsDate(strDate) Then
strAccountYearPeriodOfDate = CStr(gclsBase.AccountYear) & Format((gclsBase.Period), "00")
Exit Function
End If
Dim intYear As Integer
Dim bytPeriod As Byte
strDate = Format(C2Date(strDate), "yyyy-mm-dd")
intYear = gclsBase.FYearOfDate(C2Date(strDate))
bytPeriod = gclsBase.PeriodOfDate(C2Date(strDate))
If intYear = 0 Then
intYear = Format(C2Date(strDate), "yyyy")
End If
If bytPeriod = 0 Then
intYear = C2lng(Format(C2Date(strDate), "yyyy"))
bytPeriod = C2lng(Format(C2Date(strDate), "mm"))
End If
strAccountYearPeriodOfDate = CStr(intYear) & Format(bytPeriod, "00")
End Function
'Private Sub mclsGrid_AfterColChange(lngSourCol As Long, lngDestCol As Long)
' Dim lngTmp As Long
' Dim i As Integer
'
' lngTmp = xlngColNo(lngSourCol)
' If lngSourCol < lngDestCol Then
' For i = lngSourCol To lngDestCol - 1
' xlngColNo(i) = xlngColNo(i + 1)
' Next
' Else
' For i = lngDestCol + 1 To lngSourCol Step -1
' xlngColNo(i) = xlngColNo(i - 1)
' Next
' End If
' xlngColNo(lngDestCol) = lngTmp
'End Sub
Private Function ColName(ByVal lngCol As Long) As String
Dim strTmp As String
strTmp = GrdCol.TextMatrix(0, lngCol)
If InStr(strTmp, "↑") <> 0 Or InStr(strTmp, "↓") <> 0 Then
strTmp = Left(strTmp, Len(strTmp) - 1)
End If
ColName = strTmp
End Function
Private Sub GetLngColNO()
Dim i As Integer
Dim j As Integer
For i = 2 To GrdCol.Cols - 1
For j = 2 To GrdCol.Cols - 1
If strColName(i) = ColName(j) Then
xlngColNo(i) = j
Exit For
End If
Next
Next
End Sub
Private Sub DeleteRows(ByRef blnDelete() As Boolean)
Dim i As Long
For i = UBound(blnDelete) To 1 Step -1
If blnDelete(i) Then
If frmName.GrdCol.Rows = 2 And i = 1 Then
'frmName.grdCol.Rows = 1
frmName.SetGridRows 1
frmName.InsertARow
Else
'frmName.grdCol.RemoveItem i
frmName.blnDeleteARow i
End If
End If
Next
End Sub
Private Sub mclsGrid_BeforeEdit(blnCancel As Boolean)
Dim dblFactor As Double
With GrdCol
If DataofGrid(.RowData(.Row)).blnNoChange Then
blnCancel = True
Exit Sub
End If
If .TextMatrix(0, .col) = "本次开票数量" Then
dblFactor = DataofGrid(.RowData(.Row)).dblFactor
If dblFactor <= 1 Then
curInput.Digits = 0
Else
curInput.Digits = Len(CStr(dblFactor - 1))
End If
Else
curInput.Digits = lngCurrDec
End If
End With
End Sub
Private Sub mclsGrid_AfterSave()
CalcCanSettleAmount
End Sub
Private Sub mclsGrid_BeforeSave(blnCancel As Boolean)
GetLngColNO
Dim strNewQuantity As String
Dim strNewAmount As String
Dim dblFactor As Double
With GrdCol
dblFactor = DataofGrid(GrdCol.RowData(GrdCol.Row)).dblFactor
If .col = xlngColNo(9) Then
strNewQuantity = NumberConvert(curInput.Text, dblFactor)
If C2Dbl(NumberConvert(.TextMatrix(.Row, xlngColNo(7)), dblFactor)) <> 0 Then
strNewAmount = Format(C2Dbl(.TextMatrix(.Row, xlngColNo(8))) * C2Dbl(strNewQuantity) / C2Dbl(NumberConvert(.TextMatrix(.Row, xlngColNo(7)), dblFactor)), strCurrDec)
' Else
' strNewAmount = Format(C2Dbl(.TextMatrix(.Row, xlngColNo(10))) * C2Dbl(strNewQuantity) / C2Dbl(NumberConvert(.TextMatrix(.Row, xlngColNo(9)), dblFactor)), strCurrDec)
End If
.TextMatrix(.Row, xlngColNo(10)) = strNewAmount
Else
strNewQuantity = .TextMatrix(.Row, xlngColNo(9))
strNewAmount = Format(C2Dbl(curInput.Text), strCurrDec)
curInput.Text = strNewAmount
End If
.TextMatrix(.Row, xlngColNo(10)) = strNewAmount
If .TextMatrix(.Row, xlngColNo(8)) = strNewAmount Then
SetCloseRow .Row, True
Else
SetCloseRow .Row, False
End If
If C2Dbl(strNewQuantity) = 0 And C2Dbl(strNewAmount) = 0 Then
.TextMatrix(.Row, 1) = ""
.TextMatrix(.Row, xlngColNo(9)) = ""
.TextMatrix(.Row, xlngColNo(10)) = ""
curInput.Text = ""
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -