Kamis, 06 Juni 2013

SISTEM INFORMASI DATA PEMBELIAN OBAT



1.FROM MENU



LISTING PROGRAM MENU
Public Class Form1

    Private Sub DATAPEMBELIANToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DATAPEMBELIANToolStripMenuItem.Click
        pembelian.Show()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class


2. FROM  INPUT


LISTING PROGRAM MENU

Imports MySql.Data.MySqlClient
Public Class pembelian
    Public db As New MySql.Data.MySqlClient.MySqlConnection
    Public sql As String
    Public cmd As MySqlCommand
    Public rs As MySqlDataReader
    Sub opendb()
        sql = "server=localhost;uid=root;pwd;database=tety"
        Try
            db.ConnectionString = sql
            db.Open()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
    Sub bersih()
        no_faktur.Text = ""
        kode_sup.Text = ""
        namaa.Text = ""
        alamatt.Text = ""
        rubahbutton(True, False, False, False, False, True)
        no_faktur.Enabled = True
    End Sub
    Sub rubahbutton(ByVal btn1 As Boolean, ByVal btn2 As Boolean, ByVal btn3 As Boolean, ByVal btn4 As Boolean, ByVal btn5 As Boolean, ByVal btn6 As Boolean)
        btnbaru.Enabled = btn1
        btnsimpan.Enabled = btn2
        btnedit.Enabled = btn3
        btnhapus.Enabled = btn4
        btnbatal.Enabled = btn5
        btnkeluar.Enabled = btn6
    End Sub

    Sub buattable()
        lv.Columns.Add("no_faktur", 80, HorizontalAlignment.Center)
        lv.Columns.Add("kode_sup", 180, HorizontalAlignment.Left)
        lv.Columns.Add("nama", 80, HorizontalAlignment.Left)
        lv.Columns.Add("alamat", 100, HorizontalAlignment.Left)
        lv.GridLines = True
        lv.FullRowSelect = True
        lv.View = View.Details
    End Sub
    Sub isitable()
        lv.Items.Clear()
        sql = "select * from pembelian"
        cmd = New MySqlCommand(sql, db)
        rs = cmd.ExecuteReader
        Try
            While rs.Read
                Dim lst As New ListViewItem
                lst.Text = rs("no_faktur")
                lst.SubItems.Add(rs("kode_sup"))
                lst.SubItems.Add(rs("nama"))
                lst.SubItems.Add(rs("alamat"))
                lv.Items.Add(lst)
            End While
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        rs.Close()
    End Sub
    Sub prosesdb(ByVal log As Integer)
        Dim pesan As String = ""
        Select Case log
            Case 0
                sql = "insert into pembelian values(no_faktur,kode_sup,nama,alamat)" & _
                "values('" & no_faktur.Text & _
                "','" & kode_sup.Text & _
                "','" & namaa.Text & _
                "','" & alamatt.Text & "')"
                pesan = "data telah tersimpan"
            Case 1
                sql = "update pembelian set kode_sup='" & kode_sup.Text & "'," & _
                "nama='" & namaa.Text & "'," & _
                "alamat='" & alamatt.Text & "'," & _
                "where no_faktur='" & no_faktur.Text & "'"
                pesan = "data telah terupdate"
            Case 2
                sql = "delete from pembelian where no_faktur='" & no_faktur.Text & "'"
                pesan = "data telah dihapus"
        End Select
        Try
            cmd = New MySqlCommand(sql, db)
            cmd.ExecuteNonQuery()
            MsgBox(pesan, MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "konfirmsi")
            Call bersih()
            Call isitable()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
    Sub showdb()
        rs.Read()
        no_faktur.Text = rs("no_faktur")
        kode_sup.Text = rs("kode_sup")
        namaa.Text = rs("nama")
        alamatt.Text = rs("alamat")
        rubahbutton(False, False, True, True, True, False)
        btnsimpan.text = "edit"
        no_faktur.Enabled = False
    End Sub
    Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call opendb()
        Call bersih()
        Call buattable()
        Call isitable()
    End Sub

    Private Sub baru_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnbaru.Click
        Call bersih()
        no_faktur.Focus()
    End Sub

    Private Sub batal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnbatal.Click
        Call bersih()
        no_faktur.Focus()
    End Sub

    Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
        End
    End Sub

    Private Sub hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click
        Dim x As String
        x = MsgBox("anda yakin akan menghapus", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "hapus")
        If x = vbYes Then
            Call prosesdb(2)
        End If
    End Sub

    Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnsimpan.Click
        If btnsimpan.text = "simpan" Then prosesdb(0) Else prosesdb(1)
    End Sub

    Private Sub no_faktur_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles no_faktur.KeyPress
        Dim tombol As Integer = Asc(e.KeyChar)
        If tombol = 13 Then
            Dim x As String
            If no_faktur.Text = "" Then
                MsgBox("isi No faktur terlebih dahulu")
            Else
                sql = "select * from pembelian where no_faktur='" & no_faktur.Text & "'"
                cmd = New MySqlCommand(sql, db)
                rs = cmd.ExecuteReader
                Try
                    Call showdb()
                Catch ex As Exception
                    x = no_faktur.Text
                    bersih()
                    no_faktur.Text = x
                    rubahbutton(False, True, False, False, True, False)
                    Btnsimpan.Text = "simpan"
                End Try
                kode_sup.Focus()
                rs.Close()
            End If
        End If
    End Sub
End Class



TAMPILAN  FORM CETAK LAPORAN



DEMIKIAN HASIL POSTINGAN SAYA
NAMA: TETY GORETY LUMBAN GAOL
NPM: 1102089

Tidak ada komentar:

Posting Komentar