TABEL FROM LOGIN
Private Sub Masuk_Click()
If username.Text = "vidi" And pass.Text = "444444" Then
Me.Hide
MDIForm1.Show
Else
MsgBox "Maaf Kata Sandi yang Anda Masukkan Salah!", vbInformation, "pemakai"
End If
End Sub
TABEL FORM MAHASISWA
Listing Program:
Dim IPServer As String
Sub hapus()
nama.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 buku(kdbuku,judul,pengarang,penerbit,tahun,edisi,harga,jumlah)" & _
"values('" & nama.Text & _
"','" & alamat.Text & _
"','" & jeniskelamin.Text & _
"','" & tempatlahir.Text & _
"','" & tanggallahir.Text & _
"','" & agama.Text & _
"','" & asalsekolah.Text & _
"','" & notelepon.Text & "')"
Case 1
SQL = "UPDATE nama SET alamat='" & alamat.Text & "'," & _
"jeniskelamin='" & jeniskelamin.Text & "' " & _
"tempatlahir='" & tempatlahir.Text & "' " & _
"tanggallahir='" & tanggallahir.Text & "' " & _
"agama='" & agama.Text & "' " & _
"asalsekolah='" & asalsekolah.Text & "' " & _
"notelepon='" & notelepon.Text & "' " & _
"where nama='" & nama.Text & "'"
Case 2
SQL = "DELETE FROM nama WHERE nama='" & nama.Text & "'"
End Select
MsgBox "pemrosesan RECORD database telah berhasil...!", vbInformation, "nama"
Call hapus
nama.SetFocus
End Sub
Private Sub cmdproses_Click(Index As Integer)
Select Case Index
Case 0
Call hapus
nama.SetFocus
Case 1
If cmdproses(1).Caption = " &Simpan" Then
SQL = "INSERT INTO nama(nama,alamat,jeniskelamin,tempatlahir,tanggallahir,agama,asalsekolah,notelepon)" & _
"values('" & nama.Text & _
"','" & alamat.Text & _
"','" & jeniskelamin.Text & _
"','" & tempatlahir.Text & _
"','" & tanggallahir.Text & _
"','" & agama.Text & _
"','" & asalsekolah.Text & _
"','" & notelepon.Text & "')"
ws.SendData "UPDATE-" & SQL
Else
SQL = "UPDATE nama SET alamat = '" & alamat.Text & "'," & _
"' , jeniskelamin = '" & jeniskelamin.Text & _
"' , tempatlahir= '" & tempatlahir.Text & _
"' , tenggallahir= '" & tanggallahir.Text & _
"' , agama= '" & agama.Text & _
"' , asalsekolah= '" & asalsekolah.Text & _
"' , notelepon= '" & notelepon.Text & _
"' where nama= '" & nama.Text & "'"
ws.SendData "UPDATE-" & SQL
End If
Case 2
X = MsgBox("yakin RECORD buku akan dihapus...!", vbQuestion + vbYesNo, "buku")
If X = vbYes Then
ws.SendData "DELETE-" & nama.Text
End If
Call hapus
nama.SetFocus
Case 3
Call hapus
nama.SetFocus
Case 4
Unload Me
End Select
End Sub
Private Sub Form_Load()
Call hapus
mulaikoneksi
End Sub
Private Sub nama_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If nama.Text = "" Then Exit Sub
ws.SendData "SEARCH-" & nama.Text
End If
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 ws_DataArrival(ByVal bytesTotal As Long)
Dim xkirim As String
Dim xdata1() As String
Dim xdata2() As String
Dim xdata3() As String
Dim xdata4() As String
ws.GetData xkirim, vbString, bytesTotal
xdata1 = Split(xkirim, "-")
Select Case xdata1(0)
Case "NOTHING"
X = nama.Text
Call hapus
nama.Text = X
Call rubahCMD(Me, False, True, False, True)
cmdproses(1).Caption = "&Simpan"
alamat.SetFocus
Case "RECORD"
xdata2 = Split(xdata1(1), "/")
alamat.Text = xdata2(0)
jeniskelamin.Text = xdata2(1)
tempatlahir.Text = xdata2(2)
tanggallahir.Text = xdata2(3)
Call rubahCMD(Me, False, True, True, True)
cmdproses(1).Caption = "&Edit"
nama.Enabled = False
alamat.SetFocus
Case "DEL"
MsgBox "penghapusan data berhasil!"
Call hapus
Case "EDIT"
MsgBox "Pengeditan Record berhasil!"
Call hapus
End Select
End Sub
TABEL FORM MENU:
Listing Program:
Private Sub Keluar_Click()
Unload Me
End Sub
Private Sub Mahasiswa_Click()
frmmahasiswa.Show
End Sub
MODUL:
Public SQL As String
Sub ClearFORM(f As Form)
Dim ctl As Control
For Each ctl In f
If TypeOf ctl Is TextBox Then ctl.Text = ""
If TypeOf ctl Is ComboBox Then ctl.Text = ""
Next
End Sub
Sub Center(f As Form)
f.Move (Screen.Width - f.Width) / 2, (Screen.Height - f.Height) / 4
End Sub
Sub rubahCMD(f As Form, L0 As Boolean, L1 As Boolean, L2 As Boolean, L3 As Boolean)
f.cmdproses(0).Enabled = L0
f.cmdproses(1).Enabled = L1
f.cmdproses(2).Enabled = L2
f.cmdproses(3).Enabled = L3
End Sub
Tidak ada komentar:
Posting Komentar