private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { int id = Convert.ToInt32(dataGridView1.CurrentRow.Cells["participantIdDataGridViewTextBoxColumn"].Value); // updating if (e.ColumnIndex == 9) { formDTO.op = CrudOpr.Update; ViewConferencesWithParticipant findParticipant = dataFormDTO.db.ViewConferencesWithParticipants.SingleOrDefault(o => o.participantId == id); formDTO.obj = findParticipant; CreateUpdateParticipantForm form = new CreateUpdateParticipantForm(this, formDTO); form.Show(); } // deleting if (e.ColumnIndex == 10) { // Запрашиваем подтверждение string message = "Do you want to delete?"; string caption = "Y/n"; var result = MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { participant participant = new participant(); participant.participantId = id; // deleting if (crud.delete(participant)) { MessageBox.Show("Conference was deleted!"); resetData(); } else { MessageBox.Show("Deleting was denied"); } } } }
private void initDataForUpdate(ViewConferencesWithParticipant obj) { ScientistLabel.Text = formDTO.obj.firstName + " " + formDTO.obj.secondName + "," + formDTO.obj.degree + "\n" + formDTO.obj.companyName; ChooseScientistButton.Visible = false; cbConference.Text = obj.conferenceName; cbTheme.Text = obj.themeName; cbSubject.Text = obj.subject; cbPublication.CheckState = obj.publication.Equals("y") ? CheckState.Checked : CheckState.Unchecked; if (cbPublication.CheckState == CheckState.Checked) { isChecked = true; } participantDTO.conference = obj.conferenceId; participantDTO.subject = obj.subjectId; participantDTO.theme = obj.themeId; }