#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <Date.au3>
Global $qd1,$qd2,$qd3,$qd4,$qd5,$qd6,$Date21,$Date22
$mdb_data_path = @ScriptDir&"\daoqi.mdb"
$mdb_password = "test"
$T = "*"
$tblname = "myjishi"
If Not FileExists ($mdb_data_path) Then create()
;-----------------------------------------------------------------------------1
$Form1 = GUICreate("门店到期注册提示器", 690, 565, -1, -1)
$xinzeng = GUICtrlCreateButton("新增", 32, 8, 75, 25)
$xiugai = GUICtrlCreateButton("修改", 144, 8, 75, 25)
$shanchu = GUICtrlCreateButton("删除", 248, 8, 75, 25)
$shezhi = GUICtrlCreateButton("设置", 352, 8, 75, 25)
$List = GUICtrlCreateListView("", 0, 40, 489, 505,-1,BitOR($LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT))
GUICtrlSetBkColor(-1,0xFCFCFC)
_GUICtrlListView_AddColumn($list, "ID", 60)
_GUICtrlListView_AddColumn($list, "门店", 100)
_GUICtrlListView_AddColumn($list, "类别", 50)
_GUICtrlListView_AddColumn($list, "注册时间",100)
_GUICtrlListView_AddColumn($list, "剩余(天)", 70)
_GUICtrlListView_AddColumn($list, "到期时间", 100)
_GUICtrlListView_JustifyColumn($list,0,2)
_GUICtrlListView_JustifyColumn($list,1,2)
_GUICtrlListView_JustifyColumn($list,2,2)
_GUICtrlListView_JustifyColumn($list,3,2)
_GUICtrlListView_JustifyColumn($list,4,2)
_GUICtrlListView_JustifyColumn($list,5,2)
_GUICtrlListView_JustifyColumn($list,6,2)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
$ipt = GUICtrlCreateInput("",490,40,200,25)
$list1 = GUICtrlCreateList("",490,66,200,485)
GUISetState(@SW_SHOW)
;------------------------------------------------------------------------2
$Form2 = GUICreate("添加门店信息", 234, 318, 210, 242)
$Label21 = GUICtrlCreateLabel("ID:", 48, 24, 32, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label22 = GUICtrlCreateLabel("门店:", 37, 67, 43, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label23 = GUICtrlCreateLabel("类别:", 37, 110, 43, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label24 = GUICtrlCreateLabel("注册时间:", 11, 154, 69, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label25 = GUICtrlCreateLabel("剩余天数:", 11, 197, 69, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label26 = GUICtrlCreateLabel("到期时间:", 11, 240, 69, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Input21 = GUICtrlCreateInput("", 80, 24, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
$Input22 = GUICtrlCreateInput("", 80, 66, 121, 21)
$Input23 = GUICtrlCreateInput("服务器", 80, 107, 121, 21)
$Input24 = GUICtrlCreateInput("", 80, 198, 121, 21)
GUICtrlSetState(-1,$GUI_DISABLE)
$Button21 = GUICtrlCreateButton("OK", 32, 280, 75, 25)
$Button22 = GUICtrlCreateButton("Cancle", 128, 280, 75, 25)
$Date21 = GUICtrlCreateDate("", 80, 152, 122, 21, $WS_BORDER)
$Date22 = GUICtrlCreateDate("", 80, 240, 122, 21, $WS_BORDER)
GUISetState(@SW_HIDE)
;------------------------------------------------------------------3
$Form3 = GUICreate("修改门店信息", 234, 318, 210, 242)
$Label31 = GUICtrlCreateLabel("ID:", 48, 24, 32, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label32 = GUICtrlCreateLabel("门店:", 37, 67, 43, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label33 = GUICtrlCreateLabel("类别:", 37, 110, 43, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label34 = GUICtrlCreateLabel("注册时间:", 11, 154, 69, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label35 = GUICtrlCreateLabel("剩余天数:", 11, 197, 69, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label36 = GUICtrlCreateLabel("到期时间:", 11, 240, 69, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Input31 = GUICtrlCreateInput("", 80, 24, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
$Input32 = GUICtrlCreateInput("", 80, 66, 121, 21)
$Input33 = GUICtrlCreateInput("服务器", 80, 107, 121, 21)
$Input34 = GUICtrlCreateInput("", 80, 198, 121, 21)
GUICtrlSetState(-1,$GUI_DISABLE)
$Button31 = GUICtrlCreateButton("OK", 32, 280, 75, 25)
$Button32 = GUICtrlCreateButton("Cancle", 128, 280, 75, 25)
$Date31 = GUICtrlCreateDate("", 80, 152, 122, 21, $WS_BORDER)
$Date32 = GUICtrlCreateDate("", 80, 240, 122, 21, $WS_BORDER)
GUISetState(@SW_HIDE)
If FileExists($mdb_data_path) Then du()
;--------------------------------------------------------------------4
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $xinzeng;新增
GUISetState(@SW_SHOW,$Form2)
Case $xiugai;修改
GUISetState(@SW_SHOW,$Form3)
Case $shanchu;删除
delete()
du()
Case $shezhi;设置
sy()
Case $Button21;确定新增
qdxz()
Case $Button22;退出新增
GUISetState(@SW_HIDE,$Form2)
Case $Button31;确定修改
qdxg()
Case $Button32;退出修改
GUISetState(@SW_HIDE,$Form3)
EndSwitch
WEnd
Func create()
$newMdb = ObjCreate('ADOX.Catalog')
$newMdb.Create("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_password)
$newmdb.ActiveConnection.Close;建数据库
$addtbl = ObjCreate("ADODB.Connection")
$addTbl.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_password)
$addTbl.Execute("CREATE TABLE " & $tblname)
$addtbl.Close;建表
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_password)
$addfld.Execute("ALTER TABLE "&$tblname&" ADD geshu int , mendian text(255) ,leibie text(255), zhuce text(50), shengy text(50), daoqi text(50)")
$addfld.Close;建列表名
MsgBox(0,'提示:','数据库创建成功!!!')
EndFunc
Func du()
GUICtrlSendMsg($list, $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_password)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("Select "&$T & " From " & $tblname&" order by shengy" )
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,$list)
$rs.movenext
WEnd
$rs.close
$addfld.Close
EndFunc
Func baocun()
If $qd5 >= $qd6 Then
MsgBox(16,"","注册时间与到期时间填写不正确,请重新填写。")
ElseIf $qd1 <> "" and $qd2 <> "" Then
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &$mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_password)
$addfld.execute("insert into "&$tblname&" (geshu,mendian,leibie,zhuce,daoqi) values('"&$qd1&"','"&$qd2&"','"&$qd3&"','"&$qd5&"','"&$qd6&"')")
$addfld.close
GUICtrlSetData($Date21,_NowDate())
GUICtrlSetData($Date22,_NowTime())
GUICtrlSetData($Input21,"")
GUICtrlSetData($Input22,"")
GUICtrlSetData($Input23,"服务器")
EndIf
EndFunc
Func delete()
$read_1 = GUICtrlRead(GUICtrlRead($list))
$read_2 = StringSplit($read_1,"|")
If $read_2[1] = '0' Then
MsgBox(16,"","请选择您所要删除的行!")
else
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &$mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_password)
$addfld.execute("delete from "&$tblname& " where geshu = "& $read_2[1])
$addfld.Close
EndIf
EndFunc
Func qdxz() ;确定新增
$qd1= GUICtrlRead($Input21)
$qd2= GUICtrlRead($Input22)
$qd3= GUICtrlRead($Input23)
$qd5= GUICtrlRead($Date21)
$qd6= GUICtrlRead($Date22)
baocun()
du()
EndFunc
Func sy()
EndFunc
Func qdxg();确定修改
EndFunc