#include <Array.au3>
#include <GuiStatusBar.au3>
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <GuiListView.au3>
#include <GuiIPAddress.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <Timers.au3>
Opt("GUIOnEventMode", 1)
Opt("GUICoordMode", 1)
;SplashImageOn("", @TempDir & "\HISTools\Login.jpg", 500, 180, -1, -1, 1)
Global $Label, $ListView, $ListViewPX, $Group = 0, $GroupName, $StatusBar, $sip, $pic, $ZYH, $ZYHCF, $BHID, $YBH, $ZXYW, $Progress, $Edit;定义全局变量
Global $nCurCol = -1, $nSortDir = 1, $bSet = 0, $nCol = -1
$sip = @IPAddress1;获取本机ip
If $sip = "0.0.0.0" Then $sip = @IPAddress2
If $sip = "0.0.0.0" Then $sip = @IPAddress3
If $sip = "0.0.0.0" Then $sip = @IPAddress4
If $sip = "0.0.0.0" Then $sip = "IP地址获取失败"
Global $LoginMain, $Mail, $Button, $LoginName, $LoginPassword, $UserGroup, $TabShell, $Tab, $Tool, $Bom, $iFOCUS, $ListView, $Arry, $MailTool[25], $ToolMail[50], $error, $loginout = 0, $Tooll
#endregion ### 连接数据库 ###
bl()
While 1
Sleep(1000)
WEnd
Func bl()
Dim $Tool[20], $Label[30], $ListView[5], $TabTools[5], $pic[3], $error = 0, $Tooll[5]
Global $errorBox, $OK = 3, $Bak = 0
$MailTool[4] = GUICreate("病历管理", 740, 680, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "BLGL")
GUISetIcon(@TempDir & "\HISTools\12.ico")
$Group1 = GUICtrlCreateGroup("", 8, 0, 721, 177)
$Tool[10] = GUICtrlCreateButton("所有病历", 56, 300, 73, 25)
$Tool[11] = GUICtrlCreateButton("问题病历", 168, 300, 73, 25)
$Tool[12] = GUICtrlCreateButton("退调病历", 280, 300, 73, 25)
$Tool[13] = GUICtrlCreateButton("病历统计", 392, 300, 73, 25)
$Tool[14] = GUICtrlCreateButton("病历日志", 504, 300, 73, 25)
$Tool[15] = GUICtrlCreateButton("返 回", 616, 300, 73, 25)
$List = GUICtrlCreateListView("", 8, 335, 725, 280, $LVS_EX_CHECKBOXES, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
GUICtrlRegisterListViewSort(-1, "LVSort")
GUICtrlSetFont($ListView, 10)
_GUICtrlListView_AddColumn($List, "住院号", 70, 2, 0)
_GUICtrlListView_AddColumn($List, "姓名", 110, 2, 1)
_GUICtrlListView_AddColumn($List, "病历状态", 80, 2, 2)
_GUICtrlListView_AddColumn($List, "详细信息", 135, 2, 3)
_GUICtrlListView_AddColumn($List, "科室信息", 80, 2, 4)
_GUICtrlListView_AddColumn($List, "操作人员", 80, 2, 5)
_GUICtrlListView_AddColumn($List, "操作日期", 85, 2, 6)
_GUICtrlListView_AddColumn($List, "操作时间", 80, 2, 7)
GUICtrlCreateListViewItem("073871|测试1|状态1|信息2|1科室|02|2011年10月23日|02:45:52", $list)
GUICtrlCreateListViewItem("073872|测试3状态2|信息1|4科室|00|2011年10月22日|03:45:52", $list)
GUICtrlCreateListViewItem("073873|测试2|状态14|信息12|2科室|00|2011年10月23日|02:45:52", $list)
GUICtrlCreateListViewItem("073879|测试8|状态4|信息1|科室|02|2011年10月23日|02:45:52", $list)
$lv = GUICtrlCreateListView("", 8, 10, 725, 280, $LVS_EX_CHECKBOXES, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
GUICtrlRegisterListViewSort(-1, "LVSort") ; Register the function "SortLV" for the sorting callback
_GUICtrlListView_AddColumn($lv, "住院号", 70, 2, 0)
_GUICtrlListView_AddColumn($lv, "姓名", 110, 2, 1)
_GUICtrlListView_AddColumn($lv, "病历状态", 80, 2, 2)
_GUICtrlListView_AddColumn($lv, "详细信息", 135, 2, 3)
_GUICtrlListView_AddColumn($lv, "科室信息", 80, 2, 4)
_GUICtrlListView_AddColumn($lv, "操作人员", 80, 2, 5)
_GUICtrlListView_AddColumn($lv, "操作日期", 85, 2, 6)
_GUICtrlListView_AddColumn($lv, "操作时间", 80, 2, 7)
Dim $Arry[10][7]
$Arry[0][0]="07871"
$Arry[0][1]="Tes1"
$Arry[1][0]="03232"
$Arry[1][1]="Tes2"
_GUICtrlListView_AddArray($lv, $Arry)
;~ GUICtrlCreateListViewItem("073871|测试1|状态1|信息2|1科室|02|2011年10月23日|02:45:52", $lv)
;~ GUICtrlCreateListViewItem("073872|测试3状态2|信息1|4科室|00|2011年10月22日|03:45:52", $lv)
;~ GUICtrlCreateListViewItem("073873|测试2|状态14|信息12|2科室|00|2011年10月23日|02:45:52", $lv)
;~ GUICtrlCreateListViewItem("073879|测试8|状态4|信息1|科室|02|2011年10月23日|02:45:52", $lv)
;~
;_GUICtrlListView_SetColumnWidth($ListView[1], 0, 80)
;_GUICtrlListView_SetColumnWidth($ListView[1], 1, 120)
;_GUICtrlListView_SetColumnWidth($ListView[1], 2, 80)
;_GUICtrlListView_SetColumnWidth($ListView[1], 3, 195)
;_GUICtrlListView_SetColumnWidth($ListView[1], 4, 80)
;_GUICtrlListView_SetColumnWidth($ListView[1], 5, 80)
;_GUICtrlListView_SetColumnWidth($ListView[1], 6, 80)
;_GUICtrlListView_SetItemCount($ListView[1], 9999)
; Dim $ListViewPX[_GUICtrlListView_GetColumnCount($ListView[1])]
GUICtrlCreateLabel("所有病历:", 16, 627, 84, 20)
GUICtrlSetFont(-1, 12, 400, 0, "新宋体")
$Label[24] = GUICtrlCreateLabel("0", 88, 625, 48, 27, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 2, "Arial")
GUICtrlCreateLabel("接收病历:", 168, 627, 84, 20)
GUICtrlSetFont(-1, 12, 400, 0, "新宋体")
$Label[25] = GUICtrlCreateLabel("0", 240, 625, 48, 27, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 2, "Arial")
GUICtrlCreateLabel("正常病历:", 312, 627, 84, 20)
GUICtrlSetFont(-1, 12, 400, 0, "新宋体")
$Label[26] = GUICtrlCreateLabel("0", 384, 625, 48, 27, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 2, "Arial")
GUICtrlCreateLabel("问题病历:", 456, 627, 84, 20)
GUICtrlSetFont(-1, 12, 400, 0, "新宋体")
$Label[27] = GUICtrlCreateLabel("0", 528, 625, 48, 27, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 2, "Arial")
GUICtrlCreateLabel("退调病历:", 600, 627, 84, 20)
GUICtrlSetFont(-1, 12, 400, 0, "新宋体")
$Label[28] = GUICtrlCreateLabel("0", 672, 625, 48, 27, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 2, "Arial")
GUICtrlCreateTabItem("")
;~ $TabTools[2] = GUICtrlCreateTabItem("问题病历")
;~ $ListView[2] = GUICtrlCreateListView("", 8, 335, 720, 280)
Dim $aParts[5] = [120, 280, 470, 610, -1], $StatusBar[3]
$StatusBar[2] = _GUICtrlStatusBar_Create($MailTool[4])
_GUICtrlStatusBar_SetMinHeight($StatusBar[2], 20)
_GUICtrlStatusBar_SetParts($StatusBar[2], $aParts)
_GUICtrlStatusBar_SetText($StatusBar[2], "操作员:" & $LoginName)
_GUICtrlStatusBar_SetText($StatusBar[2], "本机IP:" & $sip, 1)
_GUICtrlStatusBar_SetText($StatusBar[2], "日 期:" , 2)
_GUICtrlStatusBar_SetText($StatusBar[2], "北京时间: " & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 3)
_GUICtrlStatusBar_SetText($StatusBar[2], "新疆时间:" & StringFormat("%02d:%02d:%02d", @HOUR - 2, @MIN, @SEC), 4)
_Timer_SetTimer($MailTool[4], 1000, "_UpdateBJClock")
_Timer_SetTimer($MailTool[4], 1000, "_UpdateXJClock")
For $i = 1 To 15
GUICtrlSetOnEvent($Tool[$i], "BLGL")
Next
GUICtrlSetOnEvent($ListView[1], "BLGL")
GUICtrlSendMsg($ListView[1], $LVM_DeleteALLITEMS, 0, 0)
GUISetState(@SW_SHOW)
EndFunc
Func BLGL()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
If MsgBox(1, "提示", "是否退出程序?") = 1 Then
Exit
EndIf
Case $Tool[1]
MsgBox(0, "错误!", "嘿嘿!操作判断失误o(╯□╰)o,8好意思。。!")
Case $Tool[2] ;==>解除欠费
MsgBox(4160, "", "正在开发!")
Case $Tool[3] ;==>正常接收
For $i = 1 To 6
GUICtrlSetState($Label[$i], $GUI_HIDE)
Next
Case $Tool[4] ;==>结算出错
For $i = 3 To 6
GUICtrlSetState($Label[$i], $GUI_HIDE)
Next
For $i = 1 To 2
GUICtrlSetState($Label[$i], $GUI_SHOW)
Next
Case $Tool[5] ;==>病历退调
For $i = 1 To 2
GUICtrlSetState($Label[$i], $GUI_HIDE)
Next
For $i = 3 To 4
GUICtrlSetState($Label[$i], $GUI_SHOW)
Next
Case $Tool[6] ;==>正常结算
For $i = 1 To 6
GUICtrlSetState($Label[$i], $GUI_HIDE)
Next
Case $Tool[7] ;==>其 他
For $i = 1 To 6
GUICtrlSetState($Label[$i], $GUI_HIDE)
Next
$errorBox = InputBox("其他", "请输入其他原因!", $errorBox, "", -1, -1, 850, 250)
Case $Tool[8] ;==>锁 定
MsgBox(4160, "", "正在开发!")
Case $Tool[9] ;==>解 锁
MsgBox(4160, "", "正在开发!")
Case $Tool[10] ;==>所有病历
_ArrayDisplay($ListView)
$iIndex = _GUICtrlListView_AddItem($ListView[1], "1")
;_GUICtrlListView_AddSubItem($ListView[1], $iIndex, $BLXM, 1)
MsgBox(0, "", $iIndex)
Case $Tool[11] ;==>问题病历
MsgBox(4160, "", "正在开发!")
Case $Tool[12] ;==>其他病历
MsgBox(4160, "", "正在开发!")
Case $Tool[13] ;==>退调病历
MsgBox(4160, "", "正在开发!")
Case $Tool[14] ;==>病历日志
MsgBox(4160, "", "正在开发!")
Case $Tool[15] ;==>返回
GUIDelete(@GUI_WinHandle)
GUISwitch($Mail)
GUISetState(@SW_SHOW)
GUISetCursor(2, 1)
GUISetState(@SW_ENABLE)
_WinAPI_SetWindowPos($Mail, -1, 0, 0, 0, 0, 3)
_WinAPI_SetWindowPos($Mail, -2, 0, 0, 0, 0, 3)
Case $ListView[1]
;_GUICtrlListView_SimpleSort($ListView[1], $ListViewPX, GUICtrlGetState($ListView[1])) ;<==$ListView的排序
$bSet = 0
$nCurCol = $nCol
GUICtrlSendMsg($ListView[1], $LVM_SETSELECTEDCOLUMN, GUICtrlGetState($ListView[1]), 0)
EndSwitch
EndFunc ;==>BLGL
Func LVSort($hWnd, $nItem1, $nItem2, $nColumn)
MsgBox(0, "", "调用了自定义函数," & $hWnd & "," & $nItem1 & "," & $nItem2 & "," & $nColumn)
Local $nSort, $val1, $val2, $nResult
; Switch the sorting direction
If $nColumn = $nCurCol Then
If Not $bSet Then
$nSortDir = $nSortDir * - 1
$bSet = 1
EndIf
Else
$nSortDir = 1
EndIf
$nCol = $nColumn
$val1 = GetSubItemText($hWnd, $nItem1, $nColumn)
$val2 = GetSubItemText($hWnd, $nItem2, $nColumn)
; If it is the 3rd colum (column starts with 0) then compare the dates
If $nColumn = 2 Then
$val1 = StringRight($val1, 4) & StringMid($val1, 4, 2) & StringLeft($val1, 2)
$val2 = StringRight($val2, 4) & StringMid($val2, 4, 2) & StringLeft($val2, 2)
EndIf
$nResult = 0 ; No change of item1 and item2 positions
If $val1 < $val2 Then
$nResult = -1 ; Put item2 before item1
ElseIf $val1 > $val2 Then
$nResult = 1 ; Put item2 behind item1
EndIf
$nResult = $nResult * $nSortDir
Return $nResult
EndFunc ;==>LVSort
; Retrieve the text of a listview item in a specified column
Func GetSubItemText($nCtrlID, $nItemID, $nColumn)
Local $stLvfi = DllStructCreate("uint;ptr;int;int[2];int")
Local $nIndex, $stBuffer, $stLvi, $sItemText
DllStructSetData($stLvfi, 1, $LVFI_PARAM)
DllStructSetData($stLvfi, 3, $nItemID)
$stBuffer = DllStructCreate("char[260]")
$nIndex = GUICtrlSendMsg($nCtrlID, $LVM_FINDITEM, -1, DllStructGetPtr($stLvfi));
$stLvi = DllStructCreate("uint;int;int;uint;uint;ptr;int;int;int;int")
DllStructSetData($stLvi, 1, $LVIF_TEXT)
DllStructSetData($stLvi, 2, $nIndex)
DllStructSetData($stLvi, 3, $nColumn)
DllStructSetData($stLvi, 6, DllStructGetPtr($stBuffer))
DllStructSetData($stLvi, 7, 260)
GUICtrlSendMsg($nCtrlID, $LVM_GETITEMA, 0, DllStructGetPtr($stLvi));
$sItemText = DllStructGetData($stBuffer, 1)
$stLvi = 0
$stLvfi = 0
$stBuffer = 0
Return $sItemText
EndFunc ;==>GetSubItemText
; Our sorting callback funtion
Func LVSort2($hWnd, $nItem1, $nItem2, $nColumn)
Local $nSort, $val1, $val2, $nResult
; Switch the sorting direction
If $nColumn = $nCurCol Then
If Not $bSet Then
$nSortDir = $nSortDir * - 1
$bSet = 1
EndIf
Else
$nSortDir = 1
EndIf
$nCol = $nColumn
$val1 = GetSubItemText($hWnd, $nItem1, $nColumn)
$val2 = GetSubItemText($hWnd, $nItem2, $nColumn)
; If it is the 3rd colum (column starts with 0) then compare the dates
If $nColumn = 2 Then
$val1 = StringRight($val1, 4) & StringMid($val1, 4, 2) & StringLeft($val1, 2)
$val2 = StringRight($val2, 4) & StringMid($val2, 4, 2) & StringLeft($val2, 2)
EndIf
$nResult = 0 ; No change of item1 and item2 positions
If $val1 < $val2 Then
$nResult = -1 ; Put item2 before item1
ElseIf $val1 > $val2 Then
$nResult = 1 ; Put item2 behind item1
EndIf
$nResult = $nResult * $nSortDir
Return $nResult
EndFunc ;==>LVSort2
; Retrieve the text of a listview item in a specified column
Func GetSubItemText2($nCtrlID, $nItemID, $nColumn)
Local $stLvfi = DllStructCreate("uint;ptr;int;int[2];int")
Local $stBuffer, $nIndex, $stLvi, $sItemText
DllStructSetData($stLvfi, 1, $LVFI_PARAM) ; Find the item by our saved index
DllStructSetData($stLvfi, 3, $nItemID)
$stBuffer = DllStructCreate("char[260]")
$nIndex = GUICtrlSendMsg($nCtrlID, $LVM_FINDITEM, -1, DllStructGetPtr($stLvfi));
$stLvi = DllStructCreate("uint;int;int;uint;uint;ptr;int;int;int;int")
DllStructSetData($stLvi, 1, $LVIF_TEXT)
DllStructSetData($stLvi, 2, $nIndex)
DllStructSetData($stLvi, 3, $nColumn)
DllStructSetData($stLvi, 6, DllStructGetPtr($stBuffer))
DllStructSetData($stLvi, 7, 260)
GUICtrlSendMsg($nCtrlID, $LVM_GETITEMA, 0, DllStructGetPtr($stLvi));
$sItemText = DllStructGetData($stBuffer, 1)
$stLvi = 0
$stLvfi = 0
$stBuffer = 0
Return $sItemText
EndFunc ;==>GetSubItemText2
; Create and insert items directly into the listview
Func MyGUICtrlCreateListViewItem($sText, $nCtrlID, $nIndex)
Local $stLvItem = DllStructCreate("uint;int;int;uint;uint;ptr;int;int;int;int;")
Local $stText = DllStructCreate("char[260]")
Local $arText = StringSplit($sText, "|")
If $nIndex = -1 Then $nIndex = GUICtrlSendMsg($nCtrlID, $LVM_GETITEMCOUNT, 0, 0)
DllStructSetData($stText, 1, $arText[1]) ; Save the item text in the struct
DllStructSetData($stLvItem, 1, BitOR($LVIF_TEXT, $LVIF_PARAM))
DllStructSetData($stLvItem, 2, $nIndex)
DllStructSetData($stLvItem, 6, DllStructGetPtr($stText))
; Set the lParam of the struct to the line index - unique within the listview
DllStructSetData($stLvItem, 9, $nIndex)
$nIndex = GUICtrlSendMsg($nCtrlID, $LVM_INSERTITEMA, 0, DllStructGetPtr($stLvItem))
If $nIndex > -1 Then
; Insert now the rest of the column text
For $i = 2 To $arText[0]
DllStructSetData($stText, 1, $arText[$i])
DllStructSetData($stLvItem, 3, $i - 1) ; Store the subitem index
GUICtrlSendMsg($nCtrlID, $LVM_SETITEMTEXTA, $nIndex, DllStructGetPtr($stLvItem))
Next
EndIf
$stText = 0
$stLvItem = 0
; Change the column width to fit the item text
For $i = 0 To 2
GUICtrlSendMsg($nCtrlID, $LVM_SETCOLUMNWIDTH, $i, -1)
GUICtrlSendMsg($nCtrlID, $LVM_SETCOLUMNWIDTH, $i, -2)
Next
EndFunc ;==>MyGUICtrlCreateListViewItem