[总算解决了]日期框可以实现可选和手动输入两种输入方式吗?(带源码)
本帖最后由 superpangya 于 2010-4-12 13:59 编辑1.日期框的扩展风格里有这种功能吗?
2.我下面的这个功能怎么实现?
虽然有点太难看了.但想实现这个功能,或者有更简单的办法?
我的输入框名称都是变量,这个比较麻烦.搞得头大了.
修改后的代码上传到#22,大家帮忙看看,CASE那里用不用再修改.. :face (37):大家帮帮忙... 不知道你要这个来做什么,你要添加数据时,写入的是那个? 楼主要干什么,没说明白呀 原来做的那个,做查询的时候日期项一直存在,我的本意只是想让这一项在必要的时候可以为空而已, 但是想想,软件做得太简单了,还是做得更好一点吧.
所以现在的想法是,这个日期框可以为空,然后自己手动输入,或者可以利用日期控件选择输入...上面的那个输入,日期,和按钮的组合是我的初步构想(简单的笨办法),问题是,我的输入框,日期框都是变量,这个功能要实现就复杂了(至少我不会),在while.... case button 那里的代码应该怎么写?
或者说,日期控件本身允许为空么?就是实现手动输入? 你那个输入的按钮是做什么用的?取代下面的添加数据按钮吗
或者你的意思是说,按下这个输入按钮后,希望日期框变这空,不希望里面有数据? 日期和输入控件搭配,
第一种情况是我对日期控件的操作结果会实时显示在输入框中,
第二种情况是,只有我按下输入按钮,日期控件的日期才会在输入框中显示,(不知道我说明白没有?), 我要这种. #include <GUIConstants.au3>
Global $input,$date,$Button0
GUICreate ( "我的 GUI 之日期控件", 500,200,200,200)
$input = GUICtrlCreateInput("", 10, 10, 90, 20)
$date = GUICtrlCreateDate ("", 100,10,120,20 )
$Button0 = GUICtrlCreateButton("输入", 220, 10,30, 20, 0)
GUISetState ()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
GUIDelete()
Case $Button0 ;输入
GUICtrlSetData($input,GUICtrlRead($date))
EndSwitch
WEnd就是要这种效果 $ninput[$i]输入框
$data[$i]日期控件
$button[$i] 按钮
这三个都是根据表的字段(datatime)产生的,是个变量,要实现上面的功能,这个在while case那里应该怎么写?
或者有什么简单的办法能实现上面的功能? 帮你改了一下,你看看是不是你要的效果
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
#include <GUIConstants.au3>
#include <EditConstants.au3>
Global $databutton,$DataTemp
Global $nLabel ;定义Label数量
Global $ninput ;定义input数量
Global $data ;定义input数量
Global $button ;定义input数量
Global $tabmain = "tabmain"
Global $Dll, $name_1, $pass_1, $qq_1, $w, $arr, $tblname,$e = 0,$T = "*",$mdb_data_path = "BB.mdb",$mdb_data_pwd = "",$linshi,$z,$a="",$b,$k,$j
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("***XXXX报备系统***", 800, 600, 100, 50)
;查看是否有皮肤
If FileExists("SkinCrafterDll.dll") Then
$search = FileFindFirstFile("*.skf")
If $search <> -1 Then
_SkinGUI("SkinCrafterDll.dll", "BlackPearl.skf", $Form1);Crimson.skf,DarkRed.skf,Stylish.skf,strait.skf
EndIf
EndIf
GUICtrlCreateGroup("", 5, 0, 790, 325)
$ListView0 = GUICtrlCreateListView("ID | 表名 ", 10, 15, 142, 300)
$ListView1 = GUICtrlCreateListView("| | | | | | | | | |", 155, 15, 635, 300);返回控件标识符(控件ID).
GUICtrlCreateGroup("", 5, 325, 790, 265)
GUICtrlCreateGroup("1、创建数据库", 5, 335, 260, 50)
GUICtrlCreateGroup("2、创建表及字段", 5, 390, 260, 190)
GUICtrlCreateGroup("3、添加、修改、删除数据", 270, 335, 525, 245)
$Button0 = GUICtrlCreateButton("创建数据库", 35, 355, 200, 25, 0)
$Button5 = GUICtrlCreateButton("添加数据", 280, 550, 100, 25, 0)
$Button2 = GUICtrlCreateButton("修改数据", 400, 550, 100, 25, 0)
$Button3 = GUICtrlCreateButton("删除数据", 520, 550, 100, 25, 0)
$Button7 = GUICtrlCreateButton("查询", 640, 550, 100, 25, 0)
$Button8 = GUICtrlCreateButton("临时", 640, 520, 100, 25, 0)
GUICtrlCreateLabel("输入表名:", 10, 410, 100, 20)
$tblname_1 = GUICtrlCreateInput("", 110, 410, 150, 20)
GUICtrlCreateLabel("输入字段及类型:", 10, 440, 100, 20)
$zdnameandtype_1 = GUICtrlCreateInput("", 10, 465, 250, 80,$ES_MULTILINE)
$Tips = GUICtrlCreateLabel("例如:name char,age int", 110, 440, 150, 20)
GUICtrlSetState($Tips, $GUI_DISABLE)
$Button6 = GUICtrlCreateButton("创建表及定段", 35, 550, 200, 25, 0)
If FileExists($mdb_data_path) Then
read_tabmain()
EndIf
;AdlibEnable("sendmsg",50)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY");为已知的Windows 消息代码(WM_MSG)注册一个用户自定义的函数
Func WM_NOTIFY($hWndGUI, $MsgID, $WParam, $LParam)
Local $tagNMHDR, $Event, $hWndFrom, $IDFrom
Local $tagNMHDR = DllStructCreate("int;int;int", $LParam)
If @error Then Return $GUI_RUNDEFMSG
$IDFrom = DllStructGetData($tagNMHDR, 2);返回数据结构(struct)元素的数据
$Event = DllStructGetData($tagNMHDR, 3)
$tagNMHDR = 0
Switch $IDFrom;选择产生事件的控件
Case $ListView1
Switch $Event; 选择产生的事件
Case $NM_CLICK ; 左击
Case $NM_DBLCLK ; 双击
$Strn = GUICtrlRead(GUICtrlRead($ListView1));列表视图数据
$Strnspin = StringSplit($Strn, "|");以指定分隔符把字符串拆分成若干子串
If $Strnspin > 0 Then
For $i = 0 To $w-1
GUICtrlSetData($ninput[$i], StringStripWS($Strnspin[$i+2], 2))
Next
;GUICtrlSetData($ninput, StringStripWS($Strnspin, 2));StringStripWS()删去字符串中的"空白符".
;GUICtrlSetData($ninput, StringStripWS($Strnspin, 2))
;GUICtrlSetData($ninput, StringStripWS($Strnspin, 2))
;GUICtrlSetData($ninput, StringStripWS($Strnspin, 2))
;GUICtrlSetData($ninput, StringStripWS($Strnspin, 2))
;GUICtrlSetData($ninput, StringStripWS($Strnspin, 2))
;GUICtrlSetData($ninput, StringStripWS($Strnspin, 2))
;GUICtrlSetData($ninput, StringStripWS($Strnspin, 2))
;GUICtrlSetData($ninput, StringStripWS($Strnspin, 2))
;GUICtrlSetData($ninput, StringStripWS($Strnspin, 2))
Else
MsgBox(0, "提示", "请选择相应的数据!")
EndIf
Case $NM_RCLICK ; 右击
MsgBox(0, "注意", "那个人比较懒,还没有建立右键!")
EndSwitch
Case $ListView0
Switch $Event; 选择产生的事件
Case $NM_CLICK ; 左击
$Strn = GUICtrlRead(GUICtrlRead($ListView0))
$Strnspin = StringSplit($Strn, "|")
If $Strnspin > 0 Then
$tabname = $Strnspin
du($tabname)
If $e = 0 Then
adds($w, $arr)
$e = $w
Else
dels($e)
adds($w, $arr)
$e = $w
EndIf
EndIf
Case $NM_DBLCLK ; 双击
Case $NM_RCLICK ; 右击
MsgBox(0, "嘿嘿", "NO右键!")
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func sendmsg()
$Strn = GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin = StringSplit($Strn, "|")
If $Strnspin > 0 Then
GUICtrlSetData($name_1, StringStripWS($Strnspin, 2))
GUICtrlSetData($pass_1, StringStripWS($Strnspin, 2))
GUICtrlSetData($qq_1, StringStripWS($Strnspin, 2))
EndIf
EndFunc ;==>sendmsg
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Dim $tabname
$Strn = GUICtrlRead(GUICtrlRead($ListView0))
$Strnspin = StringSplit($Strn, "|")
If $Strnspin > 0 Then
$tabname = $Strnspin
EndIf
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Quit()
Case $Button0 ;创建数据库
data($mdb_data_path, $tabmain)
Case $Button5;添加数据
If $Strnspin > 0 Then
sx($tabname)
du($tabname)
Else
MsgBox(0, "提示", "请输入相应的数据!")
EndIf
Case $Button2 ;更新,修改
If $Strnspin > 0 Then
up($tabname)
du($tabname)
Else
MsgBox(0, "提示", "请选择要更新的数据!")
EndIf
Case $Button3 ;删除
If $Strnspin > 0 Then
del($tabname)
du($tabname)
Else
MsgBox(0, "提示", "请选择要删除的数据!")
EndIf
Case $Button6 ;创建表及字段
$tblname = GUICtrlRead($tblname_1) ;读取输入的表名
$zdnameandtype = GUICtrlRead($zdnameandtype_1) ;读取输入的字段
If $tblname <> "" Then
If $zdnameandtype <> "" Then
newtable($mdb_data_path, $tblname, $zdnameandtype)
read_tabmain()
Else
MsgBox(0, "提示", "请输入要创建表的字段及类型!")
EndIf
Else
MsgBox(0, "提示", "请输入要创建表的名称!")
EndIf
Case $Button7
chaxun()
;Case $button[$a]
;GUICtrlSetData($ninput[$a],GUICtrlRead($data[$a]))
Case $databutton
GUICtrlSetData ($ninput[$datatemp],GUICtrlRead ($data[$datatemp]))
EndSwitch
WEnd
Func chaxun()
Dim $v ,$h =''
For $v = 0 To $w-1
$h = $h& GUICtrlRead($ninput[$v])
Next
MsgBox(0, "提示", $h)
IfNot $h = "" Then
GUICtrlDelete($ListView1)
Dim $k, $m,$s ='',$c
For $c = 0 To $w-1
$y = StringSplit($arr[$c+1], " ")
$k = $k & $y & ","
$s =$s & $y & "|"
If Not GUICtrlRead($ninput[$c]) = "" Then
$m = $m &$y&"='"& GUICtrlRead($ninput[$c]) & "' and "
EndIf
Next
;$ListView1 = GUICtrlCreateListView("序号|车次", 200, 88, 409, 313)
;GUICtrlCreateListView("| | | | | | | | | |", 155, 15, 635, 300)
$ListView1 = GUICtrlCreateListView("id|"&$s&"| | | | |", 155, 15, 635, 300)
$s=""
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
$conn = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$conn.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$RS.ActiveConnection = $conn
;$RS.open("select * from 设备档案 where 设备编号='" & GUICtrlRead($Input2) & "'")
MsgBox(0, "提示", StringTrimRight($m, 4))
;$RS.open("select * from 设备维护 where '& StringTrimRight($m, 4) & ' ")
MsgBox(0, "提示", $tabname)
$RS.open("Select " & $T & " From "& $tabname &"where "& StringTrimRight($m, 4) )
;$RS.open("select * from 约会 where 时间='20100330000000'")
;$RS.open("select * from 设备档案 where " & GUICtrlRead($Input2) & "='" & GUICtrlRead($Input1) & "'")
;$RS.open("select * from 设备档案 where 设备编号='B001' And 使用部门='ABC' ")
;$RS.open("select * from 1 where 1='1'")
;$RS.Open("Select " & $T & " From " & $tabmain & " where name = '" & $tabname & "'")
$i = 0
While (Not $RS.eof And Not $RS.bof)
Dim $o='',$p
For $p = 1 To $w
;$o=$o&$RS.Fields($p).value&"|"
$o=$o&StringStripWS($RS.Fields($p).value, 2)&"|"
Next
;$data = $RS.Fields(0).value
;GUICtrlCreateListViewItem($i + 1 & "|" & $data, $ListView1)
GUICtrlCreateListViewItem($i + 1 & "|" & $o, $ListView1)
$RS.movenext
$i = $i + 1
WEnd
;$linshi = $o
If $i = 0 Then
MsgBox(0, "提示", "没有找到相关数据")
;GUICtrlSetData($Label7, "没有找相关到数据")
EndIf
$RS.close
$conn.close
$ischeci = 1
;GUICtrlSetData($Label7, "共找到" & $i & "个和 " & GUICtrlRead($Input1) & " 相关的记录,点击车次可查看详细信息,双击查看该车次过站情况")
Else
MsgBox(0, "提示", "请输入查询内容")
EndIf
EndFunc
Func du_table($tblname)
GUICtrlSendMsg($ListView0, $LVM_DELETEALLITEMS, 0, 0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select " & $T & " From " & $tblname)
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, $ListView1)
; MsgBox(0, "", $RS.Fields (1).value);显示表第一个数据
$RS.movenext
WEnd
$RS.close
$addfld.Close
EndFunc ;==>du_table
Func adds($w, $arr) ;建立Label(数量)
For $i = 0 To $w - 1
;$a = $i
$y = StringSplit($arr[$i + 1], " ") ;以指定分隔符把字符串拆分成若干子串,返回一个数组,第一个元素($array)保存拆分后子串的数量,其余元素($array,$array 等等)则保存着拆分后的每个字符串
$linshi =StringRight($arr[$i + 1],8)
If $linshi = 'datetime' Then
Local $DTM_SETFORMAT_, $style
$ninput[$i]=GUICtrlCreateInput("", 340, 355 + 20 * $i, 250, 20)
$data[$i] = GUICtrlCreateDate ("", 590,355 + 20 * $i,150,20 )
$databutton = GUICtrlCreateButton("输入",740,355 + 20 * $i,50,20 )
$DataTemp = $i
$DTM_SETFORMAT_ = 0x1032 ; $DTM_SETFORMATW
$style = "yyyy/MM/dd HH:mm:ss"
GUICtrlSendMsg($ninput[$i], $DTM_SETFORMAT_, 0, $style)
;~ $ninput[$i]=GUICtrlCreateDate("", 340, 355 + 20 * $i, 450, 20)
Else
$ninput[$i] = GUICtrlCreateInput("", 340, 355 + 20 * $i, 450, 20)
EndIf
$nLabel[$i] = GUICtrlCreateLabel($y, 280, 355 + 20 * $i, 60, 20)
Next
;$b = StringSplit($a, ",") ;以指定分隔符把字符串拆分成若干子串
EndFunc ;==>adds
Func dels($w) ;清除Label(数量)
For $i = 0 To $w - 1
GUICtrlDelete($nLabel[$i])
GUICtrlDelete($ninput[$i])
Next
EndFunc ;==>dels
Func du($tabname)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select " & $T & " From " & $tabmain & " where name = '" & $tabname & "'")
$temp = StringStripWS($RS.Fields(2).value, 2) ;删去字符串中的所有"空白符" 1 char,2 char,3 int,4 char
$arr = StringSplit($temp, ",") ;以指定分隔符把字符串拆分成若干子串
$w = $arr
GUICtrlSendMsg($ListView1, $LVM_DELETEALLITEMS, 0, 0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select " & $T & " From " & $tabname)
Dim $n
While Not $RS.eof And Not $RS.bof
If @error = 1 Then ExitLoop
For $i = 0 To $w
;MsgBox(0,"",StringStripWS($RS.Fields ($i).value,2))
$n = $n & StringStripWS($RS.Fields($i).value, 2) & "|"
Next
;MsgBox(0,"",StringTrimRight ($n, 1))
GUICtrlCreateListViewItem(StringTrimRight($n, 1), $ListView1)
$RS.movenext
$n = ""
WEnd
$RS.close
$addfld.Close
Dim $strs = "ID|"
For $x = 1 To $w
$y = StringSplit($arr[$x], " ")
$strs = $strs & $y & "|"
Next
GUICtrlSetData($ListView1, "| | | | | | | | | |")
GUICtrlSetData($ListView1, $strs)
EndFunc ;==>du
Func del($tabname)
$Strn = GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin = StringSplit($Strn, "|")
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$sQuery = "DELETE FROM " & $tabname & " IN '" & $mdb_data_path & "' WHERE id" & " = " & $Strnspin
; MsgBox(0,"",$sQuery)
$addfld.execute($sQuery)
$addfld.close
MsgBox(4096, "提示:", $Strnspin & " 删除成功!!!")
EndFunc ;==>del
Func up($tabname)
$Strn = GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin = StringSplit($Strn, "|")
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select " & $T & " From " & $tabmain & " where name = '" & $tabname & "'")
$temp = StringStripWS($RS.Fields(2).value, 2)
$arr = StringSplit($temp, ",")
$w = $arr
Dim $h
For $i = 1 To $w
$arrs = StringSplit($arr[$i], " ")
$h = $h & $arrs & " = '" & GUICtrlRead($ninput[$i - 1]) & "',"
Next
$sQuery = "update " & $tabname & " set " & StringTrimRight($h, 2) & "' WHERE id" & " = " & $Strnspin
;MsgBox(0,"",$sQuery)
$addfld.execute($sQuery)
$addfld.close
MsgBox(4096, "提示:", $Strnspin & " 更新成功!!!")
EndFunc ;==>up
Func sx($tabname)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select " & $T & " From " & $tabmain & " where name = '" & $tabname & "'")
$temp = StringStripWS($RS.Fields(2).value, 2)
$arr = StringSplit($temp, ",")
$w = $arr
Dim $k, $m
For $i = 1 To $w
$y = StringSplit($arr[$i], " ")
$k = $k & $y & ","
$m = $m & GUICtrlRead($ninput[$i - 1]) & "','"
;If Not GUICtrlRead($ninput[$i-1]) = "" Then
;$m = $m & GUICtrlRead($ninput[$i - 1]) & "','"
;EndIf
Next
;MsgBox(0,"",$k)
;MsgBox(0,"",$m)
;MsgBox(0,"","insert into "& $tabname &"("& StringTrimRight ( $k,1) &") values('"& StringTrimRight ( $m,3) &"')")
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$addfld.Execute("insert into " & $tabname & "(" & StringTrimRight($k, 1) & ") values('" & StringTrimRight($m, 3) & "')")
$addfld.close
MsgBox(4096, "提示:", " 成功写入数据库!")
EndFunc ;==>sx
Func read_tabmain()
GUICtrlSendMsg($ListView0, $LVM_DELETEALLITEMS, 0, 0) ;向指定控件发送消息
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select * from tabmain")
While Not $RS.eof And Not $RS.bof
If @error = 1 Then ExitLoop
GUICtrlCreateListViewItem($RS.Fields(0).value & "|" & StringStripWS($RS.Fields(1).value, 2), $ListView0)
; MsgBox(0, "", $RS.Fields (1).value);显示表第一个数据
$RS.movenext
WEnd
$RS.close
$addfld.Close
EndFunc ;==>read_tabmain
Func data($mdb_data_path, $tabmain)
If Not FileExists($mdb_data_path) Then
$newMdb = ObjCreate("ADOX.Catalog")
$newMdb.Create("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$newMdb.ActiveConnection.Close;建数据库
$addtbl = ObjCreate("ADODB.Connection")
$addtbl.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$addtbl.Execute("CREATE TABLE " & $tabmain)
$addtbl.Close;建表
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$addfld.Execute("ALTER TABLE " & $tabmain & " ADD id identity(1, 1) primary key,name char,zdnameandtype char");id identity(1, 1) primary key为自动编号和主键
$addfld.Close;建列表名
MsgBox(64, "提示", "建立数据库成功", 5)
Else
MsgBox(64, "提示", "你已经建立了一个数据库了", 5)
EndIf
EndFunc ;==>data
Func newtable($mdb_data_path, $tblname, $zdnameandtype)
$addtbl = ObjCreate("ADODB.Connection")
$addtbl.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
;添加表之前查一下是否表明存在
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addtbl
$RS.Open("select * from tabmain where name = '" & $tblname & "'")
If Not $RS.eof And Not $RS.bof Then
MsgBox(0, "提示", "新建失败,改表明已存在!")
Else
$addtbl.Execute("CREATE TABLE " & $tblname)
$addtbl.Close;建表
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$addfld.Execute("ALTER TABLE " & $tblname & " ADD id identity(1, 1) primary key," & $zdnameandtype) ;id identity(1, 1) primary key为自动编号和主键
$addfld.Close;建列表名
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$addfld.Execute("insert into tabmain (name,zdnameandtype) values('" & $tblname & "','" & $zdnameandtype & "')")
$addfld.close;新建的表放到该表中
EndIf
EndFunc ;==>newtable
Func _SkinGUI($SkincrafterDll, $SkincrafterSkin, $Handle)
$Dll = DllOpen($SkincrafterDll)
DllCall($Dll, "int:cdecl", "InitLicenKeys", "wstr", "1", "wstr", "", "wstr", "1@1.com", "wstr", "1")
DllCall($Dll, "int:cdecl", "InitDecoration", "int", 1)
DllCall($Dll, "int:cdecl", "LoadSkinFromFile", "wstr", $SkincrafterSkin)
DllCall($Dll, "int:cdecl", "DecorateAs", "int", $Handle, "int", 25)
DllCall($Dll, "int:cdecl", "ApplySkin")
EndFunc ;==>_SkinGUI
Func Quit()
GUISetState(@SW_HIDE)
DllCall($Dll, "int:cdecl", "DeInitDecoration")
DllCall($Dll, "int:cdecl", "RemoveSkin")
DllClose($Dll)
;DirRemove(@AppDataDir&"\skin",1)
Exit
EndFunc ;==>Quit
如果一个表中有两个或更多的日期字段,这个功能就不能实现, $DataTemp = $i , $DataTemp应该是几个值..... 你的这个日期输入框,是按照数据库类型是否返回有Datetime字段来确定是否建立的,如果有多个日期的字段,具体出现什么情况还真不好说 本帖最后由 superpangya 于 2010-4-7 10:21 编辑
If $linshi = 'datetime' Then............
这样的话,只有最后一个输入,日期,按钮的组合能起作用,前面的都无效...
我想加一个
$a=$a&$i
$b = StringSplit($a, ",")
在IF里面,
数组$b就是所有字段为datetime的值, 比如,第3\7两项为日期字段,如果这样的话,以后怎么写? 本帖最后由 C.L 于 2010-4-7 11:16 编辑
If $linshi = 'datetime' Then............
这样的话,只有最后一个输入,日期,按钮的组合能起作用,前面的 ...
superpangya 发表于 2010-4-7 10:18 http://www.autoitx.com/images/common/back.gif
不是,我想应该是每一个"Datetime"都会建立一组控件,只是控件会重叠起来,使用的时候,可能会出现莫名其妙的事情
我想加一个
$a=$a&$i
$b = StringSplit($a, ",")
在IF里面,
数组$b就是所有字段为datetime的值, 比如,第3\7两项为日期字段,如果这样的话,以后怎么写?
我想你需要记录Datetime字段的总数,然后按照总数增加日期的控件,每一个字段都应该对应相应的控件吧.还要记录每个控件相对的$i值,以便可以操作控件.
或者干脆日期控件不要变量名,用实名来控制. 本帖最后由 superpangya 于 2010-4-7 11:28 编辑
If $linshi = 'datetime' Then
$ninput[$i]=GUICtrlCreateInput("", 340, 355 + 20 * $i, 250, 20)
$data[$i] = GUICtrlCreateDate ("", 590,355 + 20 * $i,150,20 )
$button[$i] = GUICtrlCreateButton("输入",740,355 + 20 * $i,50,20 )
$a=$a&$i
..........................
endif
$b = StringSplit($a, ",")
$b-1 就是datetime 字段的数量, $b,$b.....就是对应的$i的值,
我是这么想的,这个有办法继续往下写吗,最主要是CASE那里,
(因为好多表,每个表里时间字段数量 位置不同,所以,输入框,日期,按钮,这几个一定是在变的,实名的话,应该不成吧.)
页:
[1]
2