public Int32 Salvar(TAgendamentoVO tagendamentovo) { try { if (tagendamentovo.IDUsuarioVendedor == null && (tagendamentovo.IDAtendimento == 0 || tagendamentovo.IDAtendimento == null)) { return(SalvarCallCenter(tagendamentovo)); } if (tagendamentovo.IDUsuarioVendedor != null && (tagendamentovo.IDAtendimento == 0 || tagendamentovo.IDAtendimento == null)) { return(SalvarVendedor(tagendamentovo)); } if (tagendamentovo.IDAtendimento > 0) { return(SalvarAdministrador(tagendamentovo)); } return(0); } catch (CABTECException) { throw new CABTECException("Erro ao Salvar Agendamento."); } catch (Exception) { throw new CABTECException("Erro ao Salvar Agendamento."); } }
private TAgendamentoVO PreencheVO() { TAgendamentoVO agendamentoVO = new TAgendamentoVO(); agendamentoVO.IDAgendamento = atualizar ? Convert.ToInt32(hiddenIDAgendamento.Value) : 0; agendamentoVO.Nome = txtNome.Text; agendamentoVO.DataNascimento = !string.IsNullOrEmpty(txtDataNascimento.Text) ? Convert.ToDateTime(txtDataNascimento.Text) : DateTime.MinValue; agendamentoVO.Email = txtEmail.Text; agendamentoVO.Telefone = txtTelefone.Text; agendamentoVO.Celular = txtCelular.Text; agendamentoVO.CEP = !string.IsNullOrEmpty(txtCEP.Text) ? Convert.ToInt32(txtCEP.Text.Replace(".", string.Empty).Replace("-", string.Empty)) : 0; agendamentoVO.Logradouro = txtEndereco.Text; agendamentoVO.Numero = !string.IsNullOrEmpty(txtNumero.Text) ? Convert.ToInt32(txtNumero.Text): 0; agendamentoVO.Complemento = txtComplemento.Text; agendamentoVO.Bairro = txtBairro.Text; agendamentoVO.Cidade = txtCidade.Text; agendamentoVO.UF = ddlEstado.SelectedValue; agendamentoVO.PontoReferencia = txtPontoReferencia.Text; agendamentoVO.IDUsuarioAgendamento = Sessao.UsuarioLogado.IDUsuario; if (TipoUsuario == Util.Util.Cargo.VENDEDOR) { agendamentoVO.IDUsuarioVendedor = Sessao.UsuarioLogado.IDUsuario; } return(agendamentoVO); }
private TAgendamentoVO PreencheVO() { TAgendamentoVO agendamentoVO = new TAgendamentoVO(); agendamentoVO.NomeUsuarioAgendamento = txtAtendente.Text; agendamentoVO.NomeUsuarioVendedor = txtVendedor.Text; agendamentoVO.Unidade = Sessao.UsuarioLogado.Unidade; return(agendamentoVO); }
public int Inserir(TAgendamentoVO tagendamentovo) { var banco = new SINAF_WebEntities(); var query = new TAgendamento { Nome = tagendamentovo.Nome, DataNascimento = tagendamentovo.DataNascimento, Email = tagendamentovo.Email, Telefone = tagendamentovo.Telefone, Celular = tagendamentovo.Celular, CEP = tagendamentovo.CEP, Logradouro = tagendamentovo.Logradouro, Numero = tagendamentovo.Numero, Complemento = tagendamentovo.Complemento, Bairro = tagendamentovo.Bairro, Cidade = tagendamentovo.Cidade, UF = tagendamentovo.UF, PontoReferencia = tagendamentovo.PontoReferencia, TAtendimento = banco.TAtendimento.FirstOrDefault(registro => registro.IDAtendimento == tagendamentovo.IDAtendimento), TUsuario = banco.TUsuario.First(registro => registro.IDUsuario == tagendamentovo.IDUsuarioAgendamento), TUsuario1 = banco.TUsuario.FirstOrDefault(registro => registro.IDUsuario == tagendamentovo.IDUsuarioVendedor), }; banco.AddToTAgendamento(query); banco.SaveChanges(); tagendamentovo.IDAgendamento = query.IDAgendamento; return(query.IDAgendamento); }
private void PreencheTela(TAgendamentoVO agendamentoVO) { hiddenIDAgendamento.Value = agendamentoVO.IDAgendamento.ToString(); txtNome.Text = agendamentoVO.Nome; txtDataNascimento.Text = agendamentoVO.DataNascimento.ToShortDateString(); txtEmail.Text = agendamentoVO.Email; txtTelefone.Text = agendamentoVO.Telefone; txtCelular.Text = agendamentoVO.Celular; txtCEP.Text = agendamentoVO.CEP.ToString(); txtEndereco.Text = agendamentoVO.Logradouro; txtNumero.Text = agendamentoVO.Numero.GetValueOrDefault().ToString(); txtComplemento.Text = agendamentoVO.Complemento; txtBairro.Text = agendamentoVO.Bairro; txtCidade.Text = agendamentoVO.Cidade; ddlEstado.SelectedValue = agendamentoVO.UF; txtPontoReferencia.Text = agendamentoVO.PontoReferencia; }
public IQueryable <TAgendamentoVO> Listar(TAgendamentoVO filtro) { var banco = new SINAF_WebEntities(); var query = (from registro in banco.TAgendamento select new TAgendamentoVO { IDAgendamento = registro.IDAgendamento, Nome = registro.Nome, DataNascimento = registro.DataNascimento, Email = registro.Email, Telefone = registro.Telefone, Celular = registro.Celular, CEP = registro.CEP, Logradouro = registro.Logradouro, Numero = registro.Numero, Complemento = registro.Complemento, Bairro = registro.Bairro, Cidade = registro.Cidade, UF = registro.UF, PontoReferencia = registro.PontoReferencia, IDAtendimento = registro.TAtendimento.IDAtendimento, IDUsuarioAgendamento = registro.TUsuario.IDUsuario, IDUsuarioVendedor = registro.TUsuario1.IDUsuario, }).AsQueryable(); return(query); }
public void Alterar(TAgendamentoVO tagendamentovo) { var banco = new SINAF_WebEntities(); var query = (from registro in banco.TAgendamento where registro.IDAgendamento.Equals(tagendamentovo.IDAgendamento) select registro).First(); query.Nome = tagendamentovo.Nome; query.DataNascimento = tagendamentovo.DataNascimento; query.Email = tagendamentovo.Email; query.Telefone = tagendamentovo.Telefone; query.Celular = tagendamentovo.Celular; query.CEP = tagendamentovo.CEP; query.Logradouro = tagendamentovo.Logradouro; query.Numero = tagendamentovo.Numero; query.Complemento = tagendamentovo.Complemento; query.Bairro = tagendamentovo.Bairro; query.Cidade = tagendamentovo.Cidade; query.UF = tagendamentovo.UF; query.PontoReferencia = tagendamentovo.PontoReferencia; query.TAtendimento = banco.TAtendimento.FirstOrDefault(registro => registro.IDAtendimento == tagendamentovo.IDAtendimento); query.TUsuario = banco.TUsuario.First(registro => registro.IDUsuario == tagendamentovo.IDUsuarioAgendamento); query.TUsuario1 = banco.TUsuario.FirstOrDefault(registro => registro.IDUsuario == tagendamentovo.IDUsuarioVendedor); banco.SaveChanges(); }
public Int32 SalvarVendedor(TAgendamentoVO tagendamentovo) { try { int IDBairro = 0; int IDCidade = 0; int IDFilial = 0; int IDAtendimento = 0; TUsuarioVO vendedor = new TUsuarioVO(); vendedor = TUsuarioBLL.Obter(tagendamentovo.IDUsuarioVendedor.Value); IDBairro = TBairroBLL.ObterIDBairro(tagendamentovo.Bairro); IDCidade = TCidadeBLL.ObterIDCidade(tagendamentovo.Cidade); IDFilial = TFilialBLL.ObterIDFilial(vendedor.Unidade); IDAtendimento = TAtendimentoBLL.ObterAtendimento(IDFilial, IDCidade, IDBairro); if (IDAtendimento == 0) { IDAtendimento = TAtendimentoBLL.ObterAtendimentoFilial(IDFilial); } if (tagendamentovo.IDAgendamento > 0) { TAgendamentoBLL.Alterar(tagendamentovo); } else { TAgendamentoBLL.Inserir(tagendamentovo); } return(tagendamentovo.IDAgendamento); } catch (CABTECException) { throw new CABTECException("Erro ao Salvar Agendamento."); } catch (Exception) { throw new CABTECException("Erro ao Salvar Agendamento."); } }
public Int32 SalvarCallCenter(TAgendamentoVO tagendamentovo) { try { int IDBairro = 0; int IDCidade = 0; int IDAtendimento = 0; tagendamentovo.IDUsuarioVendedor = null; IDBairro = TBairroBLL.ObterIDBairro(tagendamentovo.Bairro); IDCidade = TCidadeBLL.ObterIDCidade(tagendamentovo.Cidade); IDAtendimento = TAtendimentoBLL.ObterAtendimentoCallCenter(IDCidade, IDBairro); if (IDAtendimento == 0) { IDAtendimento = TAtendimentoBLL.ObterAtendimentoFilial(TFilialBLL.ObterIDFilial(WebConfigurationManager.AppSettings["WebMATRIZ"])); } tagendamentovo.IDAtendimento = IDAtendimento; if (tagendamentovo.IDAgendamento > 0) { TAgendamentoBLL.Alterar(tagendamentovo); } else { TAgendamentoBLL.Inserir(tagendamentovo); } return(tagendamentovo.IDAgendamento); } catch (CABTECException) { throw new CABTECException("Erro ao Salvar Agendamento."); } catch (Exception) { throw new CABTECException("Erro ao Salvar Agendamento."); } }
public void SalvarConsultaVendedor(List <int> idsAgendamentos, List <int> idsVendedores) { try { for (int i = 0; i < idsAgendamentos.Count; i++) { TAgendamentoVO agendamentoVO = new TAgendamentoVO(); agendamentoVO = TAgendamentoBLL.Obter(idsAgendamentos[i]); agendamentoVO.IDUsuarioVendedor = idsVendedores[i]; TAgendamentoBLL.Alterar(agendamentoVO); } } catch (CABTECException) { throw new CABTECException("Erro ao Salvar Agendamento/Vendedor."); } catch (Exception) { throw new CABTECException("Erro ao Salvar Agendamento/Vendedor."); } }
private void CarregarValores() { try { TAgendamentoVO agendamentoEditar = new TAgendamentoVO(); agendamentoEditar.IDAgendamento = Convert.ToInt32(hiddenIDAgendamento.Value); List <TAgendamentoVO> listaAgendamento = Controller.Listar(agendamentoEditar); if (listaAgendamento.Count > 0) { PreencheTela(listaAgendamento[0]); } } catch (CABTECException ex) { this.MostrarMensagem(ex.Message); } catch (Exception exception) { this.MostrarMensagem(exception.Message); } }
public Int32 SalvarAdministrador(TAgendamentoVO tagendamentovo) { try { if (tagendamentovo.IDAgendamento > 0) { TAgendamentoBLL.Alterar(tagendamentovo); } else { TAgendamentoBLL.Inserir(tagendamentovo); } return(tagendamentovo.IDAgendamento); } catch (CABTECException) { throw new CABTECException("Erro ao Salvar Agendamento."); } catch (Exception) { throw new CABTECException("Erro ao Salvar Agendamento."); } }
public List <TAgendamentoVO> Listar(TAgendamentoVO filtro) { try { if (filtro.IDAgendamento > 0) { List <TAgendamentoVO> listaRetorno = new List <TAgendamentoVO>(); TAgendamentoVO retornoVO = TAgendamentoBLL.Obter(filtro.IDAgendamento); if (retornoVO.IDUsuarioAgendamento > 0) { retornoVO.NomeUsuarioAgendamento = TUsuarioBLL.Obter(retornoVO.IDUsuarioAgendamento).Nome; } if (retornoVO.IDUsuarioVendedor.HasValue) { if (retornoVO.IDUsuarioVendedor.Value > 0) { retornoVO.NomeUsuarioVendedor = TUsuarioBLL.Obter(retornoVO.IDUsuarioVendedor.Value).Nome; } } listaRetorno.Add(retornoVO); return(listaRetorno); } else { List <int> usuarioAtendente = new List <int>(); List <int> usuarioVendedor = new List <int>(); List <int> usuarioUnidade = new List <int>(); if (!string.IsNullOrEmpty(filtro.NomeUsuarioAgendamento)) { usuarioAtendente = TUsuarioBLL.ListarUsuarioAgendamento(filtro.NomeUsuarioAgendamento).ToList(); if (usuarioAtendente.Count == 0) { usuarioAtendente.Add(0); } } if (!string.IsNullOrEmpty(filtro.NomeUsuarioVendedor)) { usuarioVendedor = TUsuarioBLL.ListarUsuarioAgendamento(filtro.NomeUsuarioVendedor).ToList(); if (usuarioVendedor.Count == 0) { usuarioVendedor.Add(0); } } if (!string.IsNullOrEmpty(filtro.Unidade)) { usuarioUnidade = TAtendimentoBLL.ListarAtendimentoFilial(filtro.Unidade); if (usuarioUnidade.Count == 0) { usuarioUnidade.Add(0); } } return(TAgendamentoBLL.ListarGridConsulta(usuarioUnidade, usuarioAtendente, usuarioVendedor).ToList()); } } catch (CABTECException) { throw new CABTECException("Erro ao Listar Agendamento."); } catch (Exception ex) { throw new CABTECException("Erro ao Listar Agendamento." + ex.Message); } }