public List <TColetorVO> ListarColetorLivre(int idTitular, ref bool coletorVinculo) { try { List <TColetorVO> listaRetorno = TColetorBLL.ListarColetorLivre().ToList(); coletorVinculo = false; if (idTitular > 0) { TColetorVO coletor = TColetorBLL.ObterPorVendedor(idTitular); if (coletor != null) { listaRetorno.Insert(0, coletor); coletorVinculo = true; TColetorVO coletorEmpyt = new TColetorVO(); coletorEmpyt.NumeroSerie = "Retirar Associação"; listaRetorno.Add(coletorEmpyt); } } return(listaRetorno); } catch (CABTECException) { throw new CABTECException("Erro ao Listar Coletor Livre."); } catch (Exception) { throw new CABTECException("Erro ao Listar Coletor Livre."); } }
public List <TColetorVO> ListarRelatorio(TColetorVO filtro) { try { List <TColetorVO> listaColetor = TColetorBLL.ListarRelatorio(filtro).ToList(); foreach (TColetorVO coletor in listaColetor) { int numerofaixa = TFaixaBLL.NumeroEntrevista(coletor.IDUsuarioVendedor.GetValueOrDefault()); int numerocarregado = TFaixaBLL.FaixaCarregada(coletor.IDUsuarioVendedor.GetValueOrDefault()); coletor.NumeroFaixaCarregadas = numerofaixa; coletor.TodasFaixaCarregadas = numerofaixa == numerocarregado; } return(listaColetor); } catch (CABTECException) { throw new CABTECException("Erro ao Listar Coletor."); } catch (Exception) { throw new CABTECException("Erro ao Listar Coletor."); } }
public int Inserir(TColetorVO tcoletorvo) { var banco = new SINAF_WebEntities(); var query = new TColetor { IDColetor = tcoletorvo.IDColetor, NumeroSerie = tcoletorvo.NumeroSerie, IMEI = tcoletorvo.IMEI, Fabricante = tcoletorvo.Fabricante, Modelo = tcoletorvo.Modelo, CodigoUsuarioCadastro = banco.TUsuario.First(coletor => coletor.IDUsuario == tcoletorvo.IDUsuarioCadastro).CodigoColaborador, DataCadastro = DateTime.Now, UsoBackup = tcoletorvo.UsoBackup, Ativo = true, }; banco.AddToTColetor(query); banco.SaveChanges(); tcoletorvo.IDColetor = query.IDColetor; return(query.IDColetor); }
public List <TColetorVO> Listar(TColetorVO filtro) { try { if (filtro.IDColetor > 0) { List <TColetorVO> listaRetorno = new List <TColetorVO>(); listaRetorno.Add(TColetorBLL.Obter(filtro.IDColetor)); return(listaRetorno); } else { return(TColetorBLL.Listar(filtro).ToList()); } } catch (CABTECException ex) { throw new CABTECException(ex.Message); // throw new CABTECException("Erro ao Listar Coletor."); } catch (Exception ex) { throw new CABTECException(ex.Message); //throw new CABTECException("Erro ao Listar Coletor."); } }
private void RecuperarAssociar() { int indiceColetor = lstColetor.SelectedIndex; int indiceVendedor = lstVendedor.SelectedIndex; TColetorVO filtro = new TColetorVO(); filtro.NumeroSerie = txtColetorPesquisa.Text; CarregarListColetor(filtro, -1); TUsuarioVO filtroUsuario = new TUsuarioVO(); filtroUsuario.Abreviado = txtVendedorPesquisa.Text; CarregarListVendedor(filtroUsuario, -1); if (rdbColetor.Checked) { lstColetor.SelectedIndex = indiceColetor; ColetorSelecionado(); } else { lstVendedor.SelectedIndex = indiceVendedor; VendedorSelecionado(); } }
public void Alterar(TColetorVO tcoletorvo) { var banco = new SINAF_WebEntities(); var query = (from registro in banco.TColetor where registro.IDColetor.Equals(tcoletorvo.IDColetor) select registro).First(); query.NumeroSerie = tcoletorvo.NumeroSerie; query.IMEI = tcoletorvo.IMEI; query.Fabricante = tcoletorvo.Fabricante; query.Modelo = tcoletorvo.Modelo; query.DataCadastro = DateTime.Now; if (tcoletorvo.IDUsuarioResponsavel.HasValue) { if (tcoletorvo.IDUsuarioResponsavel.Value > 0) { query.CodigoUsuarioResponsavel = banco.TUsuario.FirstOrDefault(coletor => coletor.IDUsuario == tcoletorvo.IDUsuarioResponsavel.Value).CodigoColaborador; } else { query.CodigoUsuarioResponsavel = null; } } query.UsoBackup = tcoletorvo.UsoBackup; banco.SaveChanges(); }
private void PreencheTela(TColetorVO coletorVO) { hiddenIDColetor.Value = coletorVO.IDColetor.ToString(); txtNumeroSerie.Text = coletorVO.NumeroSerie; txtIMEI.Text = coletorVO.IMEI; txtDataUltimaAlteracao.Text = coletorVO.DataUltimaSincronizacao.HasValue ? coletorVO.DataUltimaSincronizacao.Value.ToShortDateString() : string.Empty; txtDiasSemSincronizar.Text = coletorVO.DataUltimaSincronizacao.HasValue ? ((TimeSpan)(DateTime.Now - coletorVO.DataUltimaSincronizacao.Value)).Days.ToString() : string.Empty; txtDataInativacao.Text = coletorVO.DataInativacao.HasValue ? coletorVO.DataInativacao.Value.ToShortDateString() : string.Empty; }
private void Popular() { TColetorVO dadosColetor = new TColetorVO(); dadosColetor.IDColetor = IDColetor; List <TColetorVO> listColetor = Controller.Listar(dadosColetor); if (listColetor.Count == 1) { PreencheTela(listColetor[0]); } }
private TColetorVO PreencheVO() { TColetorVO coletorVO = new TColetorVO(); coletorVO.IDColetor = atualizar ? Convert.ToInt32(hiddenIDColetor.Value) : 0; coletorVO.NumeroSerie = txtNumeroSerie.Text; coletorVO.IMEI = txtIMEI.Text; coletorVO.Fabricante = txtFabricante.Text; coletorVO.Modelo = txtModelo.Text; coletorVO.UsoBackup = chkUsoBackup.Checked; coletorVO.IDUsuarioCadastro = Sessao.UsuarioLogado.IDUsuario; return(coletorVO); }
private void PreencheTela(TColetorVO coletorVO) { hiddenIDColetor.Value = coletorVO.IDColetor.ToString(); txtNumeroSerie.Text = coletorVO.NumeroSerie; txtIMEI.Text = coletorVO.IMEI; txtFabricante.Text = coletorVO.Fabricante; txtModelo.Text = coletorVO.Modelo; chkAtivo.Checked = coletorVO.Ativo; chkUsoBackup.Checked = coletorVO.UsoBackup; txtUsuarioCadastro.Text = coletorVO.NomeUsuarioCadastro; txtUsuarioResponsavel.Text = coletorVO.NomeUsuarioResponsavel; txtDataCadastro.Text = coletorVO.DataCadastro.ToShortDateString(); txtDataInativacao.Text = coletorVO.DataInativacao.HasValue ? coletorVO.DataInativacao.Value.ToShortDateString() : string.Empty; }
protected void gridConsulta_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { TColetorVO coletorRow = (TColetorVO)e.Row.DataItem; if (coletorRow.Ativo) { ((ImageButton)e.Row.Cells[0].Controls[0]).ImageUrl = "~/Images/lock_off20.ico"; } else { ((ImageButton)e.Row.Cells[0].Controls[0]).ImageUrl = "~/Images/lock20.ico"; } } }
public List <TColetorVO> ListarRelatorioVendedorColetor(TColetorVO filtro) { try { List <TColetorVO> listaColetor = TColetorBLL.ListarRelatorioVendedorColetor(filtro).ToList(); return(listaColetor); } catch (CABTECException) { throw new CABTECException("Erro ao Listar Coletor."); } catch (Exception) { throw new CABTECException("Erro ao Listar Coletor."); } }
protected void btnColetorPesquisa_Click(object sender, ImageClickEventArgs e) { try { LimparMensagem(); TColetorVO filtro = new TColetorVO(); filtro.NumeroSerie = txtColetorPesquisa.Text; CarregarListColetor(filtro, -1); } catch (CABTECException ex) { this.MostrarMensagem(ex.Message); } catch (Exception exception) { this.MostrarMensagem(exception.Message); } }
private TColetorVO PreencheVO() { TColetorVO coletorVO = new TColetorVO(); coletorVO.NumeroSerie = txtNumeroSerie.Text; coletorVO.IMEI = txtIMEI.Text; coletorVO.Fabricante = txtFabricante.Text; coletorVO.Modelo = txtModelo.Text; coletorVO.ConsultaAtivo = rdbAtivoTodos.Checked? false: true; coletorVO.Ativo = rdbAtivoSim.Checked; coletorVO.ConsultaUsoBackup = rdbUsoBackupTodos.Checked ? false : true; coletorVO.UsoBackup = rdbUsoBackupSim.Checked; return(coletorVO); }
private TColetorVO PreencheVO() { TColetorVO coletorVO = new TColetorVO(); coletorVO.NumeroSerie = txtNumeroSerie.Text; coletorVO.IMEI = txtIMEI.Text; coletorVO.NomeUsuarioResponsavel = txtVendedor.Text; coletorVO.Modelo = txtModelo.Text; coletorVO.ConsultaAtivo = rdbAtivoTodos.Checked ? false : true; coletorVO.Ativo = rdbAtivoSim.Checked; coletorVO.ConsultaUsoBackup = rdbUsoBackupTodos.Checked ? false : true; coletorVO.UsoBackup = rdbUsoBackupSim.Checked; coletorVO.DataUltimaSincronizacaoInicio = string.IsNullOrEmpty(txtDataUltimoSincronismoInicio.Text) ? (DateTime?)null : Convert.ToDateTime(txtDataUltimoSincronismoInicio.Text); coletorVO.DataUltimaSincronizacaoFim = string.IsNullOrEmpty(txtDataUltimoSincronismoFim.Text) ? (DateTime?)null : Convert.ToDateTime(txtDataUltimoSincronismoFim.Text); coletorVO.DataInativacaoInicio = string.IsNullOrEmpty(txtDataInativacaoInicio.Text) ? (DateTime?)null : Convert.ToDateTime(txtDataInativacaoInicio.Text); coletorVO.DataInativacaoFim = string.IsNullOrEmpty(txtDataInativacaoFim.Text) ? (DateTime?)null : Convert.ToDateTime(txtDataInativacaoFim.Text); return(coletorVO); }
private void CarregarListColetor(TColetorVO coletorVO, int idTitular) { try { List <TColetorVO> listaColetores = new List <TColetorVO>(); bool coletorVinculo = false; if (idTitular == -1) { listaColetores = Controller.Listar(coletorVO); } else { listaColetores = Controller.ListarColetorLivre(idTitular, ref coletorVinculo); } lstColetor.DataTextField = "NumeroSerie"; lstColetor.DataValueField = "IDColetorIDVendedor"; lstColetor.DataSource = listaColetores; lstColetor.DataBind(); if (listaColetores.Count > 0) { lstColetor.SelectedIndex = 0; } if (idTitular > 0 && listaColetores.Count > 0 && coletorVinculo) { hiddenIDColetor.Value = listaColetores[0].IDColetor.ToString(); txtColetorSelecionado.Text = listaColetores[0].NumeroSerie; } } catch (CABTECException ex) { this.MostrarMensagem(ex.Message); } catch (Exception exception) { this.MostrarMensagem(exception.Message); } }
private void CarregarValores() { try { TColetorVO coletorEditar = new TColetorVO(); coletorEditar.IDColetor = Convert.ToInt32(hiddenIDColetor.Value); List <TColetorVO> listaColetor = Controller.Listar(coletorEditar); if (listaColetor.Count > 0) { PreencheTela(listaColetor[0]); } } catch (CABTECException ex) { this.MostrarMensagem(ex.Message); } catch (Exception exception) { this.MostrarMensagem(exception.Message); } }
private void RelatorioVendedorColetor() { TColetorVO filtro = new TColetorVO(); if (_valores.Contains("coletor")) { filtro.NumeroSerie = Request.QueryString["coletor"]; } if (_valores.Contains("vendedor")) { filtro.NomeVendedor = Request.QueryString["vendedor"]; } if (_valores.Contains("tipo")) { filtro.TipoRelatorio = Request.QueryString["tipo"]; } if (_valores.Contains("inicio")) { filtro.DataRelatorioInicio = Convert.ToDateTime(Request.QueryString["inicio"]); } if (_valores.Contains("final")) { filtro.DataRelatorioFinal = Convert.ToDateTime(Request.QueryString["final"]); } ReportDataSource dtSource = new ReportDataSource("VendedorColetor", new TColetorCONTROLLER().ListarRelatorioVendedorColetor(filtro)); ReportViewer1.LocalReport.ReportPath = Path.Combine(HttpRuntime.AppDomainAppPath, "Reports/VendedorColetor.rdlc"); ReportViewer1.LocalReport.DataSources.Add(dtSource); ReportViewer1.LocalReport.Refresh(); }
public Int32 Salvar(TColetorVO tcoletorvo) { try { if (tcoletorvo.IDColetor > 0) { TColetorBLL.Alterar(tcoletorvo); } else { TColetorBLL.Inserir(tcoletorvo); } return(tcoletorvo.IDColetor); } catch (CABTECException) { throw new CABTECException("Erro ao Salvar Coletor."); } catch (Exception) { throw new CABTECException("Erro ao Salvar Coletor."); } }
public string AssociarColetorVendedor(string idColetorEscolhido, string idVendedorEscolhido) { try { string mensagem = string.Empty; //Dois IDs Nulos if (string.IsNullOrEmpty(idColetorEscolhido) && string.IsNullOrEmpty(idVendedorEscolhido)) { mensagem = "Não foi realizado a associação."; } if (!string.IsNullOrEmpty(idColetorEscolhido)) { TColetorVO coletorEscolhido = TColetorBLL.Obter(Convert.ToInt32(idColetorEscolhido)); //Limpar Associação if (string.IsNullOrEmpty(idVendedorEscolhido)) { coletorEscolhido.IDUsuarioResponsavel = 0; TColetorBLL.Alterar(coletorEscolhido); mensagem = "O Coletor: " + coletorEscolhido.NumeroSerie + " não está mais associado a nenhum Vendedor!"; } else { //Associar Coletor if (coletorEscolhido != null) { //Limpar Associação Antiga TColetorVO vendedorAntigo = TColetorBLL.ObterPorVendedor(coletorEscolhido.IDUsuarioResponsavel.GetValueOrDefault(0)); if (vendedorAntigo != null) { TUsuarioVO usuarioAntigo = TUsuarioBLL.Obter(vendedorAntigo.IDUsuarioResponsavel.Value); vendedorAntigo.IDUsuarioResponsavel = 0; TColetorBLL.Alterar(vendedorAntigo); mensagem = "O Vendedor: " + usuarioAntigo.Nome + " não está mais associado a nenhum Coletor!<br/>"; } //Limpar Associação Antiga TColetorVO coletorAntigo = TColetorBLL.ObterPorVendedor(Convert.ToInt32(idVendedorEscolhido)); if (coletorAntigo != null) { TUsuarioVO usuarioAntigo = TUsuarioBLL.Obter(coletorAntigo.IDUsuarioResponsavel.Value); coletorAntigo.IDUsuarioResponsavel = 0; TColetorBLL.Alterar(coletorAntigo); mensagem = "O Coletor: " + coletorAntigo.NumeroSerie + " não está mais associado a nenhum Vendedor!<br/>"; } coletorEscolhido.IDUsuarioResponsavel = Convert.ToInt32(idVendedorEscolhido); TColetorBLL.Alterar(coletorEscolhido); TUsuarioVO usuarioAtual = TUsuarioBLL.Obter(Convert.ToInt32(idVendedorEscolhido)); if (usuarioAtual != null) { mensagem += "O Coletor: " + coletorEscolhido.NumeroSerie + " e o Vendedor: " + usuarioAtual.Nome + " foram associados com sucesso!"; } } else { TUsuarioVO usuarioAtual = TUsuarioBLL.Obter(Convert.ToInt32(idVendedorEscolhido)); if (usuarioAtual != null) { TColetorVO coletorAntigo = TColetorBLL.ObterPorVendedor(Convert.ToInt32(idVendedorEscolhido)); if (coletorAntigo != null) { coletorAntigo.IDUsuarioResponsavel = 0; TColetorBLL.Alterar(coletorAntigo); } mensagem = "O Vendedor: " + usuarioAtual.Nome + " não está mais associado a nenhum Coletor!"; } } } } else { TColetorVO coletorAntigo = TColetorBLL.ObterPorVendedor(Convert.ToInt32(idVendedorEscolhido)); if (coletorAntigo != null) { coletorAntigo.IDUsuarioResponsavel = 0; TColetorBLL.Alterar(coletorAntigo); TUsuarioVO usuarioAtual = TUsuarioBLL.Obter(Convert.ToInt32(idVendedorEscolhido)); if (usuarioAtual != null) { mensagem = "O Vendedor: " + usuarioAtual.Nome + " não está mais associado a nenhum Coletor!"; } } } return(mensagem); } catch (CABTECException) { throw new CABTECException("Erro ao Associar Coletor e Vendedor."); } catch (Exception) { throw new CABTECException("Erro ao Associar Coletor e Vendedor."); } }
public IQueryable <TColetorVO> Listar(TColetorVO filtro) { var banco = new SINAF_WebEntities(); var query = (from registro in banco.TColetor select new TColetorVO { IDColetor = registro.IDColetor, NumeroSerie = registro.NumeroSerie, IMEI = registro.IMEI, Fabricante = registro.Fabricante, Modelo = registro.Modelo, IDUsuarioResponsavel = registro.CodigoUsuarioResponsavel, IDUsuarioCadastro = registro.CodigoUsuarioCadastro, DataCadastro = registro.DataCadastro, Ativo = registro.Ativo, DataInativacao = registro.DataInativacao, UsoBackup = registro.UsoBackup, MotivoInativacao = registro.MotivoInativacao, DataUltimaSincronizacao = registro.DataUltimaSincronizacao, }).AsQueryable(); if (!string.IsNullOrEmpty(filtro.NumeroSerie)) { query = query.Where(registro => registro.NumeroSerie.Contains(filtro.NumeroSerie)); } if (!string.IsNullOrEmpty(filtro.IMEI)) { query = query.Where(registro => registro.IMEI.Contains(filtro.IMEI)); } if (!string.IsNullOrEmpty(filtro.Fabricante)) { query = query.Where(registro => registro.Fabricante.Contains(filtro.Fabricante)); } if (!string.IsNullOrEmpty(filtro.Modelo)) { query = query.Where(registro => registro.Modelo.Contains(filtro.Modelo)); } if (filtro.ConsultaAtivo.HasValue) { if (filtro.ConsultaAtivo.Value) { query = query.Where(registro => registro.Ativo == filtro.Ativo); } } if (filtro.ConsultaUsoBackup.HasValue) { if (filtro.ConsultaUsoBackup.Value) { query = query.Where(registro => registro.UsoBackup == filtro.UsoBackup); } } if (filtro.DataUltimaSincronizacaoInicio.HasValue) { query = query.Where(registro => registro.DataUltimaSincronizacao >= filtro.DataUltimaSincronizacaoInicio.Value); } if (filtro.DataUltimaSincronizacaoFim.HasValue) { query = query.Where(registro => registro.DataUltimaSincronizacao <= filtro.DataUltimaSincronizacaoFim.Value); } if (filtro.DataInativacaoInicio.HasValue) { query = query.Where(registro => registro.DataInativacao >= filtro.DataInativacaoInicio.Value); } if (filtro.DataInativacaoFim.HasValue) { query = query.Where(registro => registro.DataInativacao <= filtro.DataInativacaoFim.Value); } return(query); }
public IQueryable <TColetorVO> ListarRelatorioVendedorColetor(TColetorVO filtro) { var banco = new SINAF_WebEntities(); var query = (from registro in banco.TColetor select new TColetorVO { IDColetor = registro.IDColetor, NumeroSerie = registro.NumeroSerie, IMEI = registro.IMEI, Fabricante = registro.Fabricante, Modelo = registro.Modelo, IDUsuarioResponsavel = registro.CodigoUsuarioResponsavel, IDUsuarioCadastro = registro.CodigoUsuarioCadastro, DataCadastro = registro.DataCadastro, Ativo = registro.Ativo, DataInativacao = registro.DataInativacao, UsoBackup = registro.UsoBackup, MotivoInativacao = registro.MotivoInativacao, DataUltimaSincronizacao = registro.DataUltimaSincronizacao, IDUsuarioVendedor = banco.TUsuario.FirstOrDefault(usuario => usuario.CodigoColaborador == registro.CodigoUsuarioResponsavel).IDUsuario, NomeVendedor = banco.TUsuario.FirstOrDefault(usuario => usuario.CodigoColaborador == registro.CodigoUsuarioResponsavel).Abreviado, UnidadeVendedor = banco.TUsuario.FirstOrDefault(usuario => usuario.CodigoColaborador == registro.CodigoUsuarioResponsavel).Unidade, }).AsQueryable(); if (!string.IsNullOrEmpty(filtro.NumeroSerie)) { query = query.Where(registro => registro.NumeroSerie.Contains(filtro.NumeroSerie)); } if (!string.IsNullOrEmpty(filtro.NomeVendedor)) { query = query.Where(registro => registro.NomeVendedor.Contains(filtro.NomeVendedor)); } if (!string.IsNullOrEmpty(filtro.TipoRelatorio)) { switch (filtro.TipoRelatorio) { case "S": query = query.Where(registro => string.IsNullOrEmpty(registro.NomeVendedor)); break; case "N": query = query.Where(registro => !string.IsNullOrEmpty(registro.NomeVendedor)); break; case "T": break; default: break; } } if (filtro.DataRelatorioInicio.HasValue) { query = query.Where(registro => registro.DataCadastro >= filtro.DataRelatorioInicio.Value); } if (filtro.DataRelatorioFinal.HasValue) { query = query.Where(registro => registro.DataCadastro <= filtro.DataRelatorioFinal.Value); } query = query.OrderBy(order => order.NomeVendedor); return(query); }