private void TxtCodigo_Leave(object sender, EventArgs e) { if (!(TxtCodigo.Text.Trim() == "")) { EPI oEPI = _Control.Selecionar((int.Parse(TxtCodigo.Text))); if (oEPI == null) { incluir = true; BtnIncluir.Enabled = true; BtnAlterar.Enabled = false; BtnExcluir.Enabled = false; } else { TxtNome.Text = oEPI.Nome; TxtCA.Text = oEPI.CA.ToString(); TxtQTD.Text = oEPI.Quantidade.ToString(); BtnIncluir.Enabled = false; BtnAlterar.Enabled = true; BtnExcluir.Enabled = true; HabilitaControles(false); } } }
public EPI ListarEPIPorNome(string nome) { using (var entities = new DB_LaborSafetyEntities()) { EPI epi = entities.EPI .Where(eqp => eqp.Nome == nome).FirstOrDefault(); return(epi); } }
public EPI ListarEPIPorIdString(string id) { using (var entities = new DB_LaborSafetyEntities()) { EPI epi = entities.EPI .Where(eqp => eqp.CodEPI.ToString() == id).FirstOrDefault(); return(epi); } }
public EPIModelo ListarEPIPorNome(string nome) { EPI epi = this.epiPersistencia.ListarEPIPorNome(nome); if (epi == null) { throw new KeyNotFoundException("EPI não encontrado."); } return(MapeamentoEPI(epi)); }
public EPIModelo ListarEPIPorID(long id) { EPI epi = this.epiPersistencia.ListarEPIPorId(id); if (epi == null) { throw new KeyNotFoundException("EPI não encontrado."); } return(MapeamentoEPI(epi)); }
public EPIModelo MapeamentoEPI(EPI epi) { EPIModelo epiModelo = new EPIModelo() { CodEPI = epi.CodEPI, Nome = epi.Nome, Descricao = epi.Descricao, N1 = epi.N1, N2 = epi.N2, N3 = epi.N3 }; return(epiModelo); }
public EPIModelo ListarEPIPorNivel(string nomeCompleto) { if (nomeCompleto == null) { throw new KeyNotFoundException("É necessário informar um nível de EPI para pesquisa."); } EPI epi = this.epiPersistencia.ListarEPIPorNivel(nomeCompleto); if (epi == null) { throw new KeyNotFoundException("EPI não encontrado."); } return(MapeamentoEPI(epi)); }
public EPI ListarEPIPorNivel(string nomeCompleto) { string[] niveis = nomeCompleto.ToString().Split('/'); using (var entities = new DB_LaborSafetyEntities()) { EPI result = null; var posicao0 = niveis[0]; var qtdPosicoes = niveis.Length; if (qtdPosicoes == 1) { result = entities.EPI.Where(eqp => eqp.N1 == posicao0).FirstOrDefault(); } else if (qtdPosicoes == 2) { var posicao1 = niveis[1]; result = entities.EPI.Where(eqp => eqp.N1 == posicao0 && eqp.N2 == posicao1).FirstOrDefault(); } else { if (string.IsNullOrEmpty(niveis[1])) { result = entities.EPI.Where(eqp => eqp.N1 == posicao0).FirstOrDefault(); } else if (string.IsNullOrEmpty(niveis[2])) { var posicao1 = niveis[1]; result = entities.EPI.Where(eqp => eqp.N1 == posicao0 && eqp.N2 == posicao1).FirstOrDefault(); } else { var posicao1 = niveis[1]; var posicao2 = niveis[2]; result = entities.EPI.Where(eqp => eqp.N1 == posicao0 && eqp.N2 == posicao1 && eqp.N3 == posicao2).FirstOrDefault(); } } return(result); } }
private void BtnIncluir_Click(object sender, EventArgs e) { if (ValidaControles()) { if (incluir) { EPI oEPI = new EPI(); oEPI.Codigo = int.Parse(TxtCodigo.Text); oEPI.Nome = (TxtNome.Text).ToString(); oEPI.CA = int.Parse(TxtCA.Text); oEPI.Quantidade = int.Parse(TxtQTD.Text); oEPI.DataEntrada = DateTime.Now; _Control.Incluir(oEPI); incluir = false; } else { var oEPI = _Control.Selecionar(int.Parse(TxtCodigo.Text)); oEPI.Nome = (TxtNome.Text).ToString(); oEPI.CA = int.Parse(TxtCA.Text); oEPI.Quantidade = int.Parse(TxtQTD.Text); oEPI.DataEntrada = DateTime.Now; _Control.Alterar(oEPI); } HabilitaControles(false); BtnIncluir.Enabled = true; BtnAlterar.Enabled = true; BtnExcluir.Enabled = false; CarregaGrid(); LimpaControles(); HabilitaControles(true); BtnAlterar.Enabled = false; TxtCodigo.Focus(); } }
public void Incluir(EPI oEPI) { _Contexto.EPI.Add(oEPI); _Contexto.SaveChanges(); }
public void Excluir(EPI oEPI) { _Repository.Excluir(oEPI); }
public void Alterar(EPI oEPI) { _Repository.Alterar(oEPI); }
public void Atualizar(EPI epi) { _epiRepository.Atualizar(epi); }
public void Alterar(EPI oEPI) { _Contexto.Entry(oEPI).State = System.Data.Entity.EntityState.Modified; _Contexto.SaveChanges(); }
public void Incluir(EPI oEPI) { _Repository.Incluir(oEPI); }
public void Excluir(EPI oEPI) { _Contexto.EPI.Remove(oEPI); _Contexto.SaveChanges(); }
public void Adicionar(EPI epi) { _epiRepository.Adicionar(epi); }