using System;
using System.Data;
using System.Data.SqlClient;

using Remuneraciones.DataSetFT;
using Municipalidad.Utils;
using Remuneraciones.DataModel;

namespace Remuneraciones.DataAccess
{
	public class Costo: CostoCRUD
	{
		//Field para almacenar la conexión
		private SqlConnection _connection = null;
		private SqlTransaction _transaction = null;

		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="connection"></param>
		public Costo(SqlConnection connection): base(connection)
		{
			_connection = connection;
		}

		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="transaction"></param>
		public Costo(SqlTransaction transaction): base(transaction)
		{
			_transaction = transaction;
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="idIdentity"></param>
		/// <returns></returns>
		public DSCosto SelectBrowse(string idEmpresa)
		{
			//Almacena retorno del SqlCommand
			SqlDataReader dr;

			try
			{
				//Ejecuta el SqlCommand
				dr = UtilsDB.ExecuteDataReader(_connection, CommandType.StoredProcedure, Schema.Costo.SP_SELECT_BROWSE, 
					UtilsDB.MP("@OrderBy", SqlDbType.Int, 0, 1),
					UtilsDB.MP("@idNumero", SqlDbType.VarChar, 3, (idEmpresa == ""? (object)null: idEmpresa)));
			}
			catch (Exception ex)
			{
				throw ex;
			}

			return GetDSFT(dr);
		}
	}
}