private void salvar_Click(object sender, RoutedEventArgs e) { try { _est.nomeFantasia = nomeFantasia.Text; _est.cnpjEstabelecimento = cnpj.Text; _est.categoria = categoria.Text; _est.telefoneEstabelecimento = telefone.Text; _est.websiteEstabelecimento = website.Text; _est.emailEstabelecimento = email.Text; _est.senhaE = senha.Password; EstabelecimentoController estContr = new EstabelecimentoController(); int resp = estContr.Editar(_est); if (resp == 1) { MessageBox.Show("Dados alterados com sucesso!"); } else if (resp == 0) { MessageBox.Show("Houston, temos um problema!"); } this.Close(); } catch (Exception ex) { MessageBox.Show("Ligue para o suporte: " + ex); } }
public AlterarEstabelecimento() { InitializeComponent(); EstabelecimentoController estCtr = new EstabelecimentoController(); EnderecoEstabelecimentoController endEstCtr = new EnderecoEstabelecimentoController(); _est = Application.Current.Properties["_user"] as Estabelecimento; _endEst = Application.Current.Properties["_user"] as EnderecoEstabelecimento; nomeFantasia.Text = _est.nomeFantasia; cnpj.Text = _est.cnpjEstabelecimento; categoria.Text = _est.categoria; telefone.Text = _est.telefoneEstabelecimento; website.Text = _est.websiteEstabelecimento; //enderecoEstab.Text = _endEst.logradouroEstabelecimento; email.Text = _est.emailEstabelecimento; senha.Password = _est.senhaE; btn_salvarEst.Visibility = Visibility.Collapsed; btn_editarEst.Visibility = Visibility.Collapsed; if (_est.ativo == true) { btn_desativar.Visibility = Visibility.Visible; btn_ativar.Visibility = Visibility.Collapsed; } else if (_est.ativo == false) { alterarEnderecoEstab.Visibility = Visibility.Collapsed; btn_desativar.Visibility = Visibility.Collapsed; btn_ativar.Visibility = Visibility.Visible; } }
private void login(object sender, RoutedEventArgs e) { try { string emailView = email.Text; string senhaView = senha.Password; if ((bool)usuario.IsChecked) { UsuarioController usuController = new UsuarioController(); if (usuController.Autenticar(emailView, senhaView)) { Application.Current.Properties["_user"] = usuController.carregaUsuarioEmail(emailView); var usuario = Application.Current.Properties["_user"] as Usuario; emailView = usuario.NomeUsuario; AlterarUsuario altUsu = new AlterarUsuario(); Home home = new Home(1); home.Show(); this.Close(); } else { MessageBox.Show("E-mail e/ou senha inválidos!"); } } else if ((bool)estabelecimento.IsChecked) { EstabelecimentoController estController = new EstabelecimentoController(); if (estController.Autenticar(emailView, senhaView)) { Application.Current.Properties["_user"] = estController.carregaEstabelecimentoEmail(emailView); var estabelecimento = Application.Current.Properties["_user"] as Estabelecimento; emailView = estabelecimento.nomeFantasia; AlterarEstabelecimento altEst = new AlterarEstabelecimento(); Home home = new Home(2); home.Show(); this.Close(); } else { MessageBox.Show("E-mail e/ou senha inválidos!"); } } else { MessageBox.Show("Selecione uma das opções de login!"); } } catch (Exception ex) { MessageBox.Show("Exception: " + ex); } }
private void ListCategoria(object sender, SelectionChangedEventArgs e) { EnderecoEstabelecimentoController endEstabController = new EnderecoEstabelecimentoController(); EstabelecimentoController estabelecimentoController = new EstabelecimentoController(); string categoria; if (bancoItem.IsSelected) { categoria = "Banco"; dgBanco.ItemsSource = estabelecimentoController.ListarPorCategoria(categoria); } else if (estacionamentoItem.IsSelected) { categoria = "Estacionamento"; dgEstacionamento.ItemsSource = estabelecimentoController.ListarPorCategoria(categoria); } else if (farmaciaItem.IsSelected) { categoria = "Farmácia"; if (estabelecimentoController.ListarPorCategoria(categoria) == null) { MessageBox.Show("Não possui estabelecimentos nesta categoria!"); } else { dgFarmacia.ItemsSource = estabelecimentoController.ListarPorCategoria(categoria); } } else if (fastfoodItem.IsSelected) { categoria = "Fast-Food"; if(estabelecimentoController.ListarPorCategoria(categoria) == null) { MessageBox.Show("Não possui estabelecimentos nesta categoria!"); } else { dgFastfood.ItemsSource = estabelecimentoController.ListarPorCategoria(categoria); } } else if (hotelItem.IsSelected) { categoria = "Hotel"; dgHotel.ItemsSource = estabelecimentoController.ListarPorCategoria(categoria); } else if (petshopItem.IsSelected) { categoria = "Pet-Shop"; dgPetshop.ItemsSource = estabelecimentoController.ListarPorCategoria(categoria); } }
private bool validar(Estabelecimento estab) { if (estab.nomeFantasia.Length < 5) { erro = "Quantidade de caracteres inválida no nome."; } else if (estab.cnpjEstabelecimento.Length != 14 && !validaCnpj(estab.cnpjEstabelecimento)) { erro = "CNJPJ inválido."; } else if (estab.telefoneEstabelecimento.Length != 10 && estab.telefoneEstabelecimento.Length != 11) { erro = " Telefone inválido"; } else if (!estab.websiteEstabelecimento.Contains(".com")) { erro = " WebSite inválido."; } else if (!estab.emailEstabelecimento.Contains('@')) { erro = " E-mail inválido."; } else if (estab.senhaE.Length < 8) { erro = " Senha deve conter no mínimo 8 caracteres."; } EstabelecimentoController estabController = new EstabelecimentoController(); foreach (Estabelecimento estabelecimento in estabController.ListarTodos()) { if (estabelecimento.emailEstabelecimento == estab.emailEstabelecimento) { erro = " E-mail já existente."; } } if (erro == null) { return(true); } else { MessageBox.Show(erro); return(false); } }
private void editar_Click(object sender, RoutedEventArgs e) { EstabelecimentoController estC = new EstabelecimentoController(); var estabelecimento = estC.BuscarPorId(_est.idEndereco); nomeFantasia.IsEnabled = true; cnpj.IsEnabled = true; categoria.IsEnabled = true; telefone.IsEnabled = true; website.IsEnabled = true; email.IsEnabled = true; senha.IsEnabled = true; btn_editarEst.Visibility = Visibility.Collapsed; btn_salvarEst.Visibility = Visibility.Visible; }
public void SetUp() { Mapper.Reset(); Mapper.Initialize(cfg => { cfg.AddProfile <DomainToViewModelMappingProfile>(); cfg.AddProfile <ViewModelToDomainMappingProfile>(); }); //Setando categoria repositoryMockCategoria = new Mock <ICategoriaRepository>(); serviceCategoria = new CategoriaService(repositoryMockCategoria.Object); var categorias = new List <CategoriaModel>(); categorias.Add(new CategoriaModel() { nome = "Supermercado" }); categorias.Add(new CategoriaModel() { nome = "Restaurante" }); categorias.Add(new CategoriaModel() { nome = "Borracharia" }); categorias.Add(new CategoriaModel() { nome = "Posto" }); categorias.Add(new CategoriaModel() { nome = "Oficina" }); repositoryMockCategoria.Setup(x => x.GetAll()).Returns(categorias); //Setando estabelecimento repositoryMock = new Mock <IEstabelecimentoRepository>(); service = new EstabelecimentoService(repositoryMock.Object, serviceCategoria); controller = new EstabelecimentoController(service, serviceCategoria); }
private void cadastrarEstab_Click(object sender, RoutedEventArgs e) { try { Estabelecimento estabelecimentoView = new Estabelecimento(); estabelecimentoView.idEndereco = int.Parse(enderecoEstab.SelectedValue.ToString()); estabelecimentoView.nomeFantasia = nomeFantasia.Text; estabelecimentoView.cnpjEstabelecimento = cnpj.Text; estabelecimentoView.categoria = categoria.Text; estabelecimentoView.telefoneEstabelecimento = telefone.Text; estabelecimentoView.websiteEstabelecimento = website.Text; estabelecimentoView.emailEstabelecimento = email.Text; estabelecimentoView.senhaE = senha.Password; estabelecimentoView.ativo = true; EstabelecimentoController estacionamentoController = new EstabelecimentoController(); if (validar(estabelecimentoView)) { int resp = estacionamentoController.Cadastrar(estabelecimentoView); if (resp == 1) { MessageBox.Show("Cadastrado com Sucesso!"); } else if (resp == 0) { MessageBox.Show("Houston, temos um problema!"); } this.Close(); /* MainWindow mainWindow = new MainWindow(); * mainWindow.Show();*/ } } catch (Exception ex) { MessageBox.Show("Ligue para o suporte: " + ex); } }
public AlterarEnderecoEstabelecimento() { InitializeComponent(); EstabelecimentoController estCtr = new EstabelecimentoController(); EnderecoEstabelecimentoController endEstCtr = new EnderecoEstabelecimentoController(); _est = Application.Current.Properties["_user"] as Estabelecimento; //_endEst = Application.Current.Properties["_user"] as EnderecoEstabelecimento; int idEnd = _est.idEndereco; _endEst = endEstCtr.BuscarPorId(idEnd); logradouro.Text = _endEst.logradouroEstabelecimento; numero.Text = _endEst.numero; bairro.Text = _endEst.bairro; cidade.Text = _endEst.cidade; uf.Text = _endEst.uf; btn_salvarEnd.Visibility = Visibility.Collapsed; btn_editarEnd.Visibility = Visibility.Visible; }
private void ButtonPesquisar_Click(object sender, RoutedEventArgs e) { EstabelecimentoController estabelecimentoController = new EstabelecimentoController(); string pesquisa = stringPesquisa.Text; dgPesquisar.ItemsSource = estabelecimentoController.ListarPorPesquisa(pesquisa); }
public EstabelecimentoControllerTest() { _service = new ServiceEstabelecimentoFake(); _controller = new EstabelecimentoController(_service); }