Example #1
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);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string hasil = Barang.HapusData(comboBoxKodeBarang.Text);
                if (hasil == "1")
                {
                    MessageBox.Show("Barang telah dihapus");

                    FormDaftarBarang frm = (FormDaftarBarang)this.Owner;
                    frm.FormDaftarBarang_Load(sender, e);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Error. Pesan : " + hasil);
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Example #3
0
        private void buttonTambahBarang_Click(object sender, EventArgs e)
        {
            try
            {
                Barang b;
                if (comboBoxPO.Text != "")
                {
                    OrderPenjualan o = listHasilData[comboBoxPO.SelectedIndex];
                    b = new Barang(textBoxKodeBarang.Text, textBoxNamaBarang.Text, (int)numericUpDownJumlah.Value, textBoxSatuanBarang.Text, (int)numericUpDownHargaSatuan.Value, richTextBoxKeterangan.Text, o);
                }
                else
                {
                    b = new Barang(textBoxKodeBarang.Text, textBoxNamaBarang.Text, (int)numericUpDownJumlah.Value, textBoxSatuanBarang.Text, (int)numericUpDownHargaSatuan.Value, richTextBoxKeterangan.Text, null);
                }
                string hasil = Barang.TambahData(b);
                if (hasil == "1")
                {
                    if (pictureBoxGambar.BackgroundImage != null)
                    {
                        pictureBoxGambar.BackgroundImage.Save(Application.StartupPath + "\\Images\\Barang\\" + textBoxKodeBarang.Text + ".jpg");
                    }

                    MessageBox.Show("Barang telah ditambahkan");

                    FormTambahBarang_Load(sender, e);
                    frmDaftar.FormDaftarBarang_Load(sender, e);
                }
                else
                {
                    MessageBox.Show("Gagal menambahkan barang. Pesan: Kode Barang telah digunakan");
                }
            }
            catch (Exception es)
            {
                MessageBox.Show(es.Message);
            }
        }