Mengenai Saya

Foto saya
Medan, sumut, Indonesia

Senin, 04 Juli 2011

PROG.PENJUALAN


Sub hapus()
    no_bukti.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 penjualan(no_bukti, tgl, kd_pelanggan,kd_produk,jumlah)" & _
                " values('" & no_bukti.Text & _
                "','" & tgl.Text & _
                "','" & kd_pelanggan.Text & _
                "','" & kd_produk.Text & _
                "','" & jumlah.Text & "')"
        Case1
            SQL = "UPDATE produk SET tgl ='" & tgl.Text & "'," & _
                  " kd_pelanggan = '" & kd_pelanggan.Text & "'," & _
                  " kd_produk = '" & kd_produk.Text & "'," & _
                  " jumlah = '" & jumlah.Text & "'," & _
                  " where no_bukti ='" & no_bukti.Text & "'"
        Case 2
            SQL = "DELETE FROM penjualan WHERE no_bukti='" & no_bukti.Text & "'"
    End Select
    MsgBox "Pemorosesan RECORD Database telah berhasil...!", vbInformation, "Data penjualan"
    Db.Execute SQL, adCmdTable
    Call hapus
    Adodc1.Refresh
    no_bukti.SetFocus
End Sub

Sub Tampilpenjualan()
    On Error Resume Next
    no_bukti.Text = RS!no_bukti
    tgl.Text = RS!tgl
    kd_pelanggan.Text = RS!kd_pelanggan
    kd_produk.Text = RS!kd_produk
    jumlah.Text = RS!jumlah
   
End Sub

Private Sub Cmdproses_Click(Index As Integer)
Select Case Index
    Case 0
        Call hapus
        no_bukti.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, "penjualan")
        If X = vbYes Then prosesDB 2
        Call hapus
        no_bukti.SetFocus
    Case 3
        Call hapus
        no_bukti.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 no_bukti_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        If no_bukti.Text = "" Then
            MsgBox "Masukkan no_bukti penjualan !", vbInformation, "penjualan"
            no_bukti.SetFocus
            Exit Sub
        End If
        SQL = "SELECT * FROM produk WHERE no_bukti='" & no_bukti.Text & "'"
        If RS.State = adStateOpen Then RS.Close
        RS.Open SQL, Db, adOpenDynamic, adLockOptimistic
        If RS.RecordCount <> 0 Then
            Tampilpenjualan
            Call RubahCMD(Me, False, True, True, True)
            cmdproses(1).Caption = "&Edit"
            no_bukti.Enabled = False
        Else
            X = no_bukti.Text
            Call hapus
            no_bukti.Text = X
            Call RubahCMD(Me, False, True, False, True)
            cmdproses(1).Caption = "&baru"
        End If
        tgl.SetFocus
    End If
End Sub





Tidak ada komentar:

Posting Komentar