private void dgv_parcelas_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete && int.Parse(lbl_linha.Text) >= 0) { if (parcela_todos[int.Parse(lbl_linha.Text)].PCA_VALOR_PAGO > 0) { MessageBox.Show("Impossível excluir parcela já paga! É necessário estorná-la antes.", "3Pratos", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (parcela_todos[int.Parse(lbl_linha.Text)].PCA_ITEM_NOVA_PARC > 0) { MessageBox.Show("Impossível excluir parcela parcial! É necessário excluir a parcela " + parcela_todos[int.Parse(lbl_linha.Text)].PCA_ITEM_NOVA_PARC.ToString() + " antes.", "3Pratos", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (MessageBox.Show("Deseja realmente excluir esta parcela?", "3Pratos", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Parcelas_PagarCollection parcela_todos_temp = new Parcelas_PagarCollection(); Cheques_PagarCollection cheque_pagar_todos_temp = new Cheques_PagarCollection(); int PCA_ITEM = 1; foreach (Cheques_Pagar cheque_pagar in cheque_pagar_todos) { cheque_pagar_todos_temp.Add(cheque_pagar); } cheque_pagar_todos.Clear(); foreach (Parcelas_Pagar parcela in parcela_todos) { if (parcela.PCA_ITEM != (int.Parse(lbl_linha.Text) + 1)) { parcela.PCA_ITEM = PCA_ITEM++; if (parcela.PCA_ITEM_NOVA_PARC == (int.Parse(lbl_linha.Text) + 1)) { parcela.PCA_ITEM_NOVA_PARC = 0; } parcela_todos_temp.Add(parcela); if (parcela.PCA_TIPO == 3) { foreach (Cheques_Pagar cheque_pagar in cheque_pagar_todos_temp) { if (parcela.PCA_ITEM == cheque_pagar.CHP_ITEM) { cheque_pagar_todos.Add(cheque_pagar); } } } } } Carregar_Grid(parcela_todos_temp); } } }