Selasa, 05 Juli 2011

Quis Program VB

DATA BASE


Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\MASDA>cd\

C:\>cd apache\mysql\bin

C:\apache\mysql\bin>mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 3.23.47-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+--------------+
| Database     |
+--------------+
| DBPenggajian |
| TOKOMASDA    |
| jesmi        |
| masda        |
| mysql        |
| test         |
+--------------+
6 rows in set (0.00 sec)

mysql> use jesmi;
Database changed
mysql> create table produk(kd_produk varchar(5),nama varchar(50),satuan varchar(
10),jumlah double);
Query OK, 0 rows affected (0.36 sec)

mysql> decs produk;
ERROR 1064: You have an error in your SQL syntax near 'decs produk' at line 1
mysql> desc produk;
+-----------+-------------+------+-----+---------+-------+
| Field     | Type        | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| kd_produk | varchar(5)  | YES  |     | NULL    |       |
| nama      | varchar(50) | YES  |     | NULL    |       |
| satuan    | varchar(10) | YES  |     | NULL    |       |
| jumlah    | double      | YES  |     | NULL    |       |
+-----------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> insert into produk values('A001',"TV","PCS",10);
Query OK, 1 row affected (0.00 sec)

mysql> insert into produk values('A002',"RADIO","PCS",10);
Query OK, 1 row affected (0.00 sec)

mysql> insert into produk values('A003',"KULKAS","PCS",10);
Query OK, 1 row affected (0.00 sec)

mysql> insert into produk values('A004',"MESIN CUCI","PCS",10);
Query OK, 1 row affected (0.00 sec)

mysql> insert into produk values('A005',"KIPAS ANGIN","PCS",10);
Query OK, 1 row affected (0.00 sec)

mysql> insert into produk values('A006',"SPIKER","PCS",10);
Query OK, 1 row affected (0.00 sec)

mysql> insert into produk values('A007',"AC","PCS",10);
Query OK, 1 row affected (0.00 sec)

mysql> insert into produk values('A008',"KOMPUTER","PCS",10);
Query OK, 1 row affected (0.00 sec)

mysql> insert into produk values('A009',"LABTOP","PCS",10);
Query OK, 1 row affected (0.00 sec)

mysql> insert into produk values('A010',"VCD","PCS",10);
Query OK, 1 row affected (0.00 sec)

mysql> select*from produk;
+-----------+-------------+--------+--------+
| kd_produk | nama        | satuan | jumlah |
+-----------+-------------+--------+--------+
| A001      | TV          | PCS    |     10 |
| A002      | RADIO       | PCS    |     10 |
| A003      | KULKAS      | PCS    |     10 |
| A004      | MESIN CUCI  | PCS    |     10 |
| A005      | KIPAS ANGIN | PCS    |     10 |
| A006      | SPIKER      | PCS    |     10 |
| A007      | AC          | PCS    |     10 |
| A008      | KOMPUTER    | PCS    |     10 |
| A009      | LABTOP      | PCS    |     10 |
| A010      | VCD         | PCS    |     10 |
+-----------+-------------+--------+--------+
10 rows in set (0.00 sec)

mysql> create table pelanggan(kd_pelanggan varchar(5),nama varchar(50),alamat va
rchar(80),telp varchar(15));
Query OK, 0 rows affected (0.00 sec)

mysql> desc pelanggan;
+--------------+-------------+------+-----+---------+-------+
| Field        | Type        | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+-------+
| kd_pelanggan | varchar(5)  | YES  |     | NULL    |       |
| nama         | varchar(50) | YES  |     | NULL    |       |
| alamat       | varchar(80) | YES  |     | NULL    |       |
| telp         | varchar(15) | YES  |     | NULL    |       |
+--------------+-------------+------+-----+---------+-------+
4 rows in set (0.01 sec)

mysql> insert into pelanggan values('B001',"JESMI","MEDAN",085217003368);
Query OK, 1 row affected (0.00 sec)

mysql> insert into pelanggan values('B002',"MEI","MEDAN",085217000368);
Query OK, 1 row affected (0.00 sec)

mysql> insert into pelanggan values('B003',"TIKA","MEDAN",085217000068);
Query OK, 1 row affected (0.00 sec)

mysql> insert into pelanggan values('B004',"TINA","MEDAN",085217000008);
Query OK, 1 row affected (0.00 sec)

mysql> insert into pelanggan values('B005',"DEWI","MEDAN",085217000000);
Query OK, 1 row affected (0.00 sec)

mysql> insert into pelanggan values('B006',"DEVI","MEDAN",085217100000);
Query OK, 1 row affected (0.00 sec)

mysql> insert into pelanggan values('B007',"DESI","MEDAN",085217180000);
Query OK, 1 row affected (0.00 sec)

mysql> insert into pelanggan values('B008',"WINDA","MEDAN",085217188000);
Query OK, 1 row affected (0.00 sec)

mysql> insert into pelanggan values('B009',"RIKI","MEDAN",085217188800);
Query OK, 1 row affected (0.00 sec)

mysql> insert into pelanggan values('B010',"RINI","MEDAN",085217188880);
Query OK, 1 row affected (0.00 sec)

