Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="oVotoFilter"></param>
        /// <returns></returns>
        public List <Voto> GetValoresByFilter(VotoFilter oVotoFilter)
        {
            using (VotoDataAccess oVotoDataAccess = new VotoDataAccess())
            {
                DataSet ds = oVotoDataAccess.GetListByFilter(oVotoFilter);

                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    return(Voto.GetFromDS(ds));
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="oValor"></param>
        /// <returns></returns>
        public DataSet GetListByFilter(VotoFilter oVoto)
        {
            // Creo la conexión y la transacción
            SqlConnection oConn = new SqlConnection(ConfigurationManager.ConnectionStrings["CONEXION"].ConnectionString);

            oConn.Open();
            SqlTransaction oTran = oConn.BeginTransaction();

            DataSet ds = new DataSet();

            try
            {
                using (SqlDataAdapter adapter = new SqlDataAdapter())
                {
                    using (SqlCommand oComm = new SqlCommand())
                    {
                        oComm.Connection  = (oTran != null) ? oTran.Connection : oConn;
                        oComm.Transaction = oTran;

                        oComm.CommandType = CommandType.StoredProcedure;
                        oComm.CommandText = ObjectName + "_GetListByFilter";

                        oComm.Parameters.Add(new SqlParameter("@IdPersona", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, null, DataRowVersion.Original, oVoto.IdPersona));
                        oComm.Parameters.Add(new SqlParameter("@Puntuacion", SqlDbType.Int, 0, ParameterDirection.Input, true, 0, 0, null, DataRowVersion.Original, oVoto.Puntuacion));
                        oComm.Parameters.Add(new SqlParameter("@Comentario", SqlDbType.NVarChar, 2000, ParameterDirection.Input, true, 0, 0, null, DataRowVersion.Original, oVoto.Comentario));
                        oComm.Parameters.Add(new SqlParameter("@FechaAltaFrom", SqlDbType.DateTime, 0, ParameterDirection.Input, true, 0, 0, null, DataRowVersion.Original, oVoto.FechaAltaFrom));
                        oComm.Parameters.Add(new SqlParameter("@FechaAltaTo", SqlDbType.DateTime, 0, ParameterDirection.Input, true, 0, 0, null, DataRowVersion.Original, oVoto.FechaAltaTo));

                        adapter.SelectCommand = oComm;
                        adapter.Fill(ds);
                    }
                }
            }
            catch (Exception e)
            {
                oTran.Rollback();
                throw e;
            }
            finally
            {
                oConn.Close();
                oTran.Dispose();
            }

            return(ds);
        }
Exemplo n.º 3
0
        public List <Voto> GetListByFilter(string idPersona, string puntuacion, string comentario, string fechaAltaFrom, string fechaAltaTo)
        {
            try
            {
                int?     idPersonaInt      = null;
                DateTime?fechaAltaFromDate = null;
                DateTime?fechaAltaToDate   = null;

                // Pregunto sobre los valores para no cargar null
                if (!string.IsNullOrEmpty(idPersona))
                {
                    idPersonaInt = Int32.Parse(idPersona);
                }

                if (!string.IsNullOrEmpty(fechaAltaFrom))
                {
                    fechaAltaFromDate = DateTime.Parse(fechaAltaFrom);
                }

                if (!string.IsNullOrEmpty(fechaAltaTo))
                {
                    fechaAltaToDate = DateTime.Parse(fechaAltaTo);
                }

                VotoFilter oVoto = new VotoFilter()
                {
                    IdPersona     = idPersonaInt,
                    Puntuacion    = puntuacion,
                    Comentario    = comentario,
                    FechaAltaFrom = fechaAltaFromDate,
                    FechaAltaTo   = fechaAltaToDate
                };

                using (VotoBusiness oVotoBusiness = new VotoBusiness())
                {
                    return(oVotoBusiness.GetValoresByFilter(oVoto));
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }