Beispiel #1
0
        /// <summary>
        /// Get all scales.
        /// </summary>
        /// <returns>The requested list filled with information.</returns>
        public List <Scale> GetAll()
        {
            string       sql = string.Empty;
            Scale        scale;
            List <Scale> scales = new List <Scale>();

            try
            {
                Connect();

                sql = @"SELECT 
                        " + ScaleDAO.SQL_FIELDS_SELECT + @"
                    FROM 
                        " + ScaleDAO.SQL_TABLE + @" 
                    ORDER BY 
                        scname ASC";

                using (SQLiteDataReader reader = ExecuteReader(sql))
                {
                    while (reader.Read())
                    {
                        scale = ScaleDAO.ReadEntityRecord(reader);
                        if (scale != null)
                        {
                            scales.Add(scale);
                        }
                    }
                }

                return(scales);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);

                throw;
            }
            finally
            {
                Disconnect();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Averigua el ID de una escala a partir de su nombre.
        /// </summary>
        /// <param name="name">Nombre de la escala.</param>
        /// <returns>Identificador del registro.</returns>
        public Scale GetId(string name)
        {
            string sql = string.Empty;

            try
            {
                Connect();

                sql = @"SELECT 
                        " + ScaleDAO.SQL_FIELDS_SELECT + @"
                    FROM 
                        " + ScaleDAO.SQL_TABLE + @" 
                    WHERE 
                        LCase(scname) = @scname";

                SetParameter("@scname", name.ToLower().Trim());

                using (SQLiteDataReader reader = ExecuteReader(sql))
                {
                    if (reader.Read())
                    {
                        return(ScaleDAO.ReadEntityRecord(reader));
                    }
                }

                return(null);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);

                throw;
            }
            finally
            {
                Disconnect();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Recupera las propiedades de una escala.
        /// </summary>
        /// <param name="itemid">Identificador.</param>
        /// <returns>Una instáncia de RCScale.</returns>
        public Scale GetByID(int itemId)
        {
            string sql = string.Empty;

            try
            {
                Connect();

                sql = @"SELECT 
                        " + ScaleDAO.SQL_FIELDS_SELECT + @" 
                    FROM 
                        " + ScaleDAO.SQL_TABLE + @" 
                    WHERE 
                        scid = @scid";

                SetParameter("scid", itemId);

                using (SQLiteDataReader reader = ExecuteReader(sql))
                {
                    if (reader.Read())
                    {
                        return(ScaleDAO.ReadEntityRecord(reader));
                    }
                }

                return(null);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);

                throw;
            }
            finally
            {
                Disconnect();
            }
        }