Example #1
0
        public override int Delete(FotosPedido objDelete)
        {
            string path = objDelete.FilePath;

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            // Cria o Log de remoção do Anexo - imagem Pedido
            LogAlteracao log = new LogAlteracao();

            log.Tabela        = (int)LogAlteracao.TabelaAlteracao.Pedido;
            log.IdRegistroAlt = (int)objDelete.IdPedido;
            log.NumEvento     = LogAlteracaoDAO.Instance.GetNumEvento(LogAlteracao.TabelaAlteracao.Pedido, (int)objDelete.IdPedido);
            log.Campo         = "Anexo Pedido";
            log.DataAlt       = DateTime.Now;
            log.IdFuncAlt     = UserInfo.GetUserInfo.CodUser;
            log.ValorAnterior = string.Format("{0} - Imagem Anexada", objDelete.IdFoto);
            log.ValorAtual    = string.Format("{0} - Imagem Removida", objDelete.IdFoto);
            log.Referencia    = LogAlteracao.GetReferencia(log.Tabela, objDelete.IdPedido);
            LogAlteracaoDAO.Instance.Insert(log);

            return(GDAOperations.Delete(objDelete));
        }
Example #2
0
        public override int DeleteByPrimaryKey(uint Key)
        {
            // Veririca se existe algum pagamento associado à esta conta bancária
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From pagto_pagto Where idContaBanco=" + Key) > 0)
            {
                throw new Exception("Esta conta bancária não pode ser excluída por haver pagamentos relacionados à mesma.");
            }

            // Veririca se existe alguma movimentação para esta conta bancária
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From mov_banco Where idContaBanco=" + Key) > 0)
            {
                throw new Exception("Esta conta bancária não pode ser excluída por haver movimentações relacionadas à mesma.");
            }

            // Veririca se existe alguma parcela de cartão para esta conta bancária
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From contas_receber Where idContaBanco=" + Key + " And isParcelaCartao=True") > 0)
            {
                throw new Exception("Esta conta bancária não pode ser excluída por haver parcela(s) de cartão relacionada(s) à mesma.");
            }

            // Veririca se existe alguma associação com esta conta bancária
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From assoc_conta_banco Where idContaBanco=" + Key) > 0)
            {
                throw new Exception("Esta conta bancária não pode ser excluída por haver associações em configurações relacionadas à mesma.");
            }

            return(GDAOperations.Delete(new ContaBanco {
                IdContaBanco = (int)Key
            }));
        }
Example #3
0
 public override int DeleteByPrimaryKey(uint Key)
 {
     LogAlteracaoDAO.Instance.ApagaLogSubtipoPerda(Key);
     return(GDAOperations.Delete(new SubtipoPerda {
         IdSubtipoPerda = (int)Key
     }));
 }
Example #4
0
        public override int DeleteByPrimaryKey(uint Key)
        {
            // Verifica se existem funcionários associados à esta loja
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From funcionario Where idLoja=" + Key) > 0)
            {
                throw new Exception("Esta loja não pode ser excluída, pois existem funcionários associados à mesma.");
            }

            // Verifica se existem pedidos associados à esta loja
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From pedido Where idLoja=" + Key) > 0)
            {
                throw new Exception("Esta loja não pode ser excluída, pois existem pedidos associados à mesma.");
            }

            // Verifica se existem orçamentos associados à esta loja
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From orcamento Where idLoja=" + Key) > 0)
            {
                throw new Exception("Esta loja não pode ser excluída, pois existem orçamentos associados à mesma.");
            }

            // Verifica se existem projetos associados à esta loja
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From projeto Where idLoja=" + Key) > 0)
            {
                throw new Exception("Esta loja não pode ser excluída, pois existem projetos associados à mesma.");
            }

            return(GDAOperations.Delete(new Loja {
                IdLoja = (int)Key
            }));
        }
Example #5
0
        public override int DeleteByPrimaryKey(uint Key)
        {
            if (CurrentPersistenceObject.ExecuteSqlQueryCount(@"select count(*) from bem_ativo_imobilizado") > 0)
            {
                throw new Exception("Não é possível apagar esse bem ativo imobilizado porque ele está em uso.");
            }

            return(GDAOperations.Delete(new BemAtivoImobilizado {
                IdBemAtivoImobilizado = Key
            }));
        }
Example #6
0
        public override int DeleteByPrimaryKey(GDASession session, int Key)
        {
            if (CurrentPersistenceObject.ExecuteSqlQueryCount(session, "Select * From cliente where idTipoCliente=" + Key) > 0)
            {
                throw new Exception("Existem clientes associados à esse tipo. É necessário desassociar todos os clientes antes de excluir o tipo.");
            }

            return(GDAOperations.Delete(session, new TipoCliente {
                IdTipoCliente = Key
            }));
        }
