예제 #1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //  MessageBox.Show(e.ColumnIndex.ToString() + " " + e.RowIndex.ToString());
            //this event is triggered every time I click a cell
            string currentRoomName = dataGridView1.CurrentRow.Cells[0].Value.ToString();

            if (e.ColumnIndex == 4)
            {
                //delete classroom
                Classroom classtodelete = MainProgram.rooms.Find(croom => croom.Classroomname == currentRoomName);

                MessageBoxButtons confirmButtons = MessageBoxButtons.OKCancel;

                DialogResult result = MessageBox.Show("Are you sure you want to delete?", "Delete", confirmButtons);

                if (result == DialogResult.OK)
                {
                    MainProgram.rooms.Remove(classtodelete);
                    updateGrid();
                }
            }
            if (e.ColumnIndex == 2)
            {
                //update classroom

                Classroom classtoupdate = MainProgram.rooms.Find(croom => croom.Classroomname == currentRoomName);


                AddEditClassroom addC = new AddEditClassroom(classtoupdate);
                addC.ShowDialog(this);
            }
            if (e.ColumnIndex == 3)
            {
                //manage classroom computers
                Classroom classtoupdate = MainProgram.rooms.Find(croom => croom.Classroomname == currentRoomName);

                ManageComputersForm manageCompForm = new ManageComputersForm(classtoupdate);
                manageCompForm.ShowDialog();
            }



            //MessageBox.Show();
            //MessageBox.Show(dataGridView1.CurrentRow.Cells[0].Value.ToString());
        }
예제 #2
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //  MessageBox.Show(e.ColumnIndex.ToString() + " " + e.RowIndex.ToString());
            //this event is triggered every time I click a cell
            string currentRoomName = dataGridView1.CurrentRow.Cells[0].Value.ToString();

            if (e.ColumnIndex==4)
            {
                //delete classroom
                Classroom classtodelete = MainProgram.rooms.Find(croom => croom.Classroomname == currentRoomName);

                MessageBoxButtons confirmButtons = MessageBoxButtons.OKCancel;

                DialogResult result = MessageBox.Show("Are you sure you want to delete?","Delete", confirmButtons);

                if (result == DialogResult.OK)
                {
                    MainProgram.rooms.Remove(classtodelete);
                    updateGrid();
                }

            }
            if (e.ColumnIndex == 2)
            {
                //update classroom

                Classroom classtoupdate = MainProgram.rooms.Find(croom => croom.Classroomname == currentRoomName);

                AddEditClassroom addC = new AddEditClassroom(classtoupdate);
                addC.ShowDialog(this);
            }
            if (e.ColumnIndex == 3)
            {
                //manage classroom computers
                Classroom classtoupdate = MainProgram.rooms.Find(croom => croom.Classroomname == currentRoomName);

                ManageComputersForm manageCompForm = new ManageComputersForm(classtoupdate);
                manageCompForm.ShowDialog();
            }

            //MessageBox.Show();
            //MessageBox.Show(dataGridView1.CurrentRow.Cells[0].Value.ToString());
        }