Exemplo n.º 1
0
        public List <SYS_Population> SelectAllSYS_Population()
        {
            List <SYS_Population> sys_population = new List <SYS_Population>();
            DbDataReader          reader         = null;
            DbConnection          conn           = _DbHelper.CreateConnection(Common.ConnectionString);

            conn.Open();
            try
            {
                reader = _DbHelper.ExecuteReader(conn, Common.DatabaseSchema + "[SYS_Population_SelectAll]", (DbParameter[])null);
                if (reader.HasRows)
                {
                    SYS_PopulationDataAccess.SetListSYS_PopulationInfo(ref reader, ref sys_population);
                }
                return(sys_population);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format(" SYS_PopulationDataAccess.SelectAll: {0}", ex.Message));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                conn.Close();
            }
        }
Exemplo n.º 2
0
        public SYS_Population SelectSYS_Population(int ID)
        {
            SYS_Population sys_population = new SYS_Population();
            DbDataReader   reader         = null;
            DbConnection   conn           = _DbHelper.CreateConnection(Common.ConnectionString);

            conn.Open();
            try
            {
                List <DbParameter> para = new List <DbParameter>();
                para.Add(_DbHelper.CreateParameter(FIELD_ID, ID, false));

                reader = _DbHelper.ExecuteReader(conn, Common.DatabaseSchema + "[SYS_Population_SelectById]", para.ToArray());
                if (reader.HasRows && reader.Read())
                {
                    SYS_PopulationDataAccess.SetSYS_PopulationInfo(reader, ref sys_population);
                }
                return(sys_population);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("SYS_PopulationDataAccess.SelectById: {0}", ex.Message));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                conn.Close();
            }
        }
Exemplo n.º 3
0
        private static void SetListSYS_PopulationInfo(ref DbDataReader reader, ref List <SYS_Population> sys_populations)
        {
            SYS_Population sys_population = null;
            int            count          = 0;

            while (reader.Read())
            {
                sys_population = new SYS_Population();
                SYS_PopulationDataAccess.SetSYS_PopulationInfo(reader, ref sys_population);
                sys_population.STT = count + 1;
                sys_populations.Add(sys_population);
            }
        }