private void btnBeli_Click(object sender, EventArgs e) { try { string sjml = txtJml.Text; int jml = Convert.ToInt16(sjml); long har = Convert.ToInt16(c); int stk = Convert.ToInt16(d); har = jml * har; stk -= jml; tot += har; if (stk >= 0) { string shar = Convert.ToString(har); string stot = Convert.ToString(tot); d = Convert.ToString(stk); txtHarga.Text = shar; txtTotHarga.Text = stot; Barang std = new Barang(a, b, c, d); CRUDBarang.UpdateBarang(std, a); } else { txtID.Text = txtJml.Text = txtHarga.Text = txtTotHarga.Text = string.Empty; MessageBox.Show("Stok tidak mencukupi!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception) { MessageBox.Show("Error!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void tabelstok_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) { formm.clrscr(); formm.ID = tabelstok.Rows[e.RowIndex].Cells[2].Value.ToString(); formm.NAMA = tabelstok.Rows[e.RowIndex].Cells[3].Value.ToString(); formm.HARGA = tabelstok.Rows[e.RowIndex].Cells[4].Value.ToString(); formm.STOK = tabelstok.Rows[e.RowIndex].Cells[5].Value.ToString(); formm.UpdateBarang(); formm.ShowDialog(); return; } if (e.ColumnIndex == 1) { if (MessageBox.Show("Yakin ingin dihapus?", "Information", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information) == DialogResult.Yes) { CRUDBarang.DeleteBarang(tabelstok.Rows[e.RowIndex].Cells[2].Value.ToString()); Display(); } return; } }
private void btnTambah_Click(object sender, EventArgs e) { if (txtID.Text.Trim().Length <= 0) { MessageBox.Show("ID Kosong!"); return; } if (txtNama.Text.Trim().Length <= 0) { MessageBox.Show("Nama Kosong!"); return; } if (txtHarga.Text.Trim().Length <= 0) { MessageBox.Show("Harga Kosong!"); return; } if (txtStok.Text.Trim().Length <= 0) { MessageBox.Show("Stok Kosong!"); return; } if (btnTambah.Text == "Tambah") { Barang std = new Barang(txtID.Text.Trim(), txtNama.Text.Trim(), txtHarga.Text.Trim(), txtStok.Text.Trim()); CRUDBarang.TmbhBarang(std); clrscr(); } if (btnTambah.Text == "Edit") { Barang std = new Barang(txtID.Text.Trim(), txtNama.Text.Trim(), txtHarga.Text.Trim(), txtStok.Text.Trim()); CRUDBarang.UpdateBarang(std, ID); clrscr(); } _parent.Display(); }
private void textBox1_TextChanged(object sender, EventArgs e) { CRUDBarang.DisplayBarang("SELECT ID, NAMA, HARGA, STOK FROM databarang WHERE NAMA LIKE'%" + barpencarian.Text + "%'", tabelstok); }
public void Display() { CRUDBarang.DisplayBarang("SELECT ID, NAMA, HARGA, STOK FROM databarang", tabelstok); }
private void DataStokBarangUser_Shown(object sender, EventArgs e) { CRUDBarang.DisplayBarang("SELECT ID, NAMA, HARGA, STOK FROM databarang", tabelbarang); }