Source Code : Login
*****************************************************************************
thisform.konek
ipdb=ALLTRIM(thisform.labelip.Caption)
userdb="root"
passdb="***********"
namedb="dbbrg"
SQLSETPROP(0,"DispLogin",3)
mstr = "DATABASE="+namedb+";SERVER="+ipdb+";port=3306;UID="+userdb+";PWD="+passdb+";provider=MSDASQLR;DRIVER={MySQL ODBC 5.1 Driver};"
THISFORM.Koneksi = SQLSTRINGCONNECT( mstr )
IF THISFORM.Koneksi <= 0
thisform.lbkonek.Caption="Koneksi Ke Server Database MySQL Gagal"
ELSE
thisform.lbkonek.Caption="Koneksi Ke Server Database MySQL Berhasil"
ENDIF
THISFORM.namakursor = "QT"+SUBSTR(SYS(2015), 5)
koneksi = thisform.koneksi
namakursor=thisform.namakursor
*****************************************************************************
thisform.tampildata
SELECT ( namakursor )
THISFORM.text1.VALUE=pass
PUBLIC user_id, user_name, user_nama
user_id=id_user
user_name=name
user_nama=nama
THISFORM.REFRESH
****************************************************************************
thisform.init
LOCAL lcFileName
IF SELECT("textfile") = 0
CREATE CURSOR textfile (filename c(60),mem m)
APPEND BLANK
ENDIF
REPLACE textfile.FileName WITH "c:/Program Files/APPBRG/param.ini"
SELECT textfile
APPEND MEMO mem FROM ("c:/Program Files/APPBRG/param.ini") OVERWRITE
THISform.labelip.caption =ALLTRIM(textfile.mem)
ipdata=ALLTRIM(textfile.mem)
THISform.Refresh
thisform.konek
****************************************************************************
thisform.ambiluser
CREATE CURSOR Duser (id_user n(3),name c(10),pass c(10),nama c(50),alamat c(50))
mtf = namakursor
msql = "select * from user WHERE name = '" + THISFORM.txtname.Value + "';"
IF SQLEXEC(Koneksi, msql, "&mtf") <= 0
=MESSAGEBOX("Proses Query Ke MySQL Gagal", 0+16, "PESAN")
QUIT
RETURN
ENDIF
IF USED("&mtf")
SELECT Duser
DELETE ALL
SELECT &mtf
GO TOP
DO WHILE !EOF()
SCATTER MEMVAR
SELECT Duser
APPEND BLANK
GATHER MEMVAR
SELECT &mtf
SKIP
ENDDO
USE IN &mtf
ELSE
=MESSAGEBOX("Gagal Query Ke Data USER", 0+16, "Informasi")
RETURN
ENDIF
************************************************************************
thisform.txtname.LostFocus
IF Koneksi <= 0
=MESSAGEBOX("Anda Belum Koneksi Ke Server Database MySQL ", 0+16, "Konfirmasi")
QUIT
ELSE
mtf = namakursor
msql = "select * from user WHERE name = '" + THISFORM.txtname.Value + "';"
IF SQLEXEC(Koneksi, msql, "&mtf") <= 0
=MESSAGEBOX("Proses Query Ke MySQL Gagal", 0+16, "PESAN")
QUIT
RETURN
ENDIF
THISFORM.Baru = .T.
THISFORM.nilai_awal
IF USED("&mtf")
SELECT &mtf
GO TOP
IF !EOF()
THISFORM.Baru = .F.
THISFORM.tampil_data
ENDIF
ENDIF
RETURN
ENDIF
************************************************************************
thisform.commandOK.Click
IF EMPTY( THISFORM.txtname.Value )
MESSAGEBOX("Username Harus diisi!!",0+48,"Perhatian")
THISFORM.Txtname.SETFOCUS()
RETURN
ENDIF
IF EMPTY( THISFORM.Txtpass.Value )
MESSAGEBOX("Password Harus diisi!!",0+48,"Perhatian")
THISFORM.Txtpass.SETFOCUS()
RETURN
ENDIF
SET EXACT ON
IF ALLTRIM(thisform.txtpass.Value)=ALLTRIM(thisform.text1.Value) AND ALLTRIM(thisform.text2.Value)=ALLTRIM(thisform.text3.Value)
MESSAGEBOX('Anda mempunyai Hak Akses',0+64,'Informasi')
DO FORM 'c:/program files/appBRG/900.scx'
thisform.ambiluser
THISFORM.RELEASE
ELSE
MESSAGEBOX('User Atau Password salah',0+16,'Informasi')
ENDIF
No comments :
Post a Comment