#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Icon=uninst.exe
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Process.au3>
#include <ListViewConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("数据库操作例子", 633, 454, 193, 115)
$ListView1 = GUICtrlCreateListView(" 机器号 | 上机时间 | 押金 | 上机费用 | 应找 |下机时间 ", 8, 24, 617, 361)
$Button0 = GUICtrlCreateButton("创建数据库", 20, 408, 97, 25, 0)
$Button1 = GUICtrlCreateButton("写入1000条数据", 130, 408, 130, 25, 0)
$Button2 = GUICtrlCreateButton("更新数据", 400, 408, 97, 25, 0)
$Button3 = GUICtrlCreateButton("删除数据",510, 408, 113, 25, 0);280, 408, 113, 25, 0)
$Button4 = GUICtrlCreateButton("读取数据", 280, 408, 113, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $mdb_data_path = IniRead("config.ini", "mdb", "lujing", "");数据库文件名
Global $mdb_data_pwd="XXX" ;密码
Global $tablename="XXX"
Global $FindData=""
Global $jiqihao
Global $mdb_new_path="fxcs.mdb"
Global $tbname="fxcs"
Global $path = @ScriptDir
Global $all="*"
Global $var
Global $class="#32770"
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button0
data($mdb_new_path, $tbname)
Case $Button1;写入
sx()
du()
Case $Button2 ;更新
up()
du()
Case $Button3 ;删除
del()
du()
Case $Button4 ;读取
du()
EndSwitch
WEnd
Func sx() ;读取备注对应的机器号列表
$conn = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$conn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&$mdb_data_path&";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS.ActiveConnection = $conn
$RS.Open ("Select "&$all&" From "&$tablename&" Where Note<>'"&$FindData&"'" )
while Not $RS.eof And Not $RS.bof
If @error =1 Then ExitLoop
$PcName1 = $Rs.Fields(2).value
$time1 = $Rs.Fields(16).value
$yj1 = $Rs.Fields(12).value
$fy = $Rs.Fields(19).value
$fy1 = Round($fy, 0)
$yz1 = Number($yj1-$fy1)
$xjsj = @YEAR&"年"&@MON&"月"&@MDAY&"日"&@HOUR&"点"&@MIN&"分"
$rs.movenext
WEnd
$rs.close
$conn.Close
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_new_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$addfld.Execute("insert into fxcs (PcName,sjtime,yj,fy,yz,xjsj) values('"&$PcName1&"','"&$time1&"','"&$yj1&"','"&$fy1&"','"&$yz1&"','"&$xjsj&"')")
$addfld.close
EndFunc
Func data($mdb_new_path, $tbname)
if not FileExists($mdb_new_path) Then
$newMdb = ObjCreate("ADOX.Catalog")
$newMdb.Create("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_new_path)
$newmdb.ActiveConnection.Close;建数据库
$addtbl = ObjCreate("ADODB.Connection")
$addTbl.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_new_path)
$addTbl.Execute("CREATE TABLE " & $tbname)
$addtbl.Close;建表
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_new_path)
$addfld.Execute("ALTER TABLE " & $tbname & " ADD PcName char,sjtime int,yj int,fy int ,yz int ,xjsj char");建立6个表 分别为 计算机名 上机时间 押金 上机费用 应找金额 下机时间
$addfld.Close;建列表名
MsgBox(64,"提示","建立数据库成功",5)
Else
MsgBox(64,"提示","你已经建立了一个数据库了",5)
EndIf
EndFunc