mysql> select*from pelanggan;
+--------------+-------+--------+-------------+
| kd_pelanggan | nama  | alamat | telp        |
+--------------+-------+--------+-------------+
| B001         | JESMI | MEDAN  | 85217003368 |
| B002         | MEI   | MEDAN  | 85217000368 |
| B003         | TIKA  | MEDAN  | 85217000068 |
| B004         | TINA  | MEDAN  | 85217000008 |
| B005         | DEWI  | MEDAN  | 85217000000 |
| B006         | DEVI  | MEDAN  | 85217100000 |
| B007         | DESI  | MEDAN  | 85217180000 |
| B008         | WINDA | MEDAN  | 85217188000 |
| B009         | RIKI  | MEDAN  | 85217188800 |
| B010         | RINI  | MEDAN  | 85217188880 |
+--------------+-------+--------+-------------+
10 rows in set (0.00 sec)

mysql> create table penjualan(no_bukti varchar(5),tanggal varchar(10),kd_pelangg
an varchar(5),kd_produk varchar(5),jumlah double);
Query OK, 0 rows affected (0.00 sec)

mysql> desc penjualan;
+--------------+-------------+------+-----+---------+-------+
| Field        | Type        | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+-------+
| no_bukti     | varchar(5)  | YES  |     | NULL    |       |
| tanggal      | varchar(10) | YES  |     | NULL    |       |
| kd_pelanggan | varchar(5)  | YES  |     | NULL    |       |
| kd_produk    | varchar(5)  | YES  |     | NULL    |       |
| jumlah       | double      | YES  |     | NULL    |       |
+--------------+-------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql> insert into penjualan values('C001','1','A001','B001',50);
Query OK, 1 row affected (0.00 sec)

mysql> insert into penjualan values('C002','2','A002','B002',60);
Query OK, 1 row affected (0.00 sec)

mysql> insert into penjualan values('C003','3','A003','B003',65);
Query OK, 1 row affected (0.00 sec)

mysql> insert into penjualan values('C004','4','A004','B004',75);
Query OK, 1 row affected (0.00 sec)

mysql> insert into penjualan values('C005','5','A005','B005',70);
Query OK, 1 row affected (0.00 sec)

mysql> insert into penjualan values('C006','6','A006','B006',80);
Query OK, 1 row affected (0.00 sec)

mysql> insert into penjualan values('C007','7','A007','B008',85);
Query OK, 1 row affected (0.00 sec)

mysql> insert into penjualan values('C008','8','A008','B008',80);
Query OK, 1 row affected (0.00 sec)

mysql> insert into penjualan values('C009','9','A009','B009',90);
Query OK, 1 row affected (0.00 sec)

mysql> insert into penjualan values('C010','10','A010','B010',95);
Query OK, 1 row affected (0.02 sec)

mysql> select*from penjualan;
+----------+---------+--------------+-----------+--------+
| no_bukti | tanggal | kd_pelanggan | kd_produk | jumlah |
+----------+---------+--------------+-----------+--------+
| C001     | 1       | A001         | B001      |     50 |
| C002     | 2       | A002         | B002      |     60 |
| C003     | 3       | A003         | B003      |     65 |
| C004     | 4       | A004         | B004      |     75 |
| C005     | 5       | A005         | B005      |     70 |
| C006     | 6       | A006         | B006      |     80 |
| C007     | 7       | A007         | B008      |     85 |
| C008     | 8       | A008         | B008      |     80 |
| C009     | 9       | A009         | B009      |     90 |
| C010     | 10      | A010         | B010      |     95 |
+----------+---------+--------------+-----------+--------+
10 rows in set (0.00 sec)

mysql>




                                                              Gbr.Frm Menu


                                                  Gbr. Prm Produk




                                                  Gbr. Frm Pelanggan



                                                                 Gbr. Frm Penjualan  

LISTINGPROGRAM FORM PRODUK

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


LISTING PROGRAM FORM 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 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




LISTING PROGRAM FORM 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 & "')"
        Case 1
           
            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 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




LISTING PROGRAM FRM PEMBANTU CRISTAL REPORT 1-3 SAMA
Dim Report As New CrystalReport1

Private Sub Form_Load()
Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault

End Sub

Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth

End Sub


LISTING PROGRAM MENU
Private Sub F1_Click()
    Form1.Show
   
End Sub

Private Sub F2_Click()
Form2.Show

End Sub

Private Sub F3_Click()
Form3.Show

End Sub

Private Sub mnC1_Click()
Form4.Show

End Sub

Private Sub mnC2_Click()
Form5.Show
End Sub

Private Sub mnc3_Click()
Form6.Show

End Sub


LISTING PROGRAM MENU

Public Db As New ADODB.Connection
Public RS As New ADODB.Recordset
Public RS2 As New ADODB.Recordset
Public SQL As String

Sub OPENDB()
    If Db.State = adStateOpen Then Db.Close
    Db.CursorLocation = adUseClient
    Db.Open "Provider=MSDASQL.1;Persist Security Info=False;Data Source=barang"
End Sub

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




                                                Gbr.  Hasil Frm pPoduk
                                                     Gbr.Hasil Frm Pelanggan

                                              Gbr.Hasil Frm Penjualan


                                                    Gbr. Crstl Repot Produk




                                               Gbr. Crstl Repot Pelanggan



                                               Gbr. Crstl Repot  Penjualan


                                                  Gbr.Hasil. Crstl Repot Produk
                                         Gbr. Hasil Crstl Repot Pelanggan

                                                   Gbr. Hasil Crstl Repot Penjualan

Tidak ada komentar: