Exemple #1
0
        void ObjectsItemEndEdit(IEditableObject sender)
        {
            EspecialZoneViewModel UIObject = sender as EspecialZoneViewModel;

            try
            {
                if (UIObject.Name != null)
                {
                    int id = EspecialZonesDataAccess.UpdateZone(UIObject.GetDataObject());
                    if (id != -1)
                    {
                        UIObject.Id = id;
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.StackTrace);
                UIObjects.Remove(UIObject);
                RadWindow.Alert(new DialogParameters
                {
                    Content = MessageUtil.FormatMessage("ERROR.DuplicatedZone", UIObject.Name, UIObject.Name)
                });
            }
        }
Exemple #2
0
 void ObjectsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Remove)
     {
         try
         {
             foreach (object item in e.OldItems)
             {
                 EspecialZoneViewModel UIObject = item as EspecialZoneViewModel;
                 EspecialZonesDataAccess.DeleteZone(UIObject.GetDataObject());
             }
         }
         catch (Exception ex)
         {
             log.Error(ex.StackTrace);
         }
     }
 }
Exemple #3
0
        public EspecialZonesCollectionViewModel GetObjects()
        {
            UIObjects = new EspecialZonesCollectionViewModel();

            List <EspecialZone> dataObjects = EspecialZonesDataAccess.GetZones();

            foreach (EspecialZone dataObject in dataObjects)
            {
                UIObjects.Add(new EspecialZoneViewModel(dataObject));
            }

            if (UIObjects.Count == 0)
            {
                UIObjects.Add(new EspecialZoneViewModel());
            }

            UIObjects.ItemEndEdit       += new ItemEndEditEventHandler(ObjectsItemEndEdit);
            UIObjects.CollectionChanged += new NotifyCollectionChangedEventHandler(ObjectsCollectionChanged);

            return(UIObjects);
        }