private void button_add_Click(object sender, EventArgs e) { if ((comboBox_addWorkType.SelectedIndex + 1) == (int)WorkCollection.WorkType.Book) { Form_Book addBookForm = new Form_Book(); addBookForm.ShowDialog(this); } else { Form_CD addCDForm = new Form_CD(); addCDForm.ShowDialog(this); } }
private void dataGridView_works_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex != -1) { int workCode = (int)dataGridView_works.Rows[e.RowIndex].Cells["Code"].Value; if (WorkLibrary.GetWork(workCode) is Book) { Form_Book addBookForm = new Form_Book(workCode, readOnly: true); addBookForm.ShowDialog(this); } else { Form_CD addCDForm = new Form_CD(workCode, readOnly: true); addCDForm.ShowDialog(this); } } }
private void button_edit_Click(object sender, EventArgs e) { int workCode = 0; if (!int.TryParse(textBox_editWorkCode.Text.Trim(), out workCode)) { MessageBox.Show("Invalid work code.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (WorkLibrary.GetWork(workCode) is Book) { Form_Book addBookForm = new Form_Book(workCode); addBookForm.ShowDialog(this); } else { Form_CD addCDForm = new Form_CD(workCode); addCDForm.ShowDialog(this); } } }