找回密码
 加入
搜索
查看: 2340|回复: 0

[GUI管理] 如何获取复选框选中行的数据,记录下来?

[复制链接]
发表于 2013-1-8 12:46:40 | 显示全部楼层 |阅读模式

点击核准的时候,如何获取复选框选中行的数据(因为要更新这些数据),获取每行日期,工号,时间起,时间止的数据(因为在update的时候当为条件)!!!是否简单做个范例!
因是数据库操作,代码贴出来也无法使用!请大家谅解,请自行更改一下!
$Form1 = GuiCreate('虹華加班簽核', 1100,600, -1, -1)
$ListView1 = GUICtrlCreateListView("日期|工號|姓名|部門|時間起|時間止|加班時數", 110, 3, 988,560)
;GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES,$LVS_EX_GRIDLINES))
GUICtrlSetBkColor($ListView1,0xFFBBFF)
GUICtrlSendMsg(-1, 0x101E, 0, 100) ;设置项目宽度
GUICtrlSendMsg(-1, 0x101E, 1, 100) ;设置项目宽度
GUICtrlSendMsg(-1, 0x101E, 2, 100) ;设置项目宽度
GUICtrlSendMsg(-1, 0x101E, 3, 100) ;设置项目宽度
GUICtrlSendMsg(-1, 0x101E, 4, 100) ;设置项目宽度
GUICtrlSendMsg(-1, 0x101E, 5, 100) ;设置项目宽度
GUICtrlSendMsg(-1, 0x101E, 6, 80) ;设置项目宽度
$Button1 = GUICtrlCreateButton('查詢', 30, 252, 60, 30)
$Button2 = GUICtrlCreateButton('簽核', 30, 292, 60, 30)
GUICtrlSetColor(-1,0xFF0000)
$Button3 = GUICtrlCreateButton("全選", 110, 565, 30, 30)
$Button4 = GUICtrlCreateButton("反選", 142, 565, 30, 30)
GuiSetState(@SW_SHOW)
; 顯示視窗

While 1
        
        Switch GUIGetMsg()
 
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $RS.open ("SELECT COUNT(*) FROM cqg_file Where cqg03=TODAY-1");
                        
                        While (Not $RS.eof And Not $RS.bof);
                                $P=$RS.Fields(0).value
                                $RS.movenext;
                        WEnd;
                        $RS.close;
 
                        
                        Dim $APP[$P][7]
                        
                        
                        $i=0 
            ;            $iTimer = TimerInit()
                        $RS.open ("SELECT  cqg03,cqg02,cpf02,gem02,cqg08,cqg09,cqg10 FROM cqg_file,cpf_file,gem_file Where cqg03=TODAY-1 and cpf01=cqg02 and gem01=cqg15");
                        
                        While (Not $RS.eof And Not $RS.bof);
                                                        $name3 = $RS.Fields(2).value
                                                        $dep   = $RS.Fields(3).value
                                                        $date2 = $RS.Fields(0).value
                                                        ;Local $c3   = StringLeft ( $str1,4 )&"/"&StringMid( $str1, 5,2 )&"/"&StringMid( $str1, 7,2 )&"-"&$time1
                                                Local $c4   = StringLeft ( $date2,4 )&"-"&StringMid( $date2, 5,2 )&"-"&StringMid( $date2, 7,2 )
                                                        If @OSLang = '0804' Then
                                                        $name3 = _WinAPI_MultiByteToWideChar($name3, 950, $MB_COMPOSITE, False);转为繁体中文
                                    $name3 = _WinAPI_WideCharToMultiByte($name3, 936);转为GBK繁体中文 
                                    $dep = _WinAPI_MultiByteToWideChar($dep, 950, $MB_COMPOSITE, False);转为繁体中文
                                    $dep = _WinAPI_WideCharToMultiByte($dep, 936);转为GBK繁体中文 
                                                        EndIf
                                                ;                $APP[$i][0]=''
                                $APP[$i][0]=$c4
                                $APP[$i][1]=$RS.Fields(1).value
                                $APP[$i][2]=$name3
                                $APP[$i][3]=$dep
                                $APP[$i][4]=$RS.Fields(4).value
                                $APP[$i][5]=$RS.Fields(5).value
                                $APP[$i][6]=$RS.Fields(6).value
                                
                                $i=$i+1
                                
                                ;GUICtrlSetState($SETDATA,$GUI_ENABLE)
                                $RS.movenext;
                        WEnd;
                        $RS.close;
 
                        
                
                        _GUICtrlListView_AddArray($ListView1, $APP)
                        
                ;   MsgBox(4160, "Information", "Load time: " & TimerDiff($iTimer) / 1000 & " seconds")
                            Case $Button2
                                     $check_box = MsgBox(4,"提示","是否將選中資料核准")
                                                If $check_box = 6 Then 

                                                EndIf
                        Case $Button3
                  _GUICtrlListView_SetItemChecked($ListView1, -1)     
                                Case $Button4
                                            For $i = 0 To _GUICtrlListView_GetItemCount($ListView1) - 1
                                If  _GUICtrlListView_GetItemChecked($ListView1, $i) Then
                                                                        _GUICtrlListView_SetItemChecked($ListView1, $i, False)
                                Else
                                                                        _GUICtrlListView_SetItemChecked($ListView1, $i, True)
                                EndIf
                                                        Next

        EndSwitch
 
WEnd
EndFunc

本帖子中包含更多资源

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

×
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-18 16:16 , Processed in 0.071722 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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