Kamis, 26 Maret 2009

Make Form Add User

This exercise is to create a form to add user ... ..
This series of exercises making form login, change password and next time used for userlist and access level.

Scenario form of a user is added .... We add a new user id to login to the application and of course with its password.

Ok let's begin ... ... try creating the form as below:



Please see the form above, get :
2 textbox for data entry (for password and confirmation using the character '*')
1 spinner (9 maximum value, minimum value 0)
2 buttons (OK and Cancel)

Contents coding "load" event:
SELECT 0
USE userku Alias tbl_u
SET ORDER TO 1

Contents coding "DESTROY" event:
IF USED ( 'tbl_u')
USE IN tbl_u
Endif

Contents coding the "Cancel":
Thisform.release

Contents coding the "OK" button:
local lcusedid, lcpassword, lcconfirm, lnuserid

lcuserid = Upper (alltrim (thisform.text1.value))
lcpassword = alltrim (thisform.text2.value)
lcconfirm = alltrim (thisform.text3.value)
lnuserlvl = thisform.spinner1.value

if empty (lcpassword)
messagebox ( "Password not be empty!", 48, "Attention")
Thisform.text2.setfocus ()
RETURN. F.
endif
if lcpassword # lcconfirm
messagebox ( "Confirm password unequal!", 48, "Attention")
Thisform.text3.setfocus ()
RETURN. F.
endif

SELECT tbl_u
seek upper (lcuserid)
if found ()
messagebox ( "User already exists!", 48, "Attention")
Thisform.text1.setfocus ()
RETURN. F.
endif

SELECT tbl_u
append blank
Replace userid with lcuserid
Replace level with lnuserlvl
Replace pwd with encryption (lcpassword)

MESSAGEBOX ( "The user id of success!", 64, "Attention")
Thisform.Release


Thank your attention, please to try ... good luck

Tidak ada komentar: