private void btnVisualizar_Click(object sender, EventArgs e) { try { vw_emprestimo_locatario locatario = dgvEmprestimo.CurrentRow.DataBoundItem as vw_emprestimo_locatario; frmCadastrar frm = new frmCadastrar(); frm.PreencherCampos(locatario.id_emprestimo); ((frmPrincipal)this.ParentForm).CarregarPanel(frm); } catch (Exception ex) { if (ex.Message.Contains("Referência de objeto não definida para uma instância de um objeto")) { MessageBox.Show("Selecione um emprestimo!", "Biblioteca", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void btnRemover_Click(object sender, EventArgs e) { try { vw_emprestimo_locatario locatario = dgvEmprestimo.CurrentRow.DataBoundItem as vw_emprestimo_locatario; EmprestimoBusiness business = new EmprestimoBusiness(); business.RemoverEmprestimo(locatario.id_emprestimo); MessageBox.Show("Emprestimo removido com sucesso!", "Biblioteca", MessageBoxButtons.OK, MessageBoxIcon.Information); CarregarGrid(); } catch (Exception ex) { if (ex.Message.Contains("Referência de objeto não definida para uma instância de um objeto")) { MessageBox.Show("Selecione um emprestimo!", "Biblioteca", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void PreencherDados(int idLocatario) { AzureBiblioteca db = new AzureBiblioteca(); vw_emprestimo_locatario loc = db.vw_emprestimo_locatario.Where(x => x.id_emprestimo == idLocatario).ToList().Single(); }