找回密码
 加入
搜索
查看: 13410|回复: 21

[交流] db数据库实例,求事例

 火.. [复制链接]
发表于 2014-6-15 15:02:36 | 显示全部楼层 |阅读模式
本帖最后由 qsy666888 于 2014-6-16 08:55 编辑

各位高手,求db数据库事例。谢谢
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#Include <GuiListView.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
Opt("GUIOnEventMode", 1)
Global $main,$ListView1,$xierusjk,$Group1,$Label1,$Label2,$Input1,$Input2,$Button1,$hQuery,$aRow,$Temp, $a, $b
$SQLite_Data_Path = "SQLite.db"
_SQLite_Startup () ;加载 SQLite.dll
If Not FileExists($SQLite_Data_Path) Then
    SQLCreate()
EndIf
main()
Func main()
$main = GUICreate("数据库实例", 588, 361)
GUISetOnEvent($GUI_EVENT_CLOSE, "mainClose")
$ListView1 = GUICtrlCreateListView("序号|日期|名称", 6, 8, 574, 345)
Local $tj = GUICtrlCreateMenuItem("写入数据库...", $buttoncontext)
GUICtrlSetOnEvent($tj, "xieru")
GUISetState(@SW_SHOW)
EndFunc
While 1
        Sleep(250)
WEnd

Func mainClose()
        Exit
EndFunc

Func xieru()
$xierusjk = GUICreate("写入数据库", 202, 161)
GUISetFont(11, 400, 0, "宋体")
GUISetOnEvent($GUI_EVENT_CLOSE, "xieruClose")
$Group1 = GUICtrlCreateGroup("写入数据库", 9, 8, 186, 144)
$Label1 = GUICtrlCreateLabel("日期:", 18, 40, 49, 19)
$Label2 = GUICtrlCreateLabel("名称:", 17, 80, 49, 19)
$Input1 = GUICtrlCreateInput("", 64, 35, 121, 23)
$Input2 = GUICtrlCreateInput("", 65, 75, 121, 23)
$Button1 = GUICtrlCreateButton("确 定", 105, 112, 75, 25)
GUICtrlSetOnEvent($Button1, "queding")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
EndFunc
Func xieruClose()
    GUIDelete($xierusjk)
EndFunc
Func SQLCreate()
        _SQLite_Open ($SQLite_Data_Path);创建数据库
        _SQLite_Exec(-1, "Create Table IF NOT Exists TestTable (序列 Text PRIMARY KEY, 日期 Text(100), 名称 Text(100), Age Text);");建表
        _SQLite_Close ()
EndFunc

Func queding()
  
EndFunc

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2014-6-15 15:27:02 | 显示全部楼层
回复 1# qsy666888

是没头绪还是没有试试
 楼主| 发表于 2014-6-15 15:55:55 | 显示全部楼层
回复 2# chzj589

是没头绪
发表于 2014-6-15 18:35:02 | 显示全部楼层
搜索论坛帖子
 楼主| 发表于 2014-6-15 18:53:48 | 显示全部楼层
回复 4# joyran

找了,Data Base数据库的例子很少,有这样的例子基本上都不能正常运行(不知是不是我版本的问题,换了好几个版本都不能正常运行)
发表于 2014-6-15 21:38:45 | 显示全部楼层
mdb要不要?
 楼主| 发表于 2014-6-15 21:46:34 | 显示全部楼层
回复 6# xms77
mdb的我有,想要db的例子,谢谢
发表于 2014-6-15 22:01:51 | 显示全部楼层
回复 7# qsy666888
那就不能帮到你了。
 楼主| 发表于 2014-6-15 22:11:00 | 显示全部楼层
回复 8# xms77

谢谢你的回复
发表于 2014-6-16 08:44:46 | 显示全部楼层
回复 1# qsy666888


    有两个问题想问下 1 你的那个数据库实例的这几个字是怎么居中的 2 如何设置不同的背景色?
 楼主| 发表于 2014-6-16 08:50:12 | 显示全部楼层
回复 10# cumtljj
没有设置,是系统版本问题
发表于 2014-6-16 17:10:49 | 显示全部楼层
;===================函数解析文件===========
#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 <GUIListBox.au3>
#Include <GuiListView.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <file.au3>
#include <Base64.au3>
Opt('MustDeclareVars', 1)
Opt("GUICloseOnESC", 0)
;====================数据库自定义函数==========
Global $SQLData,$SQLData1
;====================读取数据库自定义函数==========
Global $hQuery,$aRow
;====================写入数据库自定义函数==========
Global $aRow,$Temp
;====================删除数据库自定义函数==========
Global $ret,$ret1
;====================搜索数据库自定义函数==========
Global $aRow1,$Temp1
;====================显示数据库自定义函数==========
Global $Form4,$ret4,$aRow3,$Temp3,$nMsg3
Global $H1,$H2,$H3,$H4,$H5,$H6,$H7,$H8,$H9,$H10,$H11,$H12,$H13,$H14,$H15,$H16,$H17,$H18,$H19
;====================修改数据库自定义函数==========
Global $ret3,$var1,$aRow2,$Temp2,$Form3,$nMsg2
Global $B0,$B1,$B2,$B3,$B4,$B5,$B6,$B7,$B8,$B9,$B10,$B11,$B12,$B13,$B14,$B15,$B16,$B17,$B18
Global $K1,$K2,$K3,$K4,$K5,$K6,$K7,$K8,$K9,$K10,$K11,$K12,$K13,$K14,$K15,$K16
;====================增加数据库自定义函数==========
Global $Form2,$X0,$X1,$X2,$X3,$X4,$X5,$X6,$X7,$X8,$X9,$X10,$X11,$X12,$X13,$X14,$X15,$X16,$X17,$X18,$X19,$X20,$nMsg1
Global $C1,$C2,$C3,$C4,$C5,$C6,$C7,$C8,$C9,$C10,$C11,$C12,$C13,$C14,$C15,$C16,$var,$ini2,$ini3
;====================GUI主界面自定义函数==========
Global $Form1,$Input1,$Button1,$Button2,$Button3,$Button4,$Button5,$StatusBar1,$Combo1,$nMsg,$ListView1
Global $Q1,$Q2,$Q3,$Q4,$Q5,$Q6,$Q7,$Q8,$Q9,$Q0
;====================管理界面自定义函数==========
Global $Form5,$nMsg4,$ListView2,$ini,$ini1,$ini4,$ini5,$var2,$var3,$var4,$var5
Global $U1,$U2,$U3,$U4,$U5,$U6,$U7,$U8,$U9,$U10,$U11,$U12,$U13,$U14,$U15,$U16,$U17,$U18,$U19,$U20,$U21,$U22,$U23

