Exemplo n.º 1
0
        private void buttonSimpan_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(textBoxKodeBarang.Text) && !string.IsNullOrEmpty(textBoxHargaJual.Text) && !string.IsNullOrEmpty(textBoxNama.Text) && !string.IsNullOrEmpty(textBoxStok.Text))
            {
                //ciptakan objek yg akan ditambahkan
                string   kodeKategori = textBoxKategori.Text.Substring(1, 2);
                string   namaKategori = textBoxKategori.Text.Substring(6, textBoxKategori.Text.Length - 6);
                Kategori kate         = new Kategori(kodeKategori, namaKategori);
                Barang   brg          = new Barang(textBoxKodeBarang.Text, textBoxBarcode.Text, textBoxNama.Text, int.Parse(textBoxHargaJual.Text), int.Parse(textBoxStok.Text), kate);

                //panggil static method UbahData di class Kategori
                string hasilTambah = Barang.UbahData(brg);

                if (hasilTambah == "1")
                {
                    MessageBox.Show("Barang telah diubah.", "Informasi");
                    FormUbahBarang_Load(sender, e);
                }
                else
                {
                    MessageBox.Show("Gagal Mengubah Kategori. Pesan Kesalahan : " + hasilTambah);
                }
            }
            else
            {
                MessageBox.Show("Lengkapi Data Terlebih Dahulu");
            }
        }
Exemplo n.º 2
0
        private void buttonUbahData_Click(object sender, EventArgs e)
        {
            try
            {
                Barang b = new Barang(comboBoxKodeBarang.Text, textBoxNama.Text, (int)numericUpDownJumlah.Value, textBoxSatuan.Text, (int)numericUpDownHargaSatuan.Value, textBoxKeterangan.Text, new OrderPenjualan());

                string hasil = Barang.UbahData(b);
                if (hasil == "1")
                {
                    MessageBox.Show("Barang telah diubah");
                    if (pictureBox1.BackgroundImage != null)
                    {
                        pictureBox1.BackgroundImage.Save(Application.StartupPath + "\\Images\\Barang\\" + comboBoxKodeBarang.Text + ".jpg");
                    }
                    textBoxIdOrder.Text            = "";
                    textBoxKeterangan.Text         = "";
                    textBoxSatuan.Text             = "";
                    textBoxNama.Text               = "";
                    numericUpDownJumlah.Value      = 0;
                    numericUpDownHargaSatuan.Value = 0;

                    frmDaftar.FormDaftarBarang_Load(sender, e);
                }
                else
                {
                    MessageBox.Show("Barang gagal diubah. Pesan : " + hasil);
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }