adapun bentuk lanjutan dari form beranda adalah pembuatan form obat dengan bentuk sebagai :
1. Groupbox sebanyak 2 buah
2. label sebanyak 6 buah
3. textbox sebanyak 5 buah
4. datagrid sebanyak1 buah
5. Serta sebuah database yang telah pernah disimpan dan menambahkan table tblObat dengan isi
*Kode obat
*Nama Obat
*kemasan
*harga Beli
*Harga Jual
*tgl_kadaluarsa
6. Button sebanyak 3 buah
7. icon untuk tombol sebanyak 3
ubah nama tool sesuai dengan gambar
untuk Source code sebagai berikut :
Imports System.Data.OleDb
Public Class frmObat
Private Conns As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & System.AppDomain.CurrentDomain.BaseDirectory & "\apotek.mdb;Persist Security Info=false"
Private Conn As New OleDbConnection
Public Function akses() As OleDbConnection
Dim conect As New OleDbConnection(Conns)
conect.Open()
Return conect
End Function
Private Sub frmObat_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Conn.ConnectionString = Conns
Dim grid As OleDbDataAdapter
grid = New OleDbDataAdapter("select * from tblObat", Conn)
Dim ds As DataSet
ds = New DataSet
grid.Fill(ds, "tblObat")
DataGridView1.DataSource = ds.Tables("tblObat")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Cmd As New OleDbCommand
Dim conns As New OleDbConnection
Conn.Open()
Cmd.CommandText = "INSERT INTO tblObat VALUES ('" & TextBox1.Text & "' ,'" & TextBox2.Text & "','" & TextBox3.Text & "','" & Val(TextBox4.Text) & "','" & Val(TextBox5.Text) & "','" & DateTimePicker1.Value & "' )"
Cmd.Connection = Conn
Cmd.ExecuteNonQuery()
Conn.Close()
Dim grid As OleDbDataAdapter
grid = New OleDbDataAdapter("select * from tblObat", Conn)
Dim ds As DataSet
ds = New DataSet
grid.Fill(ds, "tblObat")
DataGridView1.DataSource = ds.Tables("tblObat")
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Beranda.Show()
Me.Hide()
End Sub
End Class
debug dan jalankan program untuk menambah database obat.
Tidak ada komentar:
Posting Komentar