Beispiel #1
0
        public void PopulateInvoices()
        {
            foreach (DataInvoice inv in InvoiceHelper.GetAllInvoices())
            {
                Invoices.Add(inv);
            }

            UniqueCompanies.Clear();
            FilterBox.Items.Clear();
            List <string> companyNames = new List <string>();

            foreach (DataInvoice invoice in Invoices)
            {
                if (!companyNames.Contains(invoice.CompanyName))
                {
                    companyNames.Add(invoice.CompanyName);
                    UniqueCompanies.Add(invoice);

                    CheckBox checkBox = new CheckBox()
                    {
                        DataContext = invoice, Content = invoice.CompanyName
                    };
                    checkBox.Checked   += CheckBox_Checked;
                    checkBox.Unchecked += CheckBox_Checked;
                    FilterBox.Items.Add(checkBox);
                }
            }
        }
Beispiel #2
0
        static void TryABN(ProcessedInvoice inv)
        {
            if (String.IsNullOrEmpty(inv.ABN))
            {
                PromptTextDialog promptTextDialog = new PromptTextDialog();
                promptTextDialog.SetCaption("Can't find ABN, please specify $$");
                promptTextDialog.ShowDialog();
                inv.ABN = promptTextDialog.Text;
            }


            if (!ABNHelper.DoesABNExist(inv.ABN))
            {
                string text     = $"ABN Not found: {inv.ABN}, would you like to create a new folder for {inv.ABN}?";
                var    response = MessageBox.Show(text, "ABN not found", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes);

                if (response == MessageBoxResult.Yes)
                {
                    NewABN newABN = new NewABN();
                    newABN.InvoiceFile = inv.FilePath;
                    newABN.DataContext = new ABNData()
                    {
                        ABN = inv.ABN, Email = inv.Email, Phone = inv.Phone, CompanyName = inv.CompanyName
                    };
                    newABN.Show();
                }
            }

            string path  = ABNHelper.GetDirectory(inv.ABN);
            string iPath = path + @"\Invoices\";


            ABNHelper.CreateDirectoryFromPath(iPath);

            string tPath = iPath + System.IO.Path.GetFileName(inv.FilePath);

            if (!File.Exists(tPath))
            {
                File.Copy(inv.FilePath, tPath, false);
            }

            InvoiceHelper.OnInvoiceAdded();
        }
Beispiel #3
0
        void PopulateInvoices()
        {
            CompanyInvoices = new ObservableCollection <DataInvoice>();
            if (DataContext == null)
            {
                return;
            }

            foreach (DataInvoice inv in InvoiceHelper.GetAllInvoices())
            {
                if (((DataCompany)DataContext).CompanyName == null)
                {
                    return;
                }

                if (inv.CompanyName == ((DataCompany)DataContext).CompanyName)
                {
                    CompanyInvoices.Add(inv);
                }
            }
            ListViewInvoices.ItemsSource = CompanyInvoices;

            CollectionViewSource.GetDefaultView(ListViewInvoices.ItemsSource).Refresh();
        }