Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data.OleDb
- Public Class Input_Produk
- Sub KosongkanForm()
- txtID_Produk.Text = ""
- txtID_Supplier.Text = ""
- txtStock.Text = ""
- txtHarga.Text = ""
- txtDeskripsi.Text = ""
- txtID_Produk.Focus()
- End Sub
- Sub MatikanForm()
- txtID_Produk.Enabled = False
- txtID_Supplier.Enabled = False
- txtStock.Enabled = False
- txtHarga.Enabled = False
- txtDeskripsi.Enabled = False
- txtNamaproduk.Enabled = False
- End Sub
- Sub HidupkanForm()
- txtID_Produk.Enabled = True
- txtID_Supplier.Enabled = True
- txtStock.Enabled = True
- txtHarga.Enabled = True
- txtDeskripsi.Enabled = True
- txtNamaproduk.Enabled = True
- End Sub
- Sub TampilkanData()
- Call koneksiDB()
- DA = New OleDb.OleDbDataAdapter("select * from Produk ", Conn)
- DS = New DataSet
- DA.Fill(DS)
- DGVProduk.DataSource = DS.Tables(0)
- DGVProduk.ReadOnly = True
- End Sub
- Private Sub Input_Produk_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- 'TODO: This line of code loads data into the 'ERD_OLSHOPBangetdahDataSet.Produk' table. You can move, or remove it, as needed.
- Me.ProdukTableAdapter1.Fill(Me.ERD_OLSHOPBangetdahDataSet.Produk)
- 'TODO: This line of code loads data into the 'ERD_OLSHOP1DataSet1.Produk' table. You can move, or remove it, as needed.
- Me.ProdukTableAdapter.Fill(Me.ERD_OLSHOP1DataSet1.Produk)
- Call MatikanForm()
- Call TampilkanData()
- End Sub
- Private Sub btnInput_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInput.Click
- Call HidupkanForm()
- Call KosongkanForm()
- End Sub
- Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
- If txtID_Produk.Text = "" Or txtID_Supplier.Text = "" Or txtStock.Text = "" Or txtHarga.Text = "" Or txtDeskripsi.Text = "" Or txtNamaproduk.Text = "" Then
- MsgBox("Data Produk Belum Lengkap")
- Exit Sub
- Else
- Call koneksiDB()
- CMD = New OleDb.OleDbCommand(" select * from Produk where ID_Produk ='" & txtID_Produk.Text & "'", Conn)
- DM = CMD.ExecuteReader
- DM.Read()
- If Not DM.HasRows Then
- Call koneksiDB()
- Dim simpan As String
- simpan = "insert into Product values ('" & txtID_Produk.Text & "', '" & txtID_Supplier.Text & "', '" & txtStock.Text & "','" & txtHarga.Text & "','" & txtDeskripsi.Text & "','" & txtNamaproduk.Text & "')"
- CMD = New OleDb.OleDbCommand(simpan, Conn)
- CMD.ExecuteNonQuery()
- MsgBox("Input Data Sukses")
- Else : MsgBox("Data Sudah Ada")
- End If
- Call MatikanForm()
- Call KosongkanForm()
- Call TampilkanData()
- End If
- End Sub
- Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
- If txtID_Produk.Text = "" Or txtID_Supplier.Text = "" Or txtStock.Text = "" Or txtHarga.Text = "" Or txtDeskripsi.Text = "" Or txtNamaproduk.Text = "" Then
- MsgBox("Data Produk Belum Lengkap")
- Exit Sub
- Else
- Call koneksiDB()
- CMD = New OleDb.OleDbCommand(" update Produk set Nama_Produk = '" & txtID_Produk.Text & "', Harga ='" & txtID_Supplier.Text & "',Stock = '" &
- txtStock.Text & "',Harga Satuan = '" & txtHarga.Text & "',Deskripsi Produk = '" &
- txtDeskripsi.Text & "',Nama Produk = '" & txtNamaproduk.Text & "'", Conn)
- End If
- End Sub
- Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
- Call MatikanForm()
- Call KosongkanForm()
- End Sub
- Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
- Me.Close()
- End Sub
- Private Sub DGVProduk_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGVProduk.CellMouseClick
- On Error Resume Next
- txtID_Produk.Text = DGVProduk.Rows(e.RowIndex).Cells(0).Value
- txtID_Supplier.Text = DGVProduk.Rows(e.RowIndex).Cells(1).Value
- txtStock.Text = DGVProduk.Rows(e.RowIndex).Cells(2).Value
- txtHarga.Text = DGVProduk.Rows(e.RowIndex).Cells(3).Value
- txtDeskripsi.Text = DGVProduk.Rows(e.RowIndex).Cells(4).Value
- txtNamaproduk.Text = DGVProduk.Rows(e.RowIndex).Cells(5).Value
- Call HidupkanForm()
- txtID_Produk.Enabled = False
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement