Form Login
Listing Program
Private Sub Command1_Click()
If username.Text = "dedy" And pass.Text = "1234" Then
Menu.Show
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Form siswa
Listing program:
Sub Hapus()
Nis.Enabled = True
ClearFORM Me
Call RubahCMD(Me, True, False, False, False)
CmdProses(1).Caption = "&Simpan"
End Sub
Sub ProsesDB(Log As Byte)
Select Case Log
Case 0
SQL = "Insert into siswa(nis,nama,alamat,ttl, tahun)" & _
"values('" & Nis.Text & _
"','" & Nama.Text & _
"','" & alamat.Text & _
"','" & ttl.Text & _
"','" & tahun.Text & "')"
Case 1
SQL = "UPDATE siswa Set nama='" & Nama.Text & "'," & _
"alamat='" & alamat.Text & "'," & _
"ttl='" & ttl.Text & "'," & _
"tahun='" & tahun.Text & "'," & _
"where nis='" & Nis.Text & "'"
Case 2
SQL = " DELETE * FROM siswa WHERE nis='" & Nis.Text & "'"
End Select
MsgBox "Pemrosesan RECORD Database telah berhasil....!", vbInformation, "Data siswa"
Call Hapus
Nis.SetFocus
End Sub
Sub MulaiKoneksi()
IPServer = "192.168.10.1"
IPClient = WS.LocalIP
WS.Connect IPServer, 1000
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
DoEvents
End
End Sub
Private Sub nis_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Nis.Text = "" Then Exit Sub
WS.SendData "SEARCH-" & Nis.Text
End If
End Sub
Private Sub CmdProses_Click(Index As Integer)
Select Case Index
Case 0
Call Hapus
Nis.SetFocus
Case 1
If CmdProses(1).Caption = "&Simpan" Then
SQL = "Insert into siswa(nis, Nama,alamat,ttl, tahun)" & _
"Nama='" & Nama.Text & _
"',alamat='" & alamat.Text & _
"',ttl='" & ttl.Text & _
"',tahun='" & tahun.Text & _
"'Where nis='" & Nis.Text & "'"
WS.SendData "INSERT-" & SQL
Else
SQL = "UPDATE siswa set " & _
"Nama='" & Nama.Text & _
"',alamat='" & alamat.Text & _
"',ttl='" & ttl.Text & _
"',tahun='" & tahun.Text & _
"'Where nis='" & Nis.Text & "'"
WS.SendData "UPDATE-" & SQL
End If
Case 2
X = MsgBox("Yakin RECORD siswa Akan Dihapus.....!", vbQuestion + vbYesNo, "siswa")
If X = vbYes Then
WS.SendData "DELETE-" & Nis.Text
End If
Call Hapus
Nis.SetFocus
Case 3
Call Hapus
Nis.SetFocus
Case 4
Unload Me
End Select
End Sub
Private Sub Form_Load()
Call Hapus
MulaiKoneksi
End Sub
Private Sub WS_DataArrival(ByVal bytesTotal As Long)
Dim xKirim As String
Dim xData1() As String
Dim xData2() As String
WS.GetData xKirim, vbString, bytesTotal
xData1 = Split(xKirim, "-")
xData2 = Split(xData1(1), "/")
Select Case xData1(0)
Case "NOTHING"
X = Nis.Text
Call Hapus
Nis.Text = X
Call RubahCMD(Me, False, True, False, True)
CmdProses(1).Caption = "&Simpan"
Nama.SetFocus
Case "RECORD"
xData2 = Split(xData1(1), "/")
Nama.Text = xData2(0)
alamat.Text = xData2(1)
ttl.Text = xData2(2)
tahun.Text = xData2(3)
Call RubahCMD(Me, False, True, True, True)
CmdProses(1).Caption = "&Edit"
Nis.Enabled = False
Nama.SetFocus
Case "DEL"
MsgBox "Penghapusan Data Berhasil!"
Call Hapus
Case "EDIT"
MsgBox "Pengeditan Record Berhasil!"
Call Hapus
Case "INSERT"
MsgBox "Penginputan Data Record Berhasil!"
Call Hapus
End Select
End Sub
Form Menu
Listing program
Private Sub MDIForm_Load()
Menu.Show
End Sub
Private Sub Siswa_Click()
FrmSiswa.Show
End Sub
Tidak ada komentar:
Posting Komentar