예제 #1
0
        private void dgvTables_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = int.Parse(dgvTables.CurrentRow.Cells[0].Value.ToString());

            if (e.ColumnIndex == 3)
            {
                if (MessageBox.Show($"¿Seguro que desea eliminar '{dgvTables.CurrentRow.Cells[1].Value}'?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    Table model = db.Tables.Where(x => x.TableId == id).FirstOrDefault();
                    var   entry = db.Entry(model);
                    if (entry.State == EntityState.Unchanged)
                    {
                        db.Tables.Remove(model);
                        db.SaveChanges();
                        Filldgv();
                    }
                }
            }

            if (e.ColumnIndex == 2)
            {
                Table model = db.Tables.Where(x => x.TableId == id).FirstOrDefault();
                Visible = false;
                frmAddTable edit = new frmAddTable(model);
                edit.ShowDialog();
                Filldgv();
                Visible = true;
            }
        }
예제 #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Visible = false;
            frmAddTable add = new frmAddTable(null);

            add.ShowDialog();
            Filldgv();
            Visible = true;
        }