Example #1
0
        public bool Save(Usuarios usuario)
        {
            try
            {
                if (!Valid(usuario))
                {
                    return(false);
                }

                if (db.Find(usuario.Id) == null)
                {
                    usuario.Alteracao_pendente = true;
                    usuario.Id = db.NextId(e => e.Id);
                    db.Save(usuario);
                }
                else
                {
                    db.Update(usuario);
                }
                db.Commit();
                BStatus.Success("Usuário salvo");
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #2
0
        public bool Save(Cores cor)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(cor.Descricao))
                {
                    BStatus.Alert("A descrição da cor é obrigatória");
                    return(false);
                }

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

                db.Commit();
                BStatus.Success("Cor salva com sucesso");
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        public bool Save(Fornecedores f)
        {
            try
            {
                if (!Valid(f))
                {
                    return(false);
                }

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

                db.Commit();
                BStatus.Success("Fornecedor salvo");
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #4
0
        public bool Save(Clientes c)
        {
            try
            {
                if (!Valid(c))
                {
                    return(false);
                }

                if (db.Find(c.Id) == null)
                {
                    c.Id = db.NextId(e => e.Id);
                    db.Save(c);
                }
                else
                {
                    db.Update(c);
                }
                db.Commit();
                BStatus.Success("Cliente salvo");
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public bool Save(Unidades un)
        {
            try
            {
                if (!Valid(un))
                {
                    return(false);
                }

                if (db.Find(un.Id) == null)
                {
                    un.Id = db.NextId(u => u.Id);
                    db.Save(un);
                }
                else
                {
                    db.Update(un);
                }
                db.Commit();
                BStatus.Success("Unidade salva");
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public bool Remove(int id)
        {
            UnitOfWork unitOfWork = null;

            try
            {
                unitOfWork = new UnitOfWork();
                unitOfWork.BeginTransaction();

                db.Context = unitOfWork.Context;

                if (!ValidRemove(id))
                {
                    return(false);
                }

                EstoqueController ec = new EstoqueController();
                ec.RemoveByProduto(id, unitOfWork);

                db.Remove(Find(id));
                unitOfWork.Commit();
                BStatus.Success("Produto removido");
                return(true);
            }
            catch (Exception ex)
            {
                unitOfWork.RollBack();
                return(false);
            }
        }
Example #7
0
        public bool Save(Produtos_fornecedores pf)
        {
            try
            {
                if (!Valid(pf))
                {
                    return(false);
                }

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

                if (auto_commit)
                {
                    db.Commit();
                }
                BStatus.Success("Amarração Produto x Fornecedor salva com sucesso");
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #8
0
        public bool Save(Formas_pagamento pg)
        {
            try
            {
                if (!Valid(pg))
                {
                    return(false);
                }

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

                db.Commit();
                BStatus.Success("Forma de pagamento salva");
                return(true);
            }
            catch
            {
                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);
            }
        }
Example #10
0
        public bool Save(Tamanhos tamanho)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(tamanho.Descricao))
                {
                    BStatus.Alert("A descrição é obrigatória");
                    return(false);
                }

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

                db.Commit();
                BStatus.Success("Tamanho salvo");
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Example #11
0
        public bool Remove(int id)
        {
            try
            {
                Formas_pagamento fp = Find(id);
                if (fp.Movimentos_caixas.Count > 0)
                {
                    BStatus.Alert("Não é possível excluir esta condição de pagamento. Ela está presente em uma ou mais movimentações de caixa");
                    return(false);
                }

                if (fp.Itens_pagamento.Count > 0)
                {
                    BStatus.Alert("Não é possível excluir esta condição de pagamento. Ela está presente em um ou mais movimentos");
                    return(false);
                }

                if (fp.Pagamentos_lancamentos.Count > 0)
                {
                    BStatus.Alert("Não é possível excluir esta condição de pagamento. Ela está presente em um ou mais lançamentos financeiros");
                    return(false);
                }

                db.Remove(fp);
                db.Commit();
                BStatus.Success("Forma de pagamento removida");
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #12
0
        public bool Save(Caixas caixa)
        {
            try
            {
                if (!Valid(caixa))
                {
                    return(false);
                }

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

                db.Commit();
                BStatus.Success("Caixa salvo");
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #13
0
        public bool Save(Fabricantes fab)
        {
            try
            {
                if (!Valid(fab))
                {
                    return(false);
                }

                if (db.Find(fab.Id) == null)
                {
                    fab.Id = db.NextId(f => f.Id);
                    db.Save(fab);
                }
                else
                {
                    db.Update(fab);
                }
                db.Commit();
                BStatus.Success("Fabricante salvo");
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public bool Save(Marcas m)
        {
            try
            {
                if (!Valid(m))
                {
                    return(false);
                }

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

                db.Commit();
                BStatus.Success("Marca salva");
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #15
0
        public bool Save(Vendedores v)
        {
            try
            {
                if (!Valid(v))
                {
                    return(false);
                }

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

                db.Commit();
                BStatus.Success("Vendedor salvo");
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #16
0
        public bool Save(Operadoras_cartao oc)
        {
            try
            {
                if (!Valid(oc))
                {
                    return(false);
                }

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

                if (auto_commit)
                {
                    db.Commit();
                }
                BStatus.Success("Operadora de cartão salva");
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        private bool Valid(Produtos p)
        {
            if (string.IsNullOrWhiteSpace(p.Descricao))
            {
                BStatus.Alert("A descrição do produto é obrigatória");
                return(false);
            }

            if (string.IsNullOrWhiteSpace(p.Ean))
            {
                BStatus.Alert("O EAN é obrigatório");
                return(false);
            }

            if (p.Ean.Length > 13)
            {
                BStatus.Alert("O EAN não pode conter mais de 13 caracteres");
                return(false);
            }

            if (p.Unidade_id == 0)
            {
                BStatus.Alert("A unidade é obrigatória");
                return(false);
            }

            if (string.IsNullOrEmpty(p.Ncm))
            {
                BStatus.Alert("Atenção: o NCM do produto não é obrigatório neste cadastro, porém, este produto não poderá ser incluido em uma NFC-e");
                return(true);
            }

            return(true);
        }
Example #18
0
        private bool Valid(Operadoras_cartao op)
        {
            if (string.IsNullOrWhiteSpace(op.Nome))
            {
                BStatus.Alert("O nome da operadora é obrigatório");
                return(false);
            }

            if (op.Tipo_recebimento == (int)Tipo_recebimento.DIAS)
            {
                if (op.Prazo_recebimento > 31)
                {
                    BStatus.Alert("O prazo de recebimento não pode passar de 31 dias");
                    return(false);
                }
            }

            if (op.Prazo_recebimento == (int)Tipo_recebimento.HORAS)
            {
                if (op.Tipo_recebimento > 72)
                {
                    BStatus.Alert("O prazo de recebimento não pode passar de 72 horas");
                    return(false);
                }
            }

            return(true);
        }
        public bool Save(Contas conta)
        {
            try
            {
                if (!Valid(conta))
                {
                    return(false);
                }

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

                db.Commit();
                BStatus.Success("Conta salva.");
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #20
0
        public bool Save(Tipos_movimento tm)
        {
            try
            {
                if (!Valid(tm))
                {
                    return(false);
                }

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

                if (auto_commit)
                {
                    db.Commit();
                }
                BStatus.Success("Tipo de movimento salvo");
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #21
0
 private bool ValidDelete(int usuario_id)
 {
     if (new VendedoresController().CountByUsuario(usuario_id) > 0)
     {
         BStatus.Alert("Não é possível remover este usuário. Existe um vendedor relacionado a ele.");
         return(false);
     }
     return(true);
 }
Example #22
0
        private bool Valid(Formas_pagamento pg)
        {
            if (string.IsNullOrWhiteSpace(pg.Descricao))
            {
                BStatus.Alert("A descrição da forma de pagamento é obrigatória");
                return(false);
            }

            if (pg.Tipo_pagamento == (int)Tipo_pagamento.CREDITO)
            {
                if (pg.Tipo_intervalo == (int)Tipo_intervalo.DATA_BASE)
                {
                    if ((pg.Dia_base > 31) || (pg.Dia_base < 1))
                    {
                        BStatus.Alert("O dia base não pode ser menor que 1 ou passar de 31 ");
                        return(false);
                    }
                }

                if (pg.Tipo_intervalo == (int)Tipo_intervalo.INTERVALO)
                {
                    if (pg.Intervalo < 1)
                    {
                        BStatus.Alert("O intervalo não pode ser inferior a 1");
                        return(false);
                    }
                }
            }

            if (pg.Tipo_pagamento == (int)Tipo_pagamento.CARTAO)
            {
                if (pg.Operadora_cartao_id == 0)
                {
                    BStatus.Alert("Informe a operadora de cartão");
                    return(false);
                }
            }

            if (pg.Tipo_pagamento == (int)Tipo_pagamento.CHEQUE)
            {
                if (pg.Conta_id == 0)
                {
                    BStatus.Alert("Uma conta do tipo BANCÁRIA é necessária para o tipo pagamento CHEQUE");
                    return(false);
                }

                Contas conta = new ContasController().Find(pg.Conta_id);
                if (conta.Tipo != (int)Tipo_conta.CONTA_BANCARIA)
                {
                    BStatus.Alert("Uma conta do tipo BANCÁRIA é necessária para o tipo pagamento CHEQUE");
                    return(false);
                }
            }

            return(true);
        }
Example #23
0
        private bool Valid(Fabricantes fab)
        {
            if (string.IsNullOrWhiteSpace(fab.Nome))
            {
                BStatus.Alert("O nome do fabricante é obrigatório");
                return(false);
            }

            return(true);
        }
        private bool ValidDelete(int id)
        {
            if (new ProdutosController().CountByMarca(id) > 0)
            {
                BStatus.Alert("Não é possível excluir esta marca. Existem um ou mais produtos relacionados a ela");
                return(false);
            }

            return(true);
        }
Example #25
0
        private bool Valid(Caixas caixa)
        {
            if (string.IsNullOrWhiteSpace(caixa.Nome))
            {
                BStatus.Alert("O nome do caixa é obrigatório");
                return(false);
            }

            return(true);
        }
Example #26
0
        private bool ValidRemove(int caixa_id)
        {
            if (new Movimentos_caixasController().CountByCaixa(caixa_id) > 0)
            {
                BStatus.Alert("Não é possível excluir este caixa. Já foram realizadas uma ou mais movimentações.");
                return(false);
            }

            return(true);
        }
        private bool Valid(Marcas m)
        {
            if (string.IsNullOrWhiteSpace(m.Nome))
            {
                BStatus.Alert("O nome de marca é obrigatório");
                return(false);
            }

            return(true);
        }
Example #28
0
        private bool Valid(Clientes c)
        {
            if (string.IsNullOrWhiteSpace(c.Nome))
            {
                BStatus.Alert("O nome do cliente é obrigatório");
                return(false);
            }

            return(true);
        }
Example #29
0
        private bool ValidRemove(int id)
        {
            if (new MovimentosController().CountByTipo_movimento(id) > 0)
            {
                BStatus.Alert("Não é possível excluir este tipo de movimento. Existem um ou mais movimentos relacionados a ele");
                return(false);
            }

            return(true);
        }
        private bool Valid(Contas conta)
        {
            if (string.IsNullOrWhiteSpace(conta.Nome))
            {
                BStatus.Alert("Informe o nome da conta");
                return(false);
            }

            if (conta.Tipo == (int)Tipo_conta.CONTA_BANCARIA)
            {
                if (string.IsNullOrWhiteSpace(conta.Titular))
                {
                    BStatus.Alert("Informe o titular");
                    return(false);
                }

                if (conta.Banco_numero == 0)
                {
                    BStatus.Alert("O número do banco é obrigatório");
                    return(false);
                }

                if (string.IsNullOrWhiteSpace(conta.Nome_banco))
                {
                    BStatus.Alert("Informe o nome do banco");
                    return(false);
                }

                if (string.IsNullOrWhiteSpace(conta.Agencia))
                {
                    BStatus.Alert("Informe a agência");
                    return(false);
                }

                if (string.IsNullOrWhiteSpace(conta.Conta))
                {
                    BStatus.Alert("Informe o numero da conta");
                    return(false);
                }

                if (string.IsNullOrWhiteSpace(conta.Carteira))
                {
                    BStatus.Alert("Informe a carteira");
                    return(false);
                }

                if (string.IsNullOrWhiteSpace(conta.Nosso_numero))
                {
                    BStatus.Alert("Informe o Nosso Número");
                    return(false);
                }
            }

            return(true);
        }