private void dgvStall_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = Convert.ToInt32(dg_Stall.Rows[e.RowIndex].Cells["StallId"].Value);

            if (dg_Stall.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
            {
                string command = dg_Stall.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                if (command.ToLower() == "delete")
                {
                    try
                    {
                        if (MessageBox.Show("Do you want to delete", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            var stall = db.Stalls.Where(s => s.StallId == id).Include(s => s.AttendeeStalls).Include(s => s.Room).FirstOrDefault();
                            db.Stalls.Remove(stall);
                            db.SaveChanges();
                            MessageBox.Show("Stall Successfully deleted");
                            LoadStall();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else if (command.ToLower() == "edit")
                {
                    AddStall addStall = new AddStall(id);
                    addStall.Show();
                }
            }
        }
示例#2
0
        private void addStallToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddStall add = new AddStall(0);

            add.Show();
        }