KERJA IT - COMPUTER

Markas Rabbani Surabaya Jl.Pucang Anom Timur No. 14 Surabaya Telp. 08123015071 Email : Markas_rabbani_sby@yahoo.co.id

  • RSS
  • Google +
  • Facebook

Popular Posts

IDHOSTINGER memang OK
Radio - TV OnLine
Asyiiikk Bro

Translate Google

About Me

Foto saya

1. Kerja di Perusahaan Jualan Computer 2. Konsultan Management and Software House di Jakarta Jl. Kemang Raya Jakarta Selatan, PT Sumber Saran Sempurna 3. Honor di Kantor Bea dan Cukai TG. Perak dan Juanda Surabaya 4. Free Line di berbagai Instansi sebagai Programmer 5. Mulai awal tahun 2007 sampai sekarang kerja di Rabbani Profesor Kerudung Instan Jl. Dharmawangsa 98 A Surabaya

Popular Posts

Markas Rabbani Surabaya

HOSTINGER

Web Hosting

KOMINITAS VFP

IP ADDRESS INFO

IP

Google+ Followers

Total Tayangan Laman

HOSTINGER

Web Hosting

Prof DR KH Said Aqil Sirodj - Ketua PB NU

Gus Mus - Prof DR KH Said Aqil Sirodj - Alm Gus Dur

HOSTINGER Web Gratis Tanpa Iklan

Gak Percaya Buktikan

Griya Asy-Syifa

Jl Suromulang Timur II/18 Perum Citra Surodinawan Estate Kota Mojokerto Contac : 081231821800, 08814353000, 085746201881 Pin BB : 24D0B84C e-mail : ariesmojokerto@gmail.com

HOSTINGER Gratis tanpa Iklan

Web Hosting GRATIS dI Indonesia Tanpa Iklan

WaliSongo

Babat alas Tanah Jawa - Pengikut Nabi Muhammad saw - NU

Minggu, 14 Oktober 2012

TRANSAKSI PENJUALAN - OC

ORDER CONFIRMATION

Sebelum Transaksi Penjualan biasanya Customer pesan dulu / Order Barang
Order Barang kita Input dulu untuk di konfirmasikan benar tidak nya
Ini yang disebut Order Confirmation (OC)  
Setelah di Confirmasikan kebenarnya dan dapat ACC atasannya baru di Posting
Hasil Posting sebagai Faktur Penjualan / Invoice .

Sekarang kita buat dulu Program Order Confirmasi , ini Outputnya :


  Yang perlu kita siapkan , Kebetulan kita menggunakan VB-2010 database MYSQL (XAMPP)

1. Kita Rancang Formnya 
2. Kita buat Modulnya sebagai koneksi VB2010 ke MYSQL
    di sebelah kanan atas Klik kanan Klik ADD Module

3. Kita buat koneksinya melalui connection MYSQL versi 6.5.4

 Di Module kita buat Codingnya :

Imports MySql.Data.MySqlClient
Imports System.Data
Module modul_oc
    Public cmd As New MySqlCommand
    Public dadapter As New MySqlDataAdapter
    Public datardr As MySqlDataReader
    Public strSql As String
    Dim serv As String = "Server=192.168.1.8;"
    Dim dbase As String = "Database=toko;"
    Dim uid As String = "uid=root;"
    Dim pwd As String = "pwd=root;"
    Dim ConString = serv & dbase & uid & pwd
    Public db As New MySqlConnection(ConString)
    Public Sub konek()
        Try
            tutupDB()
            db.Open()
            '  MsgBox("Koneksi DataBase berhasil dilakukan")
        Catch ex As MySqlException
            MsgBox(ex.Message)
            MsgBox("Koneksi tidak berhasil dilakukan")
        End Try
    End Sub
    Public Sub tutupDB()
        If db.State = ConnectionState.Open Then
            db.Close()
        End If
    End Sub

End Module





Kita buatkan layar Window tambahan untuk pencarian Tabel Customer :

Ini Codingnya :

