📄 frmdlpurchase.frm
字号:
Wend
ytextRow = 1
If Index = 0 Then
'响应完全结算菜单
While ytextRow < msgGrid.Rows
'打√情况
msgGrid.TextMatrix(ytextRow, 1) = "√"
xx = getnumber(ytextRow, 11) - getnumber(ytextRow, i)
msgGrid.TextMatrix(ytextRow, i) = msgGrid.TextMatrix(ytextRow, 11)
hLb(i).Caption = CStr(CDbl(IIf(Len(hLb(i).Caption) = 0, "0", hLb(i).Caption)) + xx)
xx = getnumber(ytextRow, 12) - getnumber(ytextRow, k)
msgGrid.TextMatrix(ytextRow, k) = msgGrid.TextMatrix(ytextRow, 12)
ytextRow = ytextRow + 1
Wend
Else
'响应完全取消菜单
While ytextRow < msgGrid.Rows
' If getnumber(ytextRow, 8) = 0 Then
msgGrid.TextMatrix(ytextRow, 1) = "" '取消打√(核销)情况
' Else
' msgGrid.TextMatrix(ytextRow, 1) = "√"
' End If
' + getnumber(ytextRow, 8)
hLb(i).Caption = CStr(CDbl(hLb(i).Caption) - getnumber(ytextRow, i))
msgGrid.TextMatrix(ytextRow, k) = ""
'msgGrid.TextMatrix(ytextRow, 10)
msgGrid.TextMatrix(ytextRow, i) = ""
'msgGrid.TextMatrix(ytextRow, 8)
ytextRow = ytextRow + 1
Wend
End If
End Sub
'不存盘返回
Private Sub ExitGrid()
Unload Me
End Sub
'从对应视图取SQL语句并打开、初始化之
Private Sub GetList()
Dim sqlselect As String, strSql As String, strSelect As String, str As String
Dim strWhere As String, pbsql As String, strFrom As String
Dim q2 As QueryDef
Dim recRecordset As rdoResultset, intCount As Integer
' On Error GoTo Err
mclsGrid.ListSet.ViewId = intViewID
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'// 取本次结算金额、本次结算数量算法(连接对照表的方法): //
'// '首先:因为本次结算金额、本次结算数量是针对本次单据业务ID的;所以,可通过ItemActivity表的lngItemActivityID字段 //
'// '和ItemActivityDetail表的lngItemActivityID字段将此二表连接起来;再通过ItemActivityDetail表的lngItemActivityDetailID字段 //
'// '和BorrowToPurchase表的lngPurchaseActivityDetailID字段将此二表连接起来;这样一来表ItemActivity、ItemActivityDetail和BorrowToPurchase就被有机连接起来了。 //
'// '再用ItemActivity中的lngItemActivityID作为取本次结算金额、本次结算数量记录的条件。把单据中取过来的单据业务ID作为参数传给lngItemActivityID //
'// '就得到了所有取本次结算金额、本次结算数量的记录(取BorrowToPurchase表的全部字段)。 //
'// '然后:将上面生成的查询作为一个查询表(取别名BorrowToPurchase)再同表ItemActivityDetail连接回去就得到了我们需要的结果。连接方法是 //
'// '通过ItemActivityDetail表的lngItemActivityDetailID字段和BorrowToPurchase表的lngBorrowActivityDetailID字段将二表连接起来。 //
'// '结束 //
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
With msgGrid
.Redraw = False
.FixedCols = 0
End With
If DetailID < 1 Then
cmdOk(4).Enabled = False
End If
strWhere = ""
str = ""
strSql = ""
strFrom = ""
pbsql = ""
With mclsGrid.ListSet
strFrom = .FromOfSql
pbsql = .SelectOfSql
strWhere = .WhereOfSql
End With
'3----受托入库;23-----受托调价
'str = " Where (((ItemActivity.lngCustomerID)=[CustomerID]) AND ((ItemActivity.lngCurrencyID)=[CurrencyID]) AND" _
& " ((ItemActivity.lngActivityTypeID) In (42,23,3)) AND (([ItemActivityDetail ].[dblCurrAmount]+[ItemActivityDetail].[dblCurrTaxAmount]-[ItemActivityDetail].[dblCurrSettlementAmount])<>0))"
str = " Where (((ItemActivity.lngCustomerID)=[CustomerID]) AND ((ItemActivity.lngCurrencyID)=[CurrencyID]) AND" _
& " ((ItemActivity.lngActivityTypeID) In (23,3)) AND (([ItemActivityDetail ].[dblCurrAmount]+[ItemActivityDetail].[dblCurrTaxAmount]-[ItemActivityDetail].[dblCurrSettlementAmount]+" _
& " IIf(IsNull([BorrowToPurchase].[dblCurrAmount]),0,[BorrowToPurchase].[dblCurrAmount]))<>0))"
If Len(Trim(strWhere)) >= 1 Then str = str & "AND" & " ( " & strWhere & ")"
If Len(Trim(strWorkID)) > 4 Then
str = str & " OR ( ItemActivityDetail.lngActivityDetailID IN " & strWorkID & ")"
End If
strSql = strFrom & str
sqlselect = " Select ItemActivityDetail.lngActivityDetailID As 业务ID,(Iif((([BorrowToPurchase].[dblCurrAmount])<>0),'√','')) As 结算, " _
& " '' As 行号,0 AS 优惠日2,0 AS 优惠日3,0 AS 折扣率1,0 AS 折扣率2,0 AS 折扣率3,([BorrowToPurchase].[dblCurrAmount]) AS 原结算金额," _
& " 0 AS 原结算折扣,Trim(Str(iif(isnull([BorrowToPurchase].[dblQuantity]),0,[BorrowToPurchase].[dblQuantity])/[dblFactor]))+'.'+String(Len(Trim(Str([dblFactor])))-" _
& " Len(Trim(Str(iif(isnull([BorrowToPurchase].[dblQuantity]),0,[BorrowToPurchase].[dblQuantity]) Mod [dblFactor]))),'0')+Trim(Str(iif(isnull([BorrowToPurchase].[dblQuantity]),0,[BorrowToPurchase].[dblQuantity]) Mod [dblFactor])) AS 原结算数量," _
& " ([ItemActivityDetail ].[dblCurrAmount]+[ItemActivityDetail].[dblCurrTaxAmount]-[ItemActivityDetail].[dblCurrSettlementAmount]+" _
& " IIf(IsNull([BorrowToPurchase].[dblCurrAmount]),0,[BorrowToPurchase].[dblCurrAmount])) AS 原未结金额," _
& " (Trim(Str(([ItemActivityDetail].[dblQuantity]-[ItemActivityDetail].[dblSettlementQuantity]+" _
& " iif(isnull([BorrowToPurchase].[dblQuantity]),0,[BorrowToPurchase].[dblQuantity]))\[dblFactor]))+'.'+String(Len(Trim(Str([dblFactor])))-"
str = " Len(Trim(Str(([ItemActivityDetail].[dblQuantity]-[ItemActivityDetail].[dblSettlementQuantity]+iif(isnull([BorrowToPurchase].[dblQuantity]),0,[BorrowToPurchase].[dblQuantity])) Mod " _
& " [dblFactor]))),'0')+Trim(Str(([ItemActivityDetail].[dblQuantity]-[ItemActivityDetail].[dblSettlementQuantity]+iif(isnull([BorrowToPurchase].[dblQuantity]),0,[BorrowToPurchase].[dblQuantity])) Mod [dblFactor]))) AS 原未结数量," _
& " ItemActivity.lngActivityTypeID AS 类型ID, ItemActivityDetail.strProduceDate As 15,ItemActivityDetail.strValidDate As 16,ItemActivityDetail.lngItemID As 17,ItemActivityDetail.lngUnitID As 18," _
& " 100 As 19,dblCurrPrice*dblFactor As 20,ItemActivityDetail.lngTaxID As 21,ItemActivityDetail.lngJobID As 22,ItemActivityDetail.lngCustomID0 As 23,ItemActivityDetail.lngCustomID1 As 24," _
& " ItemActivityDetail.lngCustomID2 As 25,ItemActivityDetail.lngCustomID3 As 26,ItemActivityDetail.lngCustomID4 As 27,ItemActivityDetail.lngCustomID5 As 28,dblFactor As 29," _
& " (strItemCode & ' ' & strItemName & ' ' & strItemStyle) As 30,strUnitName As 31,strTaxName As 32,Item.lngPositionID As 33,strPositionName As 34,strJobName As 35,Custom0.strCustomName As 36," _
& " Custom1.strCustomName As 37,Custom2.strCustomName As 38,Custom3.strCustomName As 39,Custom4.strCustomName As 40,Custom5.strCustomName As 41,[ItemActivityDetail].[strProduceNum] As 42," _
& " ItemActivityDetail.intValidDay As 43,ItemActivityDetail.dblQuantity As 44,([ItemActivityDetail ].[dblCurrAmount]+[ItemActivityDetail].[dblCurrTaxAmount]) As 45," & pbsql
' sqlselect = " Select ItemActivityDetail.lngActivityDetailID As 业务ID,(Iif((([BorrowToPurchase].[dblCurrAmount])<>0),'√','')) As √, " _
& " 0 AS 优惠日1,0 AS 优惠日2,0 AS 优惠日3,0 AS 折扣率1,0 AS 折扣率2,0 AS 折扣率3,([BorrowToPurchase].[dblCurrAmount]) AS 原结算金额," _
& " 0 AS 原结算折扣,Trim(Str([BorrowToPurchase].[dblQuantity]/[dblFactor]))+'.'+String(Len(Trim(Str([dblFactor])))-" _
& " Len(Trim(Str([BorrowToPurchase].[dblQuantity] Mod [dblFactor]))),'0')+Trim(Str([BorrowToPurchase].[dblQuantity] Mod [dblFactor])) AS 原结算数量," _
& " ([ItemActivityDetail ].[dblCurrAmount]+[ItemActivityDetail].[dblCurrTaxAmount]-[ItemActivityDetail].[dblCurrSettlementAmount]+" _
& " IIf(IsNull([BorrowToPurchase].[dblCurrAmount]),0,[BorrowToPurchase].[dblCurrAmount])) AS 原未结金额," _
& " (Trim(Str(([ItemActivityDetail].[dblQuantity]-[ItemActivityDetail].[dblSettlementQuantity]+" _
& " [BorrowToPurchase].[dblQuantity])\[dblFactor]))+'.'+String(Len(Trim(Str([dblFactor])))-"
' str = " Len(Trim(Str(([ItemActivityDetail].[dblQuantity]-[ItemActivityDetail].[dblSettlementQuantity]+[BorrowToPurchase].[dblQuantity]) Mod " _
& " [dblFactor]))),'0')+Trim(Str(([ItemActivityDetail].[dblQuantity]-[ItemActivityDetail].[dblSettlementQuantity]+[BorrowToPurchase].[dblQuantity]) Mod [dblFactor]))) AS 原未结数量," _
& " ItemActivity.lngActivityTypeID AS 类型ID, ItemActivityDetail.strProduceDate As 15,ItemActivityDetail.strValidDate As 16,ItemActivityDetail.lngItemID As 17,ItemActivityDetail.lngUnitID As 18," _
& " 100 As 19,dblCurrPrice*dblFactor As 20,ItemActivityDetail.lngTaxID As 21,ItemActivityDetail.lngJobID As 22,ItemActivityDetail.lngCustomID0 As 23,ItemActivityDetail.lngCustomID1 As 24," _
& " ItemActivityDetail.lngCustomID2 As 25,ItemActivityDetail.lngCustomID3 As 26,ItemActivityDetail.lngCustomID4 As 27,ItemActivityDetail.lngCustomID5 As 28,dblFactor As 29," _
& " (strItemCode & ' ' & strItemName & ' ' & strItemStyle) As 30,strUnitName As 31,strTaxName As 32,Item.lngPositionID As 33,strPositionName As 34,strJobName As 35,Custom0.strCustomName As 36," _
& " Custom1.strCustomName As 37,Custom2.strCustomName As 38,Custom3.strCustomName As 39,Custom4.strCustomName As 40,Custom5.strCustomName As 41,[ItemActivityDetail].[strProduceNum] As 42," _
& " ItemActivityDetail.intValidDay As 43,ItemActivityDetail.dblQuantity As 44,([ItemActivityDetail ].[dblCurrAmount]+[ItemActivityDetail].[dblCurrTaxAmount]) As 45," & pbsql
sqlselect = sqlselect & str
' sqlselect = " Select ItemActivityDetail.lngActivityDetailID As 业务ID,(Iif((([BorrowToPurchase].[dblCurrAmount])<>0),'√','')) As √, " _
& " 0 AS 优惠日1,0 AS 优惠日2,0 AS 优惠日3,0 AS 折扣率1,0 AS 折扣率2,0 AS 折扣率3,([BorrowToPurchase].[dblCurrAmount]) AS 原结算金额, 0 AS 原结算折扣,Trim(Str([BorrowToPurchase].[dblQuantity]/[dblFactor]))+'.'+String(Len(Trim(Str([dblFactor])))-Len(Trim(Str([BorrowToPurchase].[dblQuantity] Mod [dblFactor]))),'0')+Trim(Str([BorrowToPurchase].[dblQuantity] Mod [dblFactor])) AS 原结算数量," _
& " ([ItemActivityDetail ].[dblCurrAmount]+[ItemActivityDetail].[dblCurrTaxAmount]-[ItemActivityDetail].[dblCurrSettlementAmount]+IIf(IsNull([BorrowToPurchase].[dblQuantity]),0,[BorrowToPurchase].[dblQuantity])) AS 原未结金额," _
& " (Trim(Str(([ItemActivityDetail].[dblQuantity]-[ItemActivityDetail].[dblSettlementQuantity]+[BorrowToPurchase].[dblQuantity])\[dblFactor]))+'.'+String(Len(Trim(Str([dblFactor])))-Len(Trim(Str(([ItemActivityDetail].[dblQuantity]-[ItemActivityDetail].[dblSettlementQuantity]+[BorrowToPurchase].[dblQuantity]) Mod [dblFactor]))),'0')+Trim(Str(([ItemActivityDetail].[dblQuantity]-[ItemActivityDetail].[dblSettlementQuantity]+[BorrowToPurchase].[dblQuantity]) Mod [dblFactor]))) AS 原未结数量, ItemActivity.lngActivityTypeID AS 类型ID, " _
& " ItemActivityDetail.strProduceDate As 15,ItemActivityDetail.strValidDate As 16,ItemActivityDetail.lngItemID As 17,ItemActivityDetail.lngUnitID As 18,100 As 19,dblCurrPrice*dblFactor As 20,ItemActivityDetail.lngTaxID As 21,ItemActivityDetail.lngJobID As 22,ItemActivityDetail.lngCustomID0 As 23,ItemActivityDetail.lngCustomID1 As 24,ItemActivityDetail.lngCustomID2 As 25,ItemActivityDetail.lngCustomID3 As 26,ItemActivityDetail.lngCustomID4 As 27,ItemActivityDetail.lngCustomID5 As 28,dblFactor As 29," _
& " (strItemCode & ' ' & strItemName & ' ' & strItemStyle) As 30,strUnitName As 31,strTaxName As 32,Item.lngPositionID As 33,strPositionName As 34,strJobName As 35,Custom0.strCustomName As 36,Custom1.strCustomName As 37,Custom2.strCu].[dblCurrAmount]+[ItemActivityDetail].[dblCurrTaxAmount]) As 45," & pbsql
strSql = sqlselect & strSql
'& "Order by √"
Set q2 = gclsBase.BaseDB.CreateQueryDef("", strSql)
q2.Parameters("DetailID") = DetailID
q2.Parameters("CustomerID") = CustomerID
q2.Parameters("CurrencyID") = CurrencyID
Set recRecordset = q2.OpenRecordset(dbOpenSnapshot)
'列表是否为空
If recRecordset.RowCount = 0 Then
msgGrid.HighLight = flexHighlightNever
'ShowMsg me.hWnd, "该受托结算单无对应受托资料!", 0, msgcaption
isinit = False
Else
recRecordset.MoveLast
End If
Set Data1.Recordset = recRecordset
msgGrid.HighLight = flexHighlightAlways
If isinit = True Then
Set mlhls = recRecordset
inittext
isinit = False
End If
recRecordset.Close
With msgGrid
.SelectionMode = flexSelectionFree
.FocusRect = flexFocusNone
.ColWidth(0) = 0
.ColWidth(1) = 488
intCount = 2
While intCount <= 44
.ColWidth(intCount) = 0
intCount = intCount + 1
Wend
.Redraw = True
End With
'Exit Sub
'Err:
' ShowMsg Me.hWnd, "受托结算程序初始化失败", MB_SYSTEMMODAL + MB_ICONEXCLAMATION, "受托结算"
End Sub
'初始化各text框中数据
Private Sub inittext()
Dim intCount As Integer, dx As Double, dz As Double
Dim wjje As Double, yjje As Double, l As Integer, n As Integer
Dim recRecordset As rdoResultset
dx = 0
dz = 0
Set Data1.Recordset = mlhls
mlhls.MoveFirst
For intCount = 1 To mlhls.RowCount
wjje = C2Dbl(mlhls.rdoColumns("未结金额"))
yjje = C2Dbl(IIf(IsNull(mlhls.rdoColumns("结算金额")), 0, mlhls.rdoColumns("结算金额")))
dx = dx + wjje
dz = dz + yjje
mlhls.MoveNext
Next intCount
l = intfixl
n = l
While (msgGrid.TextMatrix(0, l) <> "未结金额")
l = l + 1
Wend
While (msgGrid.TextMatrix(0, n) <> "结算金额")
n = n + 1
Wend
hLb(l).Caption = CStr(dx)
hLb(n).Caption = CStr(dz)
hLb(l).Refresh
hLb(n).Refresh
End Sub
'结算内容筛选
Private Sub FilterData()
Dim i As Integer
'If msgGrid.Rows > 1 Then
i = 1
strWorkID = ""
Do While i < msgGrid.Rows
If msgGrid.TextMatrix(i, 1) = "√" Then
If Len(strWorkID) > 0 Then
strWorkID = strWorkID & "," & CStr(getnumber(i, 0))
Else
strWorkID = CStr(getnumber(i, 0))
End If
End If
i = i + 1
Loop
strWorkID = "( " & strWorkID & " )"
If msgGrid.Rows > 1 Then
If ShowMsg(Me.hwnd, "筛选操作后,你刚刚做的结算将被取消,需要先存盘吗", MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2 + MB_SYSTEMMODAL, "受托结算") = IDYES Then
SaveData (0)
End If
End If
If mclsGrid.ListSet.ListID < 1 Then
mclsGrid.ListSet.SaveList
End If
Filter.ShowFilter mclsGrid.ListSet.ListID, 1
mclsGrid.ListSet.SaveList
mclsGrid.ColOfs = intfixl
isinit = True
GetList
mclsGrid.SetupStyle
If msgGrid.Rows > 1 Then
msgGrid.col = 1 '对第一列进行排序
msgGrid.ColSel = 1
msgGrid.Row = 1
msgGrid.RowSel = 1
msgGrid.Sort = 6
End If
'End If
End Sub
Private Sub SaveData(kkk As Integer) '存盘
Dim i As Integer, j As Integer, temp As Double, strSql As String, GoodsID As Long
Dim l As Integer, n As Integer, slh As String, intCount As Integer, k As Integer
Dim blnColse As Boolean, dblhl As Double
'On Error GoTo Err
i = 1
l = intfixl
n = intfixl
' MousePointer = vbHourglass
GoodsID = 0
If msgGrid.Rows > 1 Then
msgGrid.col = 16
msgGrid.ColSel = 16
msgGrid.Row = 1
msgGrid.RowSel = 1
msgGrid.Sort = 3
End If
While (msgGrid.TextMatrix(0, l) <> "结算金额")
l = l + 1
Wend
While (msgGrid.TextMatrix(0, n) <> "结算数量")
n = n + 1
Wend
intCount = mfrmToFormname.grdCol.Rows
If mfrmToFormname.grdCol.Rows < 2 Then
mfrmToFormname.InsertARow
'False
intCount = intCount + 1
End If
j = 1
Do While j < mfrmToFormname.grdCol.Rows '=0为未覆盖标志
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -