コード例 #1
0
        public void IncluirPagamento(FretePagamento fretePagamento)
        {
            DataAccess dao = new DataAccess();
            Dictionary <string, string> lstParametros = new Dictionary <string, string>();

            try
            {
                lstParametros = MontarParametrosExecutarPagamento(fretePagamento);
                dao.Executar("SP_FRETES_PAGAMENTOS_INCLUIR", lstParametros);
            }
            catch (Exception ex)
            {
                string parametrosSQL = string.Empty;
                parametrosSQL = helper.ConcatenarParametrosSQL(lstParametros);

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

                bizLogErro.IncluirLogErro(log);

                throw ex;
            }
        }
コード例 #2
0
        private Dictionary <string, string> MontarParametrosPesquisarPagamentos(FretePagamento fretePagamento)
        {
            Dictionary <string, string> lstParametros = new Dictionary <string, string>();

            lstParametros.Add("@idFrete", fretePagamento.idFrete.Equals(0) ? null : fretePagamento.idFrete.ToString());
            lstParametros.Add("@UnitTest", fretePagamento.UnitTest.Equals(0) ? null : fretePagamento.UnitTest.ToString());

            return(lstParametros);
        }
コード例 #3
0
        private Dictionary <string, string> MontarParametrosExecutarPagamento(FretePagamento fretePagamento)
        {
            Dictionary <string, string> lstParametros = new Dictionary <string, string>();

            lstParametros.Add("@idFrete", fretePagamento.idFrete.ToString());
            lstParametros.Add("@idOP", fretePagamento.idOP.ToString());
            lstParametros.Add("@UnitTest", fretePagamento.UnitTest.ToString());

            return(lstParametros);
        }
コード例 #4
0
        public List <FretePagamento> PesquisarPagamentos(FretePagamento fretePagamento)
        {
            DataAccess dao = new DataAccess();
            Dictionary <string, string> lstParametros = new Dictionary <string, string>();
            List <FretePagamento>       lstPagamentos = new List <FretePagamento>();

            try
            {
                lstParametros = MontarParametrosPesquisarPagamentos(fretePagamento);

                using (DataSet ds = dao.Pesquisar("SP_FRETES_PAGAMENTOS_PESQUISAR", lstParametros))
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        FretePagamento pagamentoItem = new FretePagamento();
                        pagamentoItem.idFrete  = int.Parse(dr["idFrete"].ToString());
                        pagamentoItem.idOP     = int.Parse(dr["idOrdemPagamento"].ToString());
                        pagamentoItem.numeroOP = dr["NumeroOP"].ToString();
                        pagamentoItem.statusOP = dr["Status"].ToString();
                        pagamentoItem.valorOP  = decimal.Parse(dr["ValorOP"].ToString());
                        lstPagamentos.Add(pagamentoItem);
                    }
                }
            }
            catch (Exception ex)
            {
                string parametrosSQL = string.Empty;
                parametrosSQL = helper.ConcatenarParametrosSQL(lstParametros);

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

                bizLogErro.IncluirLogErro(log);

                throw ex;
            }

            return(lstPagamentos);
        }
コード例 #5
0
        public string IncluirOrdemPagamento(OrdemPagamento ordemPagamento, bool origemConsultaOP, out int idOrdemPagamento)
        {
            DataAccess                  dao           = new DataAccess();
            List <_Transacao>           lstComandos   = new List <_Transacao>();
            Dictionary <string, string> lstParametros = new Dictionary <string, string>();
            BIZVeiculo                  bizVeiculo    = new BIZVeiculo();
            BIZFrete bizFrete = new BIZFrete();

            string Msg = string.Empty;

            try
            {
                Msg = ValidarCamposObrigatorios(ordemPagamento);
                idOrdemPagamento = 0;

                if (Msg == string.Empty)
                {
                    using (DataSet ds = dao.Pesquisar("SP_ORDEMPAGAMENTO_NOVONUMEROOP", lstParametros))
                    {
                        DataRow dr = ds.Tables[0].Rows[0];
                        ordemPagamento.numeroOP = dr[0].ToString();
                    }

                    lstParametros = MontarParametrosExecutarOrdemPagamento(ordemPagamento);

                    using (DataSet ds = dao.Pesquisar("SP_ORDEMPAGAMENTO_INCLUIR", lstParametros))
                    {
                        DataRow dr = ds.Tables[0].Rows[0];
                        idOrdemPagamento = int.Parse(dr[0].ToString());
                    }

                    lstComandos.AddRange(this.IncluirOrdemPagamentoItens(idOrdemPagamento, ordemPagamento.idObraEtapa, ordemPagamento.lstItens));

                    dao.ExecutarTransacao(lstComandos);

                    if (ordemPagamento.lstItens.Exists(x => x.idFrete != 0))
                    {
                        FretePagamento fretePagamento = new FretePagamento()
                        {
                            idFrete = ordemPagamento.lstItens.Where(x => x.idFrete != 0).FirstOrDefault().idFrete,
                            idOP    = idOrdemPagamento
                        };

                        bizFrete.IncluirPagamento(fretePagamento);
                    }

                    if (ordemPagamento.lstItens.Exists(x => x.idManutencao != 0))
                    {
                        Manutencao manutencao = new Manutencao()
                        {
                            idManutencao = ordemPagamento.lstItens.Where(x => x.idManutencao != 0).FirstOrDefault().idManutencao,
                            idOP         = idOrdemPagamento,
                        };

                        bizVeiculo.AtualizarManutencaoOrdemPagamento(manutencao);
                    }

                    if (ordemPagamento.lstItens.Exists(x => x.idOcorrenciaMulta != 0))
                    {
                        MultaOcorrencia ocorrencia = new MultaOcorrencia()
                        {
                            idOcorrencia = ordemPagamento.lstItens.Where(x => x.idOcorrenciaMulta != 0).FirstOrDefault().idOcorrenciaMulta,
                            idOP         = idOrdemPagamento
                        };

                        bizVeiculo.AtualizarMultaOcorrenciaOrdemPagamento(ocorrencia);
                    }
                }
            }
            catch (Exception ex)
            {
                string parametrosSQL = string.Empty;
                parametrosSQL = helper.ConcatenarParametrosSQL(lstParametros);

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

                bizLogErro.IncluirLogErro(log);

                throw ex;
            }

            return(Msg);
        }