예제 #1
0
        private void next_Click(object sender, RoutedEventArgs e)
        {
            LojasController lc   = new LojasController();
            Lojas           loja = lc.Next(int.Parse(txCod.Text));

            FillLoja(loja);
        }
예제 #2
0
        public bool EfetuaLogin(string usuario, string senha, string loja_id)
        {
            int loja = 0;

            if (!(int.TryParse(loja_id, out loja)))
            {
                MessageBox.Show("Informe a loja!", "Atenção", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return(false);
            }

            if (loja == 0)
            {
                MessageBox.Show("Informe a loja!", "Atenção", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return(false);
            }

            List <Usuarios> list = db.Where(i => i.Nome.Equals(usuario) && i.Senha.Equals(senha)).ToList();

            if (list.Count == 1)
            {
                UsuarioAtual = list.First();
                LojaAtual    = new LojasController().Find(loja);
                if (UsuarioAtual.Alteracao_pendente)
                {
                    new AlterarSenha(UsuarioAtual).ShowDialog();
                }
                return(true);
            }

            return(false);
        }
        public bool Save(Lojas loja)
        {
            try
            {
                if (!Valid(loja))
                {
                    return(false);
                }

                if (db.Find(loja.Id) == null)
                {
                    loja.Id = db.NextId(e => e.Id);
                    db.Save(loja);
                }
                else
                {
                    db.Update(loja);
                }

                db.Commit();
                BStatus.Success("Loja salva");
                return(true);
            }
            catch
            {
                return(false);
            }
        }
예제 #4
0
        private void FillLoja(Lojas loja)
        {
            if (loja == null)
            {
                return;
            }

            if (loja.Id == 0)
            {
                LimparCampos();
                return;
            }

            txCod.Text         = loja.Id.ToString();
            txRazao_s.Text     = loja.Razao_social;
            txNome_f.Text      = loja.Nome_fantasia;
            txCnpj.Text        = loja.Cnpj;
            txLogradouro.Text  = loja.Logradouro;
            txBairro.Text      = loja.Bairro;
            txNumero.Text      = loja.Numero.ToString();
            txMunicipio.Text   = loja.Municipio;
            txUF.Text          = loja.Uf;
            txResponsavel.Text = loja.Responsavel;
            txTelefone.Text    = loja.Telefone;
            txCelular.Text     = loja.Celular;
            txCod.Focus();
        }
 public void Put(Lojas loja)
 {
     using (var db = new MySqlConnection(con.MySQL))
     {
         var sql = @"UPDATE lojas SET nome = @nome, isAtivo = @isAtivo WHERE id = @id;";
         db.Execute(sql, loja);
     }
 }
 public Lojas Post(Lojas loja)
 {
     using (var db = new MySqlConnection(con.MySQL))
     {
         var sql = @"INSERT INTO lojas(nome, isAtivo) VALUES (@nome, @isAtivo);
                     SELECT LAST_INSERT_ID();";
         loja.id = db.ExecuteScalar <int>(sql, loja);
     }
     return(loja);
 }
        public Lojas Prev(int current_id)
        {
            if (current_id <= 0)
            {
                return(null);
            }

            Lojas loja = db.Where(e => e.Id < current_id).OrderByDescending(e => e.Id).FirstOrDefault();

            return(loja);
        }
        public List <Lojas> Get(Lojas loja)
        {
            List <Lojas> ListaLoja = new List <Lojas>();

            using (var db = new MySqlConnection(con.MySQL))
            {
                var sql = @"SELECT id, nome, isAtivo FROM lojas WHERE (id = @id OR @id = 0) 
                            AND (UPPER(nome) LIKE UPPER(CONCAT('%', @nome, '%' )) OR @nome IS NULL)
                            AND isAtivo = @isAtivo;";
                ListaLoja = db.Query <Lojas>(sql, loja).ToList();
            }
            return(ListaLoja);
        }
예제 #9
0
        private void prev_Click(object sender, RoutedEventArgs e)
        {
            if ((int.Parse(txCod.Text) - 1) <= 0)
            {
                LimparCampos();
                return;
            }

            LojasController lc   = new LojasController();
            Lojas           loja = lc.Prev(int.Parse(txCod.Text));

            FillLoja(loja);
        }
        private void Selecionar()
        {
            Lojas loja = (Lojas)dataGrid.SelectedItem;

            if (loja == null)
            {
                return;
            }
            if (loja.Id == 0)
            {
                return;
            }

            Selecionado = loja;
            Close();
        }
예제 #11
0
        private bool Valid(Lojas loja)
        {
            if (string.IsNullOrWhiteSpace(loja.Nome_fantasia))
            {
                BStatus.Alert("O nome fantasia é obrigatório");
                return(false);
            }

            if (string.IsNullOrWhiteSpace(loja.Razao_social))
            {
                BStatus.Alert("A razão social é obrigatória");
                return(false);
            }

            if (string.IsNullOrWhiteSpace(loja.Logradouro))
            {
                BStatus.Alert("O logradouro é obrigatório");
                return(false);
            }

            if (string.IsNullOrWhiteSpace(loja.Municipio))
            {
                BStatus.Alert("O município é obrigatório");
                return(false);
            }

            if (string.IsNullOrWhiteSpace(loja.Bairro))
            {
                BStatus.Alert("O bairro é obrigatório");
                return(false);
            }

            if (string.IsNullOrWhiteSpace(loja.Cnpj))
            {
                BStatus.Alert("O CNPJ é obrigatório");
                return(false);
            }

            if (string.IsNullOrWhiteSpace(loja.Uf))
            {
                BStatus.Alert("A UF é obrigatória");
                return(false);
            }

            return(true);
        }
예제 #12
0
        public void Start(Iniciando ini)
        {
            LojasController lc   = new LojasController();
            Lojas           loja = null;


            try
            {
                this.Visibility = Visibility.Hidden;

                loja = lc.Search("").FirstOrDefault();

                if (loja == null)
                {
                    CadLoja cadatroLoja = new CadLoja();
                    cadatroLoja.ShowDialog();
                    loja = lc.Search("").FirstOrDefault();
                }

                txCod_loja.Text  = loja.Id.ToString();
                txNome_loja.Text = loja.Razao_social;
                txUsuario.Focus();

                this.Visibility  = Visibility.Visible;
                ini.EnabledClose = true;
                ini.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(@"Não foi possível conectar-se com o servidor.
Verifique a configuração de rede do computador.
Verifique se o cabo de rede ou Wi-Fi está conectado e
tente novamente.

Caso o problema persista, acione o suporte Doware.", "Erro", MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(0);
            }

            feito = true;
        }
예제 #13
0
        private void Salvar()
        {
            LojasController lc   = new LojasController();
            Lojas           loja = (int.Parse(txCod.Text) == 0
                ? new Lojas()
                : lc.Find(int.Parse(txCod.Text)));

            loja.Id            = int.Parse(txCod.Text);
            loja.Razao_social  = txRazao_s.Text;
            loja.Nome_fantasia = txNome_f.Text;
            loja.Cnpj          = txCnpj.Text;
            loja.Logradouro    = txLogradouro.Text;
            loja.Bairro        = txBairro.Text;
            loja.Municipio     = txMunicipio.Text;

            int numero = 0;

            if (int.TryParse(txNumero.Text, out numero))
            {
                loja.Numero = int.Parse(txNumero.Text);
            }
            else
            {
                loja.Numero = 0;
            }

            loja.Uf          = txUF.Text;
            loja.Responsavel = txResponsavel.Text;
            loja.Telefone    = txTelefone.Text;
            loja.Celular     = txCelular.Text;

            if (lc.Save(loja))
            {
                LimparCampos();
            }
        }
예제 #14
0
        public Lojas Next(int current_id)
        {
            Lojas loja = db.Where(e => e.Id > current_id).FirstOrDefault();

            return(loja);
        }
 public void Put([FromBody] Lojas vm)
 {
     Repo.Put(vm);
 }
 public ActionResult <Lojas> Post([FromBody] Lojas vm)
 {
     return(Repo.Post(vm));
 }
 public ActionResult <List <Lojas> > Get([FromQuery] Lojas vm)
 {
     return(Repo.Get(vm));
 }