**************************************************************
THISFORM.HIDE()
WAIT "正在读取数据库数据,请等待... ..." WINDOWS NOWAIT
*设定视图参数,读视图数据
lcUnitCode=THISFORM.PageFrame1.Page1.Text1.Value &&选择单位代码
cs_n_year=VAL(THISFORM.PageFrame1.Page2.Combo1.Value) &&选择年度
cs_n_month=THISFORM.PageFrame1.Page2.Combo2.Value &&选择月份
cs_d_date=CTOD(STR(cs_n_year,4)+"-"+STR(cs_n_month,2)+"-01")
* 判断单位级别,确定刷新人员范围。
DO CASE
CASE RIGHT(lcUnitcode,8)="00000000"
cs_c_unitcode=""
CASE RIGHT(lcUnitcode,6)="000000"
cs_c_unitcode=SUBST(lcUnitcode,1,2)
CASE RIGHT(lcUnitcode,4)="0000"
cs_c_unitcode=SUBST(lcUnitcode,1,4)
CASE RIGHT(lcUnitcode,2)="00"
cs_c_unitcode=SUBST(lcUnitcode,1,6)
OTHER
cs_c_unitcode=SUBST(lcUnitcode,1,8)
ENDCASE
c_fpfs="计时" &&分配方式
n_rxl=THISFORM.PageFrame1.Page1.Text5.Value &&月均工日
*计算日历天数
lnRlts=30
DO CASE
CASE INLIST(cs_n_month,1,3,5,7,8,10,12)
lnRlts=31
CASE INLIST(cs_n_month,4,6,9,11)
lnRlts=30
OTHE
IF MOD(cs_n_year,400)=0 OR (MOD(cs_n_year,4)=0 AND MOD(cs_n_year,100)<>0)
lnRlts=29
ELSE
lnRlts=28
ENDIF
ENDCASE
* 读入数据
SELECT st_salaryformula && 读入公式组
cs_c_groupname=alltrim(THISFORM.PageFrame1.Page3.list1.Value)
=REQUERY()
GOTO BOTT
SELECT st_gzhssj
=REQUERY()
GOTO BOTT
*开始修改事务
cViewName="st_gzhssj"
SET DATABASE TO ldgzbase &&事务需要在数据库中进行
oldBuffer=CURSORGETPROP("Buffering",cViewName) &&视图缓冲方式
=CURSORSETPROP("Buffering",5,cViewName) &&设为表缓冲
**********************************************************
BEGIN TRANSACTION &&开始本地事务**********************************
nhandle=-1 &&远程连接句柄
IF DBGETPROP(cViewName,"VIEW","SourceType")=2 &&数据源类型 1-本地视图 2-远程视图
nhandle=CURSORGETPROP("ConnectHandle",cViewName)
=SQLSETPROP(nhandle,"Transactions",2) &&开始人工事务**************************************
ENDIF
*计算工资
WAIT CLEAR
SELECT st_salaryformula
myfrm=NewObject("_thermometer","libs\tycommon","","正在进行工资核算... ...")
COUNT TO lnReccount FOR l_correct=1
myfrm.iBasis=lnReccount
myfrm.SHOW()
lnPercent=0
SCAN FOR l_correct=1 &&正确公式
lnPercent=lnPercent+1
myfrm.Update(lnPercent,"")
SELECT st_gzhssj
lcif=ALLTRIM(st_salaryformula.c_if)
lcThen=ALLTRIM(st_salaryformula.c_salaryitem)+" WITH "+ALLTRIM(st_salaryformula.c_then)
IF (NOT TYPE(lcIf)="L" AND NOT EMPTY(lcIf)) OR NOT TYPE(ALLTRIM(st_salaryformula.c_then))="N"
MESSAGEBOX("计算公式有错误,跳过!"+chr(13)+CHR(13)+ALLTRIM(st_salaryformula.c_itemname)+":"+STR(st_salaryformula.n_sxh,3),64,"操作提示")
ELSE
IF EMPTY(lcif)
REPL &lcThen ALL
ELSE
REPL &lcThen FOR &lcif
ENDIF
ENDIF
SELECT st_salaryformula
ENDSCAN
myfrm.COMPLETE()
IF TABLEUPDATE(.T.,.T.,cViewName)
IF nhandle>0
=SQLCOMMIT(nhandle) &&提交远程事务***************************
ENDIF
END TRANSACTION &&结束本地事务***************************************
MESSAGEBOX("工资数据核算操作完成!",64,"操作提示")
ELSE
IF nhandle>0
=SQLROLLBACK(nhandle) &&回滚远程事务
ENDIF
ROLLBACK &&回退本地事务*************************************************
MESSAGEBOX("工资数据核算操作失败, 请重新操作!",64,"操作提示")
ENDIF
=CURSORSETPROP("Buffering",3,cViewName) &&设为表缓冲
*刷新显示
FOR x = 1 TO _SCREEN.FormCount
IF UPPER(_SCREEN.Forms(x).NAME) = "TY_MAINFORMN1"
_SCREEN.Forms(x).RefreshData()
EXIT
ENDIF
ENDFOR
THISFORM.release()
*************** THE END **************