Imports System.Data
Imports MySql.Data.MySqlClient
Public Class form2
    Private Sub TampilDataG()
        modul_oc.konek()

        Dim da As New MySqlDataAdapter("SELECT customercode,customername,enddate,alamat,telp FROM customer", db)

        Dim dt As New DataTable
        da.Fill(dt)
        dgvb.DataSource = dt
        ' Dim da As New MySqlDataAdapter("select TORDER,TGLORDER,CUSTOMERCODE,NOMOR,NAMRANG,POL,KDRANG,jumlah,hsat,stot,pdiskont,diskont,uang,inv,idisk,bersih from sdeler", db)

        'Dim query As String = "SELECT * FROM sdeler"
        ' Dim da As New MySqlDataAdapter(query, db)
        '  Dim ds As New DataSet()

        ' If da.Fill(ds) Then
        'dgv.DataSource = ds.Tables(1)
        ' End If


    End Sub

    Private Sub CekCustb()
        txtcarib.Text = Trim(UCase(txtcarib.Text))
       modul_oc.konek()
        Try
            strSql = "SELECT customercode,customername,enddate,alamat,telp FROM customer WHERE customername like '%" & txtcarib.Text & "%'"
            cmd.CommandText = strSql
            cmd.Connection = db
            dadapter.SelectCommand = cmd

            datardr = cmd.ExecuteReader
            datardr.Read()
            If datardr.HasRows Then
                ' datardr.Read()
                'Dim da As New MySqlDataAdapter("SELECT customercode,customername,enddate,alamat,telp FROM customer WHERE customername like '%" & txtcarib.Text & "%'", db)

                Dim query As String = "SELECT customercode,customername,enddate,alamat,telp FROM customer WHERE customername like '%" & txtcarib.Text & "%'"
                Dim da As New MySqlDataAdapter(query, db)
                Dim ds As New DataSet()

                If da.Fill(ds, "ketemu") Then
                    dgvb.DataSource = ds.Tables("ketemu")
                    dgvb.ReadOnly = True
                End If

            Else
                MsgBox("Data Tables Customer Tidak Ditemukan....!", MsgBoxStyle.Exclamation, "Informasi")


            End If
            ' db.Close()
        Catch ex As Exception

        End Try

    End Sub
    Private Sub form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TampilDataG()
    End Sub
    Private Sub dgvb_CellClick(ByVal sender As Object, _
 ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvb.CellClick
        With dgvb
            Form1.txtkdcust.Text = .Item(0, .CurrentRow.Index).Value
            '  dtpjual.Value = .Item(1, .CurrentRow.Index).Value
            Form1.txtnama.Text = .Item(1, .CurrentRow.Index).Value
            ' Form1.dtpexpired.Text = .Item(3, .CurrentRow.Index).Value
            Form1.txtalamat.Text = .Item(3, .CurrentRow.Index).Value
         
            ' CekCust()
        End With
    End Sub
    Private Sub dgvb_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgvb.DoubleClick
        With dgvb
            Form1.txtkdcust.Text = .Item(0, .CurrentRow.Index).Value
            '  dtpjual.Value = .Item(1, .CurrentRow.Index).Value
            Form1.txtnama.Text = .Item(1, .CurrentRow.Index).Value
            ' Form1.dtpexpired.Text = .Item(3, .CurrentRow.Index).Value
            Form1.txtalamat.Text = .Item(3, .CurrentRow.Index).Value
            Me.Close()
            Form1.txtnomor.Focus()

        End With
    End Sub



    Private Sub TampilKUST()
        modul_oc.konek()
        Dim da As New MySqlDataAdapter("SELECT customercode,customername,enddate,alamat,telp FROM customer WHERE customername like '%" & txtcarib.Text & "%'", db)
        Dim dt As New DataTable
        da.Fill(dt)
        dgvb.DataSource = dt
        dgvb.Refresh()
    End Sub
    'Private Sub txtcarib_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtcarib.KeyPress
    '  If e.KeyChar = Chr(13) Then
    '      TampilKUST()
    '   End If
    'End Sub

    Private Sub txtcarib_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcarib.TextChanged
        TampilKUST()
    End Sub
End Class



Kita buatkan Tabel  Barang sebagai Window tambahan ;

Cara Membuat Windows tambahan 

Klik kanan di Pojok Kanan atas pilih Add > Windows Form 
lalu beri nama sesuka anda :

kita buat textbox nya dan DataGridView nya

misal textbox nya kita beri Name = txtcaric
DataGridView nya kita beri name = dgvc

Baru kita buat Kodingnya :

Imports System.Data
Imports MySql.Data.MySqlClient
Public Class lyr_brg
    Private Sub TampilDataG()
        modul_oc.konek()

        Dim da As New MySqlDataAdapter("SELECT kdrang,namrang,jumlah,hsat fROM tabrang", db)

        Dim dt As New DataTable
        da.Fill(dt)
        dgvc.DataSource = dt
        dgvc.GridColor = Color.Red
        dgvc.CellBorderStyle = DataGridViewCellBorderStyle.None
        dgvc.BackgroundColor = Color.LightGray

        dgvc.DefaultCellStyle.SelectionBackColor = Color.Red
        dgvc.DefaultCellStyle.SelectionForeColor = Color.Yellow

        dgvc.DefaultCellStyle.WrapMode = DataGridViewTriState.[True]

        dgvc.SelectionMode = DataGridViewSelectionMode.FullRowSelect
        dgvc.AllowUserToResizeColumns = False

        dgvc.RowsDefaultCellStyle.BackColor = Color.Bisque
        dgvc.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige



    End Sub

    Private Sub CekCustb()
        txtcaric.Text = Trim(UCase(txtcaric.Text))
        modul_oc.konek()
        Try
            strSql = "SELECT kdrang,namrang,jumlah,hsat fROM tabrang WHERE namrang like '%" & txtcaric.Text & "%'"
            cmd.CommandText = strSql
            cmd.Connection = db
            dadapter.SelectCommand = cmd

            datardr = cmd.ExecuteReader
            datardr.Read()
            If datardr.HasRows Then
                ' datardr.Read()
                'Dim da As New MySqlDataAdapter("SELECT customercode,customername,enddate,alamat,telp FROM customer WHERE customername like '%" & txtcarib.Text & "%'", db)

                Dim query As String = "SELECT kdrang,namrang,jumlah,hsat fROM tabrang WHERE namrang like '%" & txtcaric.Text & "%'"
                Dim da As New MySqlDataAdapter(query, db)
                Dim ds As New DataSet()

                If da.Fill(ds, "ketemu") Then
                    dgvc.DataSource = ds.Tables("ketemu")
                    dgvc.ReadOnly = True
                End If

            Else
                MsgBox("Data Tables Customer Tidak Ditemukan....!", MsgBoxStyle.Exclamation, "Informasi")


            End If
            ' db.Close()
        Catch ex As Exception

        End Try

    End Sub
    Private Sub lyr_brg_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TampilDataG()
    End Sub
    Private Sub dgvc_CellClick(ByVal sender As Object, _
 ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvc.CellClick
        With dgvc
            Form1.txtkdrang.Text = .Item(0, .CurrentRow.Index).Value
            '  dtpjual.Value = .Item(1, .CurrentRow.Index).Value
            Form1.txtnamrang.Text = .Item(1, .CurrentRow.Index).Value
            ' Form1.dtpexpired.Text = .Item(3, .CurrentRow.Index).Value
            Form1.txthsat.Text = .Item(3, .CurrentRow.Index).Value

            ' CekCust()
        End With
    End Sub
    Private Sub dgvc_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgvc.DoubleClick
        With dgvc
            Form1.txtkdrang.Text = .Item(0, .CurrentRow.Index).Value
            '  dtpjual.Value = .Item(1, .CurrentRow.Index).Value
            Form1.txtnamrang.Text = .Item(1, .CurrentRow.Index).Value
            ' Form1.dtpexpired.Text = .Item(3, .CurrentRow.Index).Value
            Form1.txthsat.Text = .Item(3, .CurrentRow.Index).Value

            Me.Close()
            Form1.txtqty.Focus()

        End With
    End Sub



    Private Sub TampilRang()
        modul_oc.konek()
        Dim da As New MySqlDataAdapter("SELECT kdrang,namrang,jumlah,hsat fROM tabrang WHERE namrang like '%" & txtcaric.Text & "%'", db)
        Dim dt As New DataTable
        da.Fill(dt)
        dgvc.DataSource = dt
        dgvc.Refresh()
    End Sub
    'Private Sub txtcarib_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtcarib.KeyPress
    '  If e.KeyChar = Chr(13) Then
    '      TampilKUST()
    '   End If
    'End Sub

    Private Sub txtcaric_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcaric.TextChanged
        TampilRang()
    End Sub
End Class


Cara Membuat No.Faktur Otomatis 
Cari dahulu di data Mysql No.Faktur yg Terbesar 
Ini Contoh Coding :
  Private Sub HitungData()
        konek()
        Try
            strSql = "SELECT * from hsdeler where torderb in (select max(torderb) from hsdeler)"
        ' Mencari no.Faktur yg terbesar di tabel HSDELER 


            cmd.CommandText = strSql
            cmd.Connection = db
            dadapter.SelectCommand = cmd

            datardr = cmd.ExecuteReader
            datardr.Read()

'Jika belum ada data kita buat : Format(Now, "yyMMdd") + "0001"
            If Not datardr.HasRows Then
                ' Label21.Text = Format(Now, "yyMMdd") + "0001"
                hdata = Format(Now, "yyMMdd") + "0001"
                hdata = Trim(hdata)
                txtnofaktur.Text = "SO-C-" & Strings.Left(hdata, 6) & " - " & Strings.Right(hdata, 4)
                nofak = Val(hdata)
            Else
                If Microsoft.VisualBasic.Left(datardr.Item("torder"), 6) <> Format(Now, "yyMMdd") Then

' Jika Tgl beda nomor awal lagi, yaitu Format(Now, "yyMMdd") + "0001"
                    hdata = Format(Now, "yyMMdd") + "0001"
                    hdata = Trim(hdata)
                    nofak = Val(hdata)
                    txtnofaktur.Text = "SO-C-" & Strings.Left(hdata, 6) & " - " & Strings.Right(hdata, 4)
                Else

                    ' jika tgl sama maka nomor kita Tambah 1
                    nofak = datardr.Item("torderb") + 1
                    hdata = Trim(Str(nofak))
                    txtnofaktur.Text = "SO-C-" & Strings.Left(hdata, 6) & " - " & Strings.Right(hdata, 4)
                End If
            End If
            db.Close()
        Catch ex As Exception

        End Try
    End Sub



Dan Untuk Form1 kita buat juga Codingnya : 

Imports MySql.Data.MySqlClient
Public Class Form1
    Public mkunci, jum_record, hdata As String
    Public mthauto, nofak, mnom As Integer
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        konek()
    End Sub
    Private Sub TampilData()
        Try
            tutupDB()
            db.Open()

        Catch ex As MySqlException
            MsgBox(ex.Message)
            MsgBox("Koneksi tidak berhasil dilakukan")
            Exit Sub
        End Try
        ' Dim da As New MySqlDataAdapter("select torder,tglorder,customercode,nomor, from sdeler", db)
        Dim da As New MySqlDataAdapter("SELECT torder,tglorder,customercode,noitem,pol,kdrang,namrang,jumlah,hsat,stot,pdiskont,diskont,uang,inv,idisk,bersih FROM sdeler order by torder,noitem", db)

        '  Dim da As New MySqlDataAdapter("select TORDER,TGLORDER,CUSTOMERCODE,NOMOR,NAMRANG,POL,KDRANG,jumlah,hsat,stot,pdiskont,diskont,uang,inv,idisk,bersih from sdeler", db)
        Dim dt As New DataTable
        da.Fill(dt)
        dgv.DataSource = dt
        ' Dim da As New MySqlDataAdapter("select TORDER,TGLORDER,CUSTOMERCODE,NOMOR,NAMRANG,POL,KDRANG,jumlah,hsat,stot,pdiskont,diskont,uang,inv,idisk,bersih from sdeler", db)

        'Dim query As String = "SELECT * FROM sdeler"
        ' Dim da As New MySqlDataAdapter(query, db)
        '  Dim ds As New DataSet()

        ' If da.Fill(ds) Then
        'dgv.DataSource = ds.Tables(1)
        ' End If
        db.Close()

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TampilData()
        BersihData()
        HitungData()
        db.Close()
    End Sub
    Private Sub HitungData()
        konek()
        Try
            strSql = "SELECT * from hsdeler where torderb in (select max(torderb) from hsdeler)"

            cmd.CommandText = strSql
            cmd.Connection = db
            dadapter.SelectCommand = cmd

            datardr = cmd.ExecuteReader
            datardr.Read()
            If Not datardr.HasRows Then
                ' Label21.Text = Format(Now, "yyMMdd") + "0001"
                hdata = Format(Now, "yyMMdd") + "0001"
                hdata = Trim(hdata)
                txtnofaktur.Text = "SO-C-" & Strings.Left(hdata, 6) & " - " & Strings.Right(hdata, 4)
                nofak = Val(hdata)
            Else
                If Microsoft.VisualBasic.Left(datardr.Item("torder"), 6) <> Format(Now, "yyMMdd") Then
                    hdata = Format(Now, "yyMMdd") + "0001"
                    hdata = Trim(hdata)
                    nofak = Val(hdata)
                    txtnofaktur.Text = "SO-C-" & Strings.Left(hdata, 6) & " - " & Strings.Right(hdata, 4)
                Else
                    nofak = datardr.Item("torderb") + 1
                    hdata = Trim(Str(nofak))
                    txtnofaktur.Text = "SO-C-" & Strings.Left(hdata, 6) & " - " & Strings.Right(hdata, 4)
                End If
            End If
            db.Close()
        Catch ex As Exception

        End Try
    End Sub
    Private Sub HitungDataScreen()

        txtkotor.Text = txtqty.Text * txthsat.Text
        txtdiskont.Text = txtpdiskont.Text / 100 * txtkotor.Text
        txtsubtotal.Text = txtkotor.Text - txtdiskont.Text
        txtidisk.Text = txtpidisk.Text / 100 * txtsubtotal.Text
        txtnet.Text = txtsubtotal.Text - txtidisk.Text

    End Sub

    Private Sub BersihData()
        txtkdcust.Text = ""
        txtnama.Text = ""
        txtalamat.Text = ""
        txtnomor.Text = 0
        txtnopolibag.Text = 0
        txtkdrang.Text = ""
        txtnamrang.Text = ""
        txttipe.Text = ""
        txtqty.Text = 0
        txthsat.Text = 0
        txtkotor.Text = 0
        txtpdiskont.Text = 0
        txtdiskont.Text = 0
        txtpidisk.Text = 0
        txtidisk.Text = 0
        txtnet.Text = 0
        txtsubtotal.Text = 0

        ' dtpjual.Value = Date
        '  dtpexpired.Value = ""
    End Sub
    Private Sub CekCust()

        Try
            tutupDB()
            db.Open()

        Catch ex As MySqlException
            MsgBox(ex.Message)
            MsgBox("Koneksi tidak berhasil dilakukan")
            Exit Sub
        End Try
        Try
            strSql = "SELECT * FROM customer WHERE customercode ='" & txtkdcust.Text & "'"
            cmd.CommandText = strSql
            cmd.Connection = db
            dadapter.SelectCommand = cmd

            datardr = cmd.ExecuteReader
            If datardr.HasRows Then
                datardr.Read()
                txtnama.Text = datardr("customername")
                txtalamat.Text = datardr("alamat")
                dtpexpired.Value = datardr("enddate")

                ' cbkelamin.Focus()
                MsgBox("Data Table Customer Ditemukan....!", MsgBoxStyle.Exclamation, "Perhatian")

            Else
                MsgBox("Data Tables Customer Tidak Ditemukan....!", MsgBoxStyle.Exclamation, "Informasi")
                BersihData()

            End If
            ' db.Close()
        Catch ex As Exception

        End Try


    End Sub

    Private Sub dtpjual_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles dtpjual.KeyPress
        If e.KeyChar = Chr(13) Then
            txtkdcust.Focus()
        End If
    End Sub
    Private Sub txtkdcust_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtkdcust.KeyPress
        If e.KeyChar = Chr(13) Then
            txtkdcust.Text = UCase(txtkdcust.Text)
            ' If txtkdcust.Text = " " Then
            '  txtkdcust.Focus()
            'Exit Sub
            'Else
            CekCust()
            txtnomor.Focus()
            '  End If
        End If
    End Sub
    Private Sub txtpdiskont_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtpdiskont.KeyPress
        If e.KeyChar = Chr(13) Then
            HitungDataScreen()
            txtpidisk.Focus()
        End If
    End Sub

    Private Sub txtqty_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtqty.KeyPress
        If e.KeyChar = Chr(13) Then
            HitungDataScreen()
            txtpdiskont.Focus()

        End If
    End Sub
    Private Sub txtpidisk_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtpidisk.KeyPress
        If e.KeyChar = Chr(13) Then
            HitungDataScreen()
            btnsimpan.Focus()

        End If
    End Sub
    Private Sub txtnofaktur_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtnofaktur.KeyPress
        If e.KeyChar = Chr(13) Then
            ' txtkdcust.Text = UCase(txtkdcust.Text)
            CekHsdeler()
            txtkdcust.Focus()
        End If
    End Sub

    Private Sub CekHsdeler()
        txtnofaktur.Text = Trim(txtnofaktur.Text)
        Try
            tutupDB()
            db.Open()

        Catch ex As MySqlException
            MsgBox(ex.Message)
            MsgBox("Koneksi tidak berhasil dilakukan")
            Exit Sub
        End Try
        Try
            strSql = "SELECT * FROM Hsdeler WHERE torderoto ='" & txtnofaktur.Text & "'"
            cmd.CommandText = strSql
            cmd.Connection = db
            dadapter.SelectCommand = cmd

            datardr = cmd.ExecuteReader
            If datardr.HasRows Then
                datardr.Read()
                txtkdcust.Text = datardr("customercode")
                CekCust()
                'MsgBox("Data dari Table HSdeler Ditemukan....!", MsgBoxStyle.Exclamation, "Perhatian")
                Tampilsdeler()
            Else
                MsgBox("Data di Table HSdeler Tidak Ditemukan....!", MsgBoxStyle.Exclamation, "Informasi")
                'BersihData()

            End If
            ' db.Close()
        Catch ex As Exception

        End Try

    End Sub
    Private Sub Tampilsdeler()
        Try
            tutupDB()
            db.Open()

        Catch ex As MySqlException
            MsgBox(ex.Message)
            MsgBox("Koneksi tidak berhasil dilakukan")
            Exit Sub
        End Try
        Dim da As New MySqlDataAdapter("SELECT torderOTO,tglorder,customercode,noitem,pol,kdrang,namrang,jumlah,hsat,stot,pdiskont,diskont,uang,inv,idisk,bersih,kunci FROM sdeler WHERE torderoto ='" & txtnofaktur.Text & "' Order by torder,noitem", db)
        Dim dt As New DataTable
        da.Fill(dt)
        dgv.DataSource = dt
        dgv.Refresh()
    End Sub
    Private Sub Ceksdeler()
        txtnofaktur.Text = Trim(txtnofaktur.Text)
        Try
            tutupDB()
            db.Open()

        Catch ex As MySqlException
            MsgBox(ex.Message)
            MsgBox("Koneksi tidak berhasil dilakukan")
            Exit Sub
        End Try
        Try
            '  TextBox2.Text = mkunci
            strSql = "SELECT * FROM sdeler WHERE kunci ='" & mkunci & "'"
            cmd.CommandText = strSql
            cmd.Connection = db
            dadapter.SelectCommand = cmd

            datardr = cmd.ExecuteReader
            If datardr.HasRows Then
                datardr.Read()
                txtkdcust.Text = datardr("customercode")
                txtnopolibag.Text = datardr("pol")
                txtkdrang.Text = datardr("KDRANG")
                txtqty.Text = datardr("jumlah")
                txthsat.Text = datardr("hsat")
                txtkotor.Text = datardr("stot")
                txtpdiskont.Text = datardr("pdiskont")
                txtdiskont.Text = datardr("diskont")
                txtsubtotal.Text = datardr("uang")
                txtpidisk.Text = datardr("inv")
                txtidisk.Text = datardr("idisk")
                txtnet.Text = datardr("bersih")
                Cekbarang()
                ' formatangka()
                MsgBox("Data dari Table Sdeler Ditemukan....!", MsgBoxStyle.Exclamation, "Perhatian")

            Else
                MsgBox("Data di Table Sdeler Tidak Ditemukan....!", MsgBoxStyle.Exclamation, "Informasi")
            End If
            db.Close()
        Catch ex As Exception

        End Try


    End Sub

    Private Sub btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbersih.Click
        BersihData()
    End Sub

    Private Sub dgv_CellClick(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv.CellClick
        With dgv
            txtnofaktur.Text = .Item(0, .CurrentRow.Index).Value
            '  dtpjual.Value = .Item(1, .CurrentRow.Index).Value
            txtkdcust.Text = .Item(2, .CurrentRow.Index).Value
            txtnomor.Text = .Item(3, .CurrentRow.Index).Value
            txtnopolibag.Text = .Item(4, .CurrentRow.Index).Value
            txtkdrang.Text = .Item(5, .CurrentRow.Index).Value
            txtqty.Text = .Item(7, .CurrentRow.Index).Value
            txthsat.Text = .Item(8, .CurrentRow.Index).Value
            txtkotor.Text = .Item(9, .CurrentRow.Index).Value
            txtpdiskont.Text = .Item(10, .CurrentRow.Index).Value
            txtdiskont.Text = .Item(11, .CurrentRow.Index).Value
            txtsubtotal.Text = .Item(12, .CurrentRow.Index).Value
            txtpidisk.Text = .Item(13, .CurrentRow.Index).Value
            txtidisk.Text = .Item(14, .CurrentRow.Index).Value
            txtnet.Text = .Item(15, .CurrentRow.Index).Value
            'mkunci = .Item(16, .CurrentRow.Index).Value
            mkunci = RTrim(txtnofaktur.Text) & Str(txtnomor.Text)
            CekCust()
        End With
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If txtnofaktur.Text > " " Then
            CekHsdeler()
        Else
            MsgBox("No.Faktur tdk boleh Kosong....!", MsgBoxStyle.Exclamation, "Informasi")
            BersihData()
            txtnofaktur.Focus()
            Exit Sub
        End If

    End Sub
    Private Sub txtkdrang_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtkdrang.KeyPress
        If e.KeyChar = Chr(13) Then
            txtkdrang.Text = UCase(txtkdrang.Text)
            Cekbarang()
            txtqty.Focus()
        End If
    End Sub
    Private Sub txtnomor_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtnomor.KeyPress
        If e.KeyChar = Chr(13) Then
            If txtnomor.Text > 0 Then
                mnom = txtnomor.Text
                mkunci = RTrim(txtnofaktur.Text) & Str(txtnomor.Text)
                Ceksdeler()
                txtnopolibag.Focus()
            Else
                MessageBox.Show("Nomor Urut tidak boleh Kosong")
                txtnomor.Focus()
                Exit Sub
            End If
        End If


    End Sub
    Private Sub txtnopolibag_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtnopolibag.KeyPress
        If e.KeyChar = Chr(13) Then
            txtkdrang.Focus()
        End If
    End Sub

    Private Sub Cekbarang()
        txtnofaktur.Text = Trim(txtnofaktur.Text)
        Try
            tutupDB()
            db.Open()

        Catch ex As MySqlException
            MsgBox(ex.Message)
            MsgBox("Koneksi tidak berhasil dilakukan")
            Exit Sub
        End Try
        Try
            strSql = "SELECT * FROM tabrang WHERE kdrang ='" & txtkdrang.Text & "'"
            cmd.CommandText = strSql
            cmd.Connection = db
            dadapter.SelectCommand = cmd

            datardr = cmd.ExecuteReader
            If datardr.HasRows Then
                datardr.Read()
                txtnamrang.Text = datardr("namrang")
                txthsat.Text = datardr("hsat")
                ' txtqty.Text = datardr("jumlah")
                txttipe.Text = datardr("merkb")
                MsgBox("Data dari Table tabrang  Ditemukan....!", MsgBoxStyle.Exclamation, "Perhatian")
            Else
                MsgBox("Data di Table tabrang  Tidak Ditemukan....!", MsgBoxStyle.Exclamation, "Informasi")
            End If
            db.Close()
        Catch ex As Exception
        End Try
    End Sub

    Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
        CokHsdeler()
        Try
            tutupDB()
            db.Open()

        Catch ex As MySqlException
            MsgBox(ex.Message)
            MsgBox("Koneksi tidak berhasil dilakukan")
            Exit Sub
        End Try
        Try
            strSql = "SELECT * FROM Sdeler WHERE kunci ='" & mkunci & "'"
            cmd.CommandText = strSql
            cmd.Connection = db
            dadapter.SelectCommand = cmd

            datardr = cmd.ExecuteReader
            If datardr.HasRows Then
                datardr.Read()
                ' txtWarna.Text = datardr("Warna")
                MsgBox("Data tersebut pernah di Rekam....!", MsgBoxStyle.Exclamation, "Perhatian")
                Exit Sub
            End If

        Catch ex As Exception

        End Try
        Try
            tutupDB()
            db.Open()

        Catch ex As MySqlException
            MsgBox(ex.Message)
            MsgBox("Koneksi tidak berhasil dilakukan")
            Exit Sub
        End Try
        Try

            Dim cmd As New MySqlCommand("insert into Sdeler(kunci,torderoto,torder,tglorder,customercode,noitem,pol,kdrang,jumlah,hsat,stot,pdiskont,diskont,uang,inv,idisk,bersih) values('" & mkunci & "','" & txtnofaktur.Text & "','" & hdata & "','" & Format(dtpjual.Value, "yyyy-MM-dd HH:mm:ss") & "','" & txtkdcust.Text & "'," & txtnomor.Text & "," & txtnopolibag.Text & ",'" & txtkdrang.Text & "'," & txtqty.Text & "," & txthsat.Text & "," & txtkotor.Text & "," & txtpdiskont.Text & "," & txtdiskont.Text & "," & txtsubtotal.Text & "," & txtpidisk.Text & "," & txtidisk.Text & "," & txtnet.Text & ")", db)
            cmd.ExecuteNonQuery()
            Tampilsdeler()
            mnom = mnom + 1
            txtnomor.Text = mnom
            txtnomor.Focus()

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub CokHsdeler()
        txtnofaktur.Text = Trim(txtnofaktur.Text)
        Try
            tutupDB()
            db.Open()

        Catch ex As MySqlException
            MsgBox(ex.Message)
            MsgBox("Koneksi tidak berhasil dilakukan")
            Exit Sub
        End Try
        Try
            strSql = "SELECT * FROM Hsdeler WHERE torderoto ='" & txtnofaktur.Text & "'"
            'strSql = "SELECT * FROM Hsdeler WHERE torderb =" & nofak

            cmd.CommandText = strSql
            cmd.Connection = db
            dadapter.SelectCommand = cmd

            datardr = cmd.ExecuteReader
            If datardr.HasRows Then
                datardr.Read()
                txtkdcust.Text = datardr("customercode")
                CekCust()
                MsgBox("Data dari Table HSdeler Ditemukan....!", MsgBoxStyle.Exclamation, "Perhatian")
                Tampilsdeler()
                Exit Sub
            Else
                MsgBox("Data di Table HSdeler Tidak Ditemukan....!", MsgBoxStyle.Exclamation, "Informasi")
                Try
                    tutupDB()
                    db.Open()

                Catch ex As MySqlException
                    MsgBox(ex.Message)
                    MsgBox("Koneksi tidak berhasil dilakukan")
                    Exit Sub
                End Try
                Dim mnoautob, mfaktur As Integer
                mnoautob = 1
                mfaktur = Val(hdata)
                Dim cmd As New MySqlCommand("insert into HSdeler(torder,torderoto,tglorder,customercode,torderb) values('" & hdata & "','" & txtnofaktur.Text & "','" & Format(dtpjual.Value, "yyyy-MM-dd HH:mm:ss") & "','" & txtkdcust.Text & "', " & mfaktur & ")", db)
                cmd.ExecuteNonQuery()
                MsgBox("Data di Table HSdeler Berhasil di Rekam....!", MsgBoxStyle.Exclamation, "Informasi")
                Exit Sub
            End If
            ' db.Close()
        Catch ex As Exception

        End Try


    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        form2.Show()
    End Sub

    Private Sub btnbarang_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbarang.Click
        lyr_brg.Show()
    End Sub

    Private Sub btnfaktur_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfaktur.Click
        lyr_faktur.Show()
    End Sub
End Class






























2 komentar:

  1. gan download mysql.data.entity.dll nya dimana?
    Ane nyari di Google susah, mohon bantuannya

    BalasHapus
  2. maaf mau tanya;

    fungsi hitungdata / no faktur otomatis efektif jika untuk satu kasir, bagaimana jika menggunakan 2 kasir ?

    BalasHapus