private void EditItem(DatabaseCommunicator.Model.User user) { EditUserForm form = new EditUserForm(user); if (form.ShowDialog() == DialogResult.OK) { FillDataGridView(); } }
private void dataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { DataGridView senderGrid = (DataGridView)sender; if (e.RowIndex >= 0) { DatabaseCommunicator.Model.User user = senderGrid.Rows[e.RowIndex].Tag as DatabaseCommunicator.Model.User; EditItem(user); } }
private void RemoveItem(DatabaseCommunicator.Model.User user) { if (MessageBox.Show("Naozaj si želáte odstrániť používateľa " + user.Login, "?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (!ezkoController.RemoveUser(user)) { BasicMessagesHandler.ShowErrorMessage("Používateľa sa nepodarilo odstrániť"); } else { FillDataGridView(); } } }
private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { DataGridView senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { DatabaseCommunicator.Model.User item = senderGrid.Rows[e.RowIndex].Tag as DatabaseCommunicator.Model.User; if (senderGrid.Columns[e.ColumnIndex].Name == "Edit") { EditItem(item); } else if (senderGrid.Columns[e.ColumnIndex].Name == "Remove") { RemoveItem(item); } } }