Пример #1
0
        private void DeleteUserButton_Click(object sender, RoutedEventArgs e)
        {
            var selectedItem = this.lvAssociations.SelectedItem;

            if (selectedItem != null)
            {
                CarLicencePlateAssociationEntity association = selectedItem as CarLicencePlateAssociationEntity;

                CarLicPlateAssociationService service = new CarLicPlateAssociationService();
                if (MessageBox.Show("Sei sicuro di voler eliminare \"" + association.CarName + " " + association.LicencePlate + " \" ?", "Elimina Associazione", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    if (service.Delete(association) == 0)
                    {
                        MessageBox.Show("cancellato!");
                        this.RefreshData();
                    }
                    else
                    {
                        MessageBox.Show("NON cancellato!");
                    }
                }
                else
                {
                    MessageBox.Show("NON cancellato!");
                }
            }
        }
Пример #2
0
 public void Save()
 {
     if (CheckData())
     {
         CarLicPlateAssociationService service = new CarLicPlateAssociationService();
         if ((this.DataContext as CarLicencePlateAssociationEntity).Id == -1 && !CheckDoppione())
         {
             int id = service.Add(this.DataContext as CarLicencePlateAssociationEntity);
             if (id != -1)
             {
                 disableConcurrentRecords(id);
                 MessageBox.Show("Salvato!");
                 this.DataContext = new CarLicencePlateAssociationEntity();
                 populateLists();
             }
             else
             {
                 MessageBox.Show("Errore durante il salvataggio!");
             }
         }
         else
         {
             if (service.Update(this.DataContext as CarLicencePlateAssociationEntity) == 0)
             {
                 disableConcurrentRecords((this.DataContext as CarLicencePlateAssociationEntity).Id);
                 MessageBox.Show("Salvato!");
             }
             else
             {
                 MessageBox.Show("Errore durante il salvataggio!");
             }
         }
     }
 }
Пример #3
0
        private bool CheckDoppione()
        {
            string carName  = (this.DataContext as CarLicencePlateAssociationEntity).CarName.ToLower();
            string LicPlate = (this.DataContext as CarLicencePlateAssociationEntity).LicencePlate.ToLower();

            CarLicPlateAssociationService           service      = new CarLicPlateAssociationService();
            List <CarLicencePlateAssociationEntity> associations = service.GetAllAssociation();

            if (associations.Any(x => x.CarName.ToLower().Equals(carName) && x.LicencePlate.ToLower().Equals(LicPlate)))
            {
                return(true);
            }

            return(false);
        }