private void Delete_Click(object sender, EventArgs e) { var idFinanca = (int)this.dataGridView1.SelectedCells[0].Value; Financa financa = FinancaService.findFinanca(idFinanca); AdviceConta confirm = new AdviceConta(); DialogResult result = confirm.ShowDialog(); List <string> Erros = new List <string>(); if (result == DialogResult.OK) { Erros = FinancaService.Delete(financa); if (Erros.Count > 0) { string textError = ""; foreach (var erro in Erros) { textError += erro + "\r\n"; } MessageBox.Show(textError); } else { MessageBox.Show("Registro deletado com sucesso."); this.Form1_Load(null, EventArgs.Empty); } } }
private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.ColumnIndex == 5) { var Id = (int)dataGridView1.Rows[e.RowIndex].Cells[0].Value; var Financa = FinancaService.findFinanca(Id); Financa.Pago = !Financa.Pago; FinancaService.Edit(Financa.Id, Financa.Descricao, Financa.Valor.ToString("0.00"), Financa.ContaId, Financa.Pago, Financa.AnoMesReferencia, Financa.Vencimento, Financa.Receita, Financa.CategoriaId); if (Financa.Pago) { FinancaService.setValorConta(Financa, FinancaService.Method.Edit);//Mudou de não pago para pago } else { FinancaService.setValorConta(Financa, FinancaService.Method.Edit);//Mudou de pago para não pago } this.Form1_Load(null, EventArgs.Empty); } DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex]; foreach (DataGridViewCell item in dataGridView1.Rows[e.RowIndex].Cells) { if (item == dataGridView1.Rows[e.RowIndex].Cells["Id"]) { item.Selected = true; } else { item.Selected = false; } } }