Пример #1
0
        private Dictionary <string, string> MontarParametrosExecutarNFSItens(NFServicoItem nfServicoItens)
        {
            Dictionary <string, string> lstParametros = new Dictionary <string, string>();

            lstParametros.Add("@idNota", nfServicoItens.idNota.ToString());
            lstParametros.Add("@Quantidade", nfServicoItens.Quantidade.ToString());
            lstParametros.Add("@Unidade", nfServicoItens.Unidade.ToString());
            lstParametros.Add("@Descricao", nfServicoItens.Descricao.ToString());
            lstParametros.Add("@PrecoUnitario", nfServicoItens.precoUnitario.ToString());
            lstParametros.Add("@UnitTest", nfServicoItens.UnitTest.ToString());

            return(lstParametros);
        }
Пример #2
0
        public List <NFServico> PesquisarNFServico(NFServico nfServico)
        {
            DataAccess dao = new DataAccess();
            Dictionary <string, string> lstParametros      = new Dictionary <string, string>();
            Dictionary <string, string> lstParametrosItens = new Dictionary <string, string>();
            List <NFServico>            lstNFS             = new List <NFServico>();
            List <NFServicoItem>        lstNFSItens        = new List <NFServicoItem>();

            try
            {
                lstParametros = MontarParametrosPesquisarNFServico(nfServico);

                using (DataSet ds = dao.Pesquisar("SP_NFSERVICOS_CONSULTAR", lstParametros))
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        NFServico nfs = new NFServico();
                        nfs.idNota              = int.Parse(dr["idNota"].ToString());
                        nfs.numeroNota          = int.Parse(dr["NumeroNota"].ToString());
                        nfs.idEmpresa           = int.Parse(dr["idEmpresa"].ToString());
                        nfs.nomeEmpresa         = dr["RazaoSocial"].ToString();
                        nfs.dataEmissao         = DateTime.Parse(dr["DataEmissao"].ToString());
                        nfs.valorNota           = decimal.Parse(dr["ValorNota"].ToString());
                        nfs.idCliente           = int.Parse(dr["idCliente"].ToString());
                        nfs.Nome                = dr["NomeCliente"].ToString();
                        nfs.descricaoServico    = dr["DescricaoServico"].ToString();
                        nfs.numeroProcesso      = dr["NumeroProcesso"].ToString();
                        nfs.Empenho             = dr["Empenho"].ToString();
                        nfs.pagamentoEfetuado   = int.Parse(dr["PagamentoEfetuado"].ToString());
                        nfs.dataPagamento       = DateTime.Parse(dr["DataPagamento"].ToString());
                        nfs.valorPago           = decimal.Parse(dr["ValorPago"].ToString());
                        nfs.possuiDataAtes      = int.Parse(dr["PossuiDataAtes"].ToString());
                        nfs.dataAtes            = DateTime.Parse(dr["DataAtes"].ToString());
                        nfs.possuiDataCAT       = int.Parse(dr["PossuiDataCAT"].ToString());
                        nfs.dataCAT             = DateTime.Parse(dr["DataCAT"].ToString());
                        nfs.Cancelado           = int.Parse(dr["Cancelado"].ToString());
                        nfs.observacaoCancelado = dr["ObservacaoCancelado"].ToString();
                        nfs.IRPJ                = decimal.Parse(dr["IRPJ"].ToString());
                        nfs.CSLL                = decimal.Parse(dr["CSLL"].ToString());
                        nfs.INSS                = decimal.Parse(dr["INSS"].ToString());
                        nfs.PIS    = decimal.Parse(dr["PIS"].ToString());
                        nfs.COFINS = decimal.Parse(dr["COFINS"].ToString());
                        nfs.ISSQN  = decimal.Parse(dr["ISSQN"].ToString());

                        lstParametrosItens = new Dictionary <string, string>();
                        lstParametrosItens.Add("@idNota", nfs.idNota.ToString());

                        using (DataSet dsItens = dao.Pesquisar("SP_NFSERVICOSITENS_CONSULTAR", lstParametrosItens))
                        {
                            lstNFSItens = new List <NFServicoItem>();
                            foreach (DataRow drItens in dsItens.Tables[0].Rows)
                            {
                                NFServicoItem nfsItem = new NFServicoItem();
                                nfsItem.idNota        = int.Parse(drItens["idNota"].ToString());
                                nfsItem.Unidade       = drItens["Unidade"].ToString();
                                nfsItem.Quantidade    = int.Parse(drItens["Quantidade"].ToString());
                                nfsItem.Descricao     = drItens["Descricao"].ToString();
                                nfsItem.precoUnitario = decimal.Parse(drItens["PrecoUnitario"].ToString());
                                nfsItem.UnitTest      = int.Parse(drItens["UnitTest"].ToString());

                                lstNFSItens.Add(nfsItem);
                            }
                        }

                        nfs.lstItens = lstNFSItens;
                        lstNFS.Add(nfs);
                    }
                }
            }
            catch (Exception ex)
            {
                string parametrosSQL = string.Empty;
                parametrosSQL = helper.ConcatenarParametrosSQL(lstParametros);

                LogErro log = new LogErro()
                {
                    procedureSQL  = "SP_NFSERVICOS_CONSULTAR",
                    parametrosSQL = parametrosSQL,
                    mensagemErro  = ex.ToString()
                };

                bizLogErro.IncluirLogErro(log);

                throw ex;
            }

            return(lstNFS);
        }