private void eventAddVoucher(object sender, VoucherInfo e) { foreach (DataGridViewRow name in dataGridView1.Rows) { if (name.Cells[0].Value.ToString() == e.Code) { MessageBox.Show("Mã code này đã tồn tại"); return; } } info.Add(e); using (DatabaseController data = new DatabaseController()) { data.AddVoucher(e); } Invalidate(); }
private void eventAddVoucher(object sender, VoucherInfo e) { foreach (DataGridViewRow name in dataGridView1.Rows) { if (name.Cells[0].Value.ToString() == e.Code) { MessageBox.Show(CodeIsExists, Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } int index = dataGridView1.Rows.Add(e.Code, e.ExpiryDate, e.Value, e.NumberInit, e.NumberRemain); Console.WriteLine(index); reloadTheme(index); using (DatabaseController data = new DatabaseController()) { data.AddVoucher(e); } }