谁有登录验证的源代码?
有密码表,但是form 的load事件,不太明白 问题点数:0、回复次数:5Top
1 楼QQ29(we)回复于 2003-12-01 12:41:23 得分 0
如果不用sql语句该怎样写,输入任何字符都可以进入
Top
2 楼lai796(ast796)回复于 2003-12-01 12:45:13 得分 0
set talk off
set sysmenu off
set cent on
_screen.windowstate=2
_screen.icon="happy.ico"
_screen.maxbutton=0
_screen.minbutton=1
_screen.closable=.f.
_screen.picture="photo6.jpg"
MODIFY WINDOW SCREEN TITLE " 聊城大学勤工助学管理系统 今天是:"+dtoc(date())+" "+cdow(date())
ZOOM WINDOW SCREEN MAX
do about.mpr
open database 勤工助学数据库.dbc
do form 登录
read even
quit
2.系统登陆表单的代码:
①命令按钮“登陆”的程序代码:
use pas
go top
if thisform.user.value="qgzx" and thisform.pass.value=pas
use
do form 主窗体.scx
thisform.release
else
#define missmatch_loc "用户或口令错,请重新登录!"
wait window missmatch_loc timeout 1
thisform.user.value=''
thisform.pass.value=''
thisform.user.setfocus
numcount=numcount+1
if numcount=4
mess =messagebox("三次口令错,将退出程序!",4+16+2,"退出")
clear event
release thisform
endif
endif
set talk off
set sysmenu off
set cent on
_screen.windowstate=2
_screen.icon="happy.ico"
_screen.maxbutton=0
_screen.minbutton=1
_screen.closable=.f.
_screen.picture="photo6.jpg"
MODIFY WINDOW SCREEN TITLE " 聊城大学勤工助学管理系统 今天是:"+dtoc(date())+" "+cdow(date())
ZOOM WINDOW SCREEN MAX
do about.mpr
open database 勤工助学数据库.dbc
do form 登录
read even
quit
2.系统登陆表单的代码:
①命令按钮“登陆”的程序代码:
use pas
go top
if thisform.user.value="qgzx" and thisform.pass.value=pas
use
do form 主窗体.scx
thisform.release
else
#define missmatch_loc "用户或口令错,请重新登录!"
wait window missmatch_loc timeout 1
thisform.user.value=''
thisform.pass.value=''
thisform.user.setfocus
numcount=numcount+1
if numcount=4
mess =messagebox("三次口令错,将退出程序!",4+16+2,"退出")
clear event
release thisform
endif
endif
Top
3 楼newfang(传说中的MIC)回复于 2003-12-01 12:52:11 得分 0
select passworddbf
locate allt(username)==allt(thisform.EditUserName.text)
if eof() then
messagebox('无此用户','')
retu
endif
if not (allt(userpass)==allt(thisform.EditUserPass.text)) then
messagebox('口令错误','')
return
endif
messaebox('登陆成功’,'')Top
4 楼vtebjeeq(问楚)回复于 2003-12-01 19:20:06 得分 0
你到www.sciencep.com去下载个源程序来看看吧Top
5 楼magnetmoon(天涯明月刀)回复于 2003-12-02 08:27:56 得分 0
1.init()
#Include "Api.h"
Local mTimeOut
ThisForm.DialogInit()
&& Get default server, default user from Registry
mHKey=0
Temp=0
If RegCreateKeyEx(HKEY_CURRENT_USER,"Software\W&Y\W&Y2000\SQL Server",0,Chr(0),REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,0,@mHKey,@Temp)<>0
Return
EndIf
m_Server=Space(255)
mName="Default Server"
L=255
If RegQueryValueEx(mHKey,@mName,0,REG_SZ,@m_Server,@L)<>0
m_Server=""
Else
m_Server=Left(m_Server,L-1)
ThisForm.txtServer.Value=m_Server
EndIf
L=255
m_UserID=Space(255)
mName="Default User"
If RegQueryValueEx(mHKey,@mName,0,REG_SZ,@m_UserID,@L)<>0
m_UserID=""
Else
m_UserID=Left(m_UserID,L-1)
ThisForm.txtUserID.Value=m_UserID
EndIf
L=255
mTimeOut=Space(255)
mName="Connection TimeOut"
If RegQueryValueEx(mHKey,@mName,0,REG_SZ,@mTimeOut,@L)<>0
mTimeOut="1000"
Else
mTimeOut=Left(mTimeOut,L-1)
EndIf
ThisForm.ConnectionTimeOut=Val(mTimeOut)
RegCloseKey(mHKey)
ThisForm.txtPwd.SetFocus()
Return
2.cmdOk.click()
#Include "Api.h"
#Include "System.h"
#Include "StringID.h"
&& Delete old DSN used in system
If IsDSN(SYS_DSN)
DeleteDSN(SYS_DSN)
EndIf
If ISDSN(DB_DSN)
DeleteDSN(DB_DSN)
EndIf
&& Create new DSN for base data access
If Not CreateDSN(SYS_DSN,AllTrim(ThisForm.txtServer.Value),SYS_BASEDB)
ThisForm.RetVal=0
MessageBox(GetString(ERR_CANNOT_CONNECT),BTN_OK+ICO_STOP,GetString(MSG_ERROR))
Release ThisForm
Return
EndIf
Local m_SysPassword
If ThisForm.chkSystem.Value = 1
m_SystemType = "Test"
m_SysPassword = "wyadminpassword"
Else
m_SystemType = "Erp"
m_SysPassword = "NothingCouldMakeMeTurnBack"
EndIf
&& Open system database
mAppPath=GetAppPath()+"\Data\SysData"
Open Database &mAppPath
Delete Connection SYSCON
Create Connection SYSCON DataSource 'W&Y2000' UserID 'wyadmin' Password &m_SysPassword Database wy2000
Public m_CnSys && Connection handle for base data
Public m_CnDB && Connection handle for company data
Public m_UserLevel && User right level
Public m_CompanyID && Company ID
&& Connect to base data server
m_CnSys=SQLConnect("SYSCON","wyadmin",m_SysPassword)
If m_CnSys<=0
ThisForm.RetVal=0
MessageBox(GetString(ERR_CANNOT_CONNECT),BTN_OK+ICO_STOP,GetString(MSG_ERROR))
ThisForm.txtServer.Value=""
ThisForm.txtServer.SetFocus()
Return
EndIf
=SQLSetProp(m_CnSys,"QueryTimeOut",ThisForm.ConnectionTimeOut)
&& Switch to system database
mSQLRes=SQLExec(m_CnSys,"Use "+SYS_BASEDB)
If mSQLRes<0
ThisForm.RetVal=0
MessageBox(GetString(ERR_NO_SYS_DATA),BTN_OK+ICO_STOP,GetString(MSG_ERROR))
ThisForm.txtServer.Value=""
ThisForm.txtServer.SetFocus()
Return
EndIf
&& Generate a unique ID for temp table
mCursor=GenUID()
&& Query user information
mSQLRes=SQLExec(m_CnSys,"Select usr_yhdh,usr_yhmm,usr_yhdj,usr_zbdm,cmp_sjkmc,cmp_fwqmc,usr_gsdm from usr_mstr,cmp_mstr ;
where usr_gsdm=cmp_gsdm and usr_yhdh=?ThisForm.txtUserID.Value",mCursor)
&& Distinguish the user is leggal
If mSQLRes<=0
ThisForm.RetVal=0
MessageBox(GetString(ERR_LOGIN_FAILED),BTN_OK+ICO_STOP,GetString(MSG_ERROR))
ThisForm.txtPwd.Value=""
ThisForm.txtPwd.SetFocus()
Use In &mCursor
Return
EndIf
If RecCount(mCursor)<=0
ThisForm.RetVal=0
MessageBox(GetString(ERR_LOGIN_FAILED),BTN_OK+ICO_STOP,GetString(MSG_ERROR))
ThisForm.txtPwd.Value=""
ThisForm.txtPwd.SetFocus()
Use In &mCursor
Return
EndIf
&& Distinguish that password is OK
*!* If Not ThisForm.ComparePwd(AllTrim(ThisForm.txtPwd.Value),AllTrim(usr_yhmm))
*!* ThisForm.RetVal=0
*!* MessageBox(GetString(ERR_LOGIN_FAILED),BTN_OK+ICO_STOP,GetString(MSG_ERROR))
*!* ThisForm.txtPwd.Value=""
*!* ThisForm.txtPwd.SetFocus()
*!* Use In &mCursor
*!* Return
*!* EndIf
&& Create new DSN for company data access
Public m_Database,m_ServerData,m_CnDB20,m_CnDB30,m_CnDB31,m_CnDB80,m_CnDBlog
m_Database=cmp_sjkmc
m_ServerData=cmp_fwqmc
If Not CreateDSN(DB_DSN,AllTrim(cmp_fwqmc),AllTrim(cmp_sjkmc))
ThisForm.RetVal=0
Use In &mCursor
MessageBox(GetString(ERR_CANNOT_CONNECT),BTN_OK+ICO_STOP,GetString(MSG_ERROR))
Release ThisForm
Release m_CnSys
Return
EndIf
&& Login success, save default server,default user in Registry
mHKey=0
Temp=0
If RegCreateKeyEx(HKEY_CURRENT_USER,"Software\W&Y\W&Y2000\SQL Server",0,Chr(0),REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,0,@mHKey,@Temp)=0
mVal=AllTrim(ThisForm.txtServer.Value)
RegSetValueEx(mHKey,"Default Server",0,REG_SZ,@mVal,Len(mVal))
mVal=AllTrim(ThisForm.txtUserID.Value)
RegSetValueEx(mHKey,"Default User",0,REG_SZ,@mVal,Len(mVal))
RegCloseKey(mHKey)
EndIf
&& Switch to user company server and database
Delete Connection DBCON
Delete Connection DBCONSYS
Delete Connection DBCON20
Delete Connection DBCON30
Delete Connection DBCON31
Delete Connection DBCON80
Delete Connection DBCONlog
Create Connection DBCON DataSource 'W&Y2000DB' UserID 'wyadmin' Password &m_SysPassword
Create Connection DBCONSYS DataSource 'W&Y2000DB' UserID 'wyadmin' Password &m_SysPassword Database wy2000
Create Connection DBCON20 DataSource 'W&Y2000DB' UserID 'wyadmin' Password &m_SysPassword Database wy2000_20
Create Connection DBCON30 DataSource 'W&Y2000DB' UserID 'wyadmin' Password &m_SysPassword Database wy2000_30
Create Connection DBCON31 DataSource 'W&Y2000DB' UserID 'wyadmin' Password &m_SysPassword Database wy2000_31
Create Connection DBCON80 DataSource 'W&Y2000DB' UserID 'wyadmin' Password &m_SysPassword Database wy2000_80
Create Connection DBCONlog DataSource 'W&Y2000DB' UserID 'wyadmin' Password &m_SysPassword Database wy2000_log
m_CnDB=SQLConnect("DBCON","wyadmin",m_SysPassword)
If m_CnDB<=0
ThisForm.RetVal=0
Use In &mCursor
MessageBox(GetString(ERR_COMP_DATA_NOT_FOUND),BTN_OK+ICO_STOP,GetString(MSG_ERROR))
Release ThisForm
Release m_CnSys
Return
EndIf
=SQLSetProp(m_CnDB,"QueryTimeOut",ThisForm.ConnectionTimeOut)
mSQLRes=SQLExec(m_CnDB,"Use "+cmp_sjkmc)
If Upper(cmp_sjkmc)='WY2000_20'
m_CnDB20=m_CnDB
m_CnDB30=SQLConnect("DBCON30","wyadmin",m_SysPassword)
m_CnDB31=SQLConnect("DBCON31","wyadmin",m_SysPassword)
m_CnDB80=SQLConnect("DBCON80","wyadmin",m_SysPassword)
Else
m_CnDB30=m_CnDB
m_CnDB20=SQLConnect("DBCON20","wyadmin",m_SysPassword)
m_CnDB31=SQLConnect("DBCON31","wyadmin",m_SysPassword)
m_CnDB80=SQLConnect("DBCON80","wyadmin",m_SysPassword)
EndIf
m_CnDBlog=SQLConnect("DBCONlog","wyadmin",m_SysPassword)
If mSQLRes<0
ThisForm.RetVal=0
Use In &mCursor
MessageBox(GetString(ERR_COMP_DATA_NOT_FOUND),BTN_OK+ICO_STOP,GetString(MSG_ERROR))
Release ThisForm
Release m_CnSys
Release m_CnDB
Return
EndIf
&& OK, set the global varies, close temp table
Public m_User
m_User=CreateObject("CUser")
m_User.UserID=AllTrim(ThisForm.txtUserID.Value)
If Not m_User.IsUserID
ThisForm.RetVal=0
Use In &mCursor
MessageBox("無此用戶",BTN_OK+ICO_STOP,GetString(MSG_ERROR))
Release ThisForm
Release m_CnSys
Release m_CnDB
Release m_User
Return
EndIf
m_Server=AllTrim(ThisForm.txtServer.Value)
m_UserID=AllTrim(ThisForm.txtUserID.Value)
m_UserLevel=usr_yhdj
m_UserPwd=AllTrim(usr_yhmm)
m_CompanyID=AllTrim(usr_gsdm)
Use In &mCursor
mSQLRes=SQLExec(m_CnDB,"Exec UserLogin ?m_UserID")
If mSQLRes<0
MessageBox(GetString(ERR_LOGIN_FAILED),BTN_OK+ICO_STOP,GetString(MSG_ERROR))
ThisForm.RetVal=0
Return
EndIf
If m_CompanyID='WY'
=SQLExec(m_CnDB30,"Exec UserLogin ?m_UserID")
Else
=SQLExec(m_CnDB20,"Exec UserLogin ?m_UserID")
EndIf
If m_SystemType = 'Test'
_Screen.Caption="W&Y2000測試"+" - "+GetDescription(m_CompanyID,"CompanyName",m_LangID)+" ("+m_UserID+")"
Else
_Screen.Caption="W&Y2000"+" - "+GetDescription(m_CompanyID,"CompanyName",m_LangID)+" ("+m_UserID+")"
EndIf
Local mFile
mFile=LoadDesktop()
If Not File(mFile)
frmDsk.Picture=""
Else
frmDsk.Picture=mFile
EndIf
ThisForm.RetVal=1
Release ThisForm
Return
Top




