private void buttonSimpan_Click(object sender, EventArgs e) { try { Transaksi notaJual = new Transaksi(textBoxNoNota.Text, dateTimePickerTglNota.Value, (double)HitungTotal(), 0.1, double.Parse(labelGrandTotal.Text)); for (int i = 0; i < dataGridView1.Rows.Count; i++) { string kodebar = dataGridView1.Rows[i].Cells["IdBarang"].Value.ToString(); List <Barang> b = Barang.BacaData("idbarang", kodebar); int harga, jumlah; harga = int.Parse(dataGridView1.Rows[i].Cells["HargaJual"].Value.ToString()); jumlah = int.Parse(dataGridView1.Rows[i].Cells["Jumlah"].Value.ToString()); notaJual.TambahDetailBarang(b[0], notaJual, jumlah, (harga * jumlah), dataGridView1.Rows[i].Cells["Keterangan"].Value.ToString(), pegawai); } Transaksi.TambahData(notaJual); //FormDaftarNotaJual fdnj = (FormDaftarNotaJual)this.Owner; //fdnj.FormDaftarNotaJual_Load(buttonSimpan, e); MessageBox.Show("Input nota berhasil", "Informasi"); //saved = true; textBoxKet.Text = "-"; textBoxNoNota.Text = Transaksi.GenerateNoNota(); Close(); } catch (Exception ex) { MessageBox.Show("Input nota gagal, pesan kesalahan: " + ex.Message, "Kesalahan"); } }
private void FormTambahNotaJual_Load(object sender, EventArgs e) { ut = (FormUtama)this.MdiParent; FormatDG(); textBoxNoNota.Text = Transaksi.GenerateNoNota(); textBoxKet.Text = "-"; textBoxId.Focus(); labelKodePegawai.Text = ut.u.Id.ToString(); labelNamaPegawai.Text = ut.u.Name; pegawai = ut.u; dateTimePickerTglNota.Value = DateTime.Now; }