麻烦大家给我完善一下
本帖最后由 pizigao 于 2009-9-9 16:59 编辑刚学没两天做了这么一个小程序~现在还有两个需求搞不定!请大家指教
1、如果把从数据库字段里面取过来的1或者0赋值成中文?比如取过来的数据是0,前台显示未申报,1的话就是已申报,目前我实现的直接取过来的字段,不知道如何赋值加判断。
2、如果没有申报状态提示一下,加个判断,现在是没提示直接报错。
3、如果把申报日期从数据库日期的字段全部取过来,做成下拉列表!
请大家帮帮忙 源码如下
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$datename= @ScriptDir & "\data.mdb"
$datepass="GSDKDJV1200Jdls2008"
#Region ### START Koda GUI section ### Form=20090908.kxf
$Form1_1 = GUICreate("申报标志修改工具 FOR1.2", 291, 160, 343, 258)
$Label1 = GUICtrlCreateLabel("申报日期:", 21, 18, 64, 17)
$Label3 = GUICtrlCreateLabel("日期格式:YYYYMM;如:200908", 21, 124, 241, 17)
$Label5 = GUICtrlCreateLabel("状态说明:0 未申报;1 已申报 ", 21, 140, 241, 17)
$sbrq=GUICtrlCreateInput("200908", 97, 15, 105, 21,$ES_NUMBER)
GUICtrlSetLimit(-1, 6)
$Button1 = GUICtrlCreateButton("查询", 225, 13, 43, 25, 0)
$Button2 = GUICtrlCreateButton("修改", 225, 95, 43, 25, 0)
$xgzt=GUICtrlCreateInput("", 97, 97, 105, 21,$ES_NUMBER)
GUICtrlSetLimit(-1, 1)
$Label4 = GUICtrlCreateLabel("修改状态:", 21, 100, 64, 17)
$sbzt=GUICtrlCreateInput("", 97, 56, 105, 21,$ES_NUMBER)
GUICtrlSetLimit(-1, 10)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label2 = GUICtrlCreateLabel("申报状态:", 21, 59, 64, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
case $Button1
cx()
case $Button2
xg()
EndSwitch
WEnd
Func cx()
Global $sbzt
$Strn=GUICtrlRead($sbrq)
$addfld = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datename & ";Jet Oledb:Database Password=" & $datepass)
$RS.ActiveConnection = $addfld
$jy = "select sbbz from sbzb where sbyf= '" & $Strn & "'"
$RS.Open ($jy)
if $rs.eof and $rs.bof then
MsgBox(16,"提示","没有这个申报月份",5)
GUICtrlSetData ( $sbzt,"")
ControlFocus ( "", "", $sbzt)
Else
GUICtrlSetData ( $sbzt,$RS.Fields (0).value)
EndIf
$rs.close
$addfld.Close
EndFunc
Func xg()
$Strn=GUICtrlRead($sbrq)
$srbz=GUICtrlRead($xgzt)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datename & ";Jet Oledb:Database Password=" & $datepass)
$sQuery ="update sbzb set sbbz=" &$srbz & " where sbyf= '" & $Strn & "'"
MsgBox(64, "提示","状态更新成功!")
$addfld.execute($sQuery)
$addfld.close
EndFunc
数据库下载地址:
http://pizigao.qupan.com/4544593.html
谢谢大家 #include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$datename = @ScriptDir & "\data.mdb"
$datepass = "GSDKDJV1200Jdls2008"
#Region ### START Koda GUI section ### Form=20090908.kxf
$Form1_1 = GUICreate("申报标志修改工具 FOR1.2", 291, 160, 343, 258)
$Label1 = GUICtrlCreateLabel("申报日期:", 21, 18, 64, 17)
$Label3 = GUICtrlCreateLabel("日期格式:YYYYMM;如:200908", 21, 124, 241, 17)
$Label5 = GUICtrlCreateLabel("状态说明:0 未申报;1 已申报 ", 21, 140, 241, 17)
$sbrq = GUICtrlCreateCombo("", 97, 15, 105, 21)
GUICtrlSetLimit(-1, 6)
$Button1 = GUICtrlCreateButton("查询", 225, 13, 43, 25, 0)
$Button2 = GUICtrlCreateButton("修改", 225, 95, 43, 25, 0)
$xgzt = GUICtrlCreateInput("", 97, 97, 105, 21, $ES_NUMBER)
GUICtrlSetLimit(-1, 1)
$Label4 = GUICtrlCreateLabel("修改状态:", 21, 100, 64, 17)
$sbzt = GUICtrlCreateInput("", 97, 56, 105, 21, $ES_NUMBER)
GUICtrlSetLimit(-1, 10)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label2 = GUICtrlCreateLabel("申报状态:", 21, 59, 64, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
rq()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
cx()
Case $Button2
xg()
EndSwitch
WEnd
Func rq()
$addfld = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datename & ";Jet Oledb:Database Password=" & $datepass)
$RS.ActiveConnection = $addfld
$jy = "select sbyf from sbzb"
$RS.Open($jy)
$data=""
While(not $RS.eof and Not $RS.bof)
$data&=$RS.Fields(0).value&"|"
$rs.movenext
WEnd
$RS.close
$addfld.Close
$temp=StringSplit($data,"|")
GUICtrlSetData($sbrq,$data,$temp)
EndFunc ;==>rq
Func cx()
Global $sbzt
$Strn = GUICtrlRead($sbrq)
$addfld = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datename & ";Jet Oledb:Database Password=" & $datepass)
$RS.ActiveConnection = $addfld
$jy = "select sbbz from sbzb where sbyf= '" & $Strn & "'"
$RS.Open($jy)
If $RS.eof And $RS.bof Then
MsgBox(16, "提示", "没有这个申报月份", 5)
GUICtrlSetData($sbzt, "")
ControlFocus("", "", $sbzt)
Else
Switch $RS.Fields(0).value
Case 0
GUICtrlSetData($sbzt, "未申报")
Case 1
GUICtrlSetData($sbzt, "已申报")
Case Else
GUICtrlSetData($sbzt, "未知状态")
EndSwitch
EndIf
$RS.close
$addfld.Close
EndFunc ;==>cx
Func xg()
$Strn = GUICtrlRead($sbrq)
$srbz = GUICtrlRead($xgzt)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datename & ";Jet Oledb:Database Password=" & $datepass)
$sQuery = "update sbzb set sbbz=" & $srbz & " where sbyf= '" & $Strn & "'"
MsgBox(64, "提示", "状态更新成功!")
$addfld.execute($sQuery)
$addfld.close
EndFunc ;==>xg 谢谢大绯狼~ 再次麻烦一下大绯狼~能否最后一个地方“修改状态”加入一个对话框~就是不填数据的时候提示一下~而不是程序本身报错! Func xg()
If GUICtrlRead($xgzt, 1) <> '' Then
$Strn = GUICtrlRead($sbrq)
$srbz = GUICtrlRead($xgzt)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datename & ";Jet Oledb:Database Password=" & $datepass)
$sQuery = "update sbzb set sbbz=" & $srbz & " where sbyf= '" & $Strn & "'"
MsgBox(64, "提示", "状态更新成功!")
$addfld.execute($sQuery)
$addfld.close
Else
MsgBox(48, "提示", "请先输入状态值(0或1) ")
EndIf
EndFunc ;==>xg 谢谢afan~我试试! 本帖最后由 pizigao 于 2009-9-9 16:04 编辑
谢谢各位前辈的不吝赐教~刚才测试发现一个新问题!就是填写的时候其实就是0跟1~但是输入全角会报错~我想通过一种简单的方法~就是通过选择0(未申报)和1(已申报)~不能手工填~再次麻烦大家了!最终效果如下~这样方便些! 修改了下,且增加了修改后同步申报状态显示~#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>
$datename = @ScriptDir & "\data.mdb"
$datepass = "GSDKDJV1200Jdls2008"
#Region ### START Koda GUI section ### Form=20090908.kxf
$Form1_1 = GUICreate("申报标志修改工具 FOR1.2", 291, 160, 343, 258)
$Label1 = GUICtrlCreateLabel("申报日期:", 21, 18, 64, 17)
$Label3 = GUICtrlCreateLabel("日期格式:YYYYMM;如:200908", 21, 124, 241, 17)
$Label5 = GUICtrlCreateLabel("状态说明:0 未申报;1 已申报 ", 21, 140, 241, 17)
$sbrq = GUICtrlCreateCombo("", 97, 15, 105, 21)
GUICtrlSetLimit(-1, 6)
$Button1 = GUICtrlCreateButton("查询", 225, 13, 43, 25, 0)
$Button2 = GUICtrlCreateButton("修改", 225, 95, 43, 25, 0)
$xgzt = GUICtrlCreateCombo("", 97, 97, 105, 21,$CBS_DROPDOWNLIST)
GUICtrlSetData(-1,"1|0","1")
$Label4 = GUICtrlCreateLabel("修改状态:", 21, 100, 64, 17)
$sbzt = GUICtrlCreateInput("", 97, 56, 105, 21, $ES_NUMBER)
GUICtrlSetLimit(-1, 10)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label2 = GUICtrlCreateLabel("申报状态:", 21, 59, 64, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
rq()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
cx()
Case $Button2
xg()
EndSwitch
WEnd
Func rq()
$addfld = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datename & ";Jet Oledb:Database Password=" & $datepass)
$RS.ActiveConnection = $addfld
$jy = "select sbyf from sbzb"
$RS.Open($jy)
$data = ""
While (Not $RS.eof And Not $RS.bof)
$data &= $RS.Fields(0).value & "|"
$RS.movenext
WEnd
$RS.close
$addfld.Close
$temp = StringSplit($data, "|")
GUICtrlSetData($sbrq, $data, $temp)
EndFunc ;==>rq
Func cx()
Global $sbzt
$Strn = GUICtrlRead($sbrq)
$addfld = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datename & ";Jet Oledb:Database Password=" & $datepass)
$RS.ActiveConnection = $addfld
$jy = "select sbbz from sbzb where sbyf= '" & $Strn & "'"
$RS.Open($jy)
If $RS.eof And $RS.bof Then
MsgBox(16, "提示", "没有这个申报月份", 5)
GUICtrlSetData($sbzt, "")
ControlFocus("", "", $sbzt)
Else
Switch $RS.Fields(0).value
Case 0
GUICtrlSetData($sbzt, "未申报")
Case 1
GUICtrlSetData($sbzt, "已申报")
Case Else
GUICtrlSetData($sbzt, "未知状态")
EndSwitch
EndIf
$RS.close
$addfld.Close
EndFunc ;==>cx
Func xg()
$Strn = GUICtrlRead($sbrq)
$srbz = GUICtrlRead($xgzt)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datename & ";Jet Oledb:Database Password=" & $datepass)
$sQuery = "update sbzb set sbbz=" & $srbz & " where sbyf= '" & $Strn & "'"
MsgBox(64, "提示", "状态更新成功!")
$addfld.execute($sQuery)
$addfld.close
cx()
EndFunc ;==>xg GUICtrlCreateRadio
if BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED then
guictrlsetstate($radio 2,$GUI_UNCHECKED)
elseif BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED then
guictrlsetstate($radio1,$GUI_UNCHECKED)
endif 实在谢谢afan 大哥了~刚刚我编辑了帖子!没想到你这么快~我现在修改了方案~最终效果9楼的图!那样更直观~实在抱歉 同步的功能做的不错~开始没想到! 本帖最后由 afan 于 2009-9-9 16:28 编辑
开始我也想用单选,毕竟只有一次点击。只是看你的要求才改的...#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$datename = @ScriptDir & "\data.mdb"
$datepass = "GSDKDJV1200Jdls2008"
#Region ### START Koda GUI section ### Form=20090908.kxf
$Form1_1 = GUICreate("申报标志修改工具 FOR1.2", 291, 160, 343, 258)
$Label1 = GUICtrlCreateLabel("申报日期:", 21, 18, 64, 17)
$Label3 = GUICtrlCreateLabel("日期格式:YYYYMM;如:200908", 21, 124, 241, 17)
$sbrq = GUICtrlCreateCombo("", 97, 15, 105, 21)
GUICtrlSetLimit(-1, 6)
$Button1 = GUICtrlCreateButton("查询", 225, 13, 43, 25, 0)
$Button2 = GUICtrlCreateButton("修改", 225, 95, 43, 25, 0)
$xgzt = GUICtrlCreateRadio ( "已申报", 85, 97, 55, 20)
$xgzt1 = GUICtrlCreateRadio ( "未申报", 150, 97, 55, 20)
GUICtrlSetState (-1,$GUI_CHECKED)
$Label4 = GUICtrlCreateLabel("修改状态:", 21, 100, 64, 17)
$sbzt = GUICtrlCreateInput("", 97, 56, 105, 21, $ES_NUMBER)
GUICtrlSetLimit(-1, 10)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label2 = GUICtrlCreateLabel("申报状态:", 21, 59, 64, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
rq()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
cx()
Case $Button2
xg()
EndSwitch
WEnd
Func rq()
$addfld = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datename & ";Jet Oledb:Database Password=" & $datepass)
$RS.ActiveConnection = $addfld
$jy = "select sbyf from sbzb"
$RS.Open($jy)
$data = ""
While (Not $RS.eof And Not $RS.bof)
$data &= $RS.Fields(0).value & "|"
$RS.movenext
WEnd
$RS.close
$addfld.Close
$temp = StringSplit($data, "|")
GUICtrlSetData($sbrq, $data, $temp)
EndFunc ;==>rq
Func cx()
Global $sbzt
$Strn = GUICtrlRead($sbrq)
$addfld = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datename & ";Jet Oledb:Database Password=" & $datepass)
$RS.ActiveConnection = $addfld
$jy = "select sbbz from sbzb where sbyf= '" & $Strn & "'"
$RS.Open($jy)
If $RS.eof And $RS.bof Then
MsgBox(16, "提示", "没有这个申报月份", 5)
GUICtrlSetData($sbzt, "")
ControlFocus("", "", $sbzt)
Else
Switch $RS.Fields(0).value
Case 0
GUICtrlSetData($sbzt, "未申报")
Case 1
GUICtrlSetData($sbzt, "已申报")
Case Else
GUICtrlSetData($sbzt, "未知状态")
EndSwitch
EndIf
$RS.close
$addfld.Close
EndFunc ;==>cx
Func xg()
$Strn = GUICtrlRead($sbrq)
$srbz = GUICtrlRead($xgzt)
if BitAND(GUICtrlRead($xgzt), $GUI_CHECKED) = $GUI_CHECKED then $srbz = 1
if BitAND(GUICtrlRead($xgzt1), $GUI_CHECKED) = $GUI_CHECKED then $srbz = 0
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $datename & ";Jet Oledb:Database Password=" & $datepass)
$sQuery = "update sbzb set sbbz=" & $srbz & " where sbyf= '" & $Strn & "'"
MsgBox(64, "提示", "状态更新成功!")
$addfld.execute($sQuery)
$addfld.close
cx()
EndFunc ;==>xg 开始我也想用单选,毕竟只有一次点击。只是看你的要求才改的...#include
#include
#include
#include
#include
$datename = @ScriptDir & "\data.mdb"
$datepass = "GSDKDJV1200Jdls2008"
#Region ### S ...
afan 发表于 2009-9-9 16:26 http://www.autoitx.com/images/common/back.gif
{:3_90:} 哦也~就是这样的效果!不过你的那种方式我也保留了!以后我研究其他功能~谢谢afan 大哥!!也谢谢大绯狼大哥~感谢你们的细心指导
页:
[1]