using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using fatd_faturamento.DAL.Persistencia;
using fatd_faturamento.ENTIDADE;

namespace fatd_faturamento.BLL.Repositorio
{
    public class repositorioCnae
    {

        public IList<entidadeCnae> Select(entidadeCnae objCnae)
        {
            dalCnae dalCnae = null;

            var lstCnae = new List<entidadeCnae>();
            DataTable dt = null;

            try
            {
                dalCnae = new dalCnae();
                dt = dalCnae.Select(objCnae);

                foreach (DataRow dr in dt.Rows)
                {
                    objCnae = new entidadeCnae();


                    if (!Convert.IsDBNull(dr["ID"]))
                        objCnae.ID = Convert.ToInt32(dr["ID"]);

                    if (!Convert.IsDBNull(dr["CODIGO"]))
                        objCnae.CODIGO = dr["CODIGO"].ToString();

                    if (!Convert.IsDBNull(dr["DESCRICAO"]))
                        objCnae.DESCRICAO = dr["DESCRICAO"].ToString();

                    if (!Convert.IsDBNull(dr["SECAO"]))
                        objCnae.SECAO = dr["SECAO"].ToString();

                    if (!Convert.IsDBNull(dr["DIVISAO"]))
                        objCnae.DIVISAO = dr["DIVISAO"].ToString();

                    if (!Convert.IsDBNull(dr["GRUPO"]))
                        objCnae.GRUPO = dr["GRUPO"].ToString();

                    if (!Convert.IsDBNull(dr["CLASSE"]))
                        objCnae.CLASSE = dr["CLASSE"].ToString();

                    if (!Convert.IsDBNull(dr["SUBCLASSE"]))
                        objCnae.SUBCLASSE = dr["SUBCLASSE"].ToString();

                    if (!Convert.IsDBNull(dr["CONTROLE"]))
                        objCnae.CONTROLE = dr["CONTROLE"].ToString();

                    if (!Convert.IsDBNull(dr["IDCLASSES"]))
                        objCnae.IDCLASSES = Convert.ToInt32(dr["IDCLASSES"]);

                    if (!Convert.IsDBNull(dr["SITUACAO"]))
                        objCnae.SITUACAO = dr["SITUACAO"].ToString();

                    if (!Convert.IsDBNull(dr["IDUSUARIOS"]))
                        objCnae.IDUSUARIOS = Convert.ToInt32(dr["IDUSUARIOS"]);


                    lstCnae.Add(objCnae);
                }
                return lstCnae;
            }
            catch (Exception)
            {
                throw;
            }
        }

        public IList<entidadeCnae> Select_1(entidadeCnae objCnae)
        {
            dalCnae dalCnae = null;

            var lstCnae = new List<entidadeCnae>();
            DataTable dt = null;

            try
            {
                dalCnae = new dalCnae();
                dt = dalCnae.Select_1(objCnae);

                foreach (DataRow dr in dt.Rows)
                {
                    objCnae = new entidadeCnae();


                    if (!Convert.IsDBNull(dr["ID"]))
                        objCnae.ID = Convert.ToInt32(dr["ID"]);

                    if (!Convert.IsDBNull(dr["CODIGO"]))
                        objCnae.CODIGO = dr["CODIGO"].ToString();

                    if (!Convert.IsDBNull(dr["DESCRICAO"]))
                        objCnae.DESCRICAO = dr["DESCRICAO"].ToString();

                    if (!Convert.IsDBNull(dr["SECAO"]))
                        objCnae.SECAO = dr["SECAO"].ToString();

                    if (!Convert.IsDBNull(dr["DIVISAO"]))
                        objCnae.DIVISAO = dr["DIVISAO"].ToString();

                    if (!Convert.IsDBNull(dr["GRUPO"]))
                        objCnae.GRUPO = dr["GRUPO"].ToString();

                    if (!Convert.IsDBNull(dr["CLASSE"]))
                        objCnae.CLASSE = dr["CLASSE"].ToString();

                    if (!Convert.IsDBNull(dr["SUBCLASSE"]))
                        objCnae.SUBCLASSE = dr["SUBCLASSE"].ToString();

                    if (!Convert.IsDBNull(dr["CONTROLE"]))
                        objCnae.CONTROLE = dr["CONTROLE"].ToString();

                    if (!Convert.IsDBNull(dr["IDCLASSES"]))
                        objCnae.IDCLASSES = Convert.ToInt32(dr["IDCLASSES"]);

                    if (!Convert.IsDBNull(dr["SITUACAO"]))
                        objCnae.SITUACAO = dr["SITUACAO"].ToString();

                    if (!Convert.IsDBNull(dr["IDUSUARIOS"]))
                        objCnae.IDUSUARIOS = Convert.ToInt32(dr["IDUSUARIOS"]);


                    lstCnae.Add(objCnae);
                }
                return lstCnae;
            }
            catch (Exception)
            {
                throw;
            }
        }

    }
}
