コード例 #1
0
        public void SearchClient(ActionExecutionContext context, string phrase)
        {
            var keyArgs = context.EventArgs as KeyEventArgs;

            if (keyArgs != null && keyArgs.Key == Key.Enter)
            {
                _currentSearchClientPhrase = phrase;
                Task.Run(() =>
                {
                    if (phrase != _currentSearchClientPhrase)
                    {
                        return;
                    }

                    if (String.IsNullOrEmpty(phrase))
                    {
                        int id         = SelectedClient != null ? SelectedClient.Id : -1;
                        Clients        = new BindableCollection <Client>(AllClients);
                        SelectedClient = Clients.FirstOrDefault(c => c.Id == id);
                    }
                    else
                    {
                        Clients = new BindableCollection <Client>(AllClients.Where(c => c.FullName.ContainsAny(phrase)));
                    }
                });
            }
        }
コード例 #2
0
ファイル: ViewModel.cs プロジェクト: PalinaSh/Jewelry-shop
 public void GetSurname(string sn)
 {
     Clients.Clear();
     if (sn == "")
     {
         GetAllPerson();
     }
     else
     {
         Client[] cl = AllClients.Where(i => i.Surname == sn).ToArray <Client>();
         foreach (Client c in cl)
         {
             Clients.Add(c);
         }
     }
 }
コード例 #3
0
ファイル: ViewModel.cs プロジェクト: PalinaSh/Jewelry-shop
 public void GetID(string id)
 {
     //ObservableCollection<Jewelry> jewelries = new ObservableCollection<Jewelry>();
     //foreach()
     Clients.Clear();
     try
     {
         Client[] cl = AllClients.Where(i => i.ID == long.Parse(id)).ToArray <Client>();
         foreach (Client c in cl)
         {
             Clients.Add(c);
         }
     }
     catch (FormatException e)
     {
         GetAllPerson();
     }
 }
コード例 #4
0
        public async void SearchClient()
        {
            ObservableCollection <Client> searchedClients = new ObservableCollection <Client>(db.Clients.Where(i => i.CompanyId == SelectedCompany.CompanyId));

            await Task.Run(() =>
            {
                if (SearchBy == "Name")
                {
                    searchedClients = new ObservableCollection <Client>(db.Clients.Where(i => i.Name.ToLower() == SearchString.ToLower()));
                }
                else if (SearchBy == "Email")
                {
                    searchedClients = new ObservableCollection <Client>(AllClients.Where(i => i.Email.ToLower() == SearchString.ToLower()));
                }
            });

            AllClients = searchedClients;
        }
コード例 #5
0
        private void deleteInvoice_E(object obj)
        {
            if (MessageBox.Show("Are you sure you want to delete the selected Invoice", "Confirm delete", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                try
                {
                    if (selectedInvoiceId == null || selectedInvoiceId < 0)
                    {
                        return;
                    }
                    if (invoiceFor == "Clients")
                    {
                        ClientInvoice iv = db.ClientInvoices.Find(selectedInvoiceId);

                        db.Clients.Find(CurrentSelectedId).Invoices.Remove(iv);
                        db.ClientInvoices.Remove(iv);

                        AllClients.Where(i => i.ClientId == CurrentSelectedId).First().Invoices.Remove(iv);
                    }

                    else if (invoiceFor == "Suppliers")
                    {
                        SupplierInvoice iv = db.SupplierInvoices.Find(selectedInvoiceId);

                        db.Suppliers.Find(CurrentSelectedId).Invoices.Remove(iv);
                        db.SupplierInvoices.Remove(iv);

                        AllSuppliers.Where(i => i.SupplierId == CurrentSelectedId).First().Invoices.Remove(iv);
                    }


                    db.SaveChanges();
                    refreshCs_E(null);
                    selectedInvoiceId = -1;
                }
                catch
                {
                    MessageBox.Show("Unable to Delete Invoice", "Deletion Failed", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
        }