private void BTN_TBL_PROD_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; List <PRODUTO> TABELA_PRODUTO = null; using (var contexto = new PRODUTO_DAO()) TABELA_PRODUTO = contexto.TrazerProdutos(); var novaTela = new TELA_DE_CONSULTA("Produtos", TABELA_PRODUTO); novaTela.ShowDialog(); var query = from pd in TABELA_PRODUTO where pd.Nome.Equals(TELA_DE_CONSULTA.OpcaoSelecionada) select pd; foreach (var produto in query) { TXT_PROD_COD.Text = produto.ID.ToString(); TEXTO_PRODUTO.Text = produto.Nome; } } catch (Exception ex) { MENSAGEM_AO_USUARIO.ERRO(ex.Message); } finally { Cursor = Cursors.Default; } }
private void excluirToolStripMenuItem_Click(object sender, EventArgs e) { try { if (MENSAGEM_AO_USUARIO.APAGAR_REGISTRO() == DialogResult.No) { return; } Cursor = Cursors.WaitCursor; using (var contexto = new PRODUTO_DAO()) { var LISTA = contexto.TrazerProdutos(); if (LISTA.Count() == 0) { MENSAGEM_AO_USUARIO.ERRO_BANCO_VAZIO("produtos"); return; } progressBar1.Maximum = LISTA.Count() - 1; for (int i = 0; i < LISTA.Count(); i++) { progressBar1.Value = i; contexto.RemoverProduto(LISTA[i]); } MENSAGEM_AO_USUARIO.REMOVER_SUCESSO(); progressBar1.Value = 0; LISTA.Clear(); } } catch (DbUpdateException) { MENSAGEM_AO_USUARIO.ERRO_AO_REMOVER("produtos", "fornecedores"); } catch (Exception ex) { MENSAGEM_AO_USUARIO.ERRO(ex.Message); } finally { Cursor = Cursors.Default; } }
private void BTN_SALDO_HOSPITAL_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; var NOME_TELA = "Relatótio Saldo Hospital"; var MSG_INICIAL = "Qual Espécie?"; var MSG_LISTA = "selecione a espécie.."; var POSICAO_NA_TELA = new System.Drawing.Point(2, 49); var TAMANHO_DO_CAMPO = new System.Drawing.Size(220, 30); List <ESPECIE> LISTA_ESPECIE; List <PRODUTO> LISTA_PRODUTO; using (var contexto = new PRODUTO_DAO()) { LISTA_ESPECIE = contexto.TrazerEspecies(); LISTA_PRODUTO = contexto.TrazerProdutos(); } if (LISTA_ESPECIE.Count == 0 || LISTA_PRODUTO.Count == 0) { MENSAGEM_AO_USUARIO.ERRO("Banco de dados indisponível!"); } var novaTela = new TELA_CAPTURA_VALORES( NOME_TELA, MSG_INICIAL, MSG_LISTA, LISTA_ESPECIE, POSICAO_NA_TELA, TAMANHO_DO_CAMPO, false, true); novaTela.ShowDialog(); if (TELA_CAPTURA_VALORES.ClicouVoltar) { TELA_CAPTURA_VALORES.ClicouVoltar = false; return; } if (ESCREVER.ARQUIVO_R_PRODUTO(LISTA_PRODUTO) == false) { return; } } catch (Exception ex) { RELATORIO_EXCEPTION.CAIXA_DIALOGO_DE_EXCESSOES(ex.Message); } finally { Cursor = Cursors.Default; } }
private void adicionarToolStripMenuItem_Click(object sender, EventArgs e) { try { if (MENSAGEM_AO_USUARIO.ALTERAR_REGISTRO() == DialogResult.No) { return; } Cursor = Cursors.WaitCursor; LER.EXECUTAR(DIRETORIO.C_R_PRODUTO); var LISTA = R_PRODUTO.LISTA; if (LISTA.Count() == 0) { MENSAGEM_AO_USUARIO.ERRO_RELATORIO_NULL(); return; } using (var contexto = new PRODUTO_DAO()) { if (contexto.TrazerProdutos().Count() > 0) { MENSAGEM_AO_USUARIO.ERRO_AO_ADICIONAR("produtos"); return; } progressBar1.Maximum = LISTA.Count() - 1; foreach (var obj in LISTA) { contexto.AdicionarProduto(obj); } MENSAGEM_AO_USUARIO.ATUALIZADO_SUCESSO(); progressBar1.Value = 0; LISTA.Clear(); } } catch (DbUpdateConcurrencyException) { MENSAGEM_AO_USUARIO.ERRO_VINCULO_AO_ADICIONAR("produtos", "especies"); } //catch (InvalidOperationException) { MENSAGEM_AO_USUARIO.ERRO_VINCULO_AO_ADICIONAR("produtos", "especies"); } catch (Exception ex) { MENSAGEM_AO_USUARIO.ERRO(ex.InnerException.Message); } finally { Cursor = Cursors.Default; } }
private void adicionarToolStripMenuItem2_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; if (MENSAGEM_AO_USUARIO.ALTERAR_REGISTRO() == DialogResult.No) { return; } LER.EXECUTAR(DIRETORIO.C_R_ESPECIE_CLASS); var LISTA = R_ESPECIE_CLASS.LISTA; if (LISTA.Count() == 0) { MENSAGEM_AO_USUARIO.ERRO_BANCO_VAZIO("especies"); return; } using (var contexto = new PRODUTO_DAO()) { if (contexto.TrazerProdutos().Count() > 0) { MENSAGEM_AO_USUARIO.ERRO_AO_ADICIONAR("especies"); return; } progressBar1.Maximum = LISTA.Count() - 1; for (int i = 0; i < LISTA.Count(); i++) { progressBar1.Value = i; contexto.AdicionarEspecie(LISTA[i]); } } MENSAGEM_AO_USUARIO.ATUALIZADO_SUCESSO(); progressBar1.Value = 0; LISTA.Clear(); } catch (Exception ex) { MENSAGEM_AO_USUARIO.ERRO(ex.InnerException.Message); } finally { Cursor = Cursors.Default; } }