📄 frmwlrep.frm
字号:
Adodc1.Recordset.Fields("f10") = Adodc3.Recordset.Fields("f5")
End If
Adodc1.Recordset.Update
Adodc3.Recordset.MoveNext
Next
End If
Adodc2.CommandType = adCmdText
Adodc2.RecordSource = "Select * from 异动报表"
Adodc2.Refresh
If Adodc2.Recordset.RecordCount() > 0 Then
Adodc2.Recordset.MoveFirst
For i = 1 To Adodc2.Recordset.RecordCount()
ProgressBar1.Value = i
For k = 1 To 12
Select Case k
Case 1
TSQL$ = "Select * from 数据源食品 where f2='" & Adodc2.Recordset.Fields("仓库") & "'and f1='入库'and mid(f4,1,4)='0301'"
Case 2
TSQL$ = "Select * from 数据源食品 where f2='" & Adodc2.Recordset.Fields("仓库") & "'and f1='入库'and mid(f4,1,4)='0302'"
Case 3
TSQL$ = "Select * from 数据源食品 where f2='" & Adodc2.Recordset.Fields("仓库") & "'and f1='入库'and mid(f4,1,4)='0708'"
Case 4
TSQL$ = "Select * from 数据源食品 where f2='" & Adodc2.Recordset.Fields("仓库") & "'and f1='移入'and mid(f4,1,4)='0301'"
Case 5
TSQL$ = "Select * from 数据源食品 where f2='" & Adodc2.Recordset.Fields("仓库") & "'and f1='移入'and mid(f4,1,4)='0302'"
Case 6
TSQL$ = "Select * from 数据源食品 where f2='" & Adodc2.Recordset.Fields("仓库") & "'and f1='移入'and mid(f4,1,4)='0708'"
Case 7
TSQL$ = "Select * from 数据源食品 where f2='" & Adodc2.Recordset.Fields("仓库") & "'and f1='移出'and mid(f4,1,4)='0301'"
Case 8
TSQL$ = "Select * from 数据源食品 where f2='" & Adodc2.Recordset.Fields("仓库") & "'and f1='移出'and mid(f4,1,4)='0302'"
Case 9
TSQL$ = "Select * from 数据源食品 where f2='" & Adodc2.Recordset.Fields("仓库") & "'and f1='移出'and mid(f4,1,4)='0708'"
Case 10
TSQL$ = "Select * from 数据源食品 where f2='" & Adodc2.Recordset.Fields("仓库") & "'and f1='出库'and mid(f4,1,4)='0301'"
Case 11
TSQL$ = "Select * from 数据源食品 where f2='" & Adodc2.Recordset.Fields("仓库") & "'and f1='出库'and mid(f4,1,4)='0302'"
Case 12
TSQL$ = "Select * from 数据源食品 where f2='" & Adodc2.Recordset.Fields("仓库") & "'and f1='出库'and mid(f4,1,4)='0708'"
End Select
x = 0
y = 0
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = TSQL$
Adodc1.Refresh
If Adodc1.Recordset.RecordCount() > 0 Then
Adodc1.Recordset.MoveFirst
For j = 1 To Adodc1.Recordset.RecordCount()
If k <= 12 And k >= 10 Then
x = x + Val(Adodc1.Recordset.Fields("f9")) + Val(Adodc1.Recordset.Fields("f10"))
y = y + Val(Adodc1.Recordset.Fields("f8")) - Val(Adodc1.Recordset.Fields("f9")) - Val(Adodc1.Recordset.Fields("f10"))
Else
x = x + Val(Adodc1.Recordset.Fields("f8"))
End If
Adodc1.Recordset.MoveNext
Next
If k <= 12 And k >= 10 Then
Select Case k
Case 1
Adodc2.Recordset.Fields("冷饮入库") = x
Case 2
Adodc2.Recordset.Fields("速冻入库") = x
Case 3
Adodc2.Recordset.Fields("其它入库") = x
Case 4
Adodc2.Recordset.Fields("移入冷饮") = x
Case 5
Adodc2.Recordset.Fields("移入速冻") = x
Case 6
Adodc2.Recordset.Fields("移入其它") = x
Case 7
Adodc2.Recordset.Fields("移出冷饮") = x
Case 8
Adodc2.Recordset.Fields("移出速冻") = x
Case 9
Adodc2.Recordset.Fields("移出其它") = x
Case 10
Adodc2.Recordset.Fields("冷饮销售") = x
Adodc2.Recordset.Fields("冷饮其它出库") = y
Case 11
Adodc2.Recordset.Fields("速冻销售") = x
Adodc2.Recordset.Fields("速冻其它出库") = y
Case 12
Adodc2.Recordset.Fields("其它销售") = x
Adodc2.Recordset.Fields("三类其它出库") = y
End Select
Else
Select Case k
Case 1
Adodc2.Recordset.Fields("冷饮入库") = x
Case 2
Adodc2.Recordset.Fields("速冻入库") = x
Case 3
Adodc2.Recordset.Fields("其它入库") = x
Case 4
Adodc2.Recordset.Fields("移入冷饮") = x
Case 5
Adodc2.Recordset.Fields("移入速冻") = x
Case 6
Adodc2.Recordset.Fields("移入其它") = x
Case 7
Adodc2.Recordset.Fields("移出冷饮") = x
Case 8
Adodc2.Recordset.Fields("移出速冻") = x
Case 9
Adodc2.Recordset.Fields("移出其它") = x
Case 10
Adodc2.Recordset.Fields("冷饮销售") = x
Case 11
Adodc2.Recordset.Fields("速冻销售") = x
Case 12
Adodc2.Recordset.Fields("其它销售") = x
End Select
End If
End If
Adodc2.Recordset.Update
Next
Adodc2.Recordset.Fields("期末冷饮库存") = Adodc2.Recordset.Fields("期初冷饮库存") + Adodc2.Recordset.Fields("冷饮入库") + Adodc2.Recordset.Fields("移入冷饮") - Adodc2.Recordset.Fields("移出冷饮") - Adodc2.Recordset.Fields("冷饮销售") - Adodc2.Recordset.Fields("冷饮其它出库")
Adodc2.Recordset.Fields("期末速冻库存") = Adodc2.Recordset.Fields("期初速冻库存") + Adodc2.Recordset.Fields("速冻入库") + Adodc2.Recordset.Fields("移入速冻") - Adodc2.Recordset.Fields("移出速冻") - Adodc2.Recordset.Fields("速冻销售") - Adodc2.Recordset.Fields("速冻其它出库")
Adodc2.Recordset.Fields("期末其它库存") = Adodc2.Recordset.Fields("期初其它库存") + Adodc2.Recordset.Fields("其它入库") + Adodc2.Recordset.Fields("移入其它") - Adodc2.Recordset.Fields("移出其它") - Adodc2.Recordset.Fields("其它销售") - Adodc2.Recordset.Fields("三类其它出库")
Adodc2.Recordset.Fields("合计期末总库存") = Adodc2.Recordset.Fields("期末冷饮库存") + Adodc2.Recordset.Fields("期末速冻库存") + Adodc2.Recordset.Fields("期末其它库存")
Adodc2.Recordset.MoveNext
Next
End If
Set db = OpenDatabase("d:\物流作业报表系统\物流仓库作业数据.mdb")
If Dir(App.Path & "\异动报表.xls") <> "" Then Kill App.Path & "\异动报表.xls"
db.Execute ("SELECT * INTO [Excel 8.0;DATABASE=" & App.Path & "\异动报表.xls].[Sheet1] FROM 异动报表")
ShellExecute Me.hwnd, "Open", "d:\物流作业报表系统\异动报表.xls", vbNullString, vbNullString, SW_SHOW
abc:
End Sub
Public Sub ExportExcelSheetToAccess(sSheetName As String, sExcelPath As String, sAccessTable As String, sAccessDBPath As String)
Set db = OpenDatabase(sExcelPath, False, False, "Excel 5.0")
Call db.Execute("Select * into [;database=" & sAccessDBPath & "]." & sAccessTable & " FROM [" & sSheetName & "$]")
MsgBox "表" & sExcelPath & "数据导入成功!", vbInformation, "数据导入"
db.Close
End Sub
Public Sub gsubConnectDBF(sSourceName As String)
Set gadoCN = New ADODB.Connection
gadoCN.ConnectionString = sSourceName
gadoCN.Open
End Sub
Public Function ExistsTable(TName As String) As Boolean
On Error Resume Next
Set db = OpenDatabase("d:\物流作业报表系统\物流仓库作业数据.mdb", False, False)
' 该名字在表名中是否存在。
If Err <> 3265 Then
ExistsTable = True
Err = 0
End If
db.Close
End Function
Private Sub Command2_Click(Index As Integer)
Select Case Index
Case 0
' On Error Resume Next
If FileSystemObject.FolderExists("d:\物流作业报表系统\历史数据") = True Then
GoTo abc
Else
MkDir "d:\物流作业报表系统\历史数据"
End If
abc:
Sleep (1500)
Label2(0).Caption = " 请稍等,系统正在数据存档..."
Me.Refresh
FileSystemObject.CopyFile "d:\物流作业报表系统\异动报表.xls", "d:\物流作业报表系统\历史数据\" & Text1.Text & ".xls"
Sleep (1500)
Label2(0).Caption = " 数据存档成功,请继续..."
Me.Refresh
Sleep (1500)
If Err.Number <> 0 Then
Err.Clear
MsgBox "存档失败,请重试!"
End If
Case 1
' On Error Resume Next
Sleep (1500)
Label2(1).Caption = " 请稍等,系统正在调用历史文档..."
Me.Refresh
' Text1.Text = File1(0).Filename
' FileSystemObject.CopyFile "d:\RFIDnew\RFIDBACKUP\" & File1(0).FileName, "d:\RFIDnew\KQ.mdb"
ShellExecute Me.hwnd, "Open", "d:\物流作业报表系统\" & File1(0).FileName, vbNullString, vbNullString, SW_SHOW
Sleep (1500)
Label2(1).Caption = " 文档调用成功,请继续..."
Me.Refresh
Sleep (1500)
If Err.Number <> 0 Then
Err.Clear
MsgBox "文档调用失败,请重试!"
End If
Case 2
On Error Resume Next
Sleep (1500)
Label2(2).Caption = " 请稍等,系统正在删除无效方档..."
Me.Refresh
' Text1.Text = File1(0).Filename
FileSystemObject.DeleteFile "d:\物流作业报表系统\历史数据\" & File1(1).FileName
Sleep (1500)
Label2(2).Caption = "系统删除文档成功,请继续..."
Me.Refresh
Sleep (1500)
If Err.Number <> 0 Then
Err.Clear
MsgBox "文档删除失败,请重试!"
End If
Case 3
Command2(3).Enabled = False
DataGrid1.Enabled = False
Command2(6).Enabled = True
Adodc6.CommandType = adCmdText
Adodc6.RecordSource = "Select * from 期初库存"
Adodc6.Refresh
Adodc6.Recordset.MoveFirst
For i = 1 To Adodc6.Recordset.RecordCount()
Adodc2.CommandType = adCmdText
Adodc2.RecordSource = "Select * from 异动报表 where 仓库='" & Adodc6.Recordset.Fields("仓库") & "'"
Adodc2.Refresh
Adodc2.Recordset.Fields("期初冷饮库存") = Adodc6.Recordset.Fields("期初冷饮库存")
Adodc2.Recordset.Fields("期初速冻库存") = Adodc6.Recordset.Fields("期初速冻库存")
Adodc2.Recordset.Fields("期初其它库存") = Adodc6.Recordset.Fields("期初其它库存")
Adodc2.Recordset.Update
Adodc6.Recordset.MoveNext
Next
MsgBox "保存成功!"
Case 4
Unload Me
Case 6
Command2(6).Enabled = False
DataGrid1.Enabled = False
Command2(3).Enabled = True
Case 5
On Error Resume Next
Command2(3).Enabled = False
DataGrid1.Enabled = False
Command2(6).Enabled = False
' Frmwlrep.subGetData strData, blnExt
Set db = OpenDatabase("d:\物流作业报表系统\物流仓库作业数据.mdb", False, False)
test1 = db.TableDefs("异动报表").Name
If test1 = "异动报表" Then
db.Execute ("DROP table 异动报表")
End If
db.Close
' ExportExcelSheetToAccess "sheet1", App.Path & "\历史数据\" & File2.FileName, "异动报表", App.Path & "\物流仓库作业数据.mdb"
If File2.Selected(File2.ListIndex) = True Then
ExportExcelSheetToAccess "sheet1", App.Path & "\历史数据\" & File2.FileName, "异动报表", App.Path & "\物流仓库作业数据.mdb"
Else
MsgBox "请选中数据源文件!"
GoTo abc1
End If
Set db = OpenDatabase("d:\物流作业报表系统\物流仓库作业数据.mdb")
db.Execute ("update 异动报表 set 期初冷饮库存=期末冷饮库存 ")
db.Execute ("update 异动报表 set 期初速冻库存=期末速冻库存 ")
db.Execute ("update 异动报表 set 期初其它库存=期末其它库存 ")
db.Close
abc1:
End Select
End Sub
Private Sub Dir1_Change(Index As Integer)
Select Case Index
Case 0
File1(0).Path = Dir1(0).Path
Case 1
File1(1).Path = Dir1(1).Path
End Select
End Sub
Private Sub Form_Load()
Text1.Text = "异动报表" & Format(Date, "yymmdd")
Adodc6.CommandType = adCmdText
Adodc6.RecordSource = "Select * from 期初库存"
Adodc6.Refresh
Set DataGrid1.DataSource = Adodc6.Recordset
DataGrid1.Refresh
DataGrid1.Columns(0).Width = 400
DataGrid1.Columns(1).Width = 1000
DataGrid1.Columns(2).Width = 1200
DataGrid1.Columns(3).Width = 1200
DataGrid1.Columns(4).Width = 1200
DataGrid1.Columns(5).Width = 1200
DataGrid1.Enabled = False
File2.Path = "d:\物流作业报表系统\历史数据\"
End Sub
Private Sub TabStrip1_Click()
Select Case TabStrip1.SelectedItem.Index
Case 1
Frame1(0).Visible = True
Frame1(1).Visible = False
Frame1(2).Visible = False
Frame1(3).Visible = False
Case 2
Frame1(1).Visible = True
Frame1(0).Visible = False
Frame1(2).Visible = False
Frame1(3).Visible = False
Case 3
Frame1(2).Visible = True
Frame1(1).Visible = False
Frame1(0).Visible = False
Frame1(3).Visible = False
Case 4
Frame1(3).Visible = True
Frame1(1).Visible = False
Frame1(0).Visible = False
Frame1(2).Visible = False
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -