Exemple #1
0
        /// <summary>
        /// Dado um idArquivo consulto os dados para geração do arquivo
        /// </summary>
        /// <param name="idArquivo"></param>
        /// <returns></returns>
        public static ACSOPRGCR_RRodapeEN ConsultaPorIdArquivo(int idArquivo)
        {
            using (SqlConnection cnx = new SqlConnection(upSight.Consulta.Base.BD.Conexao.StringConexaoBDGlobal))
            {
                ACSOPRGCR_RRodapeEN acsPrgCrgRdpEN = null;
                try
                {
                    string query = " SELECT IdArquivo, NumCrg, NumCart, ValorCrg, NumCrgRej, ValCgrRej, NumLinha " +
                                   " FROM crpACSOPRGCR_RRodape " +
                                   " WHERE IdArquivo = @IdArquivo ";

                    using (SqlCommand cmd = new SqlCommand(query, cnx))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.Add("IdArquivo", SqlDbType.Int).Value = idArquivo;

                        cnx.Open();

                        using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                        {
                            while (dr.Read())
                            {
                                acsPrgCrgRdpEN = new ACSOPRGCR_RRodapeEN();
                                Mapeia(dr, acsPrgCrgRdpEN);
                            }
                        }
                    }
                }
                catch (SqlException sqlExc)
                {
                    if (upSight.Consulta.Base.BD.Geral.TS.TraceError)
                    {
                        Trace.TraceError("{0}: {1}", new object[] { "u.Integ.Servicos.CrtCorp, IdtnfRBD", sqlExc });
                    }
                    throw;
                }
                catch (Exception ex)
                {
                    if (upSight.Consulta.Base.BD.Geral.TS.TraceError)
                    {
                        Trace.TraceError("{0}: {1}", new object[] { "u.Integ.Servicos.CrtCorp, IdtnfR", ex });
                    }
                    throw;
                }
                finally
                {
                    if (cnx.State == ConnectionState.Open)
                    {
                        cnx.Close();
                    }
                }
                return(acsPrgCrgRdpEN);
            }
        }
Exemple #2
0
 private static void Mapeia(SqlDataReader dr, ACSOPRGCR_RRodapeEN acsPrgCrgRdpEN)
 {
     if (dr.HasRows)
     {
         acsPrgCrgRdpEN.IdArquivo = (int)dr["IdArquivo"];
         acsPrgCrgRdpEN.NumCrg    = (int)dr["NumCrg"];
         acsPrgCrgRdpEN.NumCart   = (int)dr["NumCart"];
         acsPrgCrgRdpEN.ValorCrg  = (decimal)dr["ValorCrg"];
         acsPrgCrgRdpEN.NumCrgRej = (int)dr["NumCrgRej"];
         acsPrgCrgRdpEN.ValCgrRej = (decimal)dr["ValCgrRej"];
         acsPrgCrgRdpEN.NumLinha  = (int)dr["NumLinha"];
     }
 }
        /// <summary>
        /// Monta o rodapé
        /// </summary>
        /// <param name="idArquivo"></param>
        /// <param name="numCrg"></param>
        /// <param name="numCart"></param>
        /// <param name="valorCrg"></param>
        /// <param name="numCrgRej"></param>
        /// <param name="valCrgRej"></param>
        /// <param name="numLinha"></param>
        /// <returns></returns>
        private ACSOPRGCR_RRodapeEN MontaRodape(int idArquivo, int numCrg, int numCart, decimal valorCrg, int numCrgRej, decimal valCrgRej, int numLinha)
        {
            var acsPrgCrgRdpEN = new ACSOPRGCR_RRodapeEN()
            {
                IdArquivo = idArquivo,
                NumCrg    = numCrg,
                NumCart   = numCart,
                ValorCrg  = valorCrg,
                NumCrgRej = numCrgRej,
                ValCgrRej = valCrgRej,
                NumLinha  = numLinha
            };

            return(acsPrgCrgRdpEN);
        }
        /// <summary>
        /// Dado um idArquivo consulto os dados para geração do arquivo
        /// </summary>
        /// <param name="idArquivo"></param>
        /// <returns></returns>
        public static ACSOPRGCR_RRodapeEN ConsultaPorIdArquivo(int idArquivo)
        {
            using (SqlConnection cnx = new SqlConnection(upSight.Consulta.Base.BD.Conexao.StringConexaoBDGlobal))
            {
                ACSOPRGCR_RRodapeEN acsPrgCrgRdpEN = null;
                try
                {
                    string query = " SELECT IdArquivo, NumCrg, NumCart, ValorCrg, NumCrgRej, ValCgrRej, NumLinha " +
                                   " FROM crpACSOPRGCR_RRodape " +
                                   " WHERE IdArquivo = @IdArquivo ";

                    using (SqlCommand cmd = new SqlCommand(query, cnx))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.Add("IdArquivo", SqlDbType.Int).Value = idArquivo;

                        cnx.Open();

                        using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                        {
                            while (dr.Read())
                            {
                                acsPrgCrgRdpEN = new ACSOPRGCR_RRodapeEN();
                                Mapeia(dr, acsPrgCrgRdpEN);
                            }
                        }
                    }
                }
                catch (SqlException sqlExc)
                {
                    if (upSight.Consulta.Base.BD.Geral.TS.TraceError)
                        Trace.TraceError("{0}: {1}", new object[] { "u.Integ.Servicos.CrtCorp, IdtnfRBD", sqlExc });
                    throw;
                }
                catch (Exception ex)
                {
                    if (upSight.Consulta.Base.BD.Geral.TS.TraceError)
                        Trace.TraceError("{0}: {1}", new object[] { "u.Integ.Servicos.CrtCorp, IdtnfR", ex });
                    throw;
                }
                finally
                {
                    if (cnx.State == ConnectionState.Open)
                        cnx.Close();
                }
                return acsPrgCrgRdpEN;
            }
        }
Exemple #5
0
        public static void Insere(this ACSOPRGCR_RRodapeEN acsPrgCrgRdpEN)
        {
            using (SqlConnection cnx = new SqlConnection(ConfigurationManager.ConnectionStrings["Global"].ConnectionString))
            {
                try
                {
                    string query = " INSERT crpACSOPRGCR_RRodape " +
                                   "        (IdArquivo, TpRegistro, NumCrg, NumCart, ValorCrg, NumCrgRej, ValCgrRej, NumLinha) " +
                                   " SELECT @IdArquivo, @TpRegistro, @NumCrg, @NumCart, @ValorCrg, @NumCrgRej, @ValCgrRej, @NumLinha ";

                    using (SqlCommand cmd = new SqlCommand(query, cnx))
                    {
                        cmd.CommandType = CommandType.Text;

                        cmd.Parameters.Add("IdArquivo", SqlDbType.Int).Value      = acsPrgCrgRdpEN.IdArquivo;
                        cmd.Parameters.Add("TpRegistro", SqlDbType.Char, 1).Value = ACSOPRGCR_RRodapeEN.TpRegistro;
                        cmd.Parameters.Add("NumCrg", SqlDbType.Int).Value         = acsPrgCrgRdpEN.NumCrg;
                        cmd.Parameters.Add("NumCart", SqlDbType.Int).Value        = acsPrgCrgRdpEN.NumCart;
                        cmd.Parameters.Add("ValorCrg", SqlDbType.Money).Value     = acsPrgCrgRdpEN.ValorCrg;
                        cmd.Parameters.Add("NumCrgRej", SqlDbType.Int).Value      = acsPrgCrgRdpEN.NumCrgRej;
                        cmd.Parameters.Add("ValCgrRej", SqlDbType.Money).Value    = acsPrgCrgRdpEN.ValCgrRej;
                        cmd.Parameters.Add("NumLinha", SqlDbType.Int).Value       = acsPrgCrgRdpEN.NumLinha;

                        cnx.Open();

                        cmd.ExecuteNonQuery();
                    }
                }
                catch (SqlException sqlExc)
                {
                    if (upSight.Consulta.Base.BD.Geral.TS.TraceError)
                    {
                        Trace.TraceError("{0}: {1}", new object[] { "u.CrtCorp.ACSOIDTSC_R.RdpBD", sqlExc });
                    }
                    throw;
                }
                catch (Exception ex)
                {
                    if (upSight.Consulta.Base.BD.Geral.TS.TraceError)
                    {
                        Trace.TraceError("{0}: {1}", new object[] { "u.CrtCorp.ACSOIDTSC_R.Rdp", ex });
                    }
                    throw;
                }
            }
        }
 private static void Mapeia(SqlDataReader dr, ACSOPRGCR_RRodapeEN acsPrgCrgRdpEN)
 {
     if(dr.HasRows)
     {
         acsPrgCrgRdpEN.IdArquivo = (int)dr["IdArquivo"];
         acsPrgCrgRdpEN.NumCrg = (int)dr["NumCrg"];
         acsPrgCrgRdpEN.NumCart = (int)dr["NumCart"];
         acsPrgCrgRdpEN.ValorCrg = (decimal)dr["ValorCrg"];
         acsPrgCrgRdpEN.NumCrgRej = (int)dr["NumCrgRej"];
         acsPrgCrgRdpEN.ValCgrRej = (decimal)dr["ValCgrRej"];
         acsPrgCrgRdpEN.NumLinha = (int)dr["NumLinha"];
     }
 }
        /// <summary>
        /// Monta o rodapé
        /// </summary>
        /// <param name="idArquivo"></param>
        /// <param name="numCrg"></param>
        /// <param name="numCart"></param>
        /// <param name="valorCrg"></param>
        /// <param name="numCrgRej"></param>
        /// <param name="valCrgRej"></param>
        /// <param name="numLinha"></param>
        /// <returns></returns>
        private ACSOPRGCR_RRodapeEN MontaRodape(int idArquivo, int numCrg, int numCart, decimal valorCrg, int numCrgRej, decimal valCrgRej, int numLinha)
        {
            var acsPrgCrgRdpEN = new ACSOPRGCR_RRodapeEN()
            {
                IdArquivo = idArquivo,
                NumCrg = numCrg,
                NumCart = numCart,
                ValorCrg = valorCrg,
                NumCrgRej = numCrgRej,
                ValCgrRej = valCrgRej,
                NumLinha = numLinha
            };

            return acsPrgCrgRdpEN;
        }