aplikasi yang saya buat ini adalah aplikasi untuk apotek yang dapat digunakan dua mode. mode pertama yaitu moder admin. dalam mode ini anda dapat edit,delete,add,view,find, dan close. sedangkan dalam mode user anda hanya bisa melihat saja
FORM:
Source Code
Form 1
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If RadioButton1.Checked Then
Form2.Show()
Me.Hide()
ElseIf RadioButton2.Checked Then
Form4.Show()
Me.Hide()
End If
End Sub
End Class
Form 2
Public Class Form2
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox1.Text = "Admin" Then
TextBox2.Text = "admin1"
Form3.Show()
Me.Hide()
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Form1.Close()
End Sub
End Class
Form 3
Imports System.Data
Imports System.Data.Sql
Imports System.Data.OleDb
Public Class Form3
Dim connection As String = "Provider=Microsoft.ACE.OLEDB.12.0; DATA Source=D:\Database\Database1.accdb"
Dim objekkoneksi As New OleDb.OleDbConnection(connection)
Dim xreader As OleDbDataReader
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
objekkoneksi.Close()
objekkoneksi.Open()
Dim add As String = "INSERT INTO tableobat values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & ComboBox1.Text & "')"
Dim ocmd = New OleDbCommand(add, objekkoneksi)
ocmd.ExecuteNonQuery()
objekkoneksi.Close()
MsgBox("Berhasil")
Form4.Show()
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim Vkode = InputBox("Enter Code")
objekkoneksi.Close()
objekkoneksi.Open()
Dim Cmd As New OleDbCommand("SELECT * FROM tableobat where kodesupplier ='" + Vkode + "'", objekkoneksi)
xreader = Cmd.ExecuteReader
If xreader.HasRows Then
xreader.Read()
TextBox1.Text = xreader("kodesupplier")
TextBox2.Text = xreader("namasuplier")
TextBox3.Text = xreader("namabarang")
TextBox4.Text = xreader("harga")
TextBox5.Text = xreader("jumlah")
ComboBox1.Text = xreader("keterangan")
Else
MsgBox("Code not Found")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
ComboBox1.Text = ""
TextBox1.Focus()
Exit Sub
End If
xreader.Close()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim DELETE As Integer
DELETE = MsgBox("Confirmation", MsgBoxStyle.OkCancel)
If vbOK Then
objekkoneksi.Close()
objekkoneksi.Open()
Dim sql As String = "DELETE from tableobat where namasuplier= '" + TextBox2.Text + "'"
Dim ocmd As New OleDbCommand
objekkoneksi.Close()
objekkoneksi.Open()
ocmd.Connection = objekkoneksi
ocmd.CommandText = sql
ocmd.ExecuteNonQuery()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
ComboBox1.Text = ""
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim sql As String = " Update tableobat set namasuplier='" + TextBox2.Text + "', namabarang = '" + TextBox3.Text + "', harga ='" + TextBox4.Text + "', jumlah ='" + TextBox5.Text + "', keterangan = '" + ComboBox1.Text + "'where kodesupplier = '" + TextBox1.Text + "'"
Dim oCmd As New OleDbCommand
objekkoneksi.Close()
objekkoneksi.Open()
oCmd.Connection = objekkoneksi
oCmd.CommandText = sql
oCmd.ExecuteNonQuery()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Form4.Show()
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Me.Close()
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
End Sub
End Class




Tidak ada komentar:
Posting Komentar