private void picRefresh_Click(object sender, EventArgs e) { if (al != null) { al = adao.BuscaPorID(al.ID); lblNome.Text = al.Nome; lblEmail.Text = al.Email; lblCargo.Text = "Advogado - " + al.Especializacao; try { picPerfil.BackgroundImage = Image.FromFile(al.Foto); } catch (Exception) { } } else { cl = cdao.BuscaPorID(cl.ID); lblNome.Text = cl.Nome; lblEmail.Text = cl.Email; lblCargo.Text = "Cliente - nº" + cl.ID; try { picPerfil.BackgroundImage = Image.FromFile(cl.Foto); } catch (Exception) { } } picNot.Visible = false; }
public ucAltA(int id) { this.a = adao.BuscaPorID(id); InitializeComponent(); Carregar(); }
private void btnExcluir_Click(object sender, EventArgs e) { if (txtNome.Text.Trim().Equals(string.Empty)) { switch (cboTipoCon.SelectedItem) { case TipoCon.Advogado: Visivel(); DataGridViewRow linhaAtual = dataGridView1.CurrentRow; int indice = linhaAtual.Index; AdvogadoDAO adao = new AdvogadoDAO(); Advogado aa = adao.BuscaPorID(Convert.ToInt32(dataGridView1.Rows[indice].Cells["ID"].Value)); adao.Remover(aa); CustomMB.Show("Advogado removido com sucesso!", CustomMB.CorFundo.Verde); var buscaA = from a in contexto.Advogados select a; dataGridView1.DataSource = buscaA.ToList(); dataGridView1.ClearSelection(); break; case TipoCon.Caso: Oculto(); var buscaC = from c in contexto.Casos select c; dataGridView1.DataSource = buscaC.ToList(); dataGridView1.ClearSelection(); break; case TipoCon.Cliente: Visivel(); DataGridViewRow linhaAtualC = dataGridView1.CurrentRow; int indiceC = linhaAtualC.Index; ClienteDAO cdao = new ClienteDAO(); Cliente cc = cdao.BuscaPorID(Convert.ToInt32(dataGridView1.Rows[indiceC].Cells["ID"].Value)); cdao.Remover(cc); CustomMB.Show("Cliente removido com sucesso!", CustomMB.CorFundo.Verde); var buscaCl = from c in contexto.Clientes select c; dataGridView1.DataSource = buscaCl.ToList(); dataGridView1.ClearSelection(); break; } } else { switch (cboTipoCon.SelectedItem) { case TipoCon.Advogado: Visivel(); DataGridViewRow linhaAtual = dataGridView1.CurrentRow; int indice = linhaAtual.Index; AdvogadoDAO adao = new AdvogadoDAO(); Advogado aa = adao.BuscaPorID(Convert.ToInt32(dataGridView1.Rows[indice].Cells["ID"].Value)); adao.Remover(aa); CustomMB.Show("Advogado removido com sucesso!", CustomMB.CorFundo.Verde); var buscaA = from a in contexto.Advogados where a.Nome.Equals(txtNome.Text) select a; dataGridView1.DataSource = buscaA.ToList(); dataGridView1.ClearSelection(); break; case TipoCon.Caso: Oculto(); var buscaC = from c in contexto.Casos select c; dataGridView1.DataSource = buscaC.ToList(); dataGridView1.ClearSelection(); break; case TipoCon.Cliente: Visivel(); DataGridViewRow linhaAtualC = dataGridView1.CurrentRow; int indiceC = linhaAtualC.Index; ClienteDAO cdao = new ClienteDAO(); Cliente cc = cdao.BuscaPorID(Convert.ToInt32(dataGridView1.Rows[indiceC].Cells["ID"].Value)); cdao.Remover(cc); CustomMB.Show("Cliente removido com sucesso", CustomMB.CorFundo.Verde); var buscaCl = from c in contexto.Clientes where c.Nome.Equals(txtNome.Text) select c; dataGridView1.DataSource = buscaCl.ToList(); dataGridView1.ClearSelection(); break; } } }