Exemplo n.º 1
0
        public FuelContractsDataGrid(EntitiesCollections entitiesCollections) : base(entitiesCollections)
        {
            InitializeComponent();

            FuelContractsCollectionViewModel items = ItemsSource as FuelContractsCollectionViewModel;

            if (items.Count == 1)
            {
                FuelContractViewModel item = items[0] as FuelContractViewModel;
                if (item.Name == null)
                {
                    CurrentColumn         = NameColumn;
                    NameColumn.IsReadOnly = false;
                }
            }
        }
Exemplo n.º 2
0
 void ObjectsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Remove)
     {
         try
         {
             foreach (object item in e.OldItems)
             {
                 FuelContractViewModel UIObject = item as FuelContractViewModel;
                 FuelContractsDataAccess.DeleteObject(UIObject.GetDataObject());
             }
         }
         catch (Exception ex)
         {
             log.Error(ex.StackTrace);
         }
     }
 }
Exemplo n.º 3
0
        void ObjectsItemEndEdit(IEditableObject sender)
        {
            FuelContractViewModel UIObject = sender as FuelContractViewModel;

            try
            {
                if (UIObject.Name != null)
                {
                    int id = FuelContractsDataAccess.UpdateObject(UIObject.GetDataObject());
                    if (id != -1)
                    {
                        UIObject.Id = id;
                    }
                }
            }
            catch
            {
                UIObjects.Remove(UIObject);
                RadWindow.Alert(new DialogParameters
                {
                    Content = MessageUtil.FormatMessage("ERROR.DuplicatedEntryName", UIObject.Name)
                });
            }
        }