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


namespace fatd_faturamento.BLL.Repositorio
{
    public class repositorioConvenios
    {

        public void Insert(entidadeConvenios objConvenios)
        {
            dalConvenios dalConvenios = null;

            try
            {
                dalConvenios = new dalConvenios();

                dalConvenios.Insert(objConvenios);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public void Insert_1(entidadeConvenios objConvenios)
        {
            dalConvenios dalConvenios = null;

            try
            {
                dalConvenios = new dalConvenios();

                dalConvenios.Insert_1(objConvenios);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public void Update(entidadeConvenios objConvenios)
        {
            dalConvenios dalConvenios = null;

            try
            {
                dalConvenios = new dalConvenios();

                dalConvenios.Update(objConvenios);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public void Update_1(entidadeConvenios objConvenios)
        {
            dalConvenios dalConvenios = null;

            try
            {
                dalConvenios = new dalConvenios();

                dalConvenios.Update_1(objConvenios);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public void Update_2(entidadeConvenios objConvenios)
        {
            dalConvenios dalConvenios = null;

            try
            {
                dalConvenios = new dalConvenios();

                dalConvenios.Update_2(objConvenios);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public void Update_3(entidadeConvenios objConvenios)
        {
            dalConvenios dalConvenios = null;

            try
            {
                dalConvenios = new dalConvenios();

                dalConvenios.Update_3(objConvenios);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public void Update_4(entidadeConvenios objConvenios)
        {
            dalConvenios dalConvenios = null;

            try
            {
                dalConvenios = new dalConvenios();

                dalConvenios.Update_4(objConvenios);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public DataTable SelectCount(entidadeConvenios objConvenios)
        {
            dalConvenios dalConvenios = null;
            DataTable dt = null;

            try
            {
                dalConvenios = new dalConvenios();
                dt = dalConvenios.SelectCount(objConvenios);

                return dt;
            }
            catch (Exception)
            {
                throw;
            }
        }

        public DataTable SelectCount_1(entidadeConvenios objConvenios)
        {
            dalConvenios dalConvenios = null;
            DataTable dt = null;

            try
            {
                dalConvenios = new dalConvenios();
                dt = dalConvenios.SelectCount_1(objConvenios);

                return dt;
            }
            catch (Exception)
            {
                throw;
            }
        }

        public DataTable SelectCount_2(entidadeConvenios objConvenios)
        {
            dalConvenios dalConvenios = null;
            DataTable dt = null;

            try
            {
                dalConvenios = new dalConvenios();
                dt = dalConvenios.SelectCount_2(objConvenios);

                return dt;
            }
            catch (Exception)
            {
                throw;
            }
        }

        public IList<entidadeConvenios> Select(entidadeConvenios objConvenios)
        {
            dalConvenios dalConvenios = null;

            var lstConvenios = new List<entidadeConvenios>();
            DataTable dt = null;

            try
            {
                dalConvenios = new dalConvenios();
                dt = dalConvenios.Select(objConvenios);

                foreach (DataRow dr in dt.Rows)
                {
                    objConvenios = new entidadeConvenios();


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

                    if (!Convert.IsDBNull(dr["ZONA"]))
                        objConvenios.ZONA = dr["ZONA"].ToString();

                    if (!Convert.IsDBNull(dr["LIVRO"]))
                        objConvenios.LIVRO = dr["LIVRO"].ToString();

                    if (!Convert.IsDBNull(dr["CONTA"]))
                        objConvenios.CONTA = dr["CONTA"].ToString();

                    if (!Convert.IsDBNull(dr["CONS_ID"]))
                        objConvenios.CONS_ID = Convert.ToInt32(dr["CONS_ID"]);

                    if (!Convert.IsDBNull(dr["UNID_ID"]))
                        objConvenios.UNID_ID = Convert.ToInt32(dr["UNID_ID"]);

                    if (!Convert.IsDBNull(dr["CONVENIO"]))
                        objConvenios.CONVENIO = dr["CONVENIO"].ToString();

                    if (!Convert.IsDBNull(dr["VALOR"]))
                        objConvenios.VALOR = Convert.ToDouble(dr["VALOR"]);

                    if (!Convert.IsDBNull(dr["DT_INI"]))
                        objConvenios.DT_INI = Convert.ToDateTime(dr["DT_INI"]);

                    if (!Convert.IsDBNull(dr["DT_FIM"]))
                        objConvenios.DT_FIM = Convert.ToDateTime(dr["DT_FIM"]);

                    if (!Convert.IsDBNull(dr["REF"]))
                        objConvenios.REF = dr["REF"].ToString();

                    if (!Convert.IsDBNull(dr["SIT"]))
                        objConvenios.SIT = dr["SIT"].ToString();

                    if (!Convert.IsDBNull(dr["DT_CADASTRO"]))
                        objConvenios.DT_CADASTRO = Convert.ToDateTime(dr["DT_CADASTRO"]);

                    if (!Convert.IsDBNull(dr["DT_ALTERACAO"]))
                        objConvenios.DT_ALTERACAO = Convert.ToDateTime(dr["DT_ALTERACAO"]);

                    if (!Convert.IsDBNull(dr["DT_CANCELADO"]))
                        objConvenios.DT_CANCELADO = Convert.ToDateTime(dr["DT_CANCELADO"]);

                    if (!Convert.IsDBNull(dr["DT_REMOVIDO"]))
                        objConvenios.DT_REMOVIDO = Convert.ToDateTime(dr["DT_REMOVIDO"]);

                    if (!Convert.IsDBNull(dr["MOTIVO"]))
                        objConvenios.MOTIVO = dr["MOTIVO"].ToString();


                    lstConvenios.Add(objConvenios);
                }
                return lstConvenios;
            }
            catch (Exception)
            {
                throw;
            }
        }

        public IList<entidadeConvenios> Select_1(entidadeConvenios objConvenios)
        {
            dalConvenios dalConvenios = null;

            var lstConvenios = new List<entidadeConvenios>();

            regraNegocioGlobal regranegocioGlobal = null;

            DataTable dt = null;

            try
            {
                dalConvenios = new dalConvenios();
                dt = dalConvenios.Select_1(objConvenios);

                regranegocioGlobal = new regraNegocioGlobal();

                lstConvenios = regraNegocioGlobal.ConvertDataTable<entidadeConvenios>(dt);

                return lstConvenios;
            }
            catch (Exception)
            {
                throw;
            }
        }

        public IList<entidadeConvenios> Select_3(entidadeConvenios objConvenios)
        {
            dalConvenios dalConvenios = null;

            var lstConvenios = new List<entidadeConvenios>();

            regraNegocioGlobal regranegocioGlobal = null;

            DataTable dt = null;

            try
            {
                dalConvenios = new dalConvenios();
                dt = dalConvenios.Select_3(objConvenios);

                regranegocioGlobal = new regraNegocioGlobal();

                lstConvenios = regraNegocioGlobal.ConvertDataTable<entidadeConvenios>(dt);

                return lstConvenios;
            }
            catch (Exception)
            {
                throw;
            }
        }

        public IList<entidadeConvenios> Select_2(entidadeConvenios objConvenios)
        {
            dalConvenios dalConvenios = null;

            var lstConvenios = new List<entidadeConvenios>();

            regraNegocioGlobal regranegocioGlobal = null;

            DataTable dt = null;

            try
            {
                dalConvenios = new dalConvenios();
                dt = dalConvenios.Select_2(objConvenios);

                regranegocioGlobal = new regraNegocioGlobal();

                lstConvenios = regraNegocioGlobal.ConvertDataTable<entidadeConvenios>(dt);

                return lstConvenios;
            }
            catch (Exception)
            {
                throw;
            }
        }



    }
}
