LISTING PROGRAM
Dim constring As String
Private Sub CMDHAPUS_Click()
Dim dbtbbarang As New ADODB.Connection
Dim rstbbarang As ADODB.Recordset
dbtbbarang.Open constring, "delta", "2104"
dbtbbarang.Execute "Delete from tbbarang where kodebrg ='" & txtkodebrg.Text & "'"
bersih
End Sub
Private Sub CMDSIMPAN_Click()
Dim dbtbbarang As New ADODB.Connection
Dim rstbbarang As ADODB.Recordset
dbtbbarang.Open constring, "delta", "2104"
Set rstbbarang = dbtbbarang.Execute("select * from tbbarang where kodebrg ='" & txtkodebrg.Text & "'")
If rstbbarang.EOF Then
dbtbbarang.Execute ("insert into tbbarang(kodebrg,nama,satuan,harga,stok) values ('" & txtkodebrg.Text & "','" & TXTNAMA.Text & "','" & TXTSATUAN.Text & "','" & TXTHARGA.Text & "','" & TXTSTOK.Text & "')")
Else
If MsgBox("data ini sudah ada dalam database," & " perbaiki?", vbQuestion + vbYesNo, "konfirmasi") Then
dbtbbarang.Execute "update barang set nama ='" & TXTNAMA.Text & ""
End If
End If
End Sub
Private Sub CMDTUTUP_Click()
Unload Me
End Sub
Private Sub Form_Load()
bersih
constring = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=delta;Initial Catalog=penjualan;Data Source=COM25"
End Sub
Private Sub bersih()
txtkodebrg.Text = ""
TXTNAMA.Text = ""
TXTSATUAN.Text = ""
TXTHARGA.Text = ""
TXTSTOK.Text = ""
End Sub
Private Sub CMDBERSIH_Click()
bersih
End Sub
Private Sub TXTKODEBRG_Change()
Dim dbtbbarang As New ADODB.Connection
Dim rstbbarang As ADODB.Recordset
dbtbbarang.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=delta;Initial Catalog=penjualan;Data Source=COM25", "delta", "2104"
Set rstbbarang = dbtbbarang.Execute("select *from tbbarang where kodebrg = '" & txtkodebrg.Text & "'")
If Not rstbbarang.EOF Then
txtkodebrg.Text = rstbbarang!kodebrg
TXTNAMA.Text = rstbbarang!nama
TXTSATUAN.Text = rstbbarang!satuan
TXTHARGA.Text = rstbbarang!harga
TXTSTOK.Text = rstbbarang!stok
End If
If txtkodebrg.Text = "" Then
bersih
End If
End Sub
Kamis, 06 November 2008
Langganan:
Postingan (Atom)