|
本帖最后由 bin0131 于 2011-2-7 17:23 编辑
#include <Excel.au3>
#include <WinAPI.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
GUICreate("工资查询系统",400,400)
$a=GUICtrlCreateButton("确认按钮",160,150,60,30)
GUICtrlCreateLabel("请输入姓名",15,40,100,20)
$d=GUICtrlCreateInput("",120,40,230,20)
GUICtrlCreateLabel("请输入密码",15,80,100,20)
$e=GUICtrlCreateInput("",120,80,230,20,$ES_PASSWORD)
$f=GUICtrlCreateInput("",120,120,230,20)
GUICtrlCreateLabel("请输入查找的月份",15,120,100,20)
$u=GUICtrlRead($d)
$x=GUICtrlRead($e)
GUICtrlCreateButton("修改密码",250,150,60,30)
GUISetState(@SW_SHOW)
func password($c,$password)
Dim $b[22],$un[22],$ten[2][22]
$sFilePath1 = "e:\鹿城分局工资汇总\"&GUICtrlRead($f)&".xls"
_ExcelBookClose($sFilePath1)
$oExcel = _excelbookopen($sFilePath1,0,"true","19820131","19820131")
If @error = 1 Then
MsgBox(0, "错误!", "无法创建 Excel 对象")
Return
ElseIf @error = 2 Then
MsgBox(0, "错误!", "文件不存在 - 请重新选择!")
Return
endif
_ExcelSheetActivate($oExcel,"工资")
for $i=5 to 300 step 1
$n=_excelreadcell($oExcel,$i,1)
if $c=$n then
For $t=1 To 21 Step 1
$b[$t]=_ExcelReadCell($oExcel,4,$t+1)
$ten[0][$t]=$b[$t]
$un[$t]=_excelreadcell($oExcel,$i,$t+1)
$ten[1][$t]=$un[$t]
Next
_ExcelBookClose($oExcel)
$sFilePath = "e:\鹿城分局工资汇总\密码.xls"
_ExcelBookClose($sFilePath)
$oExcel1=_excelbookopen($sFilePath,0,"true","19820131","19820131")
_ExcelSheetActivate($oExcel1,"sheet1")
for $j=2 to 300 step 1
$g=_excelreadcell($oExcel1,$j,2)
$tt=_excelreadcell($oExcel1,$j,1)
if $c=$tt and $password=$g then
_ArrayDisplay($ten,"工资明细表",-1,1)
_ExcelBookClose($oExcel1)
exitloop
elseif $c<>$tt and _excelreadcell($oExcel1,$j,1)="" then
$sFilePath = "e:\鹿城分局工资汇总\密码.xls"
$oExcel1=_excelbookopen($sFilePath,0,"true","19820131","19820131")
_ExcelWriteCell($oExcel1,$c,$j,1)
_excelwritecell($oExcel1,"123456",$j,2)
_ExcelBookSaveas($oExcel1,"e:\鹿城分局工资汇总\密码.xls","xls",0,1) 保存会出现问题,该文件就没有了
_ExcelBookClose($oExcel1)
Elseif $password<>$g Then
MsgBox(0,"工资","密码不正确")
_ExcelBookClose($oExcel1)
exitloop
endif
Next
_ExcelBookClose($oExcel1)
ExitLoop
Else
EndIf
Next
if $c<>$n Then
_ExcelBookClose($oExcel)
MsgBox(0,"工资","查无此人工资")
endif
_ExcelBookClose($oExcel)
endfunc
while 1
$msg=GUIGetMsg()
Select
case $msg=$GUI_EVENT_CLOSE
exit
case $msg=$a
$u=GUICtrlRead($d)
$x=GUICtrlRead($e)
password($u,$x)
EndSelect
WEnd |
|