public void validaChaveAcesso(Solicitacao_Pagamento_Detalhe Solicitacao_Pagamento_Detalhe, int numero_fornecedor) { var fornecedor = this.dados.ALD_ETL_Fornecedores.Where(f => f.Numero == numero_fornecedor).FirstOrDefault(); Solicitacao_Pagamento_Detalhe.chave_acesso = Util.SomenteNumero(Solicitacao_Pagamento_Detalhe.chave_acesso); if (Solicitacao_Pagamento_Detalhe.categoria_nf.Substring(0, 2) == "ZE" && !Util.ValidaCampo(Solicitacao_Pagamento_Detalhe.chave_acesso)) { throw new NegocioException("Por favor informe a Chave de Acesso"); } else if (Solicitacao_Pagamento_Detalhe.chave_acesso.Length != 44) { throw new NegocioException("A Chave de Acesso deve conter 44 dígitos"); } else if (Solicitacao_Pagamento_Detalhe.chave_acesso.Substring(6, 14) != fornecedor.CNPJ) { throw new NegocioException("CNPJ informado está diferente da Chave de Acesso"); } else if (Convert.ToInt32(Solicitacao_Pagamento_Detalhe.chave_acesso.Substring(2, 2)) != Convert.ToInt32(Solicitacao_Pagamento_Detalhe.dt_emissao.Value.Year.ToString().Substring(2)) || Convert.ToInt32(Solicitacao_Pagamento_Detalhe.chave_acesso.Substring(4, 2)) != Solicitacao_Pagamento_Detalhe.dt_emissao.Value.Month) { throw new NegocioException("Data de Emissão informada está diferente da Chave de Acesso"); } else if (Convert.ToInt32(Solicitacao_Pagamento_Detalhe.chave_acesso.Substring(25, 9)) != Convert.ToInt32(Solicitacao_Pagamento_Detalhe.numero_nf)) { throw new NegocioException("Número da NF informada está diferente da Chave de Acesso"); } }
public void validaDatasNotaFiscal(Solicitacao_Pagamento_Detalhe Solicitacao_Pagamento_Detalhe) { if (Solicitacao_Pagamento_Detalhe.dt_emissao > DateTime.Now) { throw new NegocioException("Data de Emissão não pode ser maior que a Data Atual"); } else if (Solicitacao_Pagamento_Detalhe.dt_emissao < DateTime.Now.AddYears(-2)) { throw new NegocioException("Data de Emissão não pode ser menor que " + DateTime.Now.AddYears(-2).ToString("dd/MM/yyyy")); } else if (Solicitacao_Pagamento_Detalhe.dt_emissao > Solicitacao_Pagamento_Detalhe.dt_vencimento) { throw new NegocioException("Data de Emissão não pode ser maior que a Data de Vencimento"); } else if (Solicitacao_Pagamento_Detalhe.dt_emissao > Solicitacao_Pagamento_Detalhe.dt_recebimento) { throw new NegocioException("Data de Emissão não pode ser maior que a Data de Recebimento"); } else if (Solicitacao_Pagamento_Detalhe.dt_recebimento > DateTime.Now) { throw new NegocioException("Data de Recebimento não pode ser maior que a Data Atual"); } }