public void ExecutarDevolucao() { string messagem = "Tem Certeza que deseja Executar essa Devolução ?" + dataGridViewLista.CurrentRow.Cells["Nome_Livro"].Value.ToString();; string captionn = "Alerta"; MessageBoxButtons buttonss = MessageBoxButtons.YesNo; DialogResult resultt; resultt = MessageBox.Show(messagem, captionn, buttonss); if (resultt == System.Windows.Forms.DialogResult.Yes) { EmprestimoAluno objetoCT = new EmprestimoAluno { IdEmprestimo = Convert.ToInt32(dataGridViewLista.CurrentRow.Cells["IdEmprestimo"].Value), //pega o valor do id emp IdLivro = Convert.ToInt32(dataGridViewLista.CurrentRow.Cells["Id_Livro"].Value), //pega o valor do id livro Id_Aluno = Convert.ToInt32(dataGridViewLista.CurrentRow.Cells["IdAluno"].Value), }; CN_EmprestimoAluno objetoCN = new CN_EmprestimoAluno(); objetoCN.Devolucao(objetoCT); ExibirConsultaAluno(); MostrarEmprestimoUnico(); checkBox1.Checked = false; MessageBox.Show("Devolução efetuada com sucesso"); } }
private void buttonDevolver_Click(object sender, EventArgs e) { string messagem = "Tem Certeza que deseja Executar essa Devolução ?" + dataGridViewLista.CurrentRow.Cells["Nome_Livro"].Value.ToString();; string captionn = "Alerta"; MessageBoxButtons buttonss = MessageBoxButtons.YesNo; DialogResult resultt; resultt = MessageBox.Show(messagem, captionn, buttonss); if (resultt == System.Windows.Forms.DialogResult.Yes) { int contagem = dataGridViewLista.Rows.Count; for (int i = 0; i < contagem; i++) { if (Convert.ToBoolean(dataGridViewLista.Rows[i].Cells["Column1"].Value) == true) { EmprestimoAluno objetoCT = new EmprestimoAluno { IdEmprestimo = Convert.ToInt32(dataGridViewLista.Rows[i].Cells["IdEmprestimo"].Value), //pega o valor do id emp IdLivro = Convert.ToInt32(dataGridViewLista.Rows[i].Cells["Id_Livro"].Value), //pega o valor do id livro Id_Aluno = Convert.ToInt32(dataGridViewLista.Rows[i].Cells["IdAluno"].Value), }; CN_EmprestimoAluno objetoCN = new CN_EmprestimoAluno(); objetoCN.Devolucao(objetoCT); } } ExibirConsultaAluno(); MostrarEmprestimoUnico(); checkBox1.Checked = false; MessageBox.Show("Devolução efetuada com sucesso"); } }