示例#1
0
文件: Pet.cs 项目: knowbody/fwp
 public Pet(int id, string name, Breed breed, Spieces spieces, Sanctuary sanctuary, int age, int gender, double weight, double bills, DateTime rescueD, string picturePath)
 {
     this.id = id;
     this.name = name;
     this.breed = breed;
     this.spieces = spieces;
     this.sanctuary = sanctuary;
     this.age = age;
     this.gender = gender;
     this.weight = weight;
     this.bills = bills;
     this.rescueD = rescueD;
     this.picturePath = picturePath;
 }
示例#2
0
        // Method that returns a list of Sanctuary objects with the details from the DB
        public static List<Sanctuary> LoadSanctuaries()
        {
            List<Sanctuary> sancuaries = new List<Sanctuary>();
            OleDbConnection myConnection = GetConnection();

            string myQuery = "SELECT * FROM sanctuaries";
            OleDbCommand myCommand = new OleDbCommand(myQuery, myConnection);

            try
            {
                myConnection.Open();
                OleDbDataReader myReader = myCommand.ExecuteReader();
                while (myReader.Read())
                {
                    Sanctuary sanctuary = new Sanctuary(int.Parse(myReader["id"].ToString()), myReader["name"].ToString());
                    sancuaries.Add(sanctuary);
                }
                return sancuaries;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception in DBHandler", ex);
                return null;
            }
            finally
            {
                myConnection.Close();
            }
        }