PROGRAM CLIENT
Listing Program Login :
Private Sub Command1_Click()
If username.Text = "okki" And pass.Text = "281090" Then
Menu.Show
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Listing Program Mobil:
Sub Hapus()
kode.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 cars(kode,namamobil,jenismobil,seri,harga)" & _
"values('" & kode.Text & _
"','" & namamobil.Text & _
"','" & jenismobil.Text & _
"','" & seri.Text & _
"','" & harga.Text & "')"
Case 1
SQL = "UPDATE cars Set namamobil='" & namamobil.Text & "'," & _
"jenismobil='" & jenismobil.Text & "'," & _
"seri='" & seri.Text & "'," & _
"harga='" & harga.Text & "'," & _
"where kode='" & kode.Text & "'"
Case 2
SQL = " DELETE * FROM cars WHERE kode='" & kode.Text & "'"
End Select
MsgBox "Pemrosesan RECORD Database telah berhasil....!", vbInformation, "Data cars"
Call Hapus
kode.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 kode_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If kode.Text = "" Then Exit Sub
WS.SendData "SEARCH-" & kode.Text
End If
End Sub
Private Sub CmdProses_Click(Index As Integer)
Select Case Index
Case 0
Call Hapus
kode.SetFocus
Case 1
If CmdProses(1).Caption = "&Simpan" Then
SQL = "Insert into sars(kode,namamobil,jenismobil,seri,harga)" & _
"namamobil='" & namamobil.Text & _
"',jenismobil='" & jenismobil.Text & _
"',seri='" & seri.Text & _
"',harga='" & harga.Text & _
"'Where kode='" & kode.Text & "'"
WS.SendData "INSERT-" & SQL
Else
SQL = "UPDATE cars set " & _
"namamobil='" & namamobil.Text & _
"',jenismobil='" & jenimobil.Text & _
"',seri='" & seri.Text & _
"',harga='" & harga.Text & _
"'Where kode='" & kode.Text & "'"
WS.SendData "UPDATE-" & SQL
End If
Case 2
X = MsgBox("Yakin RECORD cars Akan Dihapus.....!", vbQuestion + vbYesNo, "cars")
If X = vbYes Then
WS.SendData "DELETE-" & kode.Text
End If
Call Hapus
Nis.SetFocus
Case 3
Call Hapus
kode.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 = kode.Text
Call Hapus
kode.Text = X
Call RubahCMD(Me, False, True, False, True)
CmdProses(1).Caption = "&Simpan"
namamobil.SetFocus
Case "RECORD"
xData2 = Split(xData1(1), "/")
namamobil.Text = xData2(0)
jenismobil.Text = xData2(1)
seri.Text = xData2(2)
harga.Text = xData2(3)
Call RubahCMD(Me, False, True, True, True)
CmdProses(1).Caption = "&Edit"
kode.Enabled = False
namamobil.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
Private Sub Keluar_Click()
Unload Me
End Sub
Private Sub Mobil_Click()
FrmMobil.Show
End Sub
Listing Program 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