private void guna2ButtonBuy_Click(object sender, EventArgs e) { try { string no_nota = guna2TextBoxNota.Text; Student student = new Student(session.Id, session.Name); NotaJual notaJual = new NotaJual( guna2TextBoxNota.Text, guna2DateTimePicker1.Value, student); for (int i = 0; i < dataGridViewSearch.Rows.Count - 1; i++) { Course course = new Course(); string id = dataGridViewSearch.Rows[i].Cells[2].Value.ToString(); listCourse = course.QueryData("course.id", id); double harga = double.Parse(dataGridViewSearch.Rows[i].Cells[4].Value.ToString()); notaJual.TambahDetil((Course)listCourse[0], harga); } notaJual.Insert(); DialogResult printYes = MessageBox.Show("Cetak Nota ?", "Info", MessageBoxButtons.YesNo); if (printYes == DialogResult.Yes) { NotaJual.CetakNota(new Font("Courier New", 12), "nota_jual.no_nota", no_nota, Session.Instance.Id, "nota_current.txt"); } else { MessageBox.Show("Berhasil Membeli", "Info"); } //FormAddTransaction_Load(guna2ButtonBuy, e); } catch (Exception error) { MessageBox.Show($"Gagal Menyimpan, Error : {error.Message}", "Warning"); } }