コード例 #1
0
        private void EditClient()
        {
            ManagerValidation VM = new ManagerValidation();
            bool correctForm     = VM.ClientValidation(EditFirstName, EditLastName, EditCompanyName, EditNIP, EditREGON);

            if (correctForm)
            {
                MySelectedClient.FirstName = EditFirstName;
                MySelectedClient.LastName  = EditLastName;

                MySelectedClient.CompanyName = EditCompanyName;

                MySelectedClient.NIP             = EditNIP;
                MySelectedClient.REGON           = EditREGON;
                MySelectedClient.Street          = EditStreet;
                MySelectedClient.HouseNumber     = EditHouseNumber;
                MySelectedClient.ApartmentNumber = EditApartmentNumber;
                MySelectedClient.Postcode        = EditPostcode;
                MySelectedClient.City            = EditCity;

                dbContext.SaveChanges();


                _FilteredClients = new ObservableCollection <Client>(dbContext.Client);
                _Clients         = new ObservableCollection <Client>(dbContext.Client);

                RaisePropertyChanged("FilteredClients");
                RaisePropertyChanged("Clients");

                clear();

                ErrorMessage er = new ErrorMessage("Client edit successfully!");
                er.ShowDialog();
            }
        }
コード例 #2
0
        private void AddClient()
        {
            ManagerValidation VM = new ManagerValidation();
            bool correctForm     = VM.ClientValidation(FirstName, LastName, CompanyName, NIP, REGON);

            if (correctForm)
            {
                Client client;

                client = AddClientObject();

                dbContext.Client.Add(client);
                dbContext.SaveChanges();


                _FilteredClients = new ObservableCollection <Client>(dbContext.Client);
                _Clients         = new ObservableCollection <Client>(dbContext.Client);

                RaisePropertyChanged("FilteredClients");
                RaisePropertyChanged("Clients");

                clear();

                ErrorMessage er = new ErrorMessage("Client created successfully!");
                er.ShowDialog();
            }
        }