0% found this document useful (0 votes)
24 views5 pages

VB NET Mengolah Data Master Barang

Uploaded by

Tyo Boho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views5 pages

VB NET Mengolah Data Master Barang

Uploaded by

Tyo Boho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Public Class XMstr_Brg2

Dim SQL As String


Dim Proses As New ClsKoneksi
Dim DTMstr As DataTable
Protected tblMstr = New DataTable
Dim AHB, AHJ, AST As Single

Private Sub XMstr_Brg2_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'DataSet1.Mstr_Brg' table. You can
move, or remove it, as needed.
Me.Mstr_BrgTableAdapter.Fill(Me.DataSet1.Mstr_Brg)
Call ttpcellmstr()
End Sub

Sub carikodeMASTER()
If TextBox1.Text = "" Then MsgBox("Kode Barang masih kosong, tentukan kode
barangnya") : Exit Sub
Try
Call koneksi()
tblMstr = Proses.ExecuteQuery(String.Format("select * from Mstr_Brg where
KodeBarang = '{0}'", TextBox1.Text))
If tblMstr.Rows.Count = 0 Then
TextBox2.Focus()
Else
BCC.Text = TextBox1.Text
TextBox2.Text = tblMstr.rows(0).item("Kelompok")
TextBox3.Text = tblMstr.Rows(0).Item("NamaBarang")
ComboBox2.Text = tblMstr.Rows(0).Item("Satuan")
AHB = tblMstr.Rows(0).Item("HargaBeli")
TextBox4.Text = Format(AHB, "###,###,###")
AHJ = tblMstr.Rows(0).Item("HargaJual")
TextBox5.Text = Format(AHJ, "###,###,###")
'AST = tblMstr.rows(0).item("StockAkhir")
SM = tblMstr.rows(0).item("StockMinimal")
TextBox6.Text = Format(SM, "##,###")
TextBox7.Text = tblMstr.rows(0).item("Gambar")
PictureBox1.ImageLocation = TextBox7.Text
Button1.Text = "Perbaharui"
'Button2.Enabled = True
End If
Catch ex As Exception
MsgBox(ex.Message)
'Button2.Enabled = False
End Try
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click
Close()
Call bukamenu()
End Sub

#Region "LABEL2"
Private Sub TextBox2_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs)
Handles TextBox2.GotFocus
Label2.Text = "Tentukan Kelompok Barang !"
End Sub

#End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
If Button1.Text = "Baru" Then
TextBox1.Enabled = True
Button1.Text = "Batal"
TextBox1.Focus()
ElseIf Button1.Text = "Simpan" Then
If TextBox1.Text = "" Then MsgBox("Kode Barang masih ada yang kosong !") :
Exit Sub
If TextBox2.Text = "" Then MsgBox("Kelompok Barang masih kosong !") : Exit
Sub
If TextBox3.Text = "" Then MsgBox("Nama Barang masih kosong !") : Exit Sub
If TextBox4.Text = "" Then MsgBox("Harga Beli masih kosong !") : Exit Sub
If TextBox5.Text = "" Then MsgBox("Harga Jual masih kosong !") : Exit Sub
If ComboBox2.Text = "" Then MsgBox("Satuan Barang masih kosong !") : Exit Sub
If TextBox6.Text = "" Then MsgBox("Stock minimal masih kosong !") : Exit Sub
If TextBox7.Text = "" Then MsgBox("Klik kotak gambar, file gambar masih kosong
!") : Exit Sub
Call CekregMaster()
ElseIf Button1.Text = "Perbaharui" Then
If TextBox1.Text = "" Then MsgBox("Kode Barang masih ada yang kosong !") :
Exit Sub
If TextBox2.Text = "" Then MsgBox("Kelompok Barang masih kosong !") : Exit
Sub
If TextBox3.Text = "" Then MsgBox("Nama Barang masih kosong !") : Exit Sub
If TextBox4.Text = "" Then MsgBox("Harga Beli masih kosong !") : Exit Sub
If TextBox5.Text = "" Then MsgBox("Harga Jual masih kosong !") : Exit Sub
If ComboBox2.Text = "" Then MsgBox("Satuan Barang masih kosong !") : Exit Sub
If TextBox6.Text = "" Then MsgBox("Stock minimal masih kosong !") : Exit Sub
If TextBox7.Text = "" Then MsgBox("Klik kotak gambar, file gambar masih kosong
!") : Exit Sub
'Call Simpanmaster()
XStock_Brg.BKlmpk.Text = TextBox2.Text
XStock_Brg.BNabar.Text = TextBox3.Text
XStock_Brg.THargaJ.Text = TextBox5.Text
XStock_Brg.CmbSatuan.Text = ComboBox2.Text
XStock_Brg.TextBox2.Text = TextBox4.Text
XStock_Brg.TextBox3.Text = TextBox6.Text
XStock_Brg.TextBox1.Text = TextBox7.Text
XStock_Brg.PictureBox1.ImageLocation = XStock_Brg.TextBox1.Text
HB = TextBox4.Text
XStock_Brg.TSA.Focus()
Close()
XStock_Brg.Visible = True
ElseIf Button1.Text = "Batal" Then
Button1.Text = "Baru"
Call ttpcellmstr()
End If
End Sub

Sub CekregMaster()
If legalapp = "NO" Then
Try
Call koneksi()
TblData = Proses.ExecuteQuery("select * from Mstr_Brg")
If TblData.Rows.Count > 4 Then
MAxRec = 5
XRegister.Show()
XRegister.MdiParent = XUtama
Exit Sub
Else
Call Simpanmaster()
Call ttpcellmstr()
Button1.Text = "Baru"
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
Call Simpanmaster()
Call ttpcellmstr()
Button1.Text = "Baru"
End If
End Sub

Sub Simpanmaster()
'validtgl = String.Format("{0}/{1}/{2}", Year(DTP.Text), Month(DTP.Text),
Mid(DTP.Text, 1, 2))
AHB = TextBox4.Text.Replace("."c, "")
AHJ = TextBox5.Text.Replace("."c, "")
AST = TextBox6.Text
'asaldomem = Adepositmem
'MsgBox(Adepositmem & " vs " & asaldomem)
Try
'Call koneksi()
Dim sq As New OleDb.OleDbCommand
sq.Connection = database
sq.CommandType = CommandType.Text
sq.CommandText = String.Format("Insert into
Mstr_Brg(Kelompok,KodeBarang,NamaBarang,Satuan,HargaBeli,HargaJual,StockMinimal,gamba
r) values ('{0}','{1}','{2}','{3}',{4},{5},{6},'{7}')", TextBox2.Text, TextBox1.Text,
TextBox3.Text, ComboBox2.Text, AHB, AHJ, AST, TextBox7.Text)
sq.ExecuteNonQuery()
Label2.Text = "Data sudah tersimpan."
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles PictureBox1.Click
With OFDM
.InitialDirectory = Application.StartupPath & "\image\"
.Filter = "Image files (*.Jpg)|*.jpg|Image files (*.Png)|*.png|All files
(*.*)|*.*"
.FileName = TextBox1.Text
.Title = "Cari Gambar"
.ShowDialog()
End With
PictureBox1.ImageLocation = OFDM.FileName
TextBox7.Text = OFDM.FileName
End Sub

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As


System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(13) Then
SendKeys.Send(vbTab)
Call carikodeBrg()
End If
End Sub

Sub carikodeBrg()
If TextBox1.Text = "" Then MsgBox("Kode Barang masih kosong, tentukan kode
barangnya") : Exit Sub
Try
Call koneksi()
tblMstr = Proses.ExecuteQuery(String.Format("select * from Mstr_Brg where
KodeBarang = '{0}'", TextBox1.Text))
If tblMstr.Rows.Count = 0 Then
Call bkcellMstr()
TextBox2.Text = ""
TextBox3.Text = ""
ComboBox2.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox1.Enabled = False
TextBox2.Focus()
Label2.Text = "Isi semua kolom dan pilih gambar barangnya !"
Else
TextBox1.Enabled = False
TextBox2.Text = tblMstr.rows(0).item("Kelompok")
TextBox3.Text = tblMstr.Rows(0).Item("NamaBarang")
ComboBox2.Text = tblMstr.Rows(0).Item("Satuan")
AHB = tblMstr.Rows(0).Item("HargaBeli")
TextBox4.Text = Format(AHB, "###,###,###")
AHJ = tblMstr.Rows(0).Item("HargaJual")
TextBox5.Text = Format(AHJ, "###,###,###")
SM = tblMstr.rows(0).item("StockMinimal")
TextBox6.Text = Format(SM, "##,###")
TextBox7.Text = tblMstr.rows(0).item("Gambar")
PictureBox1.ImageLocation = TextBox7.Text
Button1.Text = "Perbaharui"
Label2.Text = "Data sudah ada di Master, silahkan perbaiki jika ada yang
salah !"
'Button2.Enabled = True
bkcellmstr()
TextBox2.Focus()
End If
Catch ex As Exception
MsgBox(ex.Message)
'Button2.Enabled = False
End Try
End Sub

Sub bkcellmstr()
TextBox1.Enabled = True
TextBox2.Enabled = True
TextBox3.Enabled = True
ComboBox2.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
TextBox6.Enabled = True
End Sub

Sub ttpcellmstr()
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
ComboBox2.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False
End Sub

Private Sub TextBox6_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs)


Handles TextBox6.GotFocus
Button1.Text = "Simpan"
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles TextBox1.TextChanged
BCC.Text = TextBox1.Text
End Sub
End Class

You might also like