📄 frmdlselectsalereceipt.frm
字号:
' Wend
While (msgGrid.TextMatrix(0, n) <> "关闭")
n = n + 1
Wend
ytextRow = 1
While ytextRow < msgGrid.Rows
If Trim(msgGrid.TextMatrix(ytextRow, n)) <> "√" Then
' If getnumber(ytextRow, 3) = 0 Then
msgGrid.TextMatrix(ytextRow, 1) = "" '取消打√(核销)情况
' Else
' msgGrid.TextMatrix(ytextRow, 1) = "√"
' End If
' hlb(i).Caption = CStr(CDbl(hlb(i).Caption) + getnumber(ytextRow, 3) - getnumber(ytextRow, i))
' msgGrid.TextMatrix(ytextRow, k) = msgGrid.TextMatrix(ytextRow, 2)
' msgGrid.TextMatrix(ytextRow, i) = msgGrid.TextMatrix(ytextRow, 3)
End If
ytextRow = ytextRow + 1
Wend
End Sub
Private Sub Cmdall_Click(Index As Integer)
'响应窗体按钮动作
Select Case Index
Case 7 '确定存盘
blnIsCancel = True
If msgGrid.Rows > 1 Then
SaveData (1)
Else
ExitGrid
End If
Case 1 '取消
blnIsCancel = True
ExitGrid
Case 2 '筛选
FilterData
Case 3 '栏目设置
setColumn
Case 4
ExitGrid
mfrmToFormname.ShowAOldBill DetailID
Case 5 '全部选择
If msgGrid.Rows > 1 Then
BalenceAll
End If
Case 6
If msgGrid.Rows > 1 Then
AbolishAll '全部取消
End If
End Select
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 recRecordset As rdoResultset, intCount As Integer
' On Error GoTo Err
mclsGrid.ListSet.ViewId = intViewID
With msgGrid
.Redraw = False
.FixedCols = 0
End With
If DetailID < 1 Then
Cmdall(4).Enabled = False
End If
strWhere = ""
str = ""
strSql = ""
strFrom = ""
pbsql = ""
With mclsGrid.ListSet
strFrom = .FromOfSql
pbsql = .SelectOfSql
strWhere = .WhereOfSql
End With
str = " Where ((([dblQuantity]-[dblSendQuantity])<>0) And ((SaleOrderDetail.blnIsClose)=False) AND ((SaleOrder.lngCustomerID)=" & CustomerID & ") AND ((SaleOrder.lngCurrencyID)=" & CurrencyID & " ))"
If Len(Trim(strWhere)) >= 1 Then str = str & "AND" & " ( " & strWhere & ")"
If Len(Trim(strWorkID)) > 4 Then
str = str & " OR ( SaleOrderDetail.lngSaleOrderDetailID IN " & strWorkID & ")"
End If
strSql = strFrom & str
sqlselect = " Select SaleOrderDetail.lngSaleOrderDetailID As 业务ID, iif(dblSendQuantity<>0,'','') As 选择," _
& " Trim(Str([dblSendQuantity]\[dblFactor]))+'.'+String(Len(Trim(Str([dblFactor])))-Len(Trim(Str([dblSendQuantity] Mod " _
& " [dblFactor]))),'0')+Trim(Str([dblSendQuantity] Mod [dblFactor])) AS 原销售数量, dblCurrTaxAmount+dblCurrAmount AS 原销售金额, " _
& " Trim(Str(([dblQuantity]-[dblSendQuantity])\[dblFactor]))+'.'+String(Len(Trim(Str([dblFactor])))-Len(Trim(Str(([dblQuantity]-[dblSendQuantity]) Mod " _
& " [dblFactor]))),'0')+Trim(Str(([dblQuantity]-[dblSendQuantity]) Mod [dblFactor])) AS 原未销售数量, " _
& " Format((dblCurrTaxAmount+dblCurrAmount-[dblSendQuantity]*[dblPrice]*[dblFactor]*(1+iif(isnull(dblSaleTaxRate),0,dblSaleTaxRate/100))),'####.00') AS 原未销售金额, (SaleOrder.strReceiptNO & SaleOrder.lngReceiptNO) AS 原销售单号,lngClassID1 As 7," _
& " lngClassID2 As 8,SaleOrderDetail.lngItemID As 9,SaleOrderDetail.lngUnitID As 10,dblDiscountRate As 11,dblPrice*dblFactor As 12,SaleOrderDetail.lngTaxID As 13,SaleOrderDetail.lngJobID As 14," _
& " SaleOrderDetail.lngCustomID0,SaleOrderDetail.lngCustomID1,SaleOrderDetail.lngCustomID2,SaleOrderDetail.lngCustomID3,SaleOrderDetail.lngCustomID4,SaleOrderDetail.lngCustomID5,strReceiptNO As 21," _
& " strReceiptNO & ' ' & Format(lngReceiptNO, '0000') As 22,dblFactor As 23,(strItemCode & ' ' & strItemName & ' ' & strItemStyle) As 24,strUnitName As 25,strTaxName As 26,Item.lngPositionID As 27,strPositionName As 28,strJobName As 29," _
& " Custom0.strCustomName As 30,Custom1.strCustomName As 31,Custom2.strCustomName As 32,Custom3.strCustomName As 33,Custom4.strCustomName As 34,Custom5.strCustomName As 35, " & pbsql
'备份 sqlselect = " Select SaleOrderDetail.lngSaleOrderDetailID As 业务ID, iif(dblSendQuantity<>0,'','') As 选择," _
& " Trim(Str([dblSendQuantity]\[dblFactor]))+'.'+String(Len(Trim(Str([dblFactor])))-Len(Trim(Str([dblSendQuantity] Mod " _
& " [dblFactor]))),'0')+Trim(Str([dblSendQuantity] Mod [dblFactor])) AS 原销售数量, dblCurrTaxAmount+dblCurrAmount AS 原销售金额, " _
& " Trim(Str(([dblQuantity]-[dblSendQuantity])\[dblFactor]))+'.'+String(Len(Trim(Str([dblFactor])))-Len(Trim(Str(([dblQuantity]-[dblSendQuantity]) Mod " _
& " [dblFactor]))),'0')+Trim(Str(([dblQuantity]-[dblSendQuantity]) Mod [dblFactor])) AS 原未销售数量, " _
& " Format((dblCurrTaxAmount+dblCurrAmount-[dblSendQuantity]*[dblPrice]*[dblFactor]*(1+iif(isnull(dblSaleTaxRate),0,dblSaleTaxRate/100))),'####.00') AS 原未销售金额, (SaleOrder.strReceiptNO & SaleOrder.lngReceiptNO) AS 原销售单号,lngClassID1 As 7," _
& " lngClassID2 As 8,SaleOrderDetail.lngItemID As 9,SaleOrderDetail.lngUnitID As 10,dblDiscountRate As 11,dblPrice*dblFactor As 12,SaleOrderDetail.lngTaxID As 13,SaleOrderDetail.lngJobID As 14," _
& " SaleOrderDetail.lngCustomID0,SaleOrderDetail.lngCustomID1,SaleOrderDetail.lngCustomID2,SaleOrderDetail.lngCustomID3,SaleOrderDetail.lngCustomID4,SaleOrderDetail.lngCustomID5,strReceiptNO As 21," _
& " strReceiptNO & ' ' & Format(lngReceiptNO, '0000') As 22,dblFactor As 23,(strItemCode & ' ' & strItemName & ' ' & strItemStyle) As 24,strUnitName As 25,strTaxName As 26,Item.lngPositionID As 27,strPositionName As 28,strJobName As 29," _
& " Custom0.strCustomName As 30,Custom1.strCustomName As 31,Custom2.strCustomName As 32,Custom3.strCustomName As 33,Custom4.strCustomName As 34,Custom5.strCustomName As 35, " & pbsql
' sqlselect = " Select SaleOrderDetail.lngSaleOrderDetailID As 业务ID, iif(dblSendQuantity>0,'√','') As √, Trim(Str([dblSendQuantity]\[dblFactor]))+'.'+String(Len(Trim(Str([dblFactor])))-Len(Trim(Str([dblSendQuantity] Mod [dblFactor]))),'0')+Trim(Str([dblSendQuantity] Mod [dblFactor])) AS 原销售数量, [dblSendQuantity]*[dblPrice] AS 原销售金额, Trim(Str(([dblQuantity]-[dblSendQuantity])\[dblFactor]))+'.'+String(Len(Trim(Str([dblFactor])))-Len(Trim(Str(([dblQuantity]-[dblSendQuantity]) Mod [dblFactor]))),'0')+Trim(Str(([dblQuantity]-[dblSendQuantity]) Mod [dblFactor])) AS 原未销售数量, " _
& " dblTaxAmount+dblAmount-[dblSendQuantity]*[dblPrice] AS 原未销售金额, (SaleOrder.strReceiptNO & SaleOrder.lngReceiptNO) AS 原销售单号,lngClassID1 As 7,lngClassID2 As 8,SaleOrderDetail.lngItemID As 9,SaleOrderDetail.lngUnitID As 10,100 As 11,dblPrice*dblFactor As 12,SaleOrderDetail.lngTaxID As 13,SaleOrderDetail.lngJobID As 14,SaleOrderDetail.lngCustomID0,SaleOrderDetail.lngCustomID1,SaleOrderDetail.lngCustomID2,SaleOrderDetail.lngCustomID3,SaleOrderDetail.lngCustomID4,SaleOrderDetail.lngCustomID5,strReceiptNO As 21,lngReceiptNO As 22,dblFactor As 23," _
& " (strItemCode & ' ' & strItemName & ' ' & strItemStyle) As 24,strUnitName As 25,strTaxName As 26,Item.lngPositionID As 27,strPositionName As 28,strJobName As 29,Custom0.strCustomName As 30,Custom1.strCustomName As 31,Custom2.strCustomName As 32,Custom3.strCustomName As 33,Custom4.strCustomName As 34,Custom5.strCustomName As 35, " & pbsql
strSql = sqlselect & strSql
'& "Order by √"
Set recRecordset = gclsBase.BaseDB.OpenRecordset(strSql, dbOpenSnapshot)
'列表是否为空
If recRecordset.RowCount = 0 Then
msgGrid.HighLight = flexHighlightNever
' ShowMsg me.hwnd, "该销售订单无对应销售资料!", MB_SYSTEMMODAL + MB_ICONEXCLAMATION, msgcaption
isinit = False
Else
recRecordset.MoveLast
End If
Set Datadl.Recordset = recRecordset
msgGrid.HighLight = flexHighlightAlways
If isinit = True Then
Set mlhls = recRecordset
inittext
isinit = False
msgGrid.col = 1
msgGrid.ColSel = 1
msgGrid.Row = 1
msgGrid.RowSel = 1
End If
recRecordset.Close
With msgGrid
.SelectionMode = flexSelectionByRow
.FocusRect = flexFocusNone
.ColWidth(0) = 0
.ColWidth(1) = 488
intCount = 2
While intCount <= 35
.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, l As Integer
Dim cgje As Double, wdje As Double, n As Integer
Dim recRecordset As rdoResultset
dx = 0
dz = 0
Set Datadl.Recordset = mlhls
mlhls.MoveFirst
For intCount = 1 To mlhls.RowCount
cgje = C2Dbl(IIf(IsNull(mlhls.rdoColumns("销售金额")), 0, mlhls.rdoColumns("销售金额")))
wdje = C2Dbl(IIf(IsNull(mlhls.rdoColumns("未销售金额")), 0, mlhls.rdoColumns("未销售金额")))
dx = dx + cgje
dz = dz + wdje
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
'End If
End Sub
'存盘
Private Sub SaveData(kkk As Integer) '存盘
Dim i As Integer, j As Integer, temp As Double, strSql As String
Dim l As Integer, n As Integer, slh As String, m As Integer, intCount As Integer, k As Integer
Dim blnColse As Boolean
'On Error GoTo Err
'i = 1
'MousePointer = vbHourglass
l = intfixl
n = intfixl
m = intfixl
While (msgGrid.TextMatrix(0, m) <> "关闭")
m = m + 1
Wend
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为未覆盖标志
' mfrmToFormname.grdCol.TextMatrix(j, 41) = "0"
' j = j + 1
' Loop
j = 1
While j < msgGrid.Rows
If (msgGrid.TextMatrix(j, 1) = "√") Then '前后有否变化
k = 1
Do While k < intCount '判断商品在对方GRID上是否已存在
If msgGrid.TextMatrix(j, 0) = mfrmToFormname.grdCol.TextMatrix(k, 29) Then
Exit Do
End If
k = k + 1
Loop
If k >= intCount Then '该订单商品是否为添加
'需要添加一行吗
If C2Lng(mfrmToFormname.grdCol.TextMatrix(mfrmToFormname.grdCol.Rows - 1, 28)) <> 0 Then
mfrmToFormname.InsertARow
'False
End If
i = mfrmToFormname.grdCol.Rows - 1 '记住对方GRID行号
mfrmToFormname.grdCol.TextMatrix(i, 1) = msgGrid.TextMatrix(j, 24) '商品名称
mfrmToFormname.grdCol.TextMatrix(i, 28) = msgGrid.TextMatrix(j, 9) '商品ID
mfrmToFormname.grdCol.TextMatrix(i, 2) = msgGrid.TextMatrix(j, 22) '订单号
mfrmToFormname.grdCol.TextMatrix(i, 29) = msgGrid.TextMatrix(j, 0) '订单ID
mfrmToFormname.grdCol.TextMatrix(i, 3) = msgGrid.TextMatrix(j, 28) '货位
mfrmToFormname.grdCol.TextMatrix(i, 30) = msgGrid.TextMatrix(j, 27) '货位ID
mfrmToFormname.grdCol.TextMatrix(i, 4) = msgGrid.TextMatrix(j, 25) '计量单位
mfrmToFormname.grdCol.TextMatrix(i, 31) = msgGrid.TextMatrix(j, 10) '计量单位ID
mfrmToFormname.grdCol.TextMatrix(i, 5) = msgGrid.TextMatrix(j, n) '到货数量
mfrmToFormname.grdCol.TextMatrix(i, 6) = msgGrid.TextMatrix(j, 12) '单价
mfrmToFormname.grdCol.TextMatrix(i, 14) = msgGrid.TextMatrix(j, l) '原币含税金额
mfrmToFormname.grdCol.TextMatrix(i, 8) = msgGrid.TextMatrix(j, 11) '扣率
mfrmToFormname.grdCol.TextMatrix(i, 11) = msgGrid.TextMatrix(j, 26) '税率
mfrmToFormname.grdCol.TextMatrix(i, 32) = msgGrid.TextMatrix(j, 13) '税率ID
mfrmToFormname.grdCol.TextMatrix(i, 21) = msgGrid.TextMatrix(j, 29) '工程
mfrmToFormname.grdCol.TextMatrix(i, 33) = msgGrid.TextMatrix(j, 14) '工程ID
mfrmToFormname.grdCol.TextMatrix(i, 22) = msgGrid.TextMatrix(j, 30) '自定义项目1
mfrmToFormname.grdCol.TextMatrix(i, 23) = msgGrid.TextMatrix(j, 31) '自定义项目2
mfrmToFormname.grdCol.TextMatrix(i, 24) = msgGrid.TextMatrix(j, 32) '自定义项目3
mfrmToFormname.grdCol.TextMatrix(i, 25) = msgGrid.TextMatrix(j, 33) '自定义项目4
mfrmToFormname.grdCol.TextMatrix(i, 26) = msgGrid.TextMatrix(j, 34) '自定义项目5
mfrmToFormname.grdCol.TextMatrix(i, 27) = msgGrid.TextMatrix(j, 35) '自定义项目6
mfrmToFormname.grdCol.TextMatrix(i, 34) = msgGrid.TextMatrix(j, 15) '自定义项目1ID
mfrmToFormname.grdCol.TextMatrix(i, 35) = msgGrid.TextMatrix(j, 16) '自定义项目2ID
mfrmToFormname.grdCol.TextMatrix(i, 36) = msgGrid.TextMatrix(j, 17) '自定义项目3ID
mfrmToFormname.grdCol.TextMatrix(i, 37) = msgGrid.TextMatrix(j, 18) '自定义项目4ID
mfrmToFormname.grdCol.TextMatrix(i, 38) = msgGrid.TextMatrix(j, 19) '自定义项目5ID
mfrmToFormname.grdCol.TextMatrix(i, 39) = msgGrid.TextMatrix(j, 20) '自定义项目6ID
mfrmToFormname.grdCol.TextMatrix(i, 40) = msgGrid.TextMatrix(j, 23) '计量单位折算因子
mfrmToFormname.grdCol.TextMatrix(i, 41) = msgGrid.TextMatrix(j, n) '订购数量
Else
'以下注释同上!
mfrmToFormname.grdCol.TextMatrix(k, 1) = msgGrid.TextMatrix(j, 24)
mfrmToFormname.grdCol.TextMatrix(k, 28) = msgGrid.TextMatrix(j, 9)
mfrmToFormname.grdCol.TextMatrix(k, 2) = msgGrid.TextMatrix(j, 22)
mfrmToFormname.grdCol.TextMatrix(k, 29) = msgGrid.TextMatrix(j, 0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -