Exemplo n.º 1
0
        private void teamsDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //9.10.11
            int id = Convert.ToInt32(teamsDataGridView.CurrentRow.Cells[0].Value);

            if (e.ColumnIndex == 9)
            {
                //Info
                team loct = context.teams.Find(id);
                using (TeamInfo frm = new TeamInfo(loct))
                {
                    frm.ShowDialog();
                }
            }
            if (e.ColumnIndex == 10)
            {
                if (loggedUser == "Admin")
                {
                    //Edit
                    team loct = context.teams.Find(id);
                    using (TeamEdit frm = new TeamEdit(loct))
                    {
                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            dbm.EditTeam(id, frm.teamTextBox.Text, frm.driver1ComboBox.SelectedItem.ToString(), frm.driver2ComboBox.SelectedItem.ToString(), frm.car1ComboBox.SelectedItem.ToString(), frm.car2ComboBox.SelectedItem.ToString());
                            teamsDataGridView.DataSource = dbm.GetTeamView();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Access Denied", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            if (e.ColumnIndex == 11)
            {
                if (loggedUser == "Admin")
                {
                    //Delete
                    dbm.DeleteTeam(id);
                    teamsDataGridView.DataSource = dbm.GetTeamView();
                }
                else
                {
                    MessageBox.Show("Access Denied", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }