public virtual int DeleteObject(IGenericEntity ent)
        {
            storedProcedures.Clear();
            InitializeObject(ent);
            if (!storedProcedures.ContainsKey("DeleteObject"))
            {
                throw new NotImplementedException(ApplicationMessages.EXCEPTION_IMPLEMENT_DELETEOBJECT);
            }

            DBStoredProcedure deleteSP        = storedProcedures["DeleteObject"];
            SqlCommand        cmd             = deleteSP.GetSqlCommand();
            SqlParameter      returnParameter = cmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int);

            returnParameter.Direction = ParameterDirection.ReturnValue;
            try
            {
                CurrentConnectionManager.ExecuteStoredProcedure(cmd);
            }
            catch (SqlException exc)
            {
                throw new IndException(exc);
            }

            return((int)cmd.Parameters["RETURN_VALUE"].Value);
        }
        /// <summary>
        /// Generic method used to insert an IGenericEntity to the database
        /// </summary>
        /// <param name="ent">the entity to be inserted</param>
        /// <returns>the return value from the stored procedure</returns>
        public virtual int InsertObject(IGenericEntity ent)
        {
            //Clear the stored procedures dictionary
            storedProcedures.Clear();
            InitializeObject(ent);
            //If the insert stpred procedure does not exist, throw exception
            if (!storedProcedures.ContainsKey("InsertObject"))
            {
                throw new NotImplementedException(ApplicationMessages.EXCEPTION_IMPLEMENT_INSERTOBJECT);
            }

            DBStoredProcedure insertSP        = storedProcedures["InsertObject"];
            SqlCommand        cmd             = insertSP.GetSqlCommand();
            SqlParameter      returnParameter = cmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int);

            returnParameter.Direction = ParameterDirection.ReturnValue;
            try
            {
                CurrentConnectionManager.ExecuteStoredProcedure(cmd);
            }
            catch (SqlException exc)
            {
                throw new IndException(exc);
            }
            return((int)cmd.Parameters["RETURN_VALUE"].Value);
        }
        public DataSet GetCustomDataSet(string procedureName, IGenericEntity ent)
        {
            storedProcedures.Clear();
            InitializeObject(ent);

            if (!storedProcedures.ContainsKey(procedureName))
            {
                throw new NotImplementedException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_IMPLEMENT, procedureName));
            }

            DBStoredProcedure insertSP = storedProcedures[procedureName];
            SqlCommand        cmd      = insertSP.GetSqlCommand();

            DataSet returnDS = null;

            try
            {
                returnDS = CurrentConnectionManager.GetDataSet(cmd);
            }
            catch (SqlException exc)
            {
                throw new IndException(exc);
            }

            return(returnDS);
        }
        /// <summary>
        /// Executes a custom stored procedure and returns the SP return value
        /// </summary>
        /// <param name="procedureName"></param>
        /// <param name="ent"></param>
        /// <returns>the stored procedure returned value</returns>
        public int ExecuteCustomProcedureWithReturnValue(string procedureName, IGenericEntity ent)
        {
            storedProcedures.Clear();
            InitializeObject(ent);

            if (!storedProcedures.ContainsKey(procedureName))
            {
                throw new NotImplementedException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_IMPLEMENT, procedureName));
            }

            DBStoredProcedure insertSP        = storedProcedures[procedureName];
            SqlCommand        cmd             = insertSP.GetSqlCommand();
            SqlParameter      returnParameter = cmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int);

            returnParameter.Direction = ParameterDirection.ReturnValue;

            try
            {
                CurrentConnectionManager.ExecuteStoredProcedure(cmd);
            }
            catch (SqlException exc)
            {
                throw new IndException(exc);
            }

            return((int)cmd.Parameters["RETURN_VALUE"].Value);
        }
        /// <summary>
        /// xecutes a custom stored procedure and returns the number of rows affected
        /// </summary>
        /// <param name="procedureName"></param>
        /// <param name="ent"></param>
        /// <returns>the number of rows affected</returns>
        public int ExecuteCustomProcedure(string procedureName, IGenericEntity ent)
        {
            int rowsAffected;

            storedProcedures.Clear();
            InitializeObject(ent);

            if (!storedProcedures.ContainsKey(procedureName))
            {
                throw new NotImplementedException(ApplicationMessages.MessageWithParameters(ApplicationMessages.EXCEPTION_IMPLEMENT, procedureName));
            }

            DBStoredProcedure insertSP = storedProcedures[procedureName];
            SqlCommand        cmd      = insertSP.GetSqlCommand();

            try
            {
                rowsAffected = CurrentConnectionManager.ExecuteStoredProcedure(cmd);
            }
            catch (SqlException exc)
            {
                throw new IndException(exc);
            }

            return(rowsAffected);
        }
        public virtual DataSet SelectObject(IGenericEntity ent)
        {
            storedProcedures.Clear();
            InitializeObject(ent);

            if (!storedProcedures.ContainsKey("SelectObject"))
            {
                throw new NotImplementedException(ApplicationMessages.EXCEPTION_IMPLEMENT_SELECTOBJECT);
            }

            DBStoredProcedure selectSP = storedProcedures["SelectObject"];
            SqlCommand        cmd      = selectSP.GetSqlCommand();

            DataSet returnDS = null;

            try
            {
                returnDS = CurrentConnectionManager.GetDataSet(cmd);
            }
            catch (SqlException exc)
            {
                throw new IndException(exc);
            }

            return(returnDS);
        }