|
楼主 |
发表于 2012-2-7 14:58:25
|
显示全部楼层
回复 11# kk_lee69
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <IPAddressConstants.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <StatusBarConstants.au3>
#include <WindowsConstants.au3>
#include <GuiIPAddress.au3>
#include <GuiStatusBar.au3>
#include <GUIConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <GuiDateTimePicker.au3>
#include <Date.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <windowsconstants.au3>
#include <comboconstants.au3>
Local $datadir = "C:\myproject\mydb.mdb"
_add_gui()
Func _add_gui();数据添加窗口
$Form1 = GUICreate("", 550, 260)
$Group1 = GUICtrlCreateGroup("", 8, 4, 533, 350)
GUICtrlCreateLabel("记录日期:", 40, 32, 64, 17)
GUICtrlCreateLabel("消费类型:", 40, 67, 64, 17)
GUICtrlCreateLabel("消费金额:", 39, 102, 64, 17)
GUICtrlCreateLabel("备注:", 39, 139, 64, 17)
$Date_Input = GUICtrlCreateDate("", 112, 29, 137, 20)
$Type_Input = GUICtrlCreateInput("", 112, 64, 137, 20)
$Money_Input = GUICtrlCreateInput("", 112, 99, 137, 20)
GUICtrlSetTip(-1,"必须输入金额数","提示:",1)
$Remark_Input = GUICtrlCreateInput("", 112, 134, 393, 20)
GUICtrlCreateLabel("(元)", 250, 103, 30, 17)
GUICtrlSetColor(-1, 0xFF0000)
$Removal = GUICtrlCreateButton("清除重填", 64, 189, 89, 25)
GUICtrlSetBkColor(-1, 0xCAE1FF)
$Determined = GUICtrlCreateButton("确定录入", 392, 189, 89, 25)
GUICtrlSetBkColor(-1, 0xCAE1FF)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
GUISetBkColor (0xCAE1FF)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
GUIDelete($Form1)
WinActivate("客户资料录入")
GUISetState(@SW_ENABLE, $Form1_1)
ExitLoop
Case $msg = $Determined
$Date = GUICtrlRead($Date_Input)
$Type = GUICtrlRead($Type_Input)
$Money = GUICtrlRead($Money_Input)
$Remark = GUICtrlRead($Remark_Input)
IF $Date = "" Or $Type = "" Or $Money = "" Or $Remark = "" Then
MsgBox(0,"提示:","客户资料不能为空,请认真填写!")
Else
_sql_add($Date,$Type,$Money,$Remark)
MsgBox(0,"成功:","客户资料录入成功!")
GUIDelete($Form1)
ExitLooP
MsgBox(0,"失败:","录入的资料已经存在,录入失败!")
EndIf
Case $msg = $Removal
GUICtrlSetData($Date_Input,"")
GUICtrlSetData($Type_Input,"")
GUICtrlSetData($Money_Input,"")
GUICtrlSetData($Remark_Input,"")
EndSelect
WEnd
EndFunc
Func _sql_add($Date,$Type,$Money,$Remark);数据库添加用户函数
$conn = ObjCreate("ADODB.Connection")
$conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datadir)
$conn.Execute("insert into note (Date,Type,Money,Remark) values('"&$Date&"','"&$Type&"','"&$Money&"','"&$Remark&"')")
$conn.close
EndFunc |
|