*********************************************************
* 程序名称：政风测评数据处理系统                        *
* 程序版本：2008.11 主程序 (BEGIN.PRG)                  *
* 完成日期：2008年11月                                  *
* 程序设计：王永国                                      *
* 工作单位：安徽大学数学与信息科学学院                  *
* 邮政编码：230039                                      *
* 联系电话：13605691079     0551-5159719                *
* 电子信箱：ygwang21@163.com                            *
*********************************************************
set talk off
set status bar off
SET ESCAPE OFF
set noti off
set near off
set clock on
set dele on
set safety off
set exact on
set clock status
set century on
set date ansi

clear all
public MYPATH,syspath,sys_dw,menushow,XTadmin   &&系统参数初始化
public err,err_program,err_line,err_info1

syspath=left(sys(16),rat("\",sys(16)))
MYPATH=syspath 
set defa to (syspath)   
set path to (syspath),(syspath)+"data",(syspath)+"scx",(syspath)+"dbf",(syspath)+"bmp",(syspath)+"mnx"  

ON ERROR DO errhand WITH SYS(0), ERROR(), MESSAGE(), MESSAGE(1), PROGRAM(), LINENO(1), DBF(), DATE(), TIME()  && 错误捕捉  

************系统信息初始化*************
if used("system")
   sele system
else
   sele 0
   use "dbf\system.dbf"
endif 
if date()<SYRQ
   =messagebox("    系统日期不正确，请修改后再运行！",48+0,"系统提示：")
   quit
else
   REPL SYRQ WITH DATE()
endif   
sys_dw=trim(sydw)
use

IF sysmetric(1)<>1024
   =messagebox("    系统要求分辨率为1024X768，请修改后再运行！",48+0,"系统提示：")
   quit
ENDIF     
menushow=0

local ctitle
ctitle='欢迎使用《政风行风评议数据处理系统》'
Declare integer FindWindow in win32api string cClass,String cCaption
if FindWindow(0,ctitle)#0
	_screen.windowstate=2
	_screen.caption=ctitle
	_screen.visible=.f.
	??chr(7)
    close all
	on shutdown
	quit
ENDIF
with _screen
    .windowstate=2
	.visible=.f.
endwith
_screen.autocenter=.t.
_screen.caption=ctitle

************系统主界面*****************
do form "scx\version.scx" 
read events

************启动菜单******************
 _screen.visible=.t.  &&最大化
do "mnx\begin.mpr"    &&启动菜单

************登录界面*****************
=INKEY(0.2,'m')
do form "scx\xtdl.scx"
=INKEY(0.01,'m')
read events
close database
return

*************错误捕捉设置结束**************
PROCEDURE errhand  
	PARAMETER m.machine, m.messgnum, m.messg, m.linecode, m.callprog, m.inline, m.OPENTABL, m.errdate, m.errtime
	m.errspace=SELECT()      && 保存当前工作区.  
	IF LEN(ALLTRIM(m.callprog))=0  
		m.callprog="Command Line"  
	    STORE SPACE(0) TO m.linecode  
	ENDIF
	IF !USED("ERRORLOG")  
		IF FILE(syspath+"ERRORLOG.DBF")  
	    	SELECT 0  
	     	USE errorlog  
	  	ELSE
        	CREATE TABLE syspath+"errorlog" FREE (machine c(20),messgnum N(4,0),messg c(70),linecode c(70),callprog c(40),inline N(6,0),opentabl c(100),errdate d,errtime c(8))  
	    ENDIF
	ENDIF
	INSERT INTO errorlog FROM MEMVAR  
    SELECT (m.errspace)              && 返回到保存的工作区 
    =messagebox("系统发现“"+m.messg+"”错误，请重新登录！",48,'警告！')
	close all
	release all
	on shutdown quit
	quit
ENDPROC

FUNCTION WYGGETDIR    &&打开文件夹
 PRIVATE cTitle,hOwner,pidl,MPATH,CPATH
 Declare integer FindWindow IN WIN32API String,String 
 Declare integer SHBrowseForFolder in "shell32.dll" integer @ 
 Declare integer SHGetPathFromIDList in "shell32.dll" integer,String @ 
 cTitle=_screen.caption
 hOwner=FindWindow(0,cTitle)
 pidl = SHBrowseForFolder(hOwner)
 CPATH=""
 IF not ISNULL(pidl)
  mpath=spac(512)
  =SHGetPathFromIDList(pidl,@mpath)
  MPATH=ALLT(MPATH)
  IF !EMPTY(MPATH)
   FOR I=1 TO LEN(MPATH)
    IF ASC(SUBS(MPATH,I,1)) =0
     CPATH=SUBS(MPATH,1,I-1)
     I=LEN(MPATH)+1
    ENDIF
   NEXT FOR
  ENDIF
  CPATH=IIF(RIGHT(CPATH,1)=="\",CPATH,CPATH+"\")
  RETURN CPATH
 ENDIF
ENDFUNC

FUNCTION KLJM    &&口令加解密
para pword,hh
*调用格式:kljm('password',1)
LOCAL WMZ,PLEN,i
PLEN=LEN(ALLTRIM(pword))
WMZ=''
IF HH=1     &&加密
	for i=1 to PLEN
		WMZ=WMZ+chr(asc(subs(pword,PLEN+1-i,1))+(i*13))
	endfor
ELSE        &&解密
	for i=1 to PLEN
		WMZ=WMZ+chr(asc(subs(pword,PLEN+1-i,1))-((PLEN+1-i)*13))
	endfor
ENDIF
RETU WMZ
ENDFUNC
