using System;
using System.Data.SqlClient;
using Municipalidad.Utils;
using Remuneraciones.DataAccess;
using Remuneraciones.DataSetFT;

namespace Remuneraciones.BusinessObjects
{
	public abstract class RlsSucursalCRUD
	{
		private SglAuditoria _sglAuditoria;

		/// <summary>
		/// Constructor
		/// <summary>
		public RlsSucursalCRUD()
		{
		}

		/// <summary>
		/// Constructor
		/// <summary>
		public RlsSucursalCRUD(SglAuditoria sglAuditoria)
		{
			_sglAuditoria = sglAuditoria;
		}

		/// <summary>
		/// 
		/// </summary>
		public DSSucursal LoadAll(int Ano)
		{
			//SqlConnection utilizado para ejecutar el SqlCommand
			SqlConnection connection = null;

			//Almacena retorno del DataAccess
			DSSucursal ds;

			try
			{
				//Abre la conexion
				connection = UtilsDB.GetConnection(Utils.GetAnoConnection(Ano));

				Sucursal da = new Sucursal(connection);
				ds = da.SelectAll();
			}
			catch (Exception ex)
			{
				throw ex;
			}
			finally
			{
				if (connection != null)
					connection.Dispose();
			}

			return ds;
		}
		
		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		public DSSucursal LoadBrowse(string idEmpresa, int Mes, int Ano)
		{
			//SqlConnection utilizado para ejecutar el SqlCommand
			SqlConnection connection = null;

			//Almacena retorno del DataAccess
			DSSucursal ds;

			try
			{
				//Abre la conexion
				connection = UtilsDB.GetConnection(Utils.GetAnoConnection(Ano));

				Sucursal da = new Sucursal(connection);
				ds = da.SelectBrowse(idEmpresa, Mes);
			}
			catch (Exception ex)
			{
				throw ex;
			}
			finally
			{
				if (connection != null)
					connection.Dispose();
			}

			return ds;
		}
	}
}