#include <array.au3>
#include <ButtonConstants.au3>
#include <Color.au3>
#include <ColorConstantS.au3>
#include <ComboConstants.au3>
#include <Date.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <Excel.au3>
#include <FileConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIEdit.au3>
#include <GuiImageList.au3>
#include <GUIListBox.au3>
#Include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <ListViewConstants.au3>
#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WinAPIEx.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
Opt("TrayIconHide", 1) ;0 = 顯示托盤圖標, 1 = 隱藏托盤圖標
Opt('MustDeclareVars', 1) ;1 = 變量不需預先聲明, 1 = 變量必需預先聲明
Opt("GUICloseOnESC", 0) ;1 = 點擊 Esc 鍵關閉, 0 = 點擊 Esc 鍵不關閉
Global $Title, $SQLite_Data_Path
Global $GUI_Input1, $GUI_Input2, $GUI_Input3
Global $GUI_COMBO1, $GUI_COMBO2, $GUI_COMBO3, $GUI_COMBO4, $GUI_COMBO5, $GUI_COMBO6
Global $GUI_Button1, $GUI_Button2, $GUI_Button3, $GUI_Button4, $GUI_Button5, $GUI_Button6, $GUI_Button7, $GUI_Button8, $GUI_Button9, _
$GUI_Button10, $GUI_Button11, $GUI_Button12, $GUI_Button13
Global $a, $aRow,$aRow2, $hQuery, $hImage
Global $GUI_Form, $GUI_ListBox , $GUI_ListBox2, $File_Time_Temp, $File_Time
Global $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE) ;設定視窗LISTVIEW變數
Global $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER);項目選中顯示高亮度題示,顯示項目橫列線條,緩衝控鍵顯示
Global $iHeight = 20, $g_idListView , $hEdit;視窗點擊變
Global $Shift = "早班|中班|晚班|正常班"
Global $Service = "AM|CM|PM|其他"
Global $UnitRange = "All|O6|O7|O8|O9|O10|O11|O12|O13|O14|OT1|MD|BSS3|列車|其他"
Global $SystemName = "ART(公共藝術)|CCTV(閉路電視)|CLOCK(子母鐘)|CV(結構腐蝕)|DLTS(直線電話)|" & _
"DPA(機廠廣播)|EPABX(電話及錄音)|GE(寬頻網路)|IAS(門禁)|LSPS(投射螢幕)|LU(邊坡滑動)|" & _
"OSSS(地震警報)|PA(廣播)|PIDS(旅客資訊)|PSS(通訊電源)|RADIO(無線電)|SCADA(中央監控)|" & _
"SDH(數位同步)|WN(風速儀)|R22A防侵入|其他"
Global $Status ="待交接|已到場|待追蹤|待料|已結案"
Global $Ranking = "緊急|重要|一般|其他"
$SQLite_Data_Path = "interfix.sqlite" ;sql資料庫路徑及名稱
$File_Time_Temp = FileGetTime($SQLite_Data_Path, $FT_MODIFIED, 0); 取得檔案最新更新日期
$File_Time = $File_Time_Temp[0] & "-" & $File_Time_Temp[1] & "-" & $File_Time_Temp[2] ;將更新日期陣列重新組合
$Title = "值班交接查詢(For-T2445)....." & "File_Date=" & $File_Time ;標題名稱
_SQLite_Startup ("sqlite3.dll", TRUE, 0) ;加載SQLite3.dll,工作目錄下需有SQLite3.dll 如果沒有就從autoit 網站下載並放入同一目錄下
If @error Then ;如果沒有SQLite3.dll檔案則顯示錯誤訊息
MsgBox($MB_SYSTEMMODAL, "SQLite 錯誤", "SQLite3.dll 不能載入,請檢查SQLite3.dll,SQLite3.def檔案是否存在同一目錄下!")
Exit ;離開程式不執行
EndIf
If Not FileExists($SQLite_Data_Path) Then ;如果無資料庫檔案則執行以下命令
Local $QUERY = MsgBox(1,"錯誤","資料庫無法打開,請檢查""interfix.sqlite""檔是否存在或是檔案已損毀,如要建立新檔請按確定,否則取消。")
If $QUERY = 1 Then
SQLCreate() ;建立新資料庫,參考SQLCreate() 功能,在下面
Exit
Else
Exit ;按下取消紐時,程式不執行
EndIf
EndIf
Func SQLCreate() ;建立資料庫
_SQLite_Open ($SQLite_Data_Path) ;建立資料庫,名稱為$SQLite_Data_Path 變數名稱
_SQLite_Exec(-1, "Create Table IF NOT Exists interfix ( Date Date , Shift TEXT, Service Text, LocaleName Text, " & _
"SystemName Text, Ranking Text, Matter Text, Transact Text, Status Text);") ;建立資料庫內容
;^^以上執行SQL語法建立 BM_Number 資料表,並建立相關欄位等資料內容
_SQLite_Close (-1) ;關閉資料庫
MsgBox(0,"資料庫","資料庫已建立,請重新執行程式")
Exit
EndFunc
$GUI_Form = GUICreate($Title, 750, 480, -1, -1) ;建立主視窗GUI樣式
GUISetBkColor(0xECE9C8) ; 設定視窗背景顏色
$GUI_ListBox = GUICtrlCreateListView(" 日 期 |班 別|勤務別|廠/站| 系 統 |" & _
"急迫性| 追 蹤 事 項 | 處 理 進 度 | 狀 態 ", 2, 2, 746, 230, BitOR($LVS_REPORT, $WS_BORDER), BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT))
_GUICtrlListView_SetExtendedListViewStyle($GUI_ListBox, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
;上面設定ListView內容
GUICtrlCreateLabel("日期:", 10, 250, 36, 15)
$GUI_Input1 = GUICtrlCreateInput("",45,245,80,20,0x0800) ;日期
GUICtrlCreateLabel("班別:", 150, 250, 36, 15)
$GUI_COMBO1 = GUICtrlCreateCombo("", 188, 245, 60, 20,$CBS_DROPDOWNLIST);班別
GUICtrlSetData($GUI_COMBO1, $Shift, "")
GUICtrlCreateLabel("勤務:", 255, 250, 36, 15)
$GUI_COMBO2 = GUICtrlCreateCombo("", 292, 245, 50, 20,$CBS_DROPDOWNLIST);勤務
GUICtrlSetData($GUI_COMBO2, $Service, "")
GUICtrlCreateLabel("廠站:", 350, 250, 36, 15)
$GUI_COMBO3 = GUICtrlCreateCombo("", 387, 245, 50, 20,$CBS_DROPDOWNLIST) ;廠站
GUICtrlSetData($GUI_COMBO3, $UnitRange, "")
GUICtrlCreateLabel("系統:", 445, 250, 36, 15)
$GUI_COMBO4 = GUICtrlCreateCombo("", 482, 245, 130, 20,$CBS_DROPDOWNLIST) ;系統
GUICtrlSetData($GUI_COMBO4, $SystemName, "")
GUICtrlCreateLabel("急迫性:", 640, 250, 50, 15)
$GUI_COMBO5 = GUICtrlCreateCombo("", 690, 245, 50, 20,$CBS_DROPDOWNLIST) ;急迫性
GUICtrlSetData($GUI_COMBO5, $Ranking, "")
GUICtrlCreateLabel("追蹤事項:", 15, 280, 40, 30)
$GUI_Input2 = GUICtrlCreateInput("",60,280,190,190,0x00201044) ;追蹤事項
GUICtrlCreateLabel("處理進度:", 255, 280, 40, 30)
$GUI_Input3 = GUICtrlCreateInput("",300,280,250,190,0x00201044) ;處理進度
GUICtrlCreateLabel("狀態:", 560, 280, 36, 30)
$GUI_COMBO6 = GUICtrlCreateCombo("", 598, 275, 60, 20,$CBS_DROPDOWNLIST) ;狀態
GUICtrlSetData($GUI_COMBO6, $Status, "")
GUICtrlCreateLabel("未結案查詢",580, 310, 60, 17)
GUICtrlCreateLabel("緊急:", 580, 330, 40, 17)
Local $Exigency = GUICtrlCreateLabel("00", 615, 330, 20, 17)
GUICtrlCreateLabel("重要:", 580, 345, 40, 17)
Local $Momentous = GUICtrlCreateLabel("00", 615, 345, 20, 17)
GUICtrlCreateLabel("一般:", 580, 360, 40, 17)
Local $Commonly = GUICtrlCreateLabel("00", 615, 360, 20, 17)
GUICtrlCreateLabel("其他:", 580, 375, 40, 17)
Local $other = GUICtrlCreateLabel("00", 615, 375, 20, 17)
$GUI_Button1 = GUICtrlCreateButton("讀取", 690, 350, 48, 22, 0)
$GUI_Button2 = GUICtrlCreateButton("新增", 690, 375, 48, 22, 0)
$GUI_Button3 = GUICtrlCreateButton("搜尋", 690, 275, 48, 22, 0)
$GUI_Button4 = GUICtrlCreateButton("刪除", 690, 400, 48, 22, 0)
$GUI_Button5 = GUICtrlCreateButton("確定", 560, 435, 48, 22, 0)
$GUI_Button6 = GUICtrlCreateButton("關閉", 690, 435, 48, 22, 0)
$GUI_Button7 = GUICtrlCreateButton("?", 125, 245, 15, 15, 0) ;日期蒐尋
$GUI_Button8 = GUICtrlCreateButton("?", 560, 328, 15, 15, 0) ;未結案緊急工單查詢
$GUI_Button9 = GUICtrlCreateButton("?", 560, 343, 15, 15, 0) ;未結案重要工單查詢
$GUI_Button10 = GUICtrlCreateButton("?", 560, 358, 15, 15, 0) ;未結案一般工單查詢
$GUI_Button11 = GUICtrlCreateButton("?", 560, 308, 15, 15, 0) ;全部未結案工單查詢
$GUI_Button12 = GUICtrlCreateButton("清除欄位", 677, 300, 60, 22, 0) ;清空
$GUI_Button13 = GUICtrlCreateButton("?", 560, 373, 15, 15, 0) ;未結案其他工單
_GUICtrlListView_SetExtendedListViewStyle($GUI_ListBox,$iExListViewStyle) ;將視窗設定風格顯示
$GUI_ListBox = GUICtrlGetHandle($GUI_ListBox) ;回傳控件項目句柄,針對項目雙擊後選擇其它功能
Local $hFont = _WinAPI_CreateFont($iHeight - 5, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, '新細明體') ;建立點擊項目後之顯示方式
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY') ;註冊win消息ID-訊息通知,轉WM_NOTIFY函數處理,用於項目雙擊控制
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') ;註冊win消息ID-訊息命令,轉WM_COMMAND函數處理,用於項目雙擊後,後續處理
_SQLite_Open ($SQLite_Data_Path) ;讀取資料庫,名稱為$SQLite_Data_Path 變數名稱
Update_totall() ;更新未結案筆數
GUISetState(@SW_SHOW,$GUI_Form) ;GUI 顯示
Interfix_data() ;顯示待交接資料
While 1
Switch GUIGetMsg()
Case $GUI_Button1 ;讀取
Read_Data()
Case $GUI_Button2 ;新增
New_Data()
Case $GUI_Button3 ;搜尋
Ambit_query()
Case $GUI_Button4 ;刪除
;SQLiteDelete()
Case $GUI_Button5 ;確定修改
Enter_data()
Case $GUI_EVENT_CLOSE, $GUI_Button6 ;視窗關閉
_SQLite_Close(-1)
_SQLite_Shutdown () ;本程式關閉時shutdown sqlite.dll
ExitLoop
Case $GUI_Button7 ;日期搜尋
DATE()
Case $GUI_Button8 ;未結案緊急工單查詢
Exigency_query()
Case $GUI_Button9 ;未結案重要工單查詢
Momentous_query()
Case $GUI_Button10 ;未結案一般工單查詢
Commonly_query()
Case $GUI_Button11 ;全部未結案工單查詢
All_query()
Case $GUI_Button12
clear_columu()
Case $GUI_Button13
other_columu()
EndSwitch
WEnd
Func Interfix_data() ; 顯示交接資料
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Status) FROM interfix WHERE Status = '待交接' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = int($aRow[0])
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"交接事項","無交接資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Status = '待交接' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
EndFunc
Func DATE() ;日期蒐尋及填入INPUT1欄位
Local $DATETEMP = GUICreate("日期搜尋", 200, 50, -1, -1)
Local $idDate = GUICtrlCreateDate("", 10, 10, 185, 20, $DTS_SHORTDATEFORMAT)
; 選擇特定的默認格式
Local $sStyle = "yyyy-MM-dd"
GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle)
GUISetState(@SW_SHOW)
; 循環到用戶退出.
While 1
SWITCH GUIGetMsg()
Case $GUI_EVENT_CLOSE
GUICtrlSetData($GUI_Input1, GUICtrlRead($idDate))
ExitLoop
EndSwitch
WEnd
GUIDelete($DATETEMP)
EndFunc ;==>Example
Func New_Data() ;新增跳出之視窗
LocaL $Form2 = GUICreate("新增交接資料", 497, 280, -1, -1)
GUICtrlCreateLabel("新增日期:" , 20, 12, 60, 17)
Local $NOWDATETIME=@YEAR & "-" & @MON & "-" &@MDAY
Local $Input1 = GUICtrlCreateInput($NOWDATETIME, 80, 10, 97, 21)
GUICtrlCreateLabel("班別:", 186, 12, 30, 17)
Local $Combo1 = GUICtrlCreateCombo("", 218, 8, 60, 25, $CBS_DROPDOWNLIST )
GUICtrlSetData($Combo1, $Shift, "早班")
GUICtrlCreateLabel("勤務別:", 290, 12, 42, 17)
Local $Combo2 = GUICtrlCreateCombo("", 332, 8, 60, 25, $CBS_DROPDOWNLIST )
GUICtrlSetData($Combo2, $Service, "CM")
GUICtrlCreateLabel("車站/機廠:", 18, 42, 60, 17)
Local $Combo3 = GUICtrlCreateCombo("", 78, 40, 60, 25, $CBS_DROPDOWNLIST )
GUICtrlSetData($Combo3, $UnitRange, "")
GUICtrlCreateLabel("系統:", 158, 42, 31, 17)
Local $Combo4 = GUICtrlCreateCombo("", 190, 40, 140, 25, $CBS_DROPDOWNLIST)
GUICtrlSetData($Combo4, $SystemName, "")
GUICtrlCreateLabel("急迫性:", 340, 42, 42, 17)
Local $Combo5 = GUICtrlCreateCombo("", 385, 40, 50, 25, $CBS_DROPDOWNLIST)
GUICtrlSetData($Combo5, $Ranking, "一般")
GUICtrlCreateLabel("追蹤事項:", 20, 72, 60, 17)
Local $Input2 = GUICtrlCreateInput("", 78, 72, 150, 150,0x00201044)
GUICtrlCreateLabel("處理進度:", 240, 72, 60, 17)
Local $Input3 = GUICtrlCreateEdit("", 300, 72, 180, 150, 0x00201044)
GUICtrlCreateLabel("狀態:", 45, 240, 30, 17)
Local $Combo6 = GUICtrlCreateCombo("", 78, 237, 60, 25, $CBS_DROPDOWNLIST)
GUICtrlSetData($Combo6, $Status, "待交接")
Local $Button1 = GUICtrlCreateButton("確認", 336, 235, 65, 25)
Local $Button2 = GUICtrlCreateButton("取消", 408, 235, 65, 25)
GUISetState(@SW_SHOW,$Form2)
Local $NOWDATETIME2, $Temp
While 1
Local $nMsg = GUIGetMsg()
Switch $nMsg
Case $Combo3 ;設定廠站名稱選擇到列車或是其他時,自動代入系統別
If GUICtrlRead($Combo3) = "列車" Then
GUICtrlDelete($Combo4)
Sleep(150)
$Combo4 = GUICtrlCreateCombo("", 190, 40, 140, 25, $CBS_DROPDOWNLIST )
GUICtrlSetData($Combo4, $SystemName, "RADIO(無線電)")
ElseIf GUICtrlRead($Combo3) = "其他" Then
GUICtrlDelete($Combo4)
Sleep(150)
$Combo4 = GUICtrlCreateCombo("", 190, 40, 140, 25, $CBS_DROPDOWNLIST )
GUICtrlSetData($Combo4, $SystemName, "其他")
EndIf
Case $GUI_EVENT_CLOSE ,$Button2 ; 關閉視窗或是取消鈕則退出
ExitLoop
Case $Button1 ;輸入確認
GUICtrlSetState($Button1,$GUI_DISABLE )
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Date) FROM interfix WHERE Date Like '" & $NOWDATETIME & "%" & "';", $aRow) ;執行SQL語法查詢當日產生筆數
$Temp = int($aRow[0])
If $Temp = 0 Then
$NOWDATETIME2 = $NOWDATETIME & "-1"
_SQLite_Exec(-1, "Insert into interfix (Date) values ('" & $NOWDATETIME2 & "');") ;輸入交接筆數
IF GUICtrlRead($Combo1) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Shift = '" & GUICtrlRead($Combo1) & "' WHERE Date = '" & $NOWDATETIME2 & "';") ;輸入班別
EndIf
IF GUICtrlRead($Combo2) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Service = '" & GUICtrlRead($Combo2) & "' WHERE Date = '" & $NOWDATETIME2 & "';") ;輸入勤務別
EndIf
IF GUICtrlRead($Combo3) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET LocaleName = '" & GUICtrlRead($Combo3) & "' WHERE Date = '" & $NOWDATETIME2 & "';") ;輸入廠站
EndIf
IF GUICtrlRead($Combo4) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET SystemName = '" & GUICtrlRead($Combo4) & "' WHERE Date = '" & $NOWDATETIME2 & "';") ;輸入系統別
EndIf
IF GUICtrlRead($Combo5) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Ranking = '" & GUICtrlRead($Combo5) & "' WHERE Date = '" & $NOWDATETIME2 & "';") ;輸入急迫性
EndIf
IF GUICtrlRead($Input2) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Matter = '" & GUICtrlRead($Input2) & "' WHERE Date = '" & $NOWDATETIME2 & "';") ;輸入追蹤事項
EndIf
IF GUICtrlRead($Input3) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Transact = '" & GUICtrlRead($Input3) & "' WHERE Date = '" & $NOWDATETIME2 & "';") ;輸入處理進度
EndIf
IF GUICtrlRead($Combo6) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Status = '" & GUICtrlRead($Combo6) & "' WHERE Date = '" & $NOWDATETIME2 & "';") ;輸入急迫性
EndIf
Else
$Temp = $Temp + 1
$NOWDATETIME2 = $NOWDATETIME & "-" & $Temp
_SQLite_Exec(-1, "Insert into interfix (Date) values ('" & $NOWDATETIME2 & "');") ;輸入交接筆數
IF GUICtrlRead($Combo1) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Shift = '" & GUICtrlRead($Combo1) & "' WHERE Date = '" & $NOWDATETIME2 & "';") ;輸入班別
EndIf
IF GUICtrlRead($Combo2) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Service = '" & GUICtrlRead($Combo2) & "' WHERE Date = '" & $NOWDATETIME2 & "';") ;輸入勤務別
EndIf
IF GUICtrlRead($Combo3) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET LocaleName = '" & GUICtrlRead($Combo3) & "' WHERE Date = '" & $NOWDATETIME2 & "';") ;輸入廠站
EndIf
IF GUICtrlRead($Combo4) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET SystemName = '" & GUICtrlRead($Combo4) & "' WHERE Date = '" & $NOWDATETIME2 & "';") ;輸入系統別
EndIf
IF GUICtrlRead($Combo5) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Ranking = '" & GUICtrlRead($Combo5) & "' WHERE Date = '" & $NOWDATETIME2 & "';") ;輸入急迫性
EndIf
IF GUICtrlRead($Input2) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Matter = '" & GUICtrlRead($Input2) & "' WHERE Date = '" & $NOWDATETIME2 & "';") ;輸入追蹤事項
EndIf
IF GUICtrlRead($Input3) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Transact = '" & GUICtrlRead($Input3) & "' WHERE Date = '" & $NOWDATETIME2 & "';") ;輸入處理進度
EndIf
IF GUICtrlRead($Combo6) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Status = '" & GUICtrlRead($Combo6) & "' WHERE Date = '" & $NOWDATETIME2 & "';") ;輸入急迫性
EndIf
EndIf
GUICtrlSetState($Button1,$GUI_ENABLE )
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Date) FROM interfix WHERE Date LIKE '" & $NOWDATETIME & "%" & "' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = Int($aRow[0]) ;以整數值存入變數
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
_SQLite_QueryFinalize ( $hQuery )
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Date LIKE '" & $NOWDATETIME & "%" & "' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
GUICtrlSetData($Input2, "", "" ) ;清空事項
GUICtrlSetData($Input3, "", "" ) ;清空處理情況
EndSwitch
WEnd
Update_totall()
GUIDelete($Form2)
EndFunc
Func Ambit_query() ;欄位搜尋
IF GUICtrlRead ($GUI_Input1)<> "" Then ;日期搜尋
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Date) FROM interfix WHERE Date LIKE '" & GUICtrlRead ($GUI_Input1) & "%" & "' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = int($aRow[0])
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Date LIKE '" & GUICtrlRead($GUI_Input1) & "%" & "' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
ElseIf GUICtrlRead ($GUI_Input2)<> "" Then ;追蹤事項搜尋
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Matter) FROM interfix WHERE Matter LIKE '" & "%" & GUICtrlRead ($GUI_Input2) & "%" & "' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = int($aRow[0])
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Matter LIKE '" & "%" & GUICtrlRead($GUI_Input2) & "%" & "' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
ElseIf GUICtrlRead ($GUI_Input3)<> "" Then ;追蹤事項搜尋
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Transact) FROM interfix WHERE Transact LIKE '" & "%" & GUICtrlRead ($GUI_Input3) & "%" & "' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = int($aRow[0])
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Transact LIKE '" & "%" & GUICtrlRead($GUI_Input3) & "%" & "' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
ElseIf GUICtrlRead ($GUI_COMBO1)<> "" Then;班別搜尋
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Shift) FROM interfix WHERE Shift = '" & GUICtrlRead ($GUI_COMBO1) & "' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = int($aRow[0])
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Shift = '" & GUICtrlRead($GUI_COMBO1) & "' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
ElseIf GUICtrlRead ($GUI_COMBO2)<> "" AND GUICtrlRead ($GUI_COMBO3)<> "" Then ;勤務、廠站搜尋
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Service) FROM interfix WHERE Service = '" & GUICtrlRead ($GUI_COMBO2) & "' AND LocaleName = '" & GUICtrlRead($GUI_COMBO3) & "';", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = int($aRow[0])
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Service = '" & GUICtrlRead($GUI_COMBO2) & "' AND LocaleName = '" & GUICtrlRead($GUI_COMBO3) & "' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
ElseIf GUICtrlRead ($GUI_COMBO2)<> "" AND GUICtrlRead ($GUI_COMBO6)<> "" Then ;勤務、狀態搜尋
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Service) FROM interfix WHERE Service = '" & GUICtrlRead ($GUI_COMBO2) & "' AND Status = '" & GUICtrlRead($GUI_COMBO6) & "';", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = int($aRow[0])
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Service = '" & GUICtrlRead($GUI_COMBO2) & "' AND Status = '" & GUICtrlRead($GUI_COMBO6) & "' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
ElseIf GUICtrlRead ($GUI_COMBO2)<> "" Then;勤務搜尋
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Service) FROM interfix WHERE Service = '" & GUICtrlRead ($GUI_COMBO2) & "' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = int($aRow[0])
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Service = '" & GUICtrlRead($GUI_COMBO2) & "' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
ElseIf GUICtrlRead ($GUI_COMBO3)<> "" And GUICtrlRead ($GUI_COMBO4)<> "" Then ;廠/站,系統搜尋
_SQLite_QuerySingleRow(-1, "SELECT COUNT(LocaleName) FROM interfix WHERE LocaleName = '" & GUICtrlRead ($GUI_COMBO3) & "' And SystemName = '" & GUICtrlRead ($GUI_COMBO4) & "' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = int($aRow[0])
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE LocaleName = '" & GUICtrlRead($GUI_COMBO3) & "' And SystemName = '" & GUICtrlRead ($GUI_COMBO4) & "' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
ElseIf GUICtrlRead ($GUI_COMBO3)<> "" And GUICtrlRead ($GUI_COMBO6)<> "" Then ;廠/站,狀態搜尋
_SQLite_QuerySingleRow(-1, "SELECT COUNT(LocaleName) FROM interfix WHERE LocaleName = '" & GUICtrlRead ($GUI_COMBO3) & "' And Status = '" & GUICtrlRead ($GUI_COMBO6) & "' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = int($aRow[0])
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE LocaleName = '" & GUICtrlRead($GUI_COMBO3) & "' And Status = '" & GUICtrlRead ($GUI_COMBO6) & "' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
ElseIf GUICtrlRead ($GUI_COMBO3)<> "" Then;廠/站搜尋
_SQLite_QuerySingleRow(-1, "SELECT COUNT(LocaleName) FROM interfix WHERE LocaleName = '" & GUICtrlRead ($GUI_COMBO3) & "' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = int($aRow[0])
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE LocaleName = '" & GUICtrlRead($GUI_COMBO3) & "' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
ElseIf GUICtrlRead ($GUI_COMBO4)<> "" And GUICtrlRead ($GUI_COMBO6)<> "" Then;系統,狀態搜尋
_SQLite_QuerySingleRow(-1, "SELECT COUNT(SystemName) FROM interfix WHERE SystemName = '" & GUICtrlRead ($GUI_COMBO4) & "' And Status = '" & GUICtrlRead ($GUI_COMBO6) & "' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = int($aRow[0])
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE SystemName = '" & GUICtrlRead($GUI_COMBO4) & "' And Status = '" & GUICtrlRead ($GUI_COMBO6) & "' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
ElseIf GUICtrlRead ($GUI_COMBO4)<> "" Then;系統搜尋
_SQLite_QuerySingleRow(-1, "SELECT COUNT(SystemName) FROM interfix WHERE SystemName = '" & GUICtrlRead ($GUI_COMBO4) & "' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = int($aRow[0])
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE SystemName = '" & GUICtrlRead($GUI_COMBO4) & "' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
ElseIf GUICtrlRead ($GUI_COMBO5)<> "" And GUICtrlRead ($GUI_COMBO6)<> "" Then ;急迫性,狀態搜尋
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Ranking) FROM interfix WHERE Ranking = '" & GUICtrlRead ($GUI_COMBO5) & "' And Status = '" & GUICtrlRead ($GUI_COMBO6) & "' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = int($aRow[0])
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Ranking = '" & GUICtrlRead($GUI_COMBO5) & "' And Status = '" & GUICtrlRead ($GUI_COMBO6) & "'ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
ElseIf GUICtrlRead ($GUI_COMBO5)<> "" Then ;急迫性搜尋
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Ranking) FROM interfix WHERE Ranking = '" & GUICtrlRead ($GUI_COMBO5) & "' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = int($aRow[0])
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Ranking = '" & GUICtrlRead($GUI_COMBO5) & "' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
ElseIf GUICtrlRead ($GUI_COMBO6)<> "" Then;狀態搜尋
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Status) FROM interfix WHERE Status = '" & GUICtrlRead ($GUI_COMBO6) & "' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = int($aRow[0])
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Status = '" & GUICtrlRead($GUI_COMBO6) & "' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
EndIf
clear_columu()
EndFunc
Func sql_data_array() ;取出之資料存入陣列並顯示至ViewList
Local $ArrayData[$aRow2][9] ;設定二維陣列
Local $Date_interval, $iDateCalc, $aItem
Local $c = 0 ;初始二維陣列值
$hImage = _GUIImageList_Create()
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
$ArrayData[$c][0]=$aRow[0]
$ArrayData[$c][1]=$aRow[1]
$ArrayData[$c][2]=$aRow[2]
$ArrayData[$c][3]=$aRow[3]
$ArrayData[$c][4]=$aRow[4]
$ArrayData[$c][5]=$aRow[5]
$ArrayData[$c][6]=$aRow[6]
$ArrayData[$c][7]=$aRow[7]
$ArrayData[$c][8]=$aRow[8]
$c = $c +1
WEnd
_GUICtrlListView_AddArray($GUI_ListBox, $ArrayData)
_SQLite_QueryFinalize($hQuery)
EndFunc
Func Read_Data() ;讀取全部資料
GUICtrlSetState($GUI_Button1,$GUI_DISABLE )
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Date) FROM interfix WHERE Date LIKE '" & "%" & "' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = Int($aRow[0]) ;以整數值存入變數
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Date LIKE '" & "%" & "' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
GUICtrlSetState($GUI_Button1,$GUI_ENABLE )
EndFunc
Func SQLiteDelete() ;刪除一筆資料
Local $Temp
Local $Date_DL =InputBox("刪除追蹤事項","請輸入日期編號","","",150,150) ;輸入BM工單號碼
IF @error <> 1 Then ;InputBox 如點選OK鈕
_SQLite_QuerySingleRow(-1, "SELECT * FROM interfix WHERE Date = '" & $Date_DL & "' COLLATE NOCASE ;", $aRow) ;搜尋該筆工單
$Temp = $aRow[0]
If $Temp = "" Then ;沒有該筆資料
MsgBox(262208, "刪除結果...", "無此筆資料,請重新輸入!")
Else ;有該筆資料就顯示內容
_GUICtrlListView_DeleteAllItems ($GUI_ListBox)
_GUICtrlListView_AddItem($GUI_ListBox, $aRow[0])
_GUICtrlListView_AddSubItem($GUI_ListBox, _GUICtrlListView_FindInText($GUI_ListBox, $aRow[0]), $aRow[1], 1)
_GUICtrlListView_AddSubItem($GUI_ListBox, _GUICtrlListView_FindInText($GUI_ListBox, $aRow[0]), $aRow[2], 2)
_GUICtrlListView_AddSubItem($GUI_ListBox, _GUICtrlListView_FindInText($GUI_ListBox, $aRow[0]), $aRow[3], 3)
_GUICtrlListView_AddSubItem($GUI_ListBox, _GUICtrlListView_FindInText($GUI_ListBox, $aRow[0]), $aRow[4], 4)
_GUICtrlListView_AddSubItem($GUI_ListBox, _GUICtrlListView_FindInText($GUI_ListBox, $aRow[0]), $aRow[5], 5)
_GUICtrlListView_AddSubItem($GUI_ListBox, _GUICtrlListView_FindInText($GUI_ListBox, $aRow[0]), $aRow[6], 6)
_GUICtrlListView_AddSubItem($GUI_ListBox, _GUICtrlListView_FindInText($GUI_ListBox, $aRow[0]), $aRow[7], 7)
_GUICtrlListView_AddSubItem($GUI_ListBox, _GUICtrlListView_FindInText($GUI_ListBox, $aRow[0]), $aRow[8], 8)
GUICtrlSetData($GUI_Input1, $aRow[0], "")
GUICtrlSetData($GUI_COMBO1, $aRow[1], "")
GUICtrlSetData($GUI_COMBO2, $aRow[2], "")
GUICtrlSetData($GUI_COMBO3, $aRow[3], "")
GUICtrlSetData($GUI_COMBO4, $aRow[4], "")
GUICtrlSetData($GUI_COMBO5, $aRow[5], "")
GUICtrlSetData($GUI_Input2, $aRow[6], "")
GUICtrlSetData($GUI_Input3, $aRow[7], "")
GUICtrlSetData($GUI_COMBO6, $aRow[8], "")
_SQLite_QueryFinalize($hQuery)
$a = MsgBox(1,"刪除確認","是否刪除此筆追蹤事項:" & $Date_DL ) ;詢問是否刪除該筆工單
If $a = 1 Then
_SQLite_Exec(-1, "DELETE FROM interfix WHERE Date = '" & $Date_DL & "';") ;刪除該筆工單資料
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除ListView資料
GUICtrlSetData($GUI_Input1, "", "")
GUICtrlSetData($GUI_COMBO1, $Shift, "")
GUICtrlSetData($GUI_COMBO2, $Service, "")
GUICtrlSetData($GUI_COMBO3, $UnitRange, "")
GUICtrlSetData($GUI_COMBO4, $SystemName, "")
GUICtrlSetData($GUI_COMBO5, $Ranking, "")
GUICtrlSetData($GUI_Input2, "", "")
GUICtrlSetData($GUI_Input3, "", "")
GUICtrlSetData($GUI_COMBO6, $Status, "")
_SQLite_QueryFinalize($hQuery)
EndIf
EndIf
EndIf
Update_totall()
EndFunc
Func Enter_data() ;確定修改
GUICtrlSetState($GUI_Button5,$GUI_DISABLE )
IF GUICtrlRead($GUI_Combo1) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Shift = '" & GUICtrlRead($GUI_Combo1) & "' WHERE Date = '" & GUICtrlRead($GUI_Input1) & "';") ;輸入班別
EndIf
IF GUICtrlRead($GUI_Combo2) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Service = '" & GUICtrlRead($GUI_Combo2) & "' WHERE Date = '" & GUICtrlRead($GUI_Input1) & "';") ;輸入勤務別
EndIf
IF GUICtrlRead($GUI_Combo3) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET LocaleName = '" & GUICtrlRead($GUI_Combo3) & "' WHERE Date = '" & GUICtrlRead($GUI_Input1) & "';") ;輸入廠站
EndIf
IF GUICtrlRead($GUI_Combo4) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET SystemName = '" & GUICtrlRead($GUI_Combo4) & "' WHERE Date = '" & GUICtrlRead($GUI_Input1) & "';") ;輸入系統別
EndIf
IF GUICtrlRead($GUI_Combo5) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Ranking = '" & GUICtrlRead($GUI_Combo5) & "' WHERE Date = '" & GUICtrlRead($GUI_Input1) & "';") ;輸入急迫性
EndIf
IF GUICtrlRead($GUI_Input2) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Matter = '" & GUICtrlRead($GUI_Input2) & "' WHERE Date = '" & GUICtrlRead($GUI_Input1) & "';") ;輸入追蹤事項
EndIf
IF GUICtrlRead($GUI_Input3) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Transact = '" & GUICtrlRead($GUI_Input3) & "' WHERE Date = '" & GUICtrlRead($GUI_Input1) & "';") ;輸入處理進度
EndIf
IF GUICtrlRead($GUI_Combo6) <> "" Then
_SQLite_Exec(-1, "UPDATE interfix SET Status = '" & GUICtrlRead($GUI_Combo6) & "' WHERE Date = '" & GUICtrlRead($GUI_Input1) & "';") ;輸入急迫性
EndIf
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Date) FROM interfix WHERE Date = '" & GUICtrlRead($GUI_Input1) & "' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = Int($aRow[0]) ;以整數值存入變數
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
_SQLite_QueryFinalize ( $hQuery )
MsgBox(0,"更新結果","未更新資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Date = '" & GUICtrlRead($GUI_Input1) & "' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
GUICtrlSetState($GUI_Button5,$GUI_ENABLE )
Update_totall()
EndFunc
Func Update_totall() ;更新各工單數量
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Ranking) FROM interfix WHERE Ranking = '緊急' And Status <> '已結案';", $aRow) ;執行SQL語法查詢筆數
GUICtrlSetData($Exigency,$aRow[0])
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Ranking) FROM interfix WHERE Ranking = '重要' And Status <> '已結案';", $aRow) ;執行SQL語法查詢筆數
GUICtrlSetData($Momentous,$aRow[0])
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Ranking) FROM interfix WHERE Ranking = '一般' And Status <> '已結案';", $aRow) ;執行SQL語法查詢筆數
GUICtrlSetData($Commonly,$aRow[0])
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Ranking) FROM interfix WHERE Ranking = '其他' And Status <> '已結案';", $aRow) ;執行SQL語法查詢筆數
GUICtrlSetData($other,$aRow[0])
EndFunc
Func Exigency_query() ;未結案緊急工單查詢
GUICtrlSetState($GUI_Button8,$GUI_DISABLE )
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Ranking) FROM interfix WHERE Ranking = '緊急' And Status <> '已結案';", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = Int($aRow[0]) ;以整數值存入變數
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Ranking = '緊急' And Status <> '已結案' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
GUICtrlSetState($GUI_Button8,$GUI_ENABLE )
Update_totall()
EndFunc
Func Momentous_query() ;未結案重要工單查詢
GUICtrlSetState($GUI_Button9,$GUI_DISABLE )
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Ranking) FROM interfix WHERE Ranking = '重要' And Status <> '已結案';", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = Int($aRow[0]) ;以整數值存入變數
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Ranking = '重要' And Status <> '已結案' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
GUICtrlSetState($GUI_Button9,$GUI_ENABLE )
Update_totall()
EndFunc
Func Commonly_query() ;未結案一般工單查詢
GUICtrlSetState($GUI_Button10,$GUI_DISABLE )
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Ranking) FROM interfix WHERE Ranking = '一般' And Status <> '已結案';", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = Int($aRow[0]) ;以整數值存入變數
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Ranking = '一般' And Status <> '已結案' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
GUICtrlSetState($GUI_Button10,$GUI_ENABLE )
Update_totall()
EndFunc
Func All_query() ;全部未結案工單查詢
GUICtrlSetState($GUI_Button11,$GUI_DISABLE )
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Status) FROM interfix WHERE Status <> '已結案';", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = Int($aRow[0]) ;以整數值存入變數
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Status <> '已結案' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
GUICtrlSetState($GUI_Button11,$GUI_ENABLE )
Update_totall()
EndFunc
Func other_columu() ;未結案其他工單查訊
GUICtrlSetState($GUI_Button10,$GUI_DISABLE )
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Ranking) FROM interfix WHERE Ranking = '其他' And Status <> '已結案';", $aRow) ;查詢資料筆數,並存入$hQuery 變數
$aRow2 = Int($aRow[0]) ;以整數值存入變數
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_GUICtrlListView_DeleteAllItems ($GUI_ListBox) ;清除舊資料顯示
_SQLite_Query(-1, "SELECT * FROM interfix WHERE Ranking = '其他' And Status <> '已結案' ORDER BY Date DESC ;", $hQuery) ;查詢資料,並存入$hQuery 變數
sql_data_array()
EndIf
GUICtrlSetState($GUI_Button10,$GUI_ENABLE )
Update_totall()
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) ;滑鼠點擊事件
Local $tNMHDR, $hWndFrom, $iCode,$hWndListView
$hWndListView = $GUI_ListBox
If Not IsHWnd($GUI_ListBox) Then $hWndListView = GUICtrlGetHandle($g_idListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = DllStructGetData($tNMHDR, 'hWndFrom')
$iCode = DllStructGetData($tNMHDR, 'Code')
Switch $iCode
Case $NM_DBLCLK
Global $aHit = _GUICtrlListView_SubItemHitTest($GUI_ListBox)
If $aHit[0] <> -1 Then
Local $aRect = _GUICtrlListView_GetSubItemRect($GUI_ListBox, $aHit[0], $aHit[1])
Local $sItemText = _GUICtrlListView_GetItemText($GUI_ListBox, $aHit[0], $aHit[1])
Local $aPos = ControlGetPos($hWnd, '', $GUI_ListBox)
Local $iStyle = BitOR($WS_CHILD, $WS_VISIBLE, $ES_AUTOHSCROLL, $ES_LEFT)
$hEdit = _GUICtrlEdit_Create($hWnd, $sItemText, $aPos[0] + $aRect[0], $aPos[1] + $aRect[1], _GUICtrlListView_GetColumnWidth($GUI_ListBox, $aHit[1]), $iHeight, $iStyle)
_WinAPI_BringWindowToTop($hEdit)
_WinAPI_SetFont($hEdit, $hFont, True)
_GUICtrlEdit_SetMargins($hEdit, $EC_LEFTMARGIN, 4)
_WinAPI_SetFocus($hEdit)
_GUICtrlEdit_SetSel($hEdit, 0, -1)
EndIf
Case $NM_CLICK
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$a = DllStructGetData($tInfo, "Index") ;取得listview 游標id-index
Mouse_L_Click($a)
Case $NM_RCLICK ;滑鼠右鍵點擊
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$a = DllStructGetData($tInfo, "Index") ;取得listview 游標id-index
Mouse_R_Click($a)
EndSwitch
EndFunc ;==>WM_NOTIFY
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) ;滑鼠左鍵編選事件
Local $iCode = BitShift($iwParam, 16)
Local $nMsgID = BitAND($iwParam, 0x0000FFFF)
Switch $ilParam
Case $hEdit
Switch $iCode
Case $EN_KILLFOCUS
Local $sItemText = _GUICtrlEdit_GetText($hEdit)
_WinAPI_DestroyWindow($hEdit)
EndSwitch
EndSwitch
If $nMsgID = 1 And $hEdit <> '' Then
Local $sItemText = _GUICtrlEdit_GetText($hEdit)
_WinAPI_DestroyWindow($hEdit)
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND
Func Mouse_R_Click($a) ;滑鼠右鍵選單
Local $aItem, $sText, $i
$aItem = _GUICtrlListView_GetItemTextArray($GUI_ListBox, $a) ;讀取指定LIST 內容
For $i = 1 To $aItem[0]
If $i = 1 then $sText &= StringFormat("[%2d]日期: %s", $i, $aItem[$i]) & @CRLF
If $i = 2 then $sText &= StringFormat("[%2d]班別: %s", $i, $aItem[$i]) & @CRLF
If $i = 3 then $sText &= StringFormat("[%2d]勤務別: %s", $i, $aItem[$i]) & @CRLF
If $i = 4 then $sText &= StringFormat("[%2d]廠/站: %s", $i, $aItem[$i]) & @CRLF
If $i = 5 then $sText &= StringFormat("[%2d]系統: %s", $i, $aItem[$i]) & @CRLF
If $i = 6 then $sText &= StringFormat("[%2d]急迫性: %s", $i, $aItem[$i]) & @CRLF
If $i = 7 then $sText &= StringFormat("[%2d]追蹤事項: %s", $i, $aItem[$i]) & @CRLF
If $i = 8 then $sText &= StringFormat("[%2d]處理進度: %s", $i, $aItem[$i]) & @CRLF
If $i = 9 then $sText &= StringFormat("[%2d]狀態: %s", $i, $aItem[$i]) & @CRLF
Next
$aItem = _GUICtrlListView_GetItemTextArray($GUI_ListBox, $a) ;讀取指定LIST 內容
IF $aItem[1] <> "" Then ;如果項目有資料則顯示
MsgBox($MB_SYSTEMMODAL, "交接事項內容",$sText)
ClipPut($aItem[1])
EndIf
EndFunc ;==>Example
Func Mouse_L_Click($a) ;滑鼠左鍵選單
Local $aItem, $sText, $i
$aItem = _GUICtrlListView_GetItemTextArray($GUI_ListBox, $a) ;讀取指定LIST 內容
If $aItem[1] <> "" Then
_SQLite_QuerySingleRow(-1, "SELECT COUNT(Date) FROM interfix WHERE Date = '" & $aItem[1] & "';", $aRow) ;查詢資料筆數,並存入變數
$aRow2 = Int($aRow[0]) ;以整數值存入變數
If $aRow2 = 0 Then ;如果查無資料則顯示查無資料
_SQLite_QueryFinalize ( $hQuery )
MsgBox(0,"查詢結果","查無資料" )
Else ;將資料撈出並顯示
_SQLite_QuerySingleRow(-1, "SELECT * FROM interfix WHERE Date = '" & $aItem[1] & "' COLLATE NOCASE ;", $aRow) ;查詢資料筆數,並存入變數
GUICtrlDelete($GUI_Combo1)
GUICtrlDelete($GUI_Combo2)
GUICtrlDelete($GUI_Combo3)
GUICtrlDelete($GUI_Combo4)
GUICtrlDelete($GUI_Combo5)
GUICtrlDelete($GUI_Combo6)
Sleep(100)
GUICtrlSetData($GUI_Input1, $aRow[0])
$GUI_COMBO1 = GUICtrlCreateCombo("", 188, 245, 60, 20,$CBS_DROPDOWNLIST);班別
GUICtrlSetData($GUI_COMBO1, $Shift, $aRow[1])
$GUI_COMBO2 = GUICtrlCreateCombo("", 292, 245, 50, 20,$CBS_DROPDOWNLIST);勤務
GUICtrlSetData($GUI_COMBO2, $Service, $aRow[2])
$GUI_COMBO3 = GUICtrlCreateCombo("", 387, 245, 50, 20,$CBS_DROPDOWNLIST) ;廠站
GUICtrlSetData($GUI_COMBO3, $UnitRange, $aRow[3])
$GUI_COMBO4 = GUICtrlCreateCombo("", 482, 245, 130, 20,$CBS_DROPDOWNLIST) ;系統
GUICtrlSetData($GUI_COMBO4, $SystemName, $aRow[4])
$GUI_COMBO5 = GUICtrlCreateCombo("", 690, 245, 50, 20,$CBS_DROPDOWNLIST) ;急迫性
GUICtrlSetData($GUI_COMBO5, $Ranking, $aRow[5])
GUICtrlSetData($GUI_Input2, $aRow[6], "")
GUICtrlSetData($GUI_Input3, $aRow[7], "")
$GUI_COMBO6 = GUICtrlCreateCombo("", 598, 275, 60, 20,$CBS_DROPDOWNLIST) ;狀態
GUICtrlSetData($GUI_COMBO6, $Status, $aRow[8])
EndIf
Else
GUICtrlDelete($GUI_Combo1)
GUICtrlDelete($GUI_Combo2)
GUICtrlDelete($GUI_Combo3)
GUICtrlDelete($GUI_Combo4)
GUICtrlDelete($GUI_Combo5)
GUICtrlDelete($GUI_Combo6)
Sleep(100)
$GUI_COMBO1 = GUICtrlCreateCombo("", 188, 245, 60, 20,$CBS_DROPDOWNLIST);班別
GUICtrlSetData($GUI_COMBO1, $Shift, "")
$GUI_COMBO2 = GUICtrlCreateCombo("", 292, 245, 50, 20,$CBS_DROPDOWNLIST);勤務
GUICtrlSetData($GUI_COMBO2, $Service, "")
$GUI_COMBO3 = GUICtrlCreateCombo("", 387, 245, 50, 20,$CBS_DROPDOWNLIST) ;廠站
GUICtrlSetData($GUI_COMBO3, $UnitRange, "")
$GUI_COMBO4 = GUICtrlCreateCombo("", 482, 245, 130, 20,$CBS_DROPDOWNLIST) ;系統
GUICtrlSetData($GUI_COMBO4, $SystemName, "")
$GUI_COMBO5 = GUICtrlCreateCombo("", 690, 245, 50, 20,$CBS_DROPDOWNLIST) ;急迫性
GUICtrlSetData($GUI_COMBO5, $Ranking, "")
$GUI_COMBO6 = GUICtrlCreateCombo("", 598, 275, 60, 20,$CBS_DROPDOWNLIST) ;狀態
GUICtrlSetData($GUI_COMBO6, $Status, "")
GUICtrlSetData($GUI_Input1, "" ) ;清空
GUICtrlSetData($GUI_Input2, "" ) ;清空
GUICtrlSetData($GUI_Input3, "" ) ;清空
EndIf
EndFunc ;==>Example
Func clear_columu() ;清除欄位
GUICtrlDelete($GUI_Combo1)
GUICtrlDelete($GUI_Combo2)
GUICtrlDelete($GUI_Combo3)
GUICtrlDelete($GUI_Combo4)
GUICtrlDelete($GUI_Combo5)
GUICtrlDelete($GUI_Combo6)
Sleep(100)
$GUI_COMBO1 = GUICtrlCreateCombo("", 188, 245, 60, 20,$CBS_DROPDOWNLIST);班別
GUICtrlSetData($GUI_COMBO1, $Shift, "")
$GUI_COMBO2 = GUICtrlCreateCombo("", 292, 245, 50, 20,$CBS_DROPDOWNLIST);勤務
GUICtrlSetData($GUI_COMBO2, $Service, "")
$GUI_COMBO3 = GUICtrlCreateCombo("", 387, 245, 50, 20,$CBS_DROPDOWNLIST) ;廠站
GUICtrlSetData($GUI_COMBO3, $UnitRange, "")
$GUI_COMBO4 = GUICtrlCreateCombo("", 482, 245, 130, 20,$CBS_DROPDOWNLIST) ;系統
GUICtrlSetData($GUI_COMBO4, $SystemName, "")
$GUI_COMBO5 = GUICtrlCreateCombo("", 690, 245, 50, 20,$CBS_DROPDOWNLIST) ;急迫性
GUICtrlSetData($GUI_COMBO5, $Ranking, "")
$GUI_COMBO6 = GUICtrlCreateCombo("", 598, 275, 60, 20,$CBS_DROPDOWNLIST) ;狀態
GUICtrlSetData($GUI_COMBO6, $Status, "")
GUICtrlSetData($GUI_Input1, "" ) ;清空
GUICtrlSetData($GUI_Input2, "" ) ;清空
GUICtrlSetData($GUI_Input3, "" ) ;清空
EndFunc