Mengenai Saya

Foto saya
Medan, sumut, Indonesia

Senin, 04 Juli 2011

PROGRAM PELANGGAN

Sub hapus()
    kd_pelanggan.Enabled = True
    ClearFORM Me
    Call RubahCMD(Me, True, False, False, False)
    cmdproses(1).Caption = "&baru"
End Sub

Sub prosesDB(Log As Byte)
   Select Case Log
        Case 0
            SQL = "INSERT INTO pelanggan(kd_pelanggan, nama, alamat, telp)" & _
                " values('" & kd_pelanggan.Text & _
                "','" & nama.Text & _
                "','" & alamat.Text & _
                "','" & telp.Text & "')"
        Case 1
           
            SQL = "UPDATE pelanggan SET Nama ='" & nama.Text & "'," & _
                  " alamat = '" & alamat.Text & "'," & _
                  " telp = '" & telp.Text & "'," & _
                  " where kd_pelanggan ='" & kd_pelanggan.Text & "'"
        Case 2
            SQL = "DELETE FROM pelanggan WHERE kd_pelanggan='" & kd_pelanggan.Text & "'"
    End Select
    MsgBox "Pemorosesan RECORD Database telah berhasil...!", vbInformation, "Data pelanggan"
    Db.Execute SQL, adCmdTable
    Call hapus
    Adodc1.Refresh
    kd_pelanggan.SetFocus
End Sub

Sub Tampilpelanggan()
    On Error Resume Next
    kd_pelanggan.Text = RS!kd_pelanggan
    nama.Text = RS!nama
    alamat.Text = RS!alamat
    telp.Text = RS!telp
   
End Sub

Private Sub Cmdproses_Click(Index As Integer)
Select Case Index
    Case 0
        Call hapus
        kd_pelanggan.SetFocus
    Case 1
        If cmdproses(1).Caption = "&baru" Then
            Call prosesDB(0)
        Else
            Call prosesDB(1)
        End If
    Case 2
        X = MsgBox("Yakin RECORD produk Akan Dihapus...!", vbQuestion + vbYesNo, "pelanggan")
        If X = vbYes Then prosesDB 2
        Call hapus
        kd_pelanggan.SetFocus
    Case 3
        Call hapus
        kd_pelanggan.SetFocus
    Case 4
        Unload Me
    End Select
End Sub

Private Sub Form_Load()
    Call OPENDB
    Call hapus
   
   
End Sub

Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)

End Sub

Private Sub kd_pelanggan_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        If kd_pelanggan.Text = "" Then
            MsgBox "Masukkan kd_pelanggan produk !", vbInformation, "pelanggan"
            kd_pelanggan.SetFocus
            Exit Sub
        End If
        SQL = "SELECT * FROM pelanggan WHERE kd_pelanggan='" & kd_pelanggan.Text & "'"
        If RS.State = adStateOpen Then RS.Close
        RS.Open SQL, Db, adOpenDynamic, adLockOptimistic
        If RS.RecordCount <> 0 Then
            Tampilpelanggan
            Call RubahCMD(Me, False, True, True, True)
            cmdproses(1).Caption = "&Edit"
            kd_pelanggan.Enabled = False
        Else
            X = kd_pelanggan.Text
            Call hapus
            kd_pelanggan.Text = X
            Call RubahCMD(Me, False, True, False, True)
            cmdproses(1).Caption = "&baru"
        End If
        nama.SetFocus
    End If
End Sub







Tidak ada komentar:

Posting Komentar