private void buttonTambahBarang_Click(object sender, EventArgs e) { if (dataGridViewBarang.Rows.Count < 2) { MessageBox.Show("Harap mengisi paling tidak satu data"); } else { string hasil = "1"; for (int i = 0; i < dataGridViewBarang.Rows.Count - 1; i++) { PenggunaanBahanBaku p = new PenggunaanBahanBaku(); p.BahanBaku = listChosenBahanBaku[i]; p.Spk = listChosenSpk[i]; p.JumlahMasuk = int.Parse(dataGridViewBarang.Rows[i].Cells["JumlahMasuk"].Value.ToString()); p.JumlahKeluar = int.Parse(dataGridViewBarang.Rows[i].Cells["JumlahKeluar"].Value.ToString()); p.TanggalKeluar = DateTime.Parse(dataGridViewBarang.Rows[i].Cells["Tanggal"].Value.ToString()); p.SisaStok = int.Parse(dataGridViewBarang.Rows[i].Cells["Stok"].Value.ToString()); p.StokOpnameTanggal = dataGridViewBarang.Rows[i].Cells["StokOpname"].Value.ToString(); p.Jenis = dataGridViewBarang.Rows[i].Cells["Jenis"].Value.ToString(); hasil = PenggunaanBahanBaku.TambahData(p); hasil = BahanBaku.SetStok(p.BahanBaku.Id, p.SisaStok); } if (hasil == "1") { MessageBox.Show("Penggunaan bahan baku telah ditambah"); FormDaftarPenggunaanBahanBaku form = (FormDaftarPenggunaanBahanBaku)this.Owner; form.FormDaftarPenggunaanBahanBaku_Load(sender, e); FormTambahPenggunaanBahanBaku_Load(sender, e); } else { MessageBox.Show("Penggunaan Bahan Baku gagal ditambah. pesan : " + hasil); } //BahanBaku b = listBahanBaku[comboBoxBahanBaku.SelectedIndex]; //Spk s = listSpk[comboBoxSpk.SelectedIndex]; //PenggunaanBahanBaku p = new PenggunaanBahanBaku(b, s, masuk, keluar, dateTimePickerTanggal.Value, dateTimePickerTanggal.Value.ToString("ddMMMMyyyy") + " | " + textBoxStok.Text, int.Parse(textBoxStok.Text), textBoxJenis.Text); //string hasil = PenggunaanBahanBaku.TambahData(p); //if (hasil == "1") //{ // MessageBox.Show("Penggunaan Bahan Baku telah ditambah"); // comboBoxBahanBaku.Text = ""; // comboBoxBahanBaku.Enabled = false; // textBox1.Text = ""; // textBoxKodeBarang.Text = ""; // textBoxStok.Text = ""; // comboBoxSpk.Text = ""; // textBoxJenis.Text = ""; // FormDaftarPenggunaanBahanBaku form = (FormDaftarPenggunaanBahanBaku)this.Owner; // form.FormDaftarPenggunaanBahanBaku_Load(sender, e); //} //else //{ // MessageBox.Show("Penggunaan Bahan Baku gagal ditambah. Pesan kesalahan : " + hasil); //} } }
private void penggunaanBahanBakuToolStripMenuItem_Click(object sender, EventArgs e) { Form form = Application.OpenForms["FormDaftarPenggunaanBahanBaku"]; if (form == null) { FormDaftarPenggunaanBahanBaku frm = new FormDaftarPenggunaanBahanBaku(); frm.Owner = this; frm.Show(); } else { form.Show(); form.BringToFront(); } }