예제 #1
0
        public List <GardenEntity> PlantsToPlantInThisMonth(GardenEntity.Month thisMonth)
        {
            GardenDAO           gardenDAO        = new GardenDAO();
            List <GardenEntity> gardenEntityList = new List <GardenEntity>();

            if (gardenDAO != null)
            {
                gardenEntityList = gardenDAO.PlantsToPlantInThisMonth(thisMonth);
            }
            else
            {
                throw new Exception("GardenDAO is null. PlantsToPlantInThisMonth");
            }
            return(gardenEntityList);
        }
예제 #2
0
        public List <GardenEntity> PlantsToPlantInThisMonth(GardenEntity.Month thisMonth)
        {
            List <GardenEntity> gardenEntities = new List <GardenEntity>();

            using (SqlCeConnection con = new SqlCeConnection(conString))
            {
                try
                {
                    con.Open();
                }
                catch (SqlCeException ee)
                {
                    //unable to open SqlCe connection
                    SqlCeErrorCollection errorCollection = ee.Errors;
                    StringBuilder        bld             = new StringBuilder();
                    Exception            inner           = ee.InnerException;

                    if (inner != null)
                    {
                        bld.AppendLine("Inner Exception: " + inner.ToString());
                    }

                    foreach (SqlCeError err in errorCollection)
                    {
                        bld.AppendLine(err.ToString());
                    }
                }

                string tmp = ((int)thisMonth).ToString();
                using (SqlCeCommand com = new SqlCeCommand("SELECT * FROM Plant WHERE SeedStartMonths LIKE '% " + tmp + " %'", con))
                {
                    SqlCeDataReader reader = com.ExecuteReader();

                    while (reader.Read())
                    {
                        try
                        {
                            AddReaderToGardenEntityList(gardenEntities, reader);
                        }
                        catch (Exception)
                        {
                            //unable to parse datas
                        }
                    }
                }
            }
            return(gardenEntities);
        }