;====================创建数据文件(DATA.DB)======
$SQLData = "DATA.DB"
$SQLData1 = "user.DB"
_SQLite_Startup ()                         ;加载 SQLite.dll文件信息
If Not FileExists($SQLData) Then
    SQLCreate()                                ;自动创建数据库 DATA.DB 文件
EndIf
If Not FileExists($SQLData1) Then
    SQLCreate1()                        ;自动创建数据库 USER.DB 文件
EndIf

;====================运行程序开始==========
GUI1()                        ;----主界面


;====================GUI主界面=============
Func GUI1()
$Form1 = GUICreate("员工列表", 796, 459, -1,-1)
$ListView1 = GUICtrlCreateListView("", 0, 0, 794, 398,0x0010)
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
_GUICtrlListView_AddColumn($ListView1, "ID", 40, 0)
_GUICtrlListView_AddColumn($ListView1, "姓名", 70, 1)
_GUICtrlListView_AddColumn($ListView1, "性别", 40, 2)
_GUICtrlListView_AddColumn($ListView1, "年龄", 40, 3)
_GUICtrlListView_AddColumn($ListView1, "联系电话", 100, 4)
_GUICtrlListView_AddColumn($ListView1, "QQ号吗", 70, 5)
_GUICtrlListView_AddColumn($ListView1, "单位职称", 80, 6)
_GUICtrlListView_AddColumn($ListView1, "身份证号", 110, 7)
_GUICtrlListView_AddColumn($ListView1, "网吧名称", 120, 8)
_GUICtrlListView_AddColumn($ListView1, "录入时间", 100, 9)
GUICtrlCreateLabel("查找的员工:", 13, 414, 76, 17)
$Input1 = GUICtrlCreateInput("Input1", 88, 410, 89, 21)
$Combo1 = GUICtrlCreateCombo("按ID", 192, 410, 113, 25,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData($Combo1, "按姓名|按所在网吧|按身份证")
$Button1 = GUICtrlCreateButton("搜索", 320, 408, 75, 25, 0)
$Button2 = GUICtrlCreateButton("刷新", 416, 408, 75, 25, 0)
$Button3 = GUICtrlCreateButton("上传数据", 512, 408, 75, 25, 0)
$Button4 = GUICtrlCreateButton("管理", 608, 408, 75, 25, 0)
$Button5 = GUICtrlCreateButton("退出", 704, 408, 75, 25, 0)
$Q1 = GUICtrlCreateContextMenu($ListView1)
$Q2 = GUICtrlCreateMenuItem("修改员工数据", $Q1)
$Q3 = GUICtrlCreateMenuItem("增加员工数据", $Q1)
$Q4 = GUICtrlCreateMenuItem("删除员工数据", $Q1)
$Q5 = GUICtrlCreateMenuItem("显示员工数据", $Q1)
SQLiteRead()
DZ()
GUISetState(@SW_SHOW,$Form1)

While 1
$nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        _SQLite_Close ()
                        Exit
                
                Case $Button1                                ;搜索员工列表
                        SQLiteSelect(GUICtrlRead ($Input1),GUICtrlRead ($Combo1))

                Case $Button2                                ;刷新数据库
                        SQLiteRead()
                        DZ()

                Case $Button4                                ;管理界面GUI5
                        GUI5()
                
                Case $Button5                                ;退出脚本
                        _SQLite_Close ()
                        Exit
                
                Case $Q2                                ;修改员工列表
                        $ret3 = _GUICtrlListView_GetItemText($listview1, _GUICtrlListView_GetSelectionMark($listview1),1)
                        GUI3($ret3)

                Case $Q3                                ;增加员工列表
                        GUI2()


                Case $Q4                                ;删除员工列表        
                        $ret = _GUICtrlListView_GetItemText($listview1, _GUICtrlListView_GetSelectionMark($listview1),1)
                        if $ret = "" Then 
                                MsgBox(32, "提示", "请先选者要删除的员工...")
                        Else
                        $ret1 = MsgBox(2621444527828, "提示", "确定要删除 〖"&$ret&"〗 员工吗?")
                        if $ret1 = 6 Then
                                FileDelete(@ScriptDir &"\照片"&$ret&".jpg")
                                SQLiteDelete($ret)
                        Endif
                        Endif

                Case $Q5                                ;修改员工列表
                        $ret4 = _GUICtrlListView_GetItemText($listview1, _GUICtrlListView_GetSelectionMark($listview1),1)
                        GUI4($ret4)

        EndSwitch
WEnd
EndFunc

;====================管理员控制面板=============
Func GUI5()
$Form5 = GUICreate("管理账号设置", 611, 330, 211, 150)
GUICtrlCreateGroup("经理用户设置", 0, 0, 337, 177)
$U1 = GUICtrlCreateButton("增加用户", 252, 23, 75, 25, 0)
$U2 = GUICtrlCreateButton("编辑用户", 252, 62, 75, 25, 0)
$U3 = GUICtrlCreateButton("删除用户", 252, 101, 75, 25, 0)
$U4 = GUICtrlCreateButton("刷新列表", 252, 140, 75, 25, 0)
$ListView2 = GUICtrlCreateListView("", 8, 20, 236, 147)
GUICtrlSendMsg($ListView2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
_GUICtrlListView_AddColumn($ListView2, "账号名称", 65, 0)
_GUICtrlListView_AddColumn($ListView2, "账号权限", 75, 1)
_GUICtrlListView_AddColumn($ListView2, "受权账号", 70, 2)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("省份—城市设置", 344, 0, 265, 113)
$U5 = GUICtrlCreateCombo("", 352, 16, 123, 25,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
$ini = IniReadSection(@ScriptDir & "\config.ini", "省份")
If @error Then 
    MsgBox(4096,"提示","未找到相的 config.ini 文件,请检察!")
    Exit
Else
    For $i = 1 To $ini[0][0]
        GUICtrlSetData($U5, $ini[$i][0])
    Next
EndIf
$U6 = GUICtrlCreateCombo("", 482, 16, 118, 25,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
;GUICtrlSetData(-1, "")
$U8 = GUICtrlCreateButton("增加省份", 528, 40, 75, 25, 0)
GUICtrlSetState($U8, $GUI_DISABLE)
$U7 = GUICtrlCreateInput("", 352, 48, 169, 21)
GUICtrlSetState($U7, $GUI_DISABLE)
$U10 = GUICtrlCreateButton("增加城市", 528, 80, 75, 25, 0)
$U9 = GUICtrlCreateInput("Input2", 352, 80, 169, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("网吧员工-职位管理", 344, 120, 265, 97)
$U11 = GUICtrlCreateCombo("董事长", 360, 186, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
$ini4 = IniReadSection(@ScriptDir & "\config.ini", "职位名称")
If @error Then 
    MsgBox(4096,"提示","未找到相的 config.ini 文件,请检察!")
    Exit
Else
    For $i = 1 To $ini4[0][0]
        GUICtrlSetData($U11, $ini4[$i][0])
    Next
EndIf
$U12 = GUICtrlCreateButton("删除职位", 520, 184, 75, 25, 0)
$U13 = GUICtrlCreateButton("增加职位", 520, 144, 75, 25, 0)
$U14 = GUICtrlCreateInput("Input3", 359, 147, 145, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("数据库设置", 0, 184, 337, 137)
$U15 = GUICtrlCreateInput("Input4", 16, 208, 225, 21)
$U16 = GUICtrlCreateButton("浏览", 248, 208, 75, 25, 0)
$U17 = GUICtrlCreateProgress(8, 248, 318, 32)
$U18 = GUICtrlCreateButton("立即备份", 144, 288, 75, 25, 0)
$U19 = GUICtrlCreateButton("恢复备份", 240, 288, 75, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("网吧信息添加", 344, 224, 265, 97)
GUICtrlCreateLabel("请先添写以下增加网吧信息↓", 366, 270, 160, 14)
$U20 = GUICtrlCreateInput("Input5", 360, 288, 169, 21)
$U21 = GUICtrlCreateButton("增 加", 540, 256, 59, 41, 0)
$U22 = GUICtrlCreateCombo("", 360, 244, 169, 25,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
$ini5 = IniReadSection(@ScriptDir & "\config.ini", "网吧信息")
If @error Then 
    MsgBox(4096,"提示","未找到相的 config.ini 文件,请检察!")
    Exit
Else
    For $i = 1 To $ini5[0][0]
        GUICtrlSetData($U22, $ini5[$i][0])
    Next
EndIf
GUISetState(@SW_SHOW,$Form5)
WinSetOnTop($Form5,"", 1)
WinSetState($Form1,"", @SW_DISABLE)

While 1
        $nMsg4 = GUIGetMsg()
        Switch $nMsg4
                Case $GUI_EVENT_CLOSE
                        WinSetState($Form1,"", @SW_ENABLE)
                        WinSetOnTop($Form5,"", 0)
                        Exitloop

                Case $U18
                        if FileExists(GUICtrlRead($U15)) Then
                        $var5 = FileCopy($SQLData,GUICtrlRead($U15),9)
                        $var3 = FileGetSize($SQLData)
                        $var4 = FileGetSize(GUICtrlRead($U15)&"\DATA.db")
                        for $S = 1 To 100
                                  GUICtrlSetData($U17, $S)
                                Sleep(8)
                        Next
                        Else
                        
                        FileCopy($SQLData,@ScriptDir & "\data.bak",9)
                        for $S = 1 To 100
                                  GUICtrlSetData($U17, $S)
                                Sleep(8)
                        Next
                        MsgBox(262208, "提示", "数据库备份成功!【"&$SQLData&"】")
                        Endif

                Case $U16
                        WinSetOnTop($Form5,"", 0)
                        $var2 = FileSelectFolder("请先者备份数据库文件夹...", "")
                        if $var2 = "" Then 
                                GUICtrlSetData($U15, "")
                        Else
                                GUICtrlSetData($U15, $var2&""&@YEAR&@MON&@MDAY&@HOUR&@MIN&"")
                        Endif
                        WinSetOnTop($Form5,"", 1)

                Case $U21                ;增加网吧        
                        IniWrite(@ScriptDir & "\config.ini","网吧信息",GUICtrlRead($U20),"")
                        $ini5 = IniReadSection(@ScriptDir & "\config.ini", "网吧信息")
                        If @error Then 
                                    MsgBox(4096,"提示","未找到相的 config.ini 文件,请检察!")
                                            Exitloop
                        Else
                                    For $i = 1 To $ini5[0][0]
                                GUICtrlSetData($U22, $ini5[$i][0])        
                        Next
                        EndIf
                        MsgBox(262208, "提交", "增加网吧信息成功!【"&GUICtrlRead($U20)&"】")

                Case $U12                ;删除职位
                        IniDelete(@ScriptDir & "\config.ini","职位名称",GUICtrlRead($U11))
                        MsgBox(262208, "提交", "删除职位名称成功!【"&GUICtrlRead($U11)&"】")
                        $ini4 = IniReadSection(@ScriptDir & "\config.ini", "职位名称")
                        If @error Then 
                                    MsgBox(4096,"提示","未找到相的 config.ini 文件,请检察!")
                                            Exitloop
                        Else
                                GUICtrlSetData($U11,"")
                                    For $i = 1 To $ini4[0][0]
                                GUICtrlSetData($U11, $ini4[$i][0])
                                    Next
                        EndIf

                Case $U13                ;增加职位
                        IniWrite(@ScriptDir & "\config.ini","职位名称",GUICtrlRead($U14),"")
                        $ini4 = IniReadSection(@ScriptDir & "\config.ini", "职位名称")
                        If @error Then 
                                    MsgBox(4096,"提示","未找到相的 config.ini 文件,请检察!")
                                            Exitloop
                        Else
                                    For $i = 1 To $ini4[0][0]
                                GUICtrlSetData($U11, $ini4[$i][0])
                                    Next
                        EndIf
                        MsgBox(262208, "提交", "写入职位名称成功!【"&GUICtrlRead($U14)&"】")

                Case $U10                ;增加城市
                        IniWrite(@ScriptDir & "\config.ini",GUICtrlRead($U5),GUICtrlRead($U9),"")
                        MsgBox(262208, "提交", "写入城市成功!【"&GUICtrlRead($U5)&GUICtrlRead($U9)&"】")

                Case $U5
                        $ini1 = IniReadSection(@ScriptDir & "\config.ini", GUICtrlRead($U5))
                        If @error Then 
                                    MsgBox(4096,"提示","未找到相的 config.ini 文件,请检察!")
                                            Exitloop
                        Else
                                GUICtrlSetData($U6, "")
                                    For $i = 1 To $ini1[0][0]
                                        GUICtrlSetData($U6, $ini1[$i][0])
                                    Next
                        EndIf        

        EndSwitch
WEnd
GUISetState(@SW_HIDE ,$Form5)
EndFunc

;====================增加员工列表=============
Func GUI2()
$Form2 = GUICreate("新增加员工表", 514, 383, -1,-1)
GUICtrlCreateGroup("陈氏科技员工信息添加", 3, 4, 505, 177)
GUICtrlCreateLabel("员工姓名:", 11, 33, 64, 17)
$X0 = GUICtrlCreateInput("Input1", 75, 28, 89, 21)
GUICtrlCreateLabel("性别:", 169, 31, 40, 17)
$X1 = GUICtrlCreateCombo("男", 207, 28, 49, 25,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData($X1, "女")
GUICtrlCreateLabel("年龄:", 169, 63, 40, 17)
$X2 = GUICtrlCreateInput("Input2", 207, 60, 49, 21)
GUICtrlCreateLabel("状态:", 169, 95, 40, 17)
$X3 = GUICtrlCreateCombo("在职", 207, 92, 49, 25,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData($X3, "离职|其它")
$X4 = GUICtrlCreatePic(@ScriptDir &"\照片\XX.jpg", 411, 20, 84, 100)
GUICtrlCreateLabel("联系电话:", 11, 65, 64, 17)
$X5 = GUICtrlCreateInput("Input3", 75, 60, 89, 21)
GUICtrlCreateLabel("QQ号码:", 262, 31, 56, 17)
$X6 = GUICtrlCreateInput("Input4", 315, 28, 81, 21)
GUICtrlCreateLabel("身份正号:", 11, 97, 64, 17)
$X7 = GUICtrlCreateInput("Input5", 75, 92, 89, 21)
GUICtrlCreateLabel("  职位:", 262, 63, 52, 17)
$X8 = GUICtrlCreateCombo("技术员", 315, 60, 81, 25,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlCreateLabel("家庭住址:", 11, 129, 64, 17)
$X9 = GUICtrlCreateCombo("浙江省", 75, 124, 73, 25,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
$ini2 = IniReadSection(@ScriptDir & "\config.ini", "省份")
If @error Then 
            MsgBox(4096,"提示","未找到相的 config.ini 文件,请检察!")
Else
For $i = 1 To $ini2[0][0]
              GUICtrlSetData($X9, $ini2[$i][0])
            Next
EndIf        
$X10 = GUICtrlCreateCombo("", 155, 124, 73, 25,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
$X11 = GUICtrlCreateInput("Input6", 235, 124, 161, 21)
$X12 = GUICtrlCreateButton("《更换照片》", 412, 138, 83, 25, 0)
GUICtrlCreateLabel("录入时间:", 11, 157, 64, 17)
$X13 = GUICtrlCreateDate("2009/10/04 17:41:10", 75, 153, 114, 21)
GUICtrlCreateLabel("员工编号:", 260, 92, 64, 17)
$X14 = GUICtrlCreateInput("Input7", 323, 89, 73, 21)
GUICtrlCreateLabel("网吧名称:", 211, 157, 64, 17)
$X15 = GUICtrlCreateInput("Input8", 275, 153, 121, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("工作简历", 3, 188, 505, 153)
$X16 = GUICtrlCreateEdit("", 11, 212, 489, 113, BitOR($ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, "edit")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$X17 = GUICtrlCreateButton("提交", 327, 348, 67, 25, 0)
$X18 = GUICtrlCreateButton("取消", 426, 348, 67, 25, 0)
GUISetState(@SW_SHOW,$Form2)
WinSetOnTop($Form2,"", 1)
WinSetState($Form1,"", @SW_DISABLE)

While 1
$nMsg1 = GUIGetMsg()
        Switch $nMsg1
                Case $GUI_EVENT_CLOSE
                        WinSetState($Form1,"", @SW_ENABLE)
                        WinSetOnTop($Form2,"", 0)
                        ExitLoop

                Case $X9
                        $ini3 = IniReadSection(@ScriptDir & "\config.ini", GUICtrlRead($X9))
                        If @error Then 
                                    MsgBox(4096,"提示","未找到相的 config.ini 文件,请检察!")
                                            Exitloop
                        Else
                                GUICtrlSetData($X10, "")
                                For $i = 1 To $ini3[0][0]
                                              GUICtrlSetData($X10, $ini3[$i][0])
                                    Next
                        EndIf
                
                Case $X17
                        $C1 = GUICtrlRead($X0)                ;员工姓名
                        $C2 = GUICtrlRead($X1)                ;性别
                        $C3 = GUICtrlRead($X2)                ;年龄
                        $C4 = GUICtrlRead($X3)                ;状态
                        $C5 = GUICtrlRead($X5)                ;联系电话
                        $C6 = GUICtrlRead($X6)                ;QQ号码
                        $C7 = GUICtrlRead($X7)                ;身份正号
                        $C8 = GUICtrlRead($X8)                ;职位
                        $C9 = GUICtrlRead($X9)                ;家庭住址
                        $C10 = GUICtrlRead($X10)        ;家庭住址
                        $C11 = GUICtrlRead($X11)        ;家庭住址
                        $C12 = GUICtrlRead($X4)                ;更换照片
                        $C13 = GUICtrlRead($X13)        ;录入时间
                        $C14 = GUICtrlRead($X14)        ;员工编号
                        $C15 = GUICtrlRead($X15)        ;网吧名称
                        $C16 = GUICtrlRead($X16)        ;工作简历
                        SQLiteInsert($C14,$C1,$C2,$C3,$C4,$C5,$C6,$C7,$C8,$C9,$C10,$C11,$C13,$C15,$C16)
                        SQLiteRead()
                        DZ()
                        WinSetState($Form1,"", @SW_ENABLE)
                        WinSetOnTop($Form2,"", 0)
                        ExitLoop

                Case $X18
                        WinSetState($Form1,"", @SW_ENABLE)
                        WinSetOnTop($Form2,"", 0)
                        ExitLoop

                Case $X12
                        WinSetOnTop($Form2,"", 0)
                        $var = FileOpenDialog("", @WindowsDir & "", "Images (*.jpg)", 1 + 4 )
                        WinSetOnTop($var,"", 1)
                        if FileExists($var) Then 
                                FileCopy($var,@ScriptDir &"\照片"&GUICtrlRead ($X0)&".jpg",1)
                        Endif
                        WinSetOnTop($var,"", 0)
                        WinSetOnTop($Form2,"", 1)

        EndSwitch
WEnd
GUISetState(@SW_HIDE ,$Form2)
EndFunc

;====================修改员工列表=============
Func GUI3($Z3)
_SQLite_Open ($SQLData)
_SQLite_QuerySingleRow(-1, "SELECT * FROM TestTable WHERE xinm = '" & $Z3 & "';", $aRow2)
$Temp2 = $aRow2[0]
If $Temp2 = "" Then
        MsgBox(262208, "显示结果...", "未选用户修改详细信息失败,请重新选者!")
Else
$Form3 = GUICreate("修改加员工表", 514, 383, -1,-1)
GUICtrlCreateGroup("陈氏科技员工信息修改", 3, 4, 505, 177)
GUICtrlCreateLabel("员工姓名:", 11, 33, 64, 17)
$B0 = GUICtrlCreateInput($aRow2[1], 75, 28, 89, 21)
GUICtrlCreateLabel("性别:", 169, 31, 40, 17)
$B1 = GUICtrlCreateCombo($aRow2[2], 207, 28, 49, 25,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData($B1, "男|女")
GUICtrlCreateLabel("年龄:", 169, 63, 40, 17)
$B2 = GUICtrlCreateInput($aRow2[3], 207, 60, 49, 21)
GUICtrlCreateLabel("状态:", 169, 95, 40, 17)
$B3 = GUICtrlCreateCombo($aRow2[4], 207, 92, 49, 25,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData($B3, "在职|离职|其它")
$B4 = GUICtrlCreatePic(@ScriptDir &"\照片"&$aRow2[1]&".jpg", 411, 20, 84, 100)
GUICtrlCreateLabel("联系电话:", 11, 65, 64, 17)
$B5 = GUICtrlCreateInput($aRow2[5], 75, 60, 89, 21)
GUICtrlCreateLabel("QQ号码:", 262, 31, 56, 17)
$B6 = GUICtrlCreateInput($aRow2[6], 315, 28, 81, 21)
GUICtrlCreateLabel("身份正号:", 11, 97, 64, 17)
$B7 = GUICtrlCreateInput($aRow2[7], 75, 92, 89, 21)
GUICtrlCreateLabel("  职位:", 262, 63, 52, 17)
$B8 = GUICtrlCreateCombo($aRow2[8], 315, 60, 81, 25,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlCreateLabel("家庭住址:", 11, 129, 64, 17)
$B11 = GUICtrlCreateInput($aRow2[9], 75, 124, 321, 21)
$B12 = GUICtrlCreateButton("《更换照片》", 412, 138, 83, 25, 0)
GUICtrlCreateLabel("录入时间:", 11, 157, 64, 17)
$B13 = GUICtrlCreateDate($aRow2[10], 75, 153, 114, 21)
GUICtrlCreateLabel("员工编号:", 260, 92, 64, 17)
$B14 = GUICtrlCreateInput($aRow2[0], 323, 89, 73, 21)
GUICtrlCreateLabel("网吧名称:", 211, 157, 64, 17)
$B15 = GUICtrlCreateInput($aRow2[11], 275, 153, 121, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("工作简历", 3, 188, 505, 153)
$B16 = GUICtrlCreateEdit("", 11, 212, 489, 113, BitOR($ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, $aRow2[12])
GUICtrlCreateGroup("", -99, -99, 1, 1)
$B17 = GUICtrlCreateButton("提交", 327, 348, 67, 25, 0)
$B18 = GUICtrlCreateButton("取消", 426, 348, 67, 25, 0)
GUISetState(@SW_SHOW,$Form3)
WinSetOnTop($Form3,"", 3)
WinSetState($Form1,"", @SW_DISABLE)

While 1
$nMsg2 = GUIGetMsg()
        Switch $nMsg2
                Case $GUI_EVENT_CLOSE
                        WinSetState($Form1,"", @SW_ENABLE)
                        WinSetOnTop($Form3,"", 0)
                        ExitLoop
                
                Case $B17
                        $K1 = GUICtrlRead($B0)                ;员工姓名
                        $K2 = GUICtrlRead($B1)                ;性别
                        $K3 = GUICtrlRead($B2)                ;年龄
                        $K4 = GUICtrlRead($B3)                ;状态
                        $K5 = GUICtrlRead($B5)                ;联系电话
                        $K6 = GUICtrlRead($B6)                ;QQ号码
                        $K7 = GUICtrlRead($B7)                ;身份正号
                        $K8 = GUICtrlRead($B8)                ;职位
                        $K9 = ""
                        $K10 = ""
                        $K11 = GUICtrlRead($B11)        ;家庭住址
                        $K12 = GUICtrlRead($B4)                ;更换照片
                        $K13 = GUICtrlRead($B13)        ;录入时间
                        $K14 = GUICtrlRead($B14)        ;员工编号
                        $K15 = GUICtrlRead($B15)        ;网吧名称
                        $K16 = GUICtrlRead($B16)        ;工作简历
                        SQLiteInsert($K14,$K1,$K2,$K3,$K4,$K5,$K6,$K7,$K8,$K9,$K10,$K11,$K13,$K15,$K16)
                        SQLiteRead()
                        DZ()
                        WinSetState($Form1,"", @SW_ENABLE)
                        WinSetOnTop($Form3,"", 0)
                        ExitLoop

                Case $B18
                        WinSetState($Form1,"", @SW_ENABLE)
                        WinSetOnTop($Form3,"", 0)
                        ExitLoop

                Case $B12
                        WinSetOnTop($Form3,"", 0)
                        $var1 = FileOpenDialog("", @ScriptDir &"","Images (*.jpg)", 1 + 4 )
                        WinSetOnTop($var1,"", 1)
                        if FileExists($var1) Then 
                                FileCopy($var1,@ScriptDir &"\照片"&GUICtrlRead ($B0)&".jpg",1)
                        Endif
                        WinSetOnTop($var,"", 0)
                        WinSetOnTop($Form3,"", 1)

        EndSwitch
WEnd
GUISetState(@SW_HIDE ,$Form3)
Endif
EndFunc

;====================显示员工列表信息=============
Func GUI4($Z4)
_SQLite_Open ($SQLData)
_SQLite_QuerySingleRow(-1, "SELECT * FROM TestTable WHERE xinm = '" & $Z4 & "';", $aRow3)
$Temp3 = $aRow3[0]
If $Temp3 = "" Then
        MsgBox(262208, "显示结果...", "未选用户显示详细信息失败,请重新选者!")
Else
$Form4 = GUICreate("显示用户详细信息", 514, 383, -1,-1)
GUICtrlCreateGroup("陈氏科技员工信息添加", 3, 4, 505, 177)
GUICtrlCreateLabel("员工姓名:", 11, 33, 64, 17)
$H1 = GUICtrlCreateInput($aRow3[1], 75, 28, 89, 21)
GUICtrlCreateLabel("性别:", 169, 31, 40, 17)
$H2 = GUICtrlCreateInput($aRow3[2], 207, 32, 49, 21)
GUICtrlCreateLabel("年龄:", 169, 63, 40, 17)
$H3 = GUICtrlCreateInput($aRow3[3], 207, 60, 49, 21)
GUICtrlCreateLabel("状态:", 169, 95, 40, 17)
$H4 = GUICtrlCreateInput($aRow3[4], 207, 92, 49, 21)
$H5 = GUICtrlCreatePic(@ScriptDir &"\照片"&$aRow3[1]&".jpg", 408, 45, 90, 95)
GUICtrlCreateLabel("联系电话:", 11, 65, 64, 17)
$H6 = GUICtrlCreateInput($aRow3[5], 75, 60, 89, 21)
GUICtrlCreateLabel("QQ号码:", 272, 31, 56, 17)
$H7 = GUICtrlCreateInput($aRow3[6], 324, 28, 75, 21)
GUICtrlCreateLabel("身份正号:", 11, 97, 64, 17)
$H8 = GUICtrlCreateInput($aRow3[7], 75, 92, 89, 21)
GUICtrlCreateLabel("在职位:", 272, 63, 52, 17)
$H9 = GUICtrlCreateInput($aRow3[8], 324, 56, 75, 21)
GUICtrlCreateLabel("家庭住址:", 11, 129, 64, 17)
$H10 = GUICtrlCreateInput($aRow3[9], 75, 124, 324, 21)
GUICtrlCreateLabel("员工编号:", 260, 92, 64, 17)
$H11 = GUICtrlCreateInput($aRow3[0], 323, 89, 76, 21)
GUICtrlCreateLabel("网吧名称:", 211, 157, 64, 17)
$H12 = GUICtrlCreateInput($aRow3[11], 275, 153, 124, 21)
GUICtrlCreateLabel("录入时间:", 11, 157, 64, 17)
$H13 = GUICtrlCreateInput($aRow3[13], 76, 152, 124, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("工作简", 3, 188, 505, 153)
$H14 = GUICtrlCreateEdit("", 11, 212, 489, 113, BitOR($ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, $aRow3[12])
GUICtrlCreateGroup("", -99, -99, 1, 1)
$H15 = GUICtrlCreateButton("确 定", 407, 348, 83, 25, 0)
GUISetState(@SW_SHOW,$Form4)
WinSetState($Form1,"", @SW_DISABLE)
WinSetOnTop($Form4,"", 1)

While 1
$nMsg3 = GUIGetMsg()
        Switch $nMsg3
                Case $GUI_EVENT_CLOSE
                        WinSetState($Form1,"", @SW_ENABLE)
                        WinSetOnTop($Form4,"", 0)
                        ExitLoop

                Case $H15
                        WinSetState($Form1,"", @SW_ENABLE)
                        WinSetOnTop($Form4,"", 0)
                        Exitloop

        EndSwitch
WEnd
GUISetState(@SW_HIDE ,$Form4)
Endif
EndFunc

;===============GUI主界面低下信息================
Func DZ()
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
Dim $StatusBar1_PartsWidth[5] = [140, 310, 460, 580, 680]
_GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth)
_GUICtrlStatusBar_SetText($StatusBar1, "数据库中共有条目:"&_GUICtrlListView_GetItemCount ($ListView1)&" 条", 0)
_GUICtrlStatusBar_SetText($StatusBar1, "当前操作状态:普通经理", 1)
_GUICtrlStatusBar_SetText($StatusBar1, "所属网吧:阳光网吧", 2)
_GUICtrlStatusBar_SetText($StatusBar1, "公司:陈氏集团", 3)
_GUICtrlStatusBar_SetText($StatusBar1, "作者:F4 李文杨  联系QQ:43149247", 4)
EndFunc
;===============以下是SQL数据库操作======================
;---------------读取所有SQL数据里的信息-----------
Func SQLiteRead()
        _GUICtrlListView_DeleteAllItems ( GUICtrlGetHandle ($ListView1) )
            _SQLite_Open ($SQLData)
           _SQLite_Query(-1, "SELECT * FROM TestTable ORDER BY IDs DESC;",$hQuery)
        While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
        _GUICtrlListView_AddItem($ListView1, $aRow[0])
        _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow[0]), $aRow[1], 1)
        _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow[0]), $aRow[2], 2)
        _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow[0]), $aRow[3], 3)
        _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow[0]), $aRow[5], 4)
        _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow[0]), $aRow[6], 5)
        _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow[0]), $aRow[8], 6)
        _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow[0]), $aRow[7], 7)
        _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow[0]), $aRow[11], 8)
        _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow[0]), $aRow[13], 9)
    WEnd
            _SQLite_Close ()
EndFunc

;--------------创建SQL数据库文件(DATA.DB)---------
Func SQLCreate()
    _SQLite_Open ($SQLData)
    _SQLite_Exec(-1, "Create Table IF NOT Exists TestTable (IDs Text PRIMARY KEY, xinm Text, xinbei Text, nianl Text, zhuant Text, dianh Text, QQhanm Text, shengfz Text, zhiw Text, xiangxdz Text, yuanGID Text, wangb Text, gerjl Txet, lursj Txet);")
    _SQLite_Close ()
EndFunc

;--------------创建SQL数据库文件(USER.DB)---------
Func SQLCreate1()
    _SQLite_Open ($SQLData1)
    _SQLite_Exec(-1, "Create Table IF NOT Exists TestTable (IDs Text PRIMARY KEY, YongHshij Text, MinmShiJ Text);")
    _SQLite_Close ()
EndFunc

;--------------写入SQL数据库信息---------------
Func SQLiteInsert($S1,$S2,$S3,$S4,$S5,$S6,$S7,$S8,$S9,$S10,$S11,$S12,$S14,$S15,$S16)
            _SQLite_Open ($SQLData)
            _SQLite_QuerySingleRow(-1, "SELECT IDs FROM TestTable WHERE IDs = '" & $S1 & "';", $aRow)
            $Temp = $aRow[0]
                If $Temp = "" Then
                        _SQLite_Exec(-1, "Insert into TestTable (IDs) values ('" & $S1 & "');")
                EndIf        
                        _SQLite_Exec(-1, "UPDATE TestTable SET xinm = '" & $S2 & "' WHERE IDs = '" & $S1 & "';")
                        _SQLite_Exec(-1, "UPDATE TestTable SET xinbei = '" & $S3 & "' WHERE IDs = '" & $S1 & "';")
                        _SQLite_Exec(-1, "UPDATE TestTable SET nianl = '" & $S4 & "' WHERE IDs = '" & $S1 & "';")
                        _SQLite_Exec(-1, "UPDATE TestTable SET zhuant = '" & $S5 & "' WHERE IDs = '" & $S1 & "';")
                        _SQLite_Exec(-1, "UPDATE TestTable SET dianh = '" & $S6 & "' WHERE IDs = '" & $S1 & "';")
                        _SQLite_Exec(-1, "UPDATE TestTable SET QQhanm = '" & $S7 & "' WHERE IDs = '" & $S1 & "';")
                        _SQLite_Exec(-1, "UPDATE TestTable SET shengfz = '" & $S8 & "' WHERE IDs = '" & $S1 & "';")
                        _SQLite_Exec(-1, "UPDATE TestTable SET zhiw = '" & $S9 & "' WHERE IDs = '" & $S1 & "';")
                        _SQLite_Exec(-1, "UPDATE TestTable SET xiangxdz = '" & $S10 & $S11 & $S12 &"' WHERE IDs = '" & $S1 & "';")
                        _SQLite_Exec(-1, "UPDATE TestTable SET wangb = '" & $S15 & "' WHERE IDs = '" & $S1 & "';")
                        _SQLite_Exec(-1, "UPDATE TestTable SET gerjl = '" & $S16 & "' WHERE IDs = '" & $S1 & "';")
                        _SQLite_Exec(-1, "UPDATE TestTable SET lursj = '" & $S14 & "' WHERE IDs = '" & $S1 & "';")
                _SQLite_Close ()
                MsgBox(262208, "提交", "数据提交成功!")
                
EndFunc
;----------------删除SQL数据库信息--------------
Func SQLiteDelete($Z)
    _SQLite_Open ($SQLData)
    _SQLite_Exec(-1, "DELETE FROM  TestTable WHERE xinm = '" & $Z & "';")
    _SQLite_Close ()
    MsgBox(262208, "删除记录...", "删除数据库中姓名为 【" & $Z & "】 的员工记录!")
    SQLiteRead()
    DZ()
EndFunc

;----------------查找SQL数据库------------------
Func SQLiteSelect($Z1,$Z2)
        _SQLite_Open ($SQLData)
        if $Z2 = "按ID" Then 
        _SQLite_QuerySingleRow(-1, "SELECT * FROM TestTable WHERE IDs = '" & $Z1 & "';", $aRow1)
        Endif
        if $Z2 = "按姓名" Then 
        _SQLite_QuerySingleRow(-1, "SELECT * FROM TestTable WHERE xinm = '" & $Z1 & "';", $aRow1)
        Endif
        if $Z2 = "按所在网吧" Then 
        _SQLite_QuerySingleRow(-1, "SELECT * FROM TestTable WHERE wangb = '" & $Z1 & "';", $aRow1)
        Endif
        if $Z2 = "按身份证" Then 
        _SQLite_QuerySingleRow(-1, "SELECT * FROM TestTable WHERE shengfz = '" & $Z1 & "';", $aRow1)
        Endif
        $Temp1 = $aRow1[0]
        If $Temp1 = "" Then
                MsgBox(262208, "查找结果...", "数据库中 [" & $Z1 & "] 的员工相关信息不存在!")
            Else
                _GUICtrlListView_DeleteAllItems ( GUICtrlGetHandle ($ListView1) )
                _GUICtrlListView_AddItem($ListView1, $aRow1[0])
                _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow1[0]), $aRow1[1], 1)
                _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow1[0]), $aRow1[2], 2)
                _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow1[0]), $aRow1[3], 3)
                       _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow1[0]), $aRow1[5], 4)
                _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow1[0]), $aRow1[6], 5)
                _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow1[0]), $aRow1[8], 6)
                _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow1[0]), $aRow1[7], 7)
                _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow1[0]), $aRow1[11], 8)
                _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_FindInText($ListView1, $aRow1[0]), $aRow1[13], 9)
        EndIf
                    _SQLite_Close ()
EndFunc
这个是我很早以前写的!!希望对你有帮助!!上面是打包的源码!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2014-6-16 20:11:06 | 显示全部楼层
回复 12# f4李文杨
谢谢你的帮助
 楼主| 发表于 2014-6-16 20:36:54 | 显示全部楼层
回复 12# f4李文杨
你那序号怎么不是从1开始呢
发表于 2014-6-16 23:58:07 | 显示全部楼层
你可以看一下函数就知道了!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-24 11:14 , Processed in 0.388498 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表