public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     int villageID = (int)value;
     Village village = new Village();
     village.id = villageID;
     village.select();
     return String.Format(@"{0}:", village.name);
 }
 public bool isDirty()
 {
     for (int i = 0; i < villageList.Count; i++)
     {
         var village = villageList[i];
         var villageCopy = new Village();
         villageCopy.id = village.id;
         villageCopy.select();
         var houseList = village.houseList;
         var houseListCopy = villageCopy.getAllRelatedHouse();
         var commonHouse = village.commonHouse;
         var commonHouseCopy = villageCopy.getRelatedCommonHouse();
         if (!commonHouse.compare(commonHouseCopy))
         {
             return true;
         }
         if (houseList.Count != houseListCopy.Count)
         {
             return true;
         }
         for (int j = 0; j < houseList.Count; j++)
         {
             var house = houseList[j];
             var houseCopy = houseListCopy[j];
             if (!house.compare(houseCopy))
             {
                 return true;
             }
         }
     }
     return false;
 }
        public bool isDirty()
        {
            ObservableCollection<Village> tempVillageList = program.getAllRelatedVillage();
            if (villageList.Count != tempVillageList.Count)
                return true;

            foreach (Village village in villageList)
            {
                int villageID = village.id;
                Village villageCopy = new Village();
                villageCopy.id = villageID;
                villageCopy.select();
                if (!village.compare(villageCopy))
                {
                    return true;
                }

                int innerRoadID = village.innerRoad.id;
                InnerRoad innerRoadCopy = new InnerRoad();
                innerRoadCopy.id = innerRoadID;
                innerRoadCopy.select();
                if (!village.innerRoad.compare(innerRoadCopy))
                {
                    return true;
                }
            }

            return false;
        }
Exemplo n.º 4
0
        public ObservableCollection<Village> getAllRelatedVillage()
        {
            if (!isValid(new List<string>() { "prName", "pID" }))
                return null;

            ObservableCollection<Village> villageList = new ObservableCollection<Village>();
            string sqlCommand = String.Format(@"select vID from Village where prID={0}", prID);
            Sql sql = new Sql();
            SqlDataReader reader = sql.selectAllVillageByPrID(sqlCommand);
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    int vID = Int32.Parse(reader[0].ToString());
                    Village village = new Village();
                    village.id = vID;
                    village.select();
                    villageList.Add(village);
                }
                sql.closeConnection();
                return villageList;
            }
            else
            {
                sql.closeConnection();
                return null;
            }
        }