ImportBillWindow.xaml.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System.IO;
  2. using System.Linq;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using Comal.Classes;
  6. using InABox.Clients;
  7. using InABox.Core;
  8. using InABox.DynamicGrid;
  9. using InABox.Wpf;
  10. namespace PRSDesktop
  11. {
  12. /// <summary>
  13. /// Interaction logic for ImportBillWindow.xaml
  14. /// </summary>
  15. public partial class ImportBillWindow : ThemableWindow
  16. {
  17. private readonly Bill _bill;
  18. private BillDocument[] _documents;
  19. public ImportBillWindow(Bill bill)
  20. {
  21. _bill = bill;
  22. InitializeComponent();
  23. new Client<BillDocument>().Load(
  24. new Filter<BillDocument>(x => x.EntityLink.ID).IsEqualTo(_bill.ID),
  25. null,
  26. CoreRange.All,
  27. (o, e) =>
  28. {
  29. Dispatcher.Invoke(() =>
  30. {
  31. _documents = o;
  32. ReloadDocuments();
  33. });
  34. }
  35. );
  36. }
  37. private void ReloadDocuments()
  38. {
  39. string[] exts = { ".pdf", ".png", ".jpg", ".jpeg", ".bmp" };
  40. foreach (var document in _documents)
  41. {
  42. var ext = Path.GetExtension(document.DocumentLink.FileName).ToLower();
  43. if (exts.Contains(ext))
  44. {
  45. var tab = new DynamicTabItem { Header = Path.GetFileName(document.DocumentLink.FileName) };
  46. Documents.Items.Add(tab);
  47. }
  48. }
  49. }
  50. private void Documents_SelectionChanged(object sender, SelectionChangedEventArgs e)
  51. {
  52. }
  53. }
  54. }