Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.76 KB | None | 0 0
  1. Imports System.Data.OleDb
  2.  
  3. Public Class Input_Produk
  4.  
  5. Sub KosongkanForm()
  6. txtID_Produk.Text = ""
  7. txtID_Supplier.Text = ""
  8. txtStock.Text = ""
  9. txtHarga.Text = ""
  10. txtDeskripsi.Text = ""
  11. txtID_Produk.Focus()
  12. End Sub
  13.  
  14. Sub MatikanForm()
  15. txtID_Produk.Enabled = False
  16. txtID_Supplier.Enabled = False
  17. txtStock.Enabled = False
  18. txtHarga.Enabled = False
  19. txtDeskripsi.Enabled = False
  20. txtNamaproduk.Enabled = False
  21. End Sub
  22.  
  23. Sub HidupkanForm()
  24. txtID_Produk.Enabled = True
  25. txtID_Supplier.Enabled = True
  26. txtStock.Enabled = True
  27. txtHarga.Enabled = True
  28. txtDeskripsi.Enabled = True
  29. txtNamaproduk.Enabled = True
  30. End Sub
  31. Sub TampilkanData()
  32. Call koneksiDB()
  33. DA = New OleDb.OleDbDataAdapter("select * from Produk ", Conn)
  34. DS = New DataSet
  35. DA.Fill(DS)
  36. DGVProduk.DataSource = DS.Tables(0)
  37. DGVProduk.ReadOnly = True
  38. End Sub
  39.  
  40. Private Sub Input_Produk_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  41. 'TODO: This line of code loads data into the 'ERD_OLSHOPBangetdahDataSet.Produk' table. You can move, or remove it, as needed.
  42. Me.ProdukTableAdapter1.Fill(Me.ERD_OLSHOPBangetdahDataSet.Produk)
  43. 'TODO: This line of code loads data into the 'ERD_OLSHOP1DataSet1.Produk' table. You can move, or remove it, as needed.
  44. Me.ProdukTableAdapter.Fill(Me.ERD_OLSHOP1DataSet1.Produk)
  45. Call MatikanForm()
  46. Call TampilkanData()
  47. End Sub
  48.  
  49. Private Sub btnInput_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInput.Click
  50. Call HidupkanForm()
  51. Call KosongkanForm()
  52. End Sub
  53.  
  54. Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
  55. If txtID_Produk.Text = "" Or txtID_Supplier.Text = "" Or txtStock.Text = "" Or txtHarga.Text = "" Or txtDeskripsi.Text = "" Or txtNamaproduk.Text = "" Then
  56. MsgBox("Data Produk Belum Lengkap")
  57. Exit Sub
  58. Else
  59. Call koneksiDB()
  60. CMD = New OleDb.OleDbCommand(" select * from Produk where ID_Produk ='" & txtID_Produk.Text & "'", Conn)
  61. DM = CMD.ExecuteReader
  62. DM.Read()
  63. If Not DM.HasRows Then
  64. Call koneksiDB()
  65. Dim simpan As String
  66. simpan = "insert into Product values ('" & txtID_Produk.Text & "', '" & txtID_Supplier.Text & "', '" & txtStock.Text & "','" & txtHarga.Text & "','" & txtDeskripsi.Text & "','" & txtNamaproduk.Text & "')"
  67. CMD = New OleDb.OleDbCommand(simpan, Conn)
  68. CMD.ExecuteNonQuery()
  69. MsgBox("Input Data Sukses")
  70. Else : MsgBox("Data Sudah Ada")
  71. End If
  72. Call MatikanForm()
  73. Call KosongkanForm()
  74. Call TampilkanData()
  75. End If
  76. End Sub
  77.  
  78. Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
  79. If txtID_Produk.Text = "" Or txtID_Supplier.Text = "" Or txtStock.Text = "" Or txtHarga.Text = "" Or txtDeskripsi.Text = "" Or txtNamaproduk.Text = "" Then
  80. MsgBox("Data Produk Belum Lengkap")
  81. Exit Sub
  82. Else
  83. Call koneksiDB()
  84. CMD = New OleDb.OleDbCommand(" update Produk set Nama_Produk = '" & txtID_Produk.Text & "', Harga ='" & txtID_Supplier.Text & "',Stock = '" &
  85. txtStock.Text & "',Harga Satuan = '" & txtHarga.Text & "',Deskripsi Produk = '" &
  86. txtDeskripsi.Text & "',Nama Produk = '" & txtNamaproduk.Text & "'", Conn)
  87. End If
  88. End Sub
  89.  
  90. Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
  91. Call MatikanForm()
  92. Call KosongkanForm()
  93. End Sub
  94.  
  95. Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
  96. Me.Close()
  97. End Sub
  98.  
  99. Private Sub DGVProduk_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGVProduk.CellMouseClick
  100. On Error Resume Next
  101. txtID_Produk.Text = DGVProduk.Rows(e.RowIndex).Cells(0).Value
  102. txtID_Supplier.Text = DGVProduk.Rows(e.RowIndex).Cells(1).Value
  103. txtStock.Text = DGVProduk.Rows(e.RowIndex).Cells(2).Value
  104. txtHarga.Text = DGVProduk.Rows(e.RowIndex).Cells(3).Value
  105. txtDeskripsi.Text = DGVProduk.Rows(e.RowIndex).Cells(4).Value
  106. txtNamaproduk.Text = DGVProduk.Rows(e.RowIndex).Cells(5).Value
  107.  
  108. Call HidupkanForm()
  109. txtID_Produk.Enabled = False
  110. End Sub
  111. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement