If LstTransaksi.Items.Count = 0 Then
MsgBox("Lakukan transaksi pembelian", _
MsgBoxStyle.Exclamation, "POS")
Exit Sub
End If
CekInvoice()
If objDataTable.Rows.Count >= 1 Then
MsgBox("Nomor Invoice sudah ada pada table", _
MsgBoxStyle.Exclamation, "POS")
Exit Sub
End If
Dim mYes_No As String = MsgBox("Anda yakin data mau disimpan ?", vbYesNo)
If mYes_No = vbYes Then
Dim i, Sisa, DisPersen As Integer
Dim DisRp As Double
For i = 0 To (LstTransaksi.Items.Count - 1)
MyConnectionPembelian.AccessPembelianInsert(Trim(txtInvoice.Text), dtTgl_Invoice.Text, _
LstTransaksi.Items(i).Text, LstTransaksi.Items(i).SubItems(2).Text, _
LstTransaksi.Items(i).SubItems(4).Text, LstTransaksi.Items(i).SubItems(5).Text, _
LstTransaksi.Items(i).SubItems(6).Text)
objCommand = MyConnection.open.CreateCommand
objCommand.CommandText = "select Stok from Barang Where Kode_Brg = '" & Trim(LstTransaksi.Items(i).Text) & "';"
objdatareader = objCommand.ExecuteReader
objdatareader.Read()
Stok = objdatareader.Item("Stok").ToString
MyConnection.close()
Sisa = Stok + Val(LstTransaksi.Items(i).SubItems(2).Text)
MyConnectionBarang.AccessBarangUpdateStok(Trim(LstTransaksi.Items(i).Text), Sisa)
Sisa = Nothing
Stok = Nothing
Next i
If txtTotDisPersen.Text = "" Then
DisPersen = 0
Else
DisPersen = txtTotDisPersen.Text
End If
If txtTotDisRp.Text = "" Then
DisRp = 0
Else
DisRp = txtTotDisRp.Text
End If
MyConnectionTotalPembelian.AccessTotalPembelianInsert(Trim(CbPO.SelectedItem), _
Trim(txtInvoice.Text), DisPersen, DisRp, txtTotalHarga.Text, Username, Now)
ClearAll()
Else
End If
Catch When Err.Number <> 0
MsgBox("Program error" _
& vbCrLf & Err.Description)
MyConnection.close()
End Try
End Sub
MsgBox("Lakukan transaksi pembelian", _
MsgBoxStyle.Exclamation, "POS")
Exit Sub
End If
CekInvoice()
If objDataTable.Rows.Count >= 1 Then
MsgBox("Nomor Invoice sudah ada pada table", _
MsgBoxStyle.Exclamation, "POS")
Exit Sub
End If
Dim mYes_No As String = MsgBox("Anda yakin data mau disimpan ?", vbYesNo)
If mYes_No = vbYes Then
Dim i, Sisa, DisPersen As Integer
Dim DisRp As Double
For i = 0 To (LstTransaksi.Items.Count - 1)
MyConnectionPembelian.AccessPembelianInsert(Trim(txtInvoice.Text), dtTgl_Invoice.Text, _
LstTransaksi.Items(i).Text, LstTransaksi.Items(i).SubItems(2).Text, _
LstTransaksi.Items(i).SubItems(4).Text, LstTransaksi.Items(i).SubItems(5).Text, _
LstTransaksi.Items(i).SubItems(6).Text)
objCommand = MyConnection.open.CreateCommand
objCommand.CommandText = "select Stok from Barang Where Kode_Brg = '" & Trim(LstTransaksi.Items(i).Text) & "';"
objdatareader = objCommand.ExecuteReader
objdatareader.Read()
Stok = objdatareader.Item("Stok").ToString
MyConnection.close()
Sisa = Stok + Val(LstTransaksi.Items(i).SubItems(2).Text)
MyConnectionBarang.AccessBarangUpdateStok(Trim(LstTransaksi.Items(i).Text), Sisa)
Sisa = Nothing
Stok = Nothing
Next i
If txtTotDisPersen.Text = "" Then
DisPersen = 0
Else
DisPersen = txtTotDisPersen.Text
End If
If txtTotDisRp.Text = "" Then
DisRp = 0
Else
DisRp = txtTotDisRp.Text
End If
MyConnectionTotalPembelian.AccessTotalPembelianInsert(Trim(CbPO.SelectedItem), _
Trim(txtInvoice.Text), DisPersen, DisRp, txtTotalHarga.Text, Username, Now)
ClearAll()
Else
End If
Catch When Err.Number <> 0
MsgBox("Program error" _
& vbCrLf & Err.Description)
MyConnection.close()
End Try
End Sub