private void hapusToolStripMenuItem_Click(object sender, EventArgs e) { try { if (tb_id_rak.ReadOnly == true) { DialogResult res = MessageBox.Show("Hapus " + tb_id_rak.Text + "?", "Perhatian", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (res == DialogResult.OK) { sql = "delete from rak where id_rak = '" + tb_id_rak.Text + "'"; DBClass db = new DBClass(); //panggil class db db.execute(sql); showGrid(); MessageBox.Show(tb_rak.Text + " dihapus"); //message box tambahToolStripMenuItem_Click(null, null); //panggil tombol tambah } else if (res == DialogResult.Cancel) { MessageBox.Show("Penghapusan data " + tb_rak.Text + " dibatalkan"); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { } }
private void simpanToolStripMenuItem_Click(object sender, EventArgs e) { try { if (tbID.ReadOnly == false) { sql = "INSERT into barang VALUES ('" + tbID.Text + "', " + "'" + tbBarang.Text + "'," + nudStok.Value + "," + "'" + tbMerek.Text + "','" + tbSeri.Text + "'," + "'" + cbxJenis.SelectedItem.ToString() + "'," + "'" + cbxRak.SelectedValue.ToString() + "'," + "" + tbHarga.Text + ",'" + dtpExpiredDate.Value.ToString("yyyy-MM-dd") + "')"; } else { sql = "UPDATE barang SET barang = '" + tbBarang.Text + "', stok = " + nudStok.Value + ", " + "merek='" + tbMerek.Text + "', seri ='" + tbSeri.Text + "', jenis ='" + cbxJenis.SelectedItem.ToString() + "', " + "rak ='" + cbxRak.SelectedValue.ToString() + "', harga = " + tbHarga.Text + ", " + "expired_date = '" + dtpExpiredDate.Value + "' where id_barang ='" + tbID.Text + "'"; } DBClass db = new DBClass(); //panggil class db db.execute(sql); showGrid(); tambahToolStripMenuItem_Click(null, null); //panggil tombol tambah MessageBox.Show(tbBarang.Text + " tersimpan"); //message box } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { } }
private void simpanToolStripMenuItem_Click(object sender, EventArgs e) { try { if (tb_id_rak.ReadOnly == false) { sql = "insert into rak values ('" + tb_id_rak.Text + "', '" + tb_rak.Text + "'," + nudbaris.Value + ")"; } else { sql = "update rak set rak = '" + tb_rak.Text + "', baris = " + nudbaris.Value + " " + "where id_rak = '" + tb_id_rak.Text + "'"; } DBClass db = new DBClass(); //panggil class db db.execute(sql); showGrid(); tambahToolStripMenuItem_Click(null, null); //panggil tombol tambah MessageBox.Show(tb_rak.Text + " tersimpan"); //message box } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { } }
private void simpanToolStripMenuItem_Click(object sender, EventArgs e) { try { double harga = double.Parse(tbHarga.Text); if (tbID.ReadOnly == false) { //khusus rak, yang diambil ID (value member)-nya, bukan Text (Display Member)-nya String id_rak = cbxRak.SelectedValue.ToString(); sql = "insert into barang values ('" + tbID.Text + "', '" + tbBarang.Text + "', " + "" + nudStok.Value + ", '" + tbMerek.Text + "', '" + tbSeri.Text + "', " + "'" + cbxJenis.Text + "', '" + id_rak + "', " + harga + ", '" + dtpExpiredDate.Value + "')"; } else { sql = "update barang set barang = '" + tbBarang.Text + "', stok = " + nudStok.Value + ", " + "merek = '" + tbMerek.Text + "', seri = '" + tbSeri.Text + "', jenis = '" + cbxJenis.Text + "', " + "id_rak = '" + cbxRak.ValueMember.ToString() + "', harga = " + harga + ", " + "expired_date = '" + dtpExpiredDate.Value + "' where id_barang = '" + tbID.Text + "'"; } DBClass db = new DBClass(); //panggil class DB db.execute(sql); showGrid(); tambahToolStripMenuItem_Click(null, null); //panggil tombol tambah MessageBox.Show(tbBarang.Text + " tersimpan"); //message box } catch (Exception ex) { Console.WriteLine(ex.Message); } }