#AutoIt3Wrapper_UseX64 = n
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <Excel.au3>
#include <Date.au3>
;~ FileInstall("Data.mdb", @WindowsDir & "\Data.mdb", 1)
Global $mdb_data_path = @ScriptDir & "\Data.mdb"
Global $mdb_data_pwd = ""
Global $Cahuanzx = "table1";"table1"
Global $Cahuanzy = "table2"
Global $Cahuanzz = "table3"
Global $Cahuanzu = "table4"
Global $Cahuanzv = "table5"
Dim $main
Dim $jccx
Dim $ldcx
Dim $clcx
Dim $xhps
Dim $jclength
Dim $oExcel
Dim $time
Dim $time1
Dim $time2
Dim $timearray1
Dim $timearray2
Dim $nMs
#Region ### START Koda GUI section ### Form=D:\我的文件\Documents\软著\交通运输工程大数据管理\Form2.kxf
Global $Form2 = GUICreate("交通运输工程大数据管理", 775, 677, 170, 138)
Global $MenuItem4 = GUICtrlCreateMenu("数据输出(&X)")
Global $MenuItem6 = GUICtrlCreateMenuItem("输出到Excel", $MenuItem4)
Global $MenuItem5 = GUICtrlCreateMenuItem("输出到Excel并打印", $MenuItem4)
Global $MenuItem1 = GUICtrlCreateMenu("数据处理(&Y)")
Global $MenuItem2 = GUICtrlCreateMenuItem("备份数据库", $MenuItem1)
Global $MenuItem7 = GUICtrlCreateMenu("退出(&Z)")
;~ GUICtrlCreateTab(40, 48, 660, 560)
Global $main = GUICtrlCreateTab(40, 48, 660, 560)
Global $TabSheet1 = GUICtrlCreateTabItem("交叉口查询")
Global $Group2 = GUICtrlCreateGroup("交叉口查询", 56, 136, 633, 89)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
Global $Input2 = GUICtrlCreateInput("", 240, 168, 329, 23)
Global $Button2 = GUICtrlCreateButton("查询", 592, 168, 75, 25)
Global $Label1 = GUICtrlCreateLabel("请输入交叉口名称", 96, 168, 132, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group3 = GUICtrlCreateGroup("查询结果", 56, 280, 625, 273)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
Global $ListView1 = GUICtrlCreateListView("交叉口名称|道路等级|相位", 96, 312, 553, 201, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 200)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 1, 2)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 2, 2)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $TabSheet2 = GUICtrlCreateTabItem("路段查询")
Global $Group5 = GUICtrlCreateGroup("路段查询", 54, 88, 633, 89)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
Global $Button4 = GUICtrlCreateButton("查询", 590, 120, 75, 25)
Global $Label3 = GUICtrlCreateLabel("请输入路段名称", 94, 120, 116, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
Global $Input4 = GUICtrlCreateInput("Input4", 240, 120, 337, 23)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $ListView4 = GUICtrlCreateListView("路段名称|车道数|道路交通量", 72, 200, 601, 401, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 200)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 200)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
Global $TabSheet3 = GUICtrlCreateTabItem("车辆查询")
Global $Group7 = GUICtrlCreateGroup("车辆查询", 46, 100, 633, 89)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
Global $Button1 = GUICtrlCreateButton("查询", 582, 132, 75, 25)
Global $Label7 = GUICtrlCreateLabel("请输入交叉口名称", 86, 132, 132, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
Global $Input6 = GUICtrlCreateInput("Input6", 232, 128, 337, 23)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $ListView2 = GUICtrlCreateListView("交叉口名称|进口1|进口2|进口3|进口4", 48, 200, 633, 385, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 150)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
Global $TabSheet4 = GUICtrlCreateTabItem("信号配时查询")
Global $Group4 = GUICtrlCreateGroup("交叉口查询", 61, 100, 633, 89)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
Global $Button3 = GUICtrlCreateButton("查询", 605, 124, 75, 25)
Global $Label2 = GUICtrlCreateLabel("请输入交叉口名称", 101, 132, 132, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
Global $Input3 = GUICtrlCreateInput("Input3", 248, 128, 337, 23)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $ListView5 = GUICtrlCreateListView("交叉口名称|绿灯时长|黄灯时长|红灯时长|周期", 64, 208, 625, 401, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 150)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
Global $TabSheet5 = GUICtrlCreateTabItem("交叉口排队长度查询")
Global $Group6 = GUICtrlCreateGroup("交叉口查询", 61, 88, 633, 89)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
Global $Button5 = GUICtrlCreateButton("查询", 605, 120, 75, 25)
Global $Label4 = GUICtrlCreateLabel("请输入交叉口名称", 101, 120, 132, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
Global $Input5 = GUICtrlCreateInput("Input5", 240, 120, 353, 23)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $ListView3 = GUICtrlCreateListView("交叉口名称|排队长度|延误时长", 56, 184, 633, 417, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 240)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 200)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlCreateTabItem("")
Global $Group1 = GUICtrlCreateGroup("浏览", 96, 0, 569, 49)
Global $Label5 = GUICtrlCreateLabel("当前数据库", 112, 16, 84, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
Global $Input1 = GUICtrlCreateInput($mdb_data_path, 200, 16, 249, 21)
Global $Button6 = GUICtrlCreateButton("请选择数据库", 464, 16, 177, 25)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
ex()
Case $MenuItem7
ex()
Case $MenuItem2
backup()
Case $MenuItem6
print()
Case $MenuItem5
print()
Send("^p")
Case $Button6
choose_data()
Case $Button2
Global $am = GUICtrlRead($Input2)
jccx()
Case $Button4
ldcx()
Case $Button1
clcx()
Case $Button3
xhps()
Case $Button5
jclength()
EndSwitch
WEnd
Func choose_data()
$datadir = FileOpenDialog("请选择数据库文件", @ScriptDir & "\", "ACCESS数据库文件(*.mdb)", 3);@WindowsDir &
If Not FileExists($mdb_data_path) Or StringRight($datadir, 3) <> "mdb" Then
MsgBox(64, "提示", "所选择的文件错误,请重新选择.后缀名需为(.mdb)")
$mdb_data_path = "database\交通.mdb"
GUICtrlSetData($Input1, $datadir)
EndIf
GUICtrlSetData($Input1, $datadir)
EndFunc ;==>choose_data
Func print()
Switch GUICtrlRead($main)
Case 1
$listview = $ListView1
Case 2
$listview = $ListView2
Case 3
$listview = $ListView3
Case 4
$listview = $ListView4
Case Else
$listview = $ListView5
EndSwitch
$excnum = _GUICtrlListView_GetItemCount($listview)
If $excnum = 0 Then
MsgBox(64, "提示", "没有记录可被输出.")
Else
;Local $oExcel = _ExcelBookNew(1)
For $y = 0 To $excnum
$excret = _GUICtrlListView_GetItemTextString($listview, $y)
$excarray = StringSplit($excret, "|")
For $x = 0 To $excarray[0]
;_ExcelWriteCell($oExcel, $excarray[$x], $y + 2, $x)
Next
Next
EndIf
EndFunc ;==>print
Func jccx()
$am = GUICtrlRead($Input2)
GUICtrlSendMsg($ListView1, $LVM_DELETEALLITEMS, 0, 0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select * From " & $Cahuanzx & " WHERE AA1='" & $am & "'")
While (Not $RS.eof And Not $RS.bof)
If @error = 1 Then ExitLoop
GUICtrlCreateListViewItem($RS.Fields(0).value & "|" & $RS.Fields(1).value & "|" & $RS.Fields(2).value, $ListView1)
$RS.movenext
WEnd
$RS.close
$addfld.Close
EndFunc ;==>jccx
Func ldcx()
$am = GUICtrlRead($Input4)
GUICtrlSendMsg($ListView4, $LVM_DELETEALLITEMS, 0, 0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select * From " & $Cahuanzx & " WHERE AA1='" & $am & "'")
;$RS.Open("Select * From " & $Cahuanzy & " WHERE section ='" & $Input4 & "'")
While (Not $RS.eof And Not $RS.bof)
If @error = 1 Then ExitLoop
GUICtrlCreateListViewItem($RS.Fields(0).value & "|" & $RS.Fields(1).value & "|" & $RS.Fields(2).value, $ListView4)
$RS.movenext
WEnd
$RS.close
$addfld.Close
EndFunc ;==>ldcx
Func clcx()
$am = GUICtrlRead($Input6)
GUICtrlSendMsg($ListView2, $LVM_DELETEALLITEMS, 0, 0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select * From " & $Cahuanzx & " WHERE AA1='" & $am & "'")
;$RS.Open("Select * From " & $Cahuanzz & " WHERE name ='" & $Input6 & "'")
While (Not $RS.eof And Not $RS.bof)
If @error = 1 Then ExitLoop
GUICtrlCreateListViewItem($RS.Fields(0).value & "|" & $RS.Fields(1).value & "|" & $RS.Fields(2).value, $ListView2)
$RS.movenext
WEnd
$RS.close
$addfld.Close
EndFunc ;==>clcx
Func xhps()
$am = GUICtrlRead($Input3)
GUICtrlSendMsg($ListView5, $LVM_DELETEALLITEMS, 0, 0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select * From " & $Cahuanzx & " WHERE AA1='" & $am & "'")
;$RS.Open("Select * From " & $Cahuanzu & " WHERE name ='" & $Input3 & "'")
While (Not $RS.eof And Not $RS.bof)
If @error = 1 Then ExitLoop
GUICtrlCreateListViewItem($RS.Fields(0).value & "|" & $RS.Fields(1).value & "|" & $RS.Fields(2).value, $ListView5)
$RS.movenext
WEnd
$RS.close
$addfld.Close
EndFunc ;==>xhps
Func jclength()
$am = GUICtrlRead($Input5)
GUICtrlSendMsg($ListView3, $LVM_DELETEALLITEMS, 0, 0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select * From " & $Cahuanzx & " WHERE AA1='" & $am & "'")
;$RS.Open("Select * From " & $Cahuanzv & " WHERE name ='" & $Input5 & "'")
While (Not $RS.eof And Not $RS.bof)
If @error = 1 Then ExitLoop
GUICtrlCreateListViewItem($RS.Fields(0).value & "|" & $RS.Fields(1).value & "|" & $RS.Fields(2).value, $ListView3)
$RS.movenext
WEnd
$RS.close
$addfld.Close
EndFunc ;==>jclength
Func ex()
$answer = MsgBox(1, "提示", "确定要退出本程序吗?")
If $answer = 1 Then
;FileDelete($mdb_data_path)
Exit
Else
EndIf
EndFunc ;==>ex
|