Exemplo n.º 1
0
        private void Searchbar_Keydown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Down)
            {
                if (listBoxInvoice.SelectedIndex + 1 < listBoxInvoice.Items.Count)
                {
                    listBoxInvoice.SelectedIndex++;
                }
            }
            if (e.Key == Key.Up)
            {
                if (listBoxInvoice.SelectedIndex - 1 >= 0)
                {
                    listBoxInvoice.SelectedIndex--;
                }
            }

            if (e.Key == Key.F6)
            {
                e.Handled = false;
                ((AddInvoice)addInvoiceFrame.Content).UploadInvoicesButton_Click(sender, e);
            }

            if (e.Key == Key.F5)
            {
                e.Handled = false;
                RefreshButton(sender, e);
            }


            if (e.Key == Key.Return || e.Key == Key.Enter)
            {
                int index = listBoxInvoice.SelectedIndex;
                if (index == -1 && listBoxInvoice.Items.Count > 0)
                {
                    index = 0;
                }

                if (listBoxInvoice?.Items?.GetItemAt(index) != null)
                {
                    DataInvoice i = listBoxInvoice.Items.GetItemAt(index) as DataInvoice;
                    Process.Start(i.FilePath);
                }
                else
                {
                    MessageBox.Show("Its null!");
                }
            }
        }
Exemplo n.º 2
0
        public static DataInvoice[] GetAllInvoices()
        {
            List <DataInvoice> invoices = new List <DataInvoice>();

            string[] abns = ABNHelper.GetAllABNs();
            foreach (string abn in abns)
            {
                string dir = abn + @"\Invoices";
                if (Directory.Exists(dir))
                {
                    string[] Invoices = Directory.GetFiles(dir);
                    foreach (string s in Invoices)
                    {
                        DataInvoice invoice = new DataInvoice();
                        invoice.ABN      = ABNHelper.FormatABN(Path.GetFileName(abn));
                        invoice.FilePath = s;
                        invoices.Add(invoice);
                    }
                }
            }

            return(invoices.ToArray());
        }