Project Form Pegawai
Dim IPServer As String
Sub Hapus()
Nip.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 Pegawai(Nip,Nama,Jeniskelamin,Jabatan)" & _
"values('" & Nip.Text & _
"','" & Nama.Text & _
"','" & Gol.Text & _
"','" & Jeniskelamin.Text & _
"','" & Jabatan.Text & "')"
Case 1
SQL = "UPDATE Pegawai SET Nama='" & Nama.Text & "'," & _
"Gol= '" & Gol.Text & "'," & _
"Jeniskelamin= '" & Jeniskelamin.Text & "'," & _
"Jabatan= '" & Jabatan.Text & "'," & _
"where Nip='" & Nip.Text & "'"
Case 2
SQL = "DELETE FROM Pewagai WHERE Nip='" & Nip.Text & "'"
End Select
MsgBox "Pemprosesan RECORD Database telah berhasil...!", vbInformation, "Pegawai"
Call Hapus
Nip.SetFocus
End Sub
Private Sub CmdProses_Click(Index As Integer)
Select Case Index
Case 0
Call Hapus
Nip.SetFocus
Case 1
If CmdProses(1).Caption = "&Simpan" Then
SQL = "INSERT INTO Pegawai(Nip,Nama,Gol,Jeniskelamin,Jabatan)" & _
"values('" & Nip.Text & _
"','" & Nama.Text & _
"','" & Gol.Text & _
"','" & Jeniskelamin.Text & _
"','" & Jabatan.Text & "')"
WS.SendData "INSERT-" & SQL
Else
SQL = "UPDATE pegawai set " & _
"nama= '" & Nama.Text & _
"',jabatan='" & Jabatan.Text & _
"' where Nip='" & Nip.Text & "'"
WS.SendData "UPDATE-" & SQL
End If
Case 2
x = MsgBox("Yakin RECORD Pegawai Akan Dihapus...!", vbQuestion + vbYesNo, "Pegawai")
If x = vbYes Then
WS.SendData "DELETE-" & Nip.Text
End If
Call Hapus
Nip.SetFocus
Case 3
Call Hapus
Nip.SetFocus
Case 4
Unload Me
End Select
End Sub
Private Sub Form_Load()
Call Hapus
MulaiKoneksi
End Sub
Private Sub Kode_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Nip.Text = "" Then Exit Sub
WS.SendData "SEARCH-" & Nip.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 xkrim As String
Dim xData1() As String
Dim xData2() As String
WS.GetData xkirim, vbString, bytesTotal
xData1 = Split(xkirim, "-")
Select Case xData1(0)
Case "NOTHING"
x = Nip.Text
Call Hapus
Kode.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)
Gol.Text = xData2(1)
Jeniskelamin.Text = xData2(2)
Jabatan.Text = xData2(3)
Call RubahCMD(Me, False, True, True, True)
CmdProses(1).Caption = "&Edit"
Nip.Enabled = False
Nama.SetFocus
Case "DEL"
MsgBox "penghapusan data berhasil !"
Call Hapus
Case "EDIT"
MsgBox "pengeditan record berhasil !"
Call Hapus
End Select
End Sub
Project Form Menu Utama
Private Sub F1_Click()
Form1.Show
End Sub
Private Sub C_Click()
End
End Sub
Private Sub Form_Activate()
Text1 = Time
Text2 = Date
End Sub
Private Sub MDIForm_Load()
End Sub
Project Form Login
Private Sub command1_click()
If Txt1.Text = "Nano Pranata" And Txt2.Text = "Tembung" Then
MsgBox ("Pasword Anda Benar")
Else
MsgBox ("Pasword Anda Salah")
txt = ""
txt = ""
txt.SetFocus
End Sub
Private Sub Form_Load()
End Sub
Module
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