小弟剛學PB做一個登陸視窗,用的是sql 2000資料庫,也有用戶表,但“登陸”按鈕代碼怎么寫?
uj5u.com熱心網友回復:
不就是你要根據用戶輸入的帳號,密碼去用戶表中查詢是否有匹配的資料嗎?寫一個SQL查詢,就可以了.
uj5u.com熱心網友回復:
這是最簡單的了!多看書!
uj5u.com熱心網友回復:
/* ================================== */// checklogin() 校驗登陸的區域函式
//
//
/* ================================== */
//登陸控制
String ls_logincd,ls_pwd,ls_curusername
integer li_type
ls_logincd=sle_logincd.Text
ls_pwd=sle_pwd.Text
li_type=checklogin(ls_logincd,ls_pwd)
if li_type=0 then
//登陸成功初始化登陸資訊 ,處理全域變數
GLOBAL_LoginCD=ls_logincd
GLOBAL_UserCD= ls_usercd
GLOBAL_UserLoginTime=gf_getnowdatetime()
select username into:ls_curusername from pub_users where usercd=:GLOBAL_UserCD;
GLOBAL_LoginUserName=ls_curusername
loginsuc()
else
if li_type=3 then
sle_logincd.Text=''
sle_pwd.Text=''
sle_logincd.Setfocus()
elseif li_type=4 then
sle_logincd.Text=''
sle_pwd.Text=''
sle_logincd.SetFocus()
elseif li_type=2 then
sle_pwd.SetFocus()
end if
messagebox('提示',gf_checkdata(li_type))
end if
看看吧!好多方法呢!
uj5u.com熱心網友回復:
打開生成的EXE檔案后,能進入開始的視窗,這個視窗的功能是用戶登錄,但是輸入用戶名和密碼,點擊確定后。開始視窗的OPEN事件:
ds_users=create datastore
ds_users.dataobject="dw_userinfo"
ds_users.settransobject(SQLCA)
ds_users.retrieve()
userid.text=""
password.text=""
userid.setfocus()
下面這個是確定按鈕的程式
string t1="操作提示"
string t2="登錄失敗"
string m1="請先輸入用戶名!然后重試..."
string m2= "請先輸入密碼!然后重試..."
string m3="用戶名或者密碼不正確!請重試..."
if userid.text="" then
messagebox(t1,m1)
return
end if
if password.text="" then
messagebox(t1,m2)
password.setfocus()
return
end if
int rowcount = 0
select count(*) into :rowcount
from usersinfo
where usersname = :userid.text and passwd = :password.text
;
if rowcount> 0 then
char temp
select rank into :temp
from usersinfo
where usersname = :userid.text and passwd = :password.text;
UserRank=temp
gs_userid=userid.text
gs_pwd=password.text
else
messagebox(t2,m3,Exclamation!)
return
end if
parent.visible=false
open(w_main)
close(parent)
uj5u.com熱心網友回復:
看書才是硬道理uj5u.com熱心網友回復:
forwardglobal type w_login from w_anc_xe
end type
type st_3 from statictext within w_login
end type
type phl_1 from picturehyperlink within w_login
end type
type sle_kl from singlelineedit within w_login
end type
type cb_ok from commandbutton within w_login
end type
type cb_cancel from commandbutton within w_login
end type
type sle_2 from singlelineedit within w_login
end type
type st_1 from statictext within w_login
end type
type st_2 from statictext within w_login
end type
type sle_yhm from singlelineedit within w_login
end type
type gb_1 from groupbox within w_login
end type
end forward
global type w_login from w_anc_xe
integer width = 1792
integer height = 1048
string title = "系統登錄"
boolean controlmenu = true
windowtype windowtype = response!
long backcolor = 67108864
string icon = "Application5!"
boolean center = true
st_3 st_3
phl_1 phl_1
sle_kl sle_kl
cb_ok cb_ok
cb_cancel cb_cancel
sle_2 sle_2
st_1 st_1
st_2 st_2
sle_yhm sle_yhm
gb_1 gb_1
end type
global w_login w_login
type variables
string is_get
integer ii_ret
end variables
forward prototypes
public subroutine wf_window_center (window aw_window)
end prototypes
on w_login.create
int iCurrent
call super::create
this.st_3=create st_3
this.phl_1=create phl_1
this.sle_kl=create sle_kl
this.cb_ok=create cb_ok
this.cb_cancel=create cb_cancel
this.sle_2=create sle_2
this.st_1=create st_1
this.st_2=create st_2
this.sle_yhm=create sle_yhm
this.gb_1=create gb_1
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.st_3
this.Control[iCurrent+2]=this.phl_1
this.Control[iCurrent+3]=this.sle_kl
this.Control[iCurrent+4]=this.cb_ok
this.Control[iCurrent+5]=this.cb_cancel
this.Control[iCurrent+6]=this.sle_2
this.Control[iCurrent+7]=this.st_1
this.Control[iCurrent+8]=this.st_2
this.Control[iCurrent+9]=this.sle_yhm
this.Control[iCurrent+10]=this.gb_1
end on
on w_login.destroy
call super::destroy
destroy(this.st_3)
destroy(this.phl_1)
destroy(this.sle_kl)
destroy(this.cb_ok)
destroy(this.cb_cancel)
destroy(this.sle_2)
destroy(this.st_1)
destroy(this.st_2)
destroy(this.sle_yhm)
destroy(this.gb_1)
end on
event open;this.wf_destroyDC()
this.wf_init_draw()
is_get=Message.StringParm
sle_yhm.setfocus()
end event
type sle_kl from singlelineedit within w_login
integer x = 512
integer y = 624
integer width = 498
integer height = 92
integer taborder = 20
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
boolean autohscroll = false
boolean password = true
borderstyle borderstyle = stylelowered!
end type
event modified;if keydown(keyenter!) then
cb_ok.triggerevent(clicked!)
end if
end event
type cb_ok from commandbutton within w_login
integer x = 1326
integer y = 452
integer width = 288
integer height = 96
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "確認"
boolean default = true
end type
event clicked;string ls_password,ls_get,ls_yh_mc,ls_lx
ls_get=trim(sle_kl.text)
ls_yh_mc=trim(sle_yhm.text)
if trim(ls_yh_mc)="" then
messagebox("錯誤","用戶名不正確!",StopSign!)
sle_yhm.SetFocus ( )
st_1.text="請輸入登錄口令,以進入系統"
return
end if
select yh_kl,yh_lx into :ls_password,:ls_lx from yhb where yh_mc=:ls_yh_mc;
if IsNull(ls_password) then ls_password=""
if ls_lx="" then
messagebox("錯誤","用戶名或口令不正確!",StopSign!)
sle_yhm.SetFocus ( )
st_1.text="請輸入登錄口令,以進入系統"
return
end if
if (trim(ls_password)=ls_get ) then
insert into howdo values(Now(),Today(),'進入系統',:ls_yh_mc);
select yh_id into :gs_yhid from yhb where yh_mc=:ls_yh_mc and yh_kl=:ls_password;
gs_yhmc=ls_yh_mc
gs_yhqx=ls_lx
gs_yhkl=ls_password
if is_get="更換操作員" then
closewithreturn(parent,"更換操作員")
gu_menu_qx.menu_refresh()
gu_menu_qx.menu_qxsz()
else
closewithreturn(parent,"w_main")
end if
return
else
messagebox("錯誤","口令不正確!",StopSign!)
sle_kl.SetFocus ( )
st_1.text="請輸入登錄口令,以進入系統"
ii_ret=ii_ret+1
if ii_ret>=3 then
messagebox("登錄失敗","對不起,你沒有使用權限,請確認用戶名稱和口令后再試!")
insert into howdo values(Now(),Today(),'登錄失敗',:gs_yhmc);
Halt;
end if
return
end if
end event
type cb_cancel from commandbutton within w_login
integer x = 1326
integer y = 680
integer width = 288
integer height = 96
integer taborder = 40
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "取消"
boolean cancel = true
end type
event clicked;if is_get="更換操作員" then
close(parent)
else
halt;
end if
end event
type sle_2 from singlelineedit within w_login
integer x = 229
integer y = 640
integer width = 302
integer height = 92
integer taborder = 60
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
long backcolor = 79741120
string text = "登錄口令:"
boolean border = false
boolean autohscroll = false
end type
type st_1 from statictext within w_login
integer x = 608
integer y = 64
integer width = 914
integer height = 116
integer textsize = -18
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = fixed!
fontfamily fontfamily = modern!
string facename = "隸書"
long textcolor = 134217857
long backcolor = 67108864
boolean enabled = false
string text = ""
boolean focusrectangle = false
end type
type st_2 from statictext within w_login
integer x = 229
integer y = 496
integer width = 283
integer height = 76
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
long backcolor = 67108864
boolean enabled = false
string text = "用戶名稱:"
boolean focusrectangle = false
end type
type sle_yhm from singlelineedit within w_login
integer x = 512
integer y = 480
integer width = 498
integer height = 92
integer taborder = 10
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
boolean autohscroll = false
borderstyle borderstyle = stylelowered!
end type
event modified;if keydown(keyenter!) then
sle_yhm.setfocus()
end if
end event
type gb_1 from groupbox within w_login
integer x = 87
integer y = 360
integer width = 1061
integer height = 480
integer taborder = 50
integer textsize = -10
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋體"
long textcolor = 33554432
long backcolor = 67108864
string text = "系統登錄"
end type
uj5u.com熱心網友回復:
樓上的有意思,只接把視窗檔案給整出來了uj5u.com熱心網友回復:
這個簡單啊,網上搜一下就得到答案了.轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/115093.html
標籤:腳本語言