Example #7
0
        public override int DeleteByPrimaryKey(uint Key)
        {
            if (objPersistence.ExecuteSqlQueryCount("select count(*) from obs_lanc_fiscal_nf where idObsLancFiscal=" + Key) > 0)
            {
                throw new Exception("Essa observação está vinculada a uma ou mais notas fiscais e não pode ser excluída.");
            }

            return(GDAOperations.Delete(new ObsLancFiscal {
                IdObsLancFiscal = Key
            }));
        }
Example #8
0
        public override int DeleteByPrimaryKey(uint idTipoCfop)
        {
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From cfop Where idTipoCfop=" + idTipoCfop) > 0)
            {
                throw new Exception("Este tipo de cfop não pode ser excluído pois existem cfops relacionados ao mesmo.");
            }

            return(GDAOperations.Delete(new TipoCfop {
                IdTipoCfop = (int)idTipoCfop
            }));
        }
Example #9
0
        public override int Delete(FotosTrocaDevolucao objDelete)
        {
            string path = objDelete.FilePath;

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            return(GDAOperations.Delete(objDelete));
        }
Example #10
0
        public override int DeleteByPrimaryKey(uint Key)
        {
            // Verifica se este tipo de funcionário está associado a algum funcionário
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From funcionario Where idTipoFunc=" + Key) > 0)
            {
                throw new Exception("Este tipo de funcionário não pode ser excluído pois há um ou mais funcionários associados ao mesmo.");
            }

            return(GDAOperations.Delete(new TipoFuncionario {
                IdTipoFuncionario = (int)Key
            }));
        }
Example #11
0
        public override int DeleteByPrimaryKey(uint Key)
        {
            uint idObra = ObtemValorCampo <uint>("idObra", "idProdObra=" + Key);

            int retorno = GDAOperations.Delete(new ProdutoObra {
                IdProdObra = Key
            });

            ObraDAO.Instance.UpdateValorObra(idObra);

            return(retorno);
        }
Example #12
0
        public override int DeleteByPrimaryKey(uint Key)
        {
            // Verifica se este grupo está sendo usado em alguma figura de projeto
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From figura_projeto Where idGrupoFigProj=" + Key) > 0)
            {
                throw new Exception("Este grupo não pode ser excluído pois existem projetos cadastrados no mesmo.");
            }

            return(GDAOperations.Delete(new GrupoFiguraProjeto {
                IdGrupoFigProj = Key
            }));
        }
Example #13
0
        public override int DeleteByPrimaryKey(uint Key)
        {
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select * From cliente where idGrupoCliente=" + Key) > 0)
            {
                throw new Exception("Existem clientes associados à esse grupo. É necessário desassociar todos os clientes antes de excluir o grupo.");
            }

            LogAlteracaoDAO.Instance.ApagaLogGrupoCliente(Key);
            return(GDAOperations.Delete(new GrupoCliente {
                IdGrupoCliente = (int)Key
            }));
        }
Example #14
0
        public override int DeleteByPrimaryKey(uint key)
        {
            //Busca os ids dos anexos
            var idsAnexos = ExecuteMultipleScalar <int>("select IdAnexoEmail from anexo_email where idemail=" + key).ToArray();

            //Apaga da pasta Boletos o boleto do e-mail em questão
            AnexoEmailDAO.Instance.ApagarBoletosAnexos(idsAnexos);

            AnexoEmailDAO.Instance.DeleteByEmail(key);
            return(GDAOperations.Delete(new FilaEmail {
                IdEmail = key
            }));
        }
Example #15
0
        public override int DeleteByPrimaryKey(uint Key)
        {
            // Verifica se este grupo está sendo usado em alguma figura de projeto
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From figura_peca_item_projeto Where idFiguraProjeto=" + Key) > 0)
            {
                throw new Exception("Esta figura não pode ser excluída pois existem projetos utilizando-a.");
            }

            string fotoPath = Utils.GetFigurasProjetoPath + Key + ".jpg";

            if (File.Exists(fotoPath))
            {
                File.Delete(fotoPath);
            }

            return(GDAOperations.Delete(new FiguraProjeto {
                IdFiguraProjeto = Key
            }));
        }
Example #16
0
        public override int DeleteByPrimaryKey(GDASession session, uint Key)
        {
            InsertParc(session, Key, new ImpostoServ());

            //Deleta os anexos se houver
            if (FotosImpostoServDAO.Instance.PossuiAnexo(session, Key))
            {
                var anexos = FotosImpostoServDAO.Instance.GetByImpostoServ(session, Key);

                foreach (FotosImpostoServ anexo in anexos)
                {
                    FotosImpostoServDAO.Instance.DeleteInstanceByPrimaryKey(session, anexo.IdFoto);
                }
            }

            return(GDAOperations.Delete(session, new ImpostoServ {
                IdImpostoServ = Key
            }));
        }
