#include <Constants.au3>
#Include <Date.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
#NoTrayIcon
Opt("TrayAutoPause",0) ;0=不暂停, 1=暂停
Opt("GUIOneventMode",1);应用OnEvent函数于系统托盘图标
Opt("TrayMenuMode", 3) ;没有默认的(暂停脚本和退出)菜单.
Opt("trayOnEventMode", 1)
HotKeySet("+!X","_ext")
HotKeySet("+!S","_show")
$g_szVersion = "wbhyglxt"
If WinExists($g_szVersion) Then
Send("+!S",0);MsgBox(16, "温馨提示", "貌似程序已运行^V^",3)
Exit
EndIf
AutoItWinSetTitle($g_szVersion)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
Local $tp[5],$adoProvider
Global $ErrorCount=1 ;密码错误次数
$mdb_data_path=@ScriptDir&"\NetbarDate.mdb" ;数据库文件名
$mdb_data_pwd="123" ;密码
$T="*"
$tblname="datelist"
$Numtoinsert=1
#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\桌面\网吧会员备案系统access\备案系统.kxf
$Form1 = GUICreate("网吧会员管理系统 Shift+Alt+X退出 Shift+Alt+S显示 ESC最小化", 1081, 641)
GUISetOnEvent($GUI_EVENT_CLOSE, "_minx")
GUISetIcon(@ScriptDir & "\ico.ico")
$Group1 = GUICtrlCreateGroup("", 8, 0, 1065, 529)
$ListView1 = GUICtrlCreateListView("会员编号|会员姓名|zj种类|zj号码|年龄|入会时间|会员卡号|zj数据", 16, 16, 626, 457)
_GUICtrlListView_SetExtendedListViewStyle ($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 60)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 60)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 60)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 120)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 40)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 5, 60)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 6, 60)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 7, 148)
$Pic1 = GUICtrlCreatePic(@ScriptDir&"\510722198510163057.jpg", 647, 16, 417, 228)
GUICtrlSetTip(-1,"单击打开图片","",1)
GUICtrlSetCursor (-1, 0)
GUICtrlCreateLabel("查询内容:", 648, 264, 64, 17)
$Input1 = GUICtrlCreateInput("", 713, 260, 121, 21)
GUICtrlCreateLabel("查询条件:", 847, 262, 64, 17)
$Combo1 = GUICtrlCreateCombo("", 920, 260, 145, 25,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1,"会员编号|zj号码|会员卡号","会员编号")
$Button1 = GUICtrlCreateButton("查询", 649, 289, 419, 21, $BS_FLAT)
GUICtrlSetCursor (-1, 0)
GUICtrlCreateLabel("会员姓名:", 648, 324, 64, 17)
$Input2 = GUICtrlCreateInput("", 712, 320, 121, 21)
GUICtrlCreateLabel("zj种类:", 848, 324, 64, 17)
$Combo2 = GUICtrlCreateCombo("", 920, 320, 145, 25,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1,"sfz|xsz|jgz","sfz")
GUICtrlSetState (-1, $GUI_DISABLE )
GUICtrlCreateLabel("zj号码:", 648, 356, 64, 17)
$Input3 = GUICtrlCreateInput("", 712, 352, 121, 21)
GUICtrlCreateLabel("会员年龄:", 848, 356, 64, 17)
$Input4 = GUICtrlCreateInput("", 920, 352, 145, 21)
GUICtrlSetState (-1, $GUI_DISABLE )
GUICtrlCreateLabel("入会时间:", 648, 388, 64, 17)
$date = GUICtrlCreateDate("", 712, 384, 121, 21)
GUICtrlSetState (-1, $GUI_DISABLE )
GUICtrlCreateLabel("会员卡号:", 848, 388, 64, 17)
$Input5 = GUICtrlCreateInput("", 920, 384, 145, 21)
GUICtrlCreateLabel("zj照片:", 648, 420, 64, 17)
$Input6 = GUICtrlCreateInput("", 712, 416, 209, 21)
GUICtrlSetState (-1, $GUI_DISABLE )
$Button2 = GUICtrlCreateButton("浏览", 935, 416, 130, 21, $BS_FLAT)
GUICtrlSetCursor (-1, 0)
$Button3 = GUICtrlCreateButton("写入数据", 643, 447, 130, 29, $BS_FLAT)
GUICtrlSetCursor (-1, 0)
$Button4 = GUICtrlCreateButton("更新数据", 793, 447, 130, 29, $BS_FLAT)
GUICtrlSetCursor (-1, 0)
$Button5 = GUICtrlCreateButton("删除数据", 935, 447, 130, 29, $BS_FLAT)
GUICtrlSetState (-1, $GUI_DISABLE )
GUICtrlSetCursor (-1, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 16, 480, 1049, 41)
$Label = GUICtrlCreateLabel("准备就绪……", 24, 496, 1036, 17, $SS_CENTER)
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ListView2 = GUICtrlCreateListView("会员编号|会员姓名|zj种类|证件号码|年龄|入会时间|会员卡号|zj数据", 8, 528, 1066, 86)
_GUICtrlListView_SetExtendedListViewStyle ($ListView2, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 60)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 60)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 60)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 120)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 40)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 5, 60)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 6, 60)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 7, 148)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
Dim $StatusBar1_PartsWidth[4] = [120, 260, 420, -1]
_GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth)
_GUICtrlStatusBar_SetText($StatusBar1, " 网吧会员管理系统", 0)
_GUICtrlStatusBar_SetText($StatusBar1, "", 1)
_GUICtrlStatusBar_SetText($StatusBar1, "", 2)
_GUICtrlStatusBar_SetText($StatusBar1, "", 3)
;====
$tp[1] = TrayCreateItem("显示菜单");, $tp[1])
TrayItemSetOnEvent($tp[1], "TrayMsg") ;注册第一个菜单项的事件(被点下)
$tp[2] = TrayCreateItem("隐藏菜单");, $tp[1])
TrayItemSetOnEvent($tp[2], "TrayMsg") ;注册第一个菜单项的事件(被点下)
$tp[3] = TrayCreateItem("关于程序")
TrayItemSetOnEvent($tp[3], "TrayMsg") ;注册第一个菜单项的事件(被点下)
TrayCreateItem("")
$tp[4] = TrayCreateItem("退出程序")
TrayItemSetOnEvent($tp[4], "TrayMsg") ;注册第一个菜单项的事件(被点下)
TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE,"_show")
TraySetIcon(@ScriptDir&"\ico.ico", -1)
TraySetState()
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUICtrlSetOnEvent($Button1,"GUICtrlMsg")
GUICtrlSetOnEvent($Button2,"GUICtrlMsg")
GUICtrlSetOnEvent($Button3,"GUICtrlMsg")
GUICtrlSetOnEvent($Button4,"GUICtrlMsg")
GUICtrlSetOnEvent($Button5,"GUICtrlMsg")
GUICtrlSetOnEvent($Pic1,"GUICtrlMsg")
AdlibRegister("timexiugai")
If Not FileExists($mdb_data_path) Then
_CreateData($mdb_data_path,$mdb_data_pwd,$tblname)
Else
_ReadDate($mdb_data_path,$mdb_data_pwd,$tblname,$T,$ListView1)
EndIf
While 1
Sleep(10)
WEnd
Func GUICtrlMsg()
Switch @GUI_CtrlId;选择事件 ID 或 控件 ID
Case $GUI_EVENT_CLOSE;如果点下的是$GUI_EVENT_CLOSE(关闭)
GUISetState(@SW_HIDE,@GUI_WinHandle); 隐藏产生事件的窗口
Case $Pic1
If GUICtrlRead($input6)<>"" Then
If FileExists(@ScriptDir&"\Images"&GUICtrlRead($input6)) Then
ShellExecute(@ScriptDir&"\Images"&GUICtrlRead($input6)) ;GUICtrlSetImage ($Pic1, GUICtrlRead($Input6))
Else
GUICtrlSetData($Label,"当前用户照片不存在,请检查!")
EndIf
EndIf
Case $Button1
$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
;SELECT 列名称 FROM 表名称 根据列名称查找,列名称可多个,用‘,’分割
;SELECT * FROM 表名称 查找所有
$RS.Open ("Select "&"1" & " From " & $tblname )
while Not $RS.eof And Not $RS.bof
; if @error =1 Then ExitLoop
; $account=$RS.Fields ("0").value
;MsgBox(0,"d",$account & $RS.Fields ("1").value); GUICtrlCreateListViewItem ( $RS.Fields (0).value&"|"& $RS.Fields (1).value&"|"& $RS.Fields (2).value&"|"& $RS.Fields (3).value&"|"& $RS.Fields (4).value&"|"& $RS.Fields (5).value&"|"& $RS.Fields (6).value&"|"& $RS.Fields (7).value,$List )
MsgBox(0, "", $RS.Fields (1).value);显示表第一个数据
$rs.movenext
WEnd
$rs.close
$addfld.Close
;===============
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&$mdb_data_path&";Jet OLEDB:Database Password=qinghong")
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$table="datelist"
$js=3
$RS.Open ("Select * From " & $table & "'where id" & $js)
$account=$RS.Fields ("1").value
MsgBox(0,"d",$account & $RS.Fields ("1").value)
Case $Button2
$Image = FileOpenDialog("选取身份证复印件", @ScriptDir & "", "(*.jpg;*.bmp)", 1 + 2);@DesktopDir
If $Image <> "" Then
GUICtrlSetData($Input6,$Image)
GUICtrlSetImage ($Pic1, GUICtrlRead($Input6))
EndIf
Case $Button3;写入
_InsertDate($mdb_data_path,$mdb_data_pwd,$tblname,$Numtoinsert,GUICtrlRead($Input2),GUICtrlRead($Combo2),GUICtrlRead($Input3),GUICtrlRead($Input4),GUICtrlRead($date),GUICtrlRead($Input5),GUICtrlRead($Input3)&".jpg")
_ReadDate($mdb_data_path,$mdb_data_pwd,$tblname,$T,$ListView1)
$hyhm=GUICtrlRead($Input3)
$hysj=GUICtrlRead($Input6)
$cb=FileCopy($hysj,@ScriptDir&"\Images"&$hyhm&".jpg",9)
GUICtrlSetData($Label,"添加成功")
Case $Button4;更新
_UpDate($mdb_data_path,$mdb_data_pwd,$tblname,$ListView1,GUICtrlRead($Input2),GUICtrlRead($Combo2),GUICtrlRead($Input3),GUICtrlRead($Input4),GUICtrlRead($date),GUICtrlRead($Input5),GUICtrlRead($Input3)&".jpg")
$hyhm=GUICtrlRead($Input3)
$hysj=GUICtrlRead($Input6)
$cb=FileCopy($hysj,@ScriptDir&"\Images"&$hyhm&".jpg",9)
_ReadDate($mdb_data_path,$mdb_data_pwd,$tblname,$T,$ListView1)
Case $Button5 ;删除
_DeleteDate($mdb_data_path,$mdb_data_pwd,$tblname,$ListView1)
_ReadDate($mdb_data_path,$mdb_data_pwd,$tblname,$T,$ListView1)
EndSwitch
EndFunc
Func TrayMsg() ;消息执行函数
Switch @TRAY_ID ;选择产生消息的 TrayItem 或其它特殊事件(鼠标左键双击事件)
Case $tp[1]
TraySetState(8)
_show()
Case $tp[2]
GUISetState(@SW_HIDE,$Form1)
Case $tp[3]
MsgBox(48,"关于程序","网吧会员备案系统"&@CRLF&@CRLF&"BY-Jycel QQ:472891322",5)
Case $tp[4]
$queding=MsgBox(32+4,"关闭提示","是否关闭程序?")
if $queding="7" Then
_minx()
Elseif $queding="6" Then
_ext()
EndIf
EndSwitch
EndFunc ;==>TrayMsg
Func _minx()
TraySetToolTip("网吧会员备案系统")
TrayTip("提醒您!", "程序已最小化"&@CRLF&"单击此处进行相关操作", 30, 1)
GUISetState(@SW_HIDE,$Form1)
EndFunc
Func _show() ;显示程序
GUISetState(@SW_SHOW,$Form1)
EndFunc
Func _ext()
Exit
EndFunc
Func WM_NOTIFY($hWndGUI, $MsgID, $WParam, $LParam)
Dim $lyListView1
Local $tagNMHDR, $Event, $hWndFrom, $IDFrom
Local $tagNMHDR = DllStructCreate("int;int;int", $LParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
If @error Then Return $GUI_RUNDEFMSG
$IDFrom = DllStructGetData($tagNMHDR, 2)
$Event = DllStructGetData($tagNMHDR, 3)
$tagNMHDR = 0
;=============
$tNMHDR = DllStructCreate($tagNMHDR, $LParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
;=============
Switch $IDFrom;选择产生事件的控件
Case $ListView1
Switch $Event; 选择产生的事件
Case $NM_CLICK ; 左击
$Index = _GUICtrlListView_GetSelectedIndices($ListView1)
If Not StringLen($Index) Then; 这里用以判断是否选定了ListViewItem
;GUICtrlSetState($Button9,$GUI_ENABLE)
GUICtrlSetState ($Button2, $GUI_DISABLE)
GUICtrlSetData($Input2,"")
GUICtrlSetData($Input3,"")
GUICtrlSetData($Input4,"")
GUICtrlSetData($Input5,"")
GUICtrlSetData($Input6,"")
GUICtrlSetImage ($Pic1, @ScriptDir&"\log.jpg")
GUICtrlSetData($Label,"")
Return
Else
GUICtrlSetData($Input2,_GUICtrlListView_GetItemText($ListView1, Number($Index),1))
GUICtrlSetData($Combo2,_GUICtrlListView_GetItemText($ListView1, Number($Index),2))
GUICtrlSetData($Input3,_GUICtrlListView_GetItemText($ListView1, Number($Index),3))
GUICtrlSetData($Input4,_GUICtrlListView_GetItemText($ListView1, Number($Index),4))
GUICtrlSetData($date,_GUICtrlListView_GetItemText($ListView1, Number($Index),5))
GUICtrlSetData($Input5,_GUICtrlListView_GetItemText($ListView1, Number($Index),6))
GUICtrlSetData($Input6,_GUICtrlListView_GetItemText($ListView1, Number($Index),7))
If GUICtrlRead($input6)<>"" Then
GUICtrlSetImage ($Pic1, @ScriptDir&"\Images"&GUICtrlRead($Input3)&".jpg")
EndIf
GUICtrlSetState ($Button2, $GUI_ENABLE )
EndIf
Case $NM_DBLCLK ; 双击
Case $NM_RCLICK ; 右击
Case $LVN_KEYDOWN
$tInfo = DllStructCreate($tagNMLVKEYDOWN, $LParam);$ilParam)
$psx=DllStructGetData($tInfo, "VKey")
If $psx="38" Then;向上
$Index = _GUICtrlListView_GetSelectedIndices($ListView1)
If Not StringLen($Index) Then; 这里用以判断是否选定了ListViewItem
;GUICtrlSetState($Button9,$GUI_ENABLE)
GUICtrlSetState ($Button2, $GUI_DISABLE)
GUICtrlSetData($Input2,"")
GUICtrlSetData($Input3,"")
GUICtrlSetData($Input4,"")
GUICtrlSetData($Input5,"")
GUICtrlSetData($Input6,"")
GUICtrlSetImage ($Pic1, @ScriptDir&"\log.jpg")
Return
Else
If Number(_GUICtrlListView_GetSelectedIndices($ListView1)) <> 0 Then
GUICtrlSetData($Input2,_GUICtrlListView_GetItemText($ListView1, Number($Index)-1,1))
GUICtrlSetData($Combo2,_GUICtrlListView_GetItemText($ListView1, Number($Index)-1,2))
GUICtrlSetData($Input3,_GUICtrlListView_GetItemText($ListView1, Number($Index)-1,3))
GUICtrlSetData($Input4,_GUICtrlListView_GetItemText($ListView1, Number($Index)-1,4))
GUICtrlSetData($date,_GUICtrlListView_GetItemText($ListView1, Number($Index)-1,5))
GUICtrlSetData($Input5,_GUICtrlListView_GetItemText($ListView1, Number($Index)-1,6))
GUICtrlSetData($Input6,_GUICtrlListView_GetItemText($ListView1, Number($Index)-1,7))
If GUICtrlRead($input6)<>"" Then
GUICtrlSetImage ($Pic1, @ScriptDir&"\Images"&GUICtrlRead($Input3)&".jpg")
EndIf
GUICtrlSetState ($Button2, $GUI_ENABLE )
EndIf
EndIf
ElseIf $psx="40" Then;向下
$Index = _GUICtrlListView_GetSelectedIndices($ListView1)
If Not StringLen($Index) Then; 这里用以判断是否选定了ListViewItem
;GUICtrlSetState($Button9,$GUI_ENABLE)
GUICtrlSetState ($Button2, $GUI_DISABLE)
GUICtrlSetData($Input2,"")
GUICtrlSetData($Input3,"")
GUICtrlSetData($Input4,"")
GUICtrlSetData($Input5,"")
GUICtrlSetData($Input6,"")
GUICtrlSetImage ($Pic1, @ScriptDir&"\log.jpg")
Return
Else
If Number(_GUICtrlListView_GetSelectedIndices($ListView1)) <> Number(_GUICtrlListView_GetItemCount($ListView1)) - 1 Then
GUICtrlSetData($Input2,_GUICtrlListView_GetItemText($ListView1, Number($Index)+1,1))
GUICtrlSetData($Combo2,_GUICtrlListView_GetItemText($ListView1, Number($Index)+1,2))
GUICtrlSetData($Input3,_GUICtrlListView_GetItemText($ListView1, Number($Index)+1,3))
GUICtrlSetData($Input4,_GUICtrlListView_GetItemText($ListView1, Number($Index)+1,4))
GUICtrlSetData($date,_GUICtrlListView_GetItemText($ListView1, Number($Index)+1,5))
GUICtrlSetData($Input5,_GUICtrlListView_GetItemText($ListView1, Number($Index)+1,6))
GUICtrlSetData($Input6,_GUICtrlListView_GetItemText($ListView1, Number($Index)+1,7))
If GUICtrlRead($input6)<>"" Then
GUICtrlSetImage ($Pic1, @ScriptDir&"\Images"&GUICtrlRead($Input3)&".jpg")
EndIf
GUICtrlSetState ($Button2, $GUI_ENABLE )
EndIf
EndIf
EndIf
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func timexiugai()
If @WDAY=1 Then
$xinqi="日"
ElseIf @WDAY=2 Then
$xinqi="一"
ElseIf @WDAY=3 Then
$xinqi="二"
ElseIf @WDAY=4 Then
$xinqi="三"
ElseIf @WDAY=5 Then
$xinqi="四"
ElseIf @WDAY=6 Then
$xinqi="五"
ElseIf @WDAY=7 Then
$xinqi="六"
EndIf
$ylfj=StringLen(GUICtrlRead($input3))
If $ylfj=18 Then
$yan=StringMid (GUICtrlRead($input3), 7,4 )
$yue=StringMid (GUICtrlRead($input3), 11,2 )
$ri=StringMid (GUICtrlRead($input3), 13,2 )
$shuis=_DateDiff( 'd',$yan&"-"&$yue&"-"&$ri,_NowDate())/365
GUICtrlSetData($Input4,Int($shuis))
If Int($shuis)<18 Then
$cb=_DateDiff( 'd',_NowDate(),_DateAdd( 'd',6570, $yan&"-"&$yue&"-"&$ri))
If $cb>365 Then
GUICtrlSetData($Label,"警告!本身份证未满18岁!请立即请离网吧!"&_DateAdd( 'd',6570, $yan&"-"&$yue&"-"&$ri)&"满18岁 还有["&$cb&"]天 约["&Int($cb/365)&"]年")
Else
GUICtrlSetData($Label,"警告!本身份证未满18岁!请立即请离网吧!"&_DateAdd( 'd',6570, $yan&"-"&$yue&"-"&$ri)&"满18岁 还有["&$cb&"]天")
EndIf
Else
;GUICtrlSetData($Label,"")
EndIf
EndIf
_GUICtrlStatusBar_SetText($StatusBar1, _Now()&" 星期"&$xinqi, 2)
TraySetToolTip("网吧会员备案系统"&@CRLF&"当前时间:"&_Now()&@CRLF&"")
EndFunc
Func _ReadDate($mdbdatapath,$mdbdatapwd,$TableName,$chaxuntiaojian,$List) ;读取函数
if FileExists($mdbdatapath) Then
_GUICtrlListView_DeleteAllItems($List)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &$mdbdatapath& ";Jet Oledb:Database Password=" & $mdbdatapwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
;SELECT 列名称 FROM 表名称 根据列名称查找,列名称可多个,用‘,’分割
;SELECT * FROM 表名称 查找所有
$RS.Open ("Select "&$chaxuntiaojian & " From " & $TableName )
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&"|"& $RS.Fields (3).value&"|"& $RS.Fields (4).value&"|"& $RS.Fields (5).value&"|"& $RS.Fields (6).value&"|"& $RS.Fields (7).value,$List )
;MsgBox(0, "", $RS.Fields (1).value);显示表第一个数据
$rs.movenext
WEnd
$rs.close
$addfld.Close
Else
GUICtrlSetData($Label,"1你还没有创建数据库");MsgBox(64,"错误!","你还没有创建数据库!",5)
EndIf
EndFunc
Func _DeleteDate($mdbdatapath,$mdbdatapwd,$TableName,$List) ;删除
if FileExists($mdbdatapath) Then
Local $ISOKDO
;从列表中读取选中行的数据
$Strn=GUICtrlRead(GUICtrlRead($List))
;用“|”分割读出的数据 目的是为了分离出选中行是第几行
$Strnspin=StringSplit($Strn,"|")
;创建OLEDB数据库链接
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &$mdbdatapath& ";Jet Oledb:Database Password=" & $mdbdatapwd)
;delete from 表名 in 数据库文件名 where id = 'ID' 删除指定ID
;delete from 表名 where id = 'ID'
;delete from 表名 删除全部
If $Strnspin[1]=0 Then
$sQuery ="DELETE FROM " & $TableName
Else
$sQuery ="DELETE FROM " & $TableName & " WHERE id" & " = " & $Strnspin[1]
EndIf
$ISOKDO=MsgBox(36,"确认删除吗?","是否删除本条数据?请慎重操作!") ;确认操作
If $ISOKDO = 6 Then
$addfld.execute($sQuery)
$addfld.close
GUICtrlSetData($Label,$Strnspin[1]&"删除成功!!!");MsgBox(64, "提示:",$Strnspin[1]&@CRLF&"删除成功!!!")
Else
$addfld.close
EndIf
Else
GUICtrlSetData($Label,"你还没有创建数据库");MsgBox(64,"错误!","你还没有创建数据库!",5)
EndIf
EndFunc
Func _UpDate($mdbdatapath,$mdbdatapwd,$TableName,$List,$Newdatea,$Newdateb,$Newdatec,$Newdated,$Newdatee,$Newdatef,$Newdateg) ;更新
if FileExists($mdbdatapath) Then
;从列表中读取选中行的数据
$Strn=GUICtrlRead(GUICtrlRead($List))
;用“|”分割读出的数据 目的是为了分离出选中行是第几行
$Strnspin=StringSplit($Strn,"|")
;创建OLEDB数据库链接
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &$mdbdatapath& ";Jet Oledb:Database Password=" & $mdbdatapwd)
;UPDATE 表名称 SET 列名称1 = 新值1,列名称2 = 新值2,... WHERE 列名称 = 某值
$sQuery ="update " & $TableName & " set datea='"&$Newdatea&"',dateb='"&$Newdateb&"',datec='"&$Newdatec&"',dated='"&$Newdated&"',datee='"&$Newdatee&"',datef='"&$Newdatef&"',dateg='"&$Newdateg&"' WHERE id" & " = " & $Strnspin[1]
; MsgBox(0,"",$sQuery)
;执行语句
$addfld.execute($sQuery)
$addfld.close
GUICtrlSetData($Label,$Strnspin[1]&"更新成功!!!");MsgBox(4096, "提示:",$Strnspin[1]&" 更新成功!!!")
Else
GUICtrlSetData($Label,"你还没有创建数据库");MsgBox(64,"错误!","你还没有创建数据库!",5)
EndIf
EndFunc
Func _InsertDate($mdbdatapath,$mdbdatapwd,$TableName,$NumToInst,$datea,$dateb,$datec,$dated,$datee,$datef,$dateg) ;写入数据
if FileExists($mdbdatapath) Then
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdbdatapath & ";Jet Oledb:Database Password=" & $mdbdatapwd)
$addfld.Execute("insert into " & $TableName & " (datea,dateb,datec,dated,datee,datef,dateg) values('"&$datea&"','"&$dateb&"','"&$datec&"','"&$dated&"','"&$datee&"','"&$datef&"','"&$dateg&"')")
$addfld.close
Else
GUICtrlSetData($Label,"你还没有创建数据库");MsgBox(64,"错误!","你还没有创建数据库!",5)
EndIf
EndFunc
Func _CreateData($mdbdatapath,$mdbdatapwd,$TableName) ;创建
if not FileExists($mdbdatapath) Then
$newMdb = ObjCreate("ADOX.Catalog")
$newMdb.Create("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdbdatapath& ";Jet Oledb:Database Password=" & $mdbdatapwd)
$newmdb.ActiveConnection.Close;建数据库
$addtbl = ObjCreate("ADODB.Connection")
$addTbl.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdbdatapath& ";Jet Oledb:Database Password=" & $mdbdatapwd)
$addTbl.Execute("CREATE TABLE " & $TableName)
$addtbl.Close;建表
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdbdatapath& ";Jet Oledb:Database Password=" & $mdbdatapwd)
$addfld.Execute("ALTER TABLE " & $TableName & " ADD id identity(1, 1) primary key,datea VARCHAR ,dateb VARCHAR ,datec VARCHAR,dated VARCHAR,datee VARCHAR,datef VARCHAR,dateg VARCHAR");id identity(1, 1) primary key为自动编号和主键
$addfld.Close;建列表名
GUICtrlSetData($Label,"数据库建立成功!!!");MsgBox(64,"提示","建立数据库成功",5)
Else
GUICtrlSetData($Label,"数据库已经存在!!!"); MsgBox(64,"提示","你已经建立了一个数据库了",5)
EndIf
EndFunc