244
With rsBarang txtNamaBarang.Text = nama_barang
txtStokLama.Text = sisa boxSatuan.Text = satuan
txtKadaluarsa.Text = Formatkadaluarsa, ddmmyyyy txtKurangStok.SetFocus
End With koneksi.Close
Else With rsBarang
txtNamaBarang.Text = nama_barang txtStokLama.Text = sisa
boxSatuan.Text = satuan txtKurangStok.SetFocus
End With koneksi.Close
End If End If
End If End Sub
Private Sub txtKurangStok_KeyPressKeyAscii As Integer If ValtxtKurangStok.Text ValtxtStokLama.Text Then
MsgBox Stok barang yang akan diambil tidak mencukupi, vbCritical, INFORMASI Else
persediaan = ValtxtStokLama.Text - ValtxtKurangStok.Text txtTotal.Text = persediaan
If KeyAscii = vbKeyReturn Then cmdSimpan.SetFocus
End If End If
End Sub Private Sub txtNamaBarang_keypressKeyAscii As Integer
KeyAscii = AscUCaseChrKeyAscii End Sub
Private Sub txtstoklama_change persediaan = ValtxtStokLama.Text - ValtxtKurangStok.Text
txtTotal.Text = persediaan End Sub
Q. Form Pengolahan Data Suplier Administrator
Sub formKosong txtNamaSuplier.Text =
txtAlamat.Text = End Sub
Sub formAktif txtNamaSuplier.Enabled = True
txtAlamat.Enabled = True End Sub
Sub formNonAktif txtNamaSuplier.Enabled = False
txtAlamat.Enabled = False End Sub
Sub formAwal
245
cmdTambah.Enabled = True cmdUbah.Enabled = False
cmdHapus.Enabled = False cmdSimpan.Enabled = False
cmdBatal.Enabled = False cmdKeluar.Enabled = True
End Sub Private Sub cmdBatal_Click
Call formKosong Call formNonAktif
Call formAwal End Sub
Private Sub cmdHapus_Click temp.Caption = DataGrid2.Text
temp2.Caption = DataGrid2.Columns1.Value jawab = MsgBoxHapus Id Suplier temp2.Caption, vbYesNo, _
Konfirmasi If jawab = vbYes Then
jawab1 = MsgBoxHapus Id Suplier temp2.Caption _ ???, vbYesNo, Konfirmasi
If vbYes Then Call konekDB
sql = sql = delete from suplier where id_suplier= _
temp.Caption koneksi.Execute sql, , adCmdText
Adodc2.Refresh DataGrid2.Refresh
Call formKosong Call formNonAktif
Call formAwal Else
Me.Refresh End If
Else Me.Refresh
End If End Sub
Private Sub cmdKeluar_Click Unload Me
End Sub Private Sub cmdSimpan_Click
menampilkan data suplier berdasarkan nama_suplier Call konekDB
rsSuplier.Open select from suplier where _ nama_suplier = TrimtxtNamaSuplier.Text , _
koneksi, adOpenDynamic, adLockBatchOptimistic Adodc2.Refresh
DataGrid2.Refresh If txtNamaSuplier.Text = Then
konfirmasi jiga nama suplier masih dalam keadaan kosong MsgBox Isi Nama Suplier, vbOKOnly + vbCritical, Gagal
txtNamaSuplier.SetFocus
246
ElseIf Not rsSuplier.EOF Then konfirmasi nama suplier sudah ada
MsgBox Maaf, Nama Suplier _ UCasetxtNamaSuplier.Text _
telah tersedia, _ vbInformation + vbOKOnly, Informasi
koneksi.Close txtNamaSuplier.Text =
txtNamaSuplier.SetFocus Exit Sub
Else perintah SQL untuk menyimpan data ke dalam tabel suplier
koneksi.Close Call konekDB
sql = sql = CALL id_suplier txtNamaSuplier.Text , _
txtAlamat.Text koneksi.Execute sql, , adCmdText
Adodc2.Refresh DataGrid2.Refresh
MsgBox Data berhasil ditambahkan, vbInformation, Berhasil Call formKosong
Call formNonAktif Call formAwal
End If Adodc2.Refresh
DataGrid2.Refresh Adodc2.RecordSource = select id_suplier KODE SUPLIER, nama_suplier NAMA
SUPLIER, alamat ALAMAT from suplier order by id_suplier koneksi.Close
End Sub Private Sub cmdTambah_Click
Call formKosong Call formAktif
txtNamaSuplier.SetFocus cmdUbah.Enabled = False
cmdHapus.Enabled = False cmdTambah.Enabled = False
cmdSimpan.Enabled = True cmdBatal.Enabled = True
cmdKeluar.Enabled = False End Sub
Private Sub cmdUbah_Click temp2.Caption = DataGrid2.Columns1.Value
MsgBox Ubah Id Suplier temp2.Caption ???, vbYesNo, _ PERINGATAN
If vbYes Then temp.Caption = DataGrid2.Columns0.Value
Call konekDB sql =
sql = UPDATE suplier set nama_suplier = txtNamaSuplier.Text _
247
, alamat = txtAlamat.Text where id_suplier = temp.Caption koneksi.Execute sql, , adCmdText
Adodc2.Refresh DataGrid2.Refresh
Call formKosong Call formNonAktif
Call formAwal Else
Me.Refresh Call formKosong
Call formNonAktif End If
End Sub Private Sub DataGrid2_dblClick
Call formAktif cmdTambah.Enabled = False
cmdHapus.Enabled = True cmdUbah.Enabled = True
cmdSimpan.Enabled = False cmdBatal.Enabled = True
cmdKeluar.Enabled = False txtNamaSuplier.Text = DataGrid2.Columns1.Value
txtAlamat.Text = DataGrid2.Columns2.Value End Sub
Private Sub Form_Load Call formNonAktif
Call formAwal With boxKategori
.AddItem KODE SUPLIER .AddItem NAMA SUPLIER
End With End Sub
Private Sub Form_UnloadCancel As Integer Do Until Me.Top = -9000
DoEvents Me.Move Me.Left, Me.Top - 50
DoEvents Loop
End Sub Private Sub txtCari_Change
If boxKategori.Text = KODE SUPLIER Then Adodc2.RecordSource = select id_suplier KODE SUPLIER, nama_suplier NAMA
SUPLIER, alamat ALAMAT from suplier where id_suplier LIKE _ txtCari.Text order by id_suplier
Adodc2.Refresh DataGrid2.Refresh
Else Adodc2.RecordSource = select id_suplier KODE SUPLIER, nama_suplier NAMA
SUPLIER, alamat ALAMAT from suplier where nama_suplier LIKE _ txtCari.Text order by id_suplier
Adodc2.Refresh
248
DataGrid2.Refresh End If
End Sub Private Sub txtCari_KeyPressKeyAscii As Integer
KeyAscii = AscUCaseChrKeyAscii End Sub
Private Sub txtNamaSuplier_keypressKeyAscii As Integer KeyAscii = AscUCaseChrKeyAscii
End Sub Private Sub txtalamat_keypressKeyAscii As Integer
KeyAscii = AscUCaseChrKeyAscii End Sub
R. Form Pengolahan Data Suplier Operator