Example #17
0
        public override int DeleteByPrimaryKey(uint Key)
        {
            // Verifica se existem compras para este fornecedor
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From compra Where idFornec=" + Key) > 0)
            {
                throw new Exception("Este fornecedor não pode ser excluído pois existem compras relacionadas à ele.");
            }

            // Verifica se existem contas a pagar/pagas para este fornecedor
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From contas_pagar Where idFornec=" + Key) > 0)
            {
                throw new Exception("Este fornecedor não pode ser excluído pois existem contas a pagar/pagas relacionadas à ele.");
            }

            // Verifica se existem produtos associados à este fornecedor
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From produto Where idFornec=" + Key) > 0)
            {
                throw new Exception("Este fornecedor não pode ser excluído pois existem produtos relacionados à ele.");
            }

            // Verifica se existem notas fiscais associadas à este fornecedor
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From nota_fiscal Where idFornec=" + Key) > 0)
            {
                throw new Exception("Este fornecedor não pode ser excluído pois existem notas fiscais relacionadas à ele.");
            }

            LogAlteracaoDAO.Instance.ApagaLogFornecedor(Key);
            int retorno = GDAOperations.Delete(new Fornecedor {
                IdFornec = (int)Key
            });

            // Apaga os registros da tabela produto_fornecedor
            CurrentPersistenceObject.ExecuteCommand("delete from produto_fornecedor where idFornec=" + Key);

            CurrentPersistenceObject.ExecuteCommand("delete from parcelas_nao_usar where idfornec=" + Key);

            return(retorno);
        }
Example #18
0
 public override int Delete(MaterialProjetoModelo objDelete)
 {
     LogAlteracaoDAO.Instance.ApagaLogMaterialProjetoModelo(objDelete.IdMaterProjMod);
     LogCancelamentoDAO.Instance.LogMaterialProjetoModelo(objDelete, objDelete.MotivoCancelamento, true);
     return(GDAOperations.Delete(objDelete));
 }
Example #19
0
 public override int DeleteByPrimaryKey(uint Key)
 {
     return(GDAOperations.Delete(GetElementByPrimaryKey((uint)Key)));
 }
Example #20
0
        public override int DeleteByPrimaryKey(uint Key)
        {
            #region Verifica se existe associação

            /* Chamado 57311.
             * Impede que o plano de conta contábil seja removido do sistema caso esteja sendo utilizado. */

            var mensagemBloqueio    = "Não é possível apagar esse plano de conta contábil, pois, ele está associado a pelo menos {0}.";
            var associacoesBloqueio = new List <string>();

            if (objPersistence.ExecuteSqlQueryCount(string.Format("SELECT COUNT(*) FROM bem_ativo_imobilizado WHERE IdContaContabil={0}", Key)) > 0)
            {
                associacoesBloqueio.Add("um bem ativo imobilizado");
            }

            if (objPersistence.ExecuteSqlQueryCount(string.Format("SELECT COUNT(*) FROM cliente WHERE IdContaContabil={0}", Key)) > 0)
            {
                associacoesBloqueio.Add("um cliente");
            }

            if (objPersistence.ExecuteSqlQueryCount(string.Format("SELECT COUNT(*) FROM efd_cte WHERE IdContaContabil={0}", Key)) > 0)
            {
                associacoesBloqueio.Add("um EFD CTe");
            }

            if (objPersistence.ExecuteSqlQueryCount(string.Format("SELECT COUNT(*) FROM fornecedor WHERE IdContaContabil={0}", Key)) > 0)
            {
                associacoesBloqueio.Add("um fornecedor");
            }

            if (objPersistence.ExecuteSqlQueryCount(string.Format("SELECT COUNT(*) FROM info_adicional_nf WHERE IdContaContabil={0}", Key)) > 0)
            {
                associacoesBloqueio.Add("uma informação adicional de nota fiscal");
            }

            if (objPersistence.ExecuteSqlQueryCount(string.Format("SELECT COUNT(*) FROM plano_contas WHERE IdContaContabil={0}", Key)) > 0)
            {
                associacoesBloqueio.Add("um plano de contas");
            }

            if (objPersistence.ExecuteSqlQueryCount(string.Format("SELECT COUNT(*) FROM produto WHERE IdContaContabil={0}", Key)) > 0)
            {
                associacoesBloqueio.Add("um produto");
            }

            if (objPersistence.ExecuteSqlQueryCount(string.Format("SELECT COUNT(*) FROM produtos_nf WHERE IdContaContabil={0}", Key)) > 0)
            {
                associacoesBloqueio.Add("um produto de nota fiscal");
            }

            if (objPersistence.ExecuteSqlQueryCount(string.Format("SELECT COUNT(*) FROM receitas_diversas WHERE IdContaContabil={0}", Key)) > 0)
            {
                associacoesBloqueio.Add("uma receita diversa");
            }

            if (associacoesBloqueio.Count > 0)
            {
                throw new Exception(string.Format(mensagemBloqueio, string.Join(", ", associacoesBloqueio)));
            }

            #endregion

            return(GDAOperations.Delete(new PlanoContaContabil {
                IdContaContabil = (int)Key
            }));
        }