Exemplo n.º 1
0
        // Delete button
        private void button7_Click(object sender, EventArgs e)
        {
            if (listPassword_control.password_grid.CurrentRow == null)
            {
                MessageBox.Show("No item selected.", "System Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (MessageBox.Show("Are you sure to delete this record ?", "DELETE", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    int             rowIndex      = listPassword_control.password_grid.CurrentCell.RowIndex;
                    DataGridViewRow selectedRowId = listPassword_control.password_grid.Rows[rowIndex];

                    password pass_delete = model.password.Find(selectedRowId.Cells[0].Value);
                    model.password.Remove(pass_delete);
                    model.SaveChanges();

                    //    var query_delete = model.password.Where(p => p.id_user == userID && p.id_password.ToString() == selectedRowId.Cells[0].Value.ToString());
                    displayData();
                }
            }
        }