diff --git a/BeWo/DebugConfig.cs b/BeWo/DebugConfig.cs index ab638d99a..dfb16be26 100644 --- a/BeWo/DebugConfig.cs +++ b/BeWo/DebugConfig.cs @@ -161,9 +161,10 @@ namespace BeWo AutoLogin = true, SelectView = UIContext.Finance, SelectIndex = 7, - //Username = "m1", - //Password = "bewobewo", - //Profilename = "5000000000" + DefaultLoginUsername = "m1", + DefaultLoginPassword = "bewobewo", + DefaultProfilename = "5000000000", + EnableAutoRemoteDebugging = true }); return name2config; diff --git a/BeWo/ServiceProxy/GeneratedOperationsEnhancedService.cs b/BeWo/ServiceProxy/GeneratedOperationsEnhancedService.cs index 17311477e..289c4c0ed 100644 --- a/BeWo/ServiceProxy/GeneratedOperationsEnhancedService.cs +++ b/BeWo/ServiceProxy/GeneratedOperationsEnhancedService.cs @@ -17,6 +17,12 @@ namespace BeWo.ServiceProxy [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/HelloWorld", ReplyAction="http://tempuri.org/IOperationsEnhancedService/HelloWorldResponse")] [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsEnhancedService/HelloWorldBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] void HelloWorld(); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/CreateXRechnung", ReplyAction="http://tempuri.org/IOperationsEnhancedService/CreateXRechnungResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsEnhancedService/CreateXRechnungBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BeWo.ServiceProxy.BeWoFault))] + [System.ServiceModel.ServiceKnownTypeAttribute(typeof(BeWo.ServiceProxy.BeWoFaultType))] + object CreateXRechnung(long invoice_base_oid, int report_type, string report_url); } [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] @@ -57,5 +63,10 @@ namespace BeWo.ServiceProxy { base.Channel.HelloWorld(); } + + public object CreateXRechnung(long invoice_base_oid, int report_type, string report_url) + { + return base.Channel.CreateXRechnung(invoice_base_oid, report_type, report_url); + } } } diff --git a/BeWo/Services/BeWoControlFactory.cs b/BeWo/Services/BeWoControlFactory.cs index efe57308d..bbaa77f59 100644 --- a/BeWo/Services/BeWoControlFactory.cs +++ b/BeWo/Services/BeWoControlFactory.cs @@ -1,5 +1,6 @@ using BeWo.View.Controls; using BeWo.View.Detail.AI; +using BeWo.ViewModel; using BS.Shared; using System; using System.Collections.Generic; @@ -36,6 +37,24 @@ namespace BeWo.Services return control; } + public TextViewer GetTextViewer(string text) + { + var textViewer = new TextViewer(); + + textViewer.Text = text; + + return textViewer; + } + + public GkvAbrechnungDetailControl GetGkvAbrechnungDetailControl(GkvAbrechnungVM vm) + { + var control = new GkvAbrechnungDetailControl(vm); + + return control; + } + + + private string getStyleString(UIContext uIContext) { switch (uIContext) { diff --git a/BeWo/Services/BeWoWindowFactory.cs b/BeWo/Services/BeWoWindowFactory.cs index fa097fc88..53191d9c9 100644 --- a/BeWo/Services/BeWoWindowFactory.cs +++ b/BeWo/Services/BeWoWindowFactory.cs @@ -1,5 +1,6 @@ using BeWo.View.Detail.AI; using BeWo.View.Windows; +using BeWo.ViewModel; using BS.Shared; using System; using System.Collections.Generic; @@ -64,5 +65,10 @@ namespace BeWo.Services return "default"; } + + public string GetGkvTitle(GkvAbrechnungVM vm) + { + return "GKV-Abrechnung Nr. " + vm.GkvAbrechnungOid; + } } } diff --git a/BeWo/Services/BeWoWindowService.cs b/BeWo/Services/BeWoWindowService.cs index 295de509d..261855418 100644 --- a/BeWo/Services/BeWoWindowService.cs +++ b/BeWo/Services/BeWoWindowService.cs @@ -1,4 +1,7 @@ -using BeWo.View.Windows; +using BeWo.View.Controls; +using BeWo.View; +using BeWo.View.Windows; +using BeWo.ViewModel; using BS.Shared; using System; using System.Collections.Generic; @@ -10,6 +13,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; +using System.ComponentModel; namespace BeWo.Services { @@ -51,10 +55,29 @@ namespace BeWo.Services public void ShowERechnungModalViewWindow(MemoryStream pdf) { ShowModalViewWindow( - "E-Rechnung", + "E-Rechnung", cf => cf.GetPdfViewer(pdf)); } + public void ShowTextViewerWindow(string title, string text, double height, double width) + { + ShowWindowDialog( + title, + cf => cf.GetTextViewer(text), + height, width); + } + + public void ShowGkvAbrechnungDetailWindow(GkvAbrechnungVM vm, CancelEventHandler cancelEvent, double height, double width) + { + // Kleiner Hack + // - Ggf WindowFactory kapselt Zuorgnudn von Control zu Window + var title = _windowFactory.GetGkvTitle(vm); + var control = _controlFactory.GetGkvAbrechnungDetailControl(vm); + var window = _windowFactory.GetAnimatedBeWoWindow(title, control, height, width); + window.Closing += cancelEvent; + window.ShowDialog(); + } + private void ShowWindow(Func getTitle, Func getControl, double height, double width) => ShowWindow(getTitle(_windowFactory), getControl, height, width); private void ShowWindowDialog(Func getTitle, Func getControl, double height, double width) @@ -93,5 +116,9 @@ namespace BeWo.Services window.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => BeWoApp.MainControl.CloseCurrentPopUp())); BeWoApp.MainControl.ShowControlAsModalPopup(window); } + public void ShowTest(string str) + { + throw new NotImplementedException(); + } } } diff --git a/BeWo/Services/IControlFactory.cs b/BeWo/Services/IControlFactory.cs index bcb836b63..74e27f884 100644 --- a/BeWo/Services/IControlFactory.cs +++ b/BeWo/Services/IControlFactory.cs @@ -1,4 +1,5 @@ using BeWo.View.Controls; +using BeWo.ViewModel; using BS.Shared; using System; using System.Collections.Generic; @@ -17,5 +18,9 @@ namespace BeWo.Services PdfViewer GetPdfViewer(MemoryStream ms); PdfViewer GetPdfViewer(byte[] bytes); + + TextViewer GetTextViewer(string text); + + GkvAbrechnungDetailControl GetGkvAbrechnungDetailControl(GkvAbrechnungVM vm); } } diff --git a/BeWo/Services/IWindowFactory.cs b/BeWo/Services/IWindowFactory.cs index 2cfe53f31..e5a11d74e 100644 --- a/BeWo/Services/IWindowFactory.cs +++ b/BeWo/Services/IWindowFactory.cs @@ -1,4 +1,5 @@ using BeWo.View.Windows; +using BeWo.ViewModel; using BS.Shared; using System; using System.Collections.Generic; @@ -16,5 +17,6 @@ namespace BeWo.Services Control GetGenericModalViewWindow(string title, Control control, double? height = null, double? width = null); string GetAiTitle(UIContext context); + string GetGkvTitle(GkvAbrechnungVM vm); } } diff --git a/BeWo/Services/IWindowService.cs b/BeWo/Services/IWindowService.cs index 7e9c839aa..b2cd66951 100644 --- a/BeWo/Services/IWindowService.cs +++ b/BeWo/Services/IWindowService.cs @@ -1,6 +1,8 @@ -using BS.Shared; +using BeWo.ViewModel; +using BS.Shared; using System; using System.Collections.Generic; +using System.ComponentModel; using System.IO; using System.Linq; using System.Text; @@ -16,5 +18,9 @@ namespace BeWo.Services void ShowAiConversationModalViewWindow(UIContext uIContext, Dictionary bewoObjects, long? reference_oid = null, double height = 600, double width = 1200); void ShowERechnungModalViewWindow(MemoryStream pdf); + + void ShowTextViewerWindow(string title, string text, double height = 900, double width = 600); + + void ShowGkvAbrechnungDetailWindow(GkvAbrechnungVM vm, CancelEventHandler cancelEvent, double height = 900, double width = 600); } } diff --git a/BeWo/View/Controls/GkvAbrechnungDetailControl.xaml.cs b/BeWo/View/Controls/GkvAbrechnungDetailControl.xaml.cs index 325800574..a95163779 100644 --- a/BeWo/View/Controls/GkvAbrechnungDetailControl.xaml.cs +++ b/BeWo/View/Controls/GkvAbrechnungDetailControl.xaml.cs @@ -30,16 +30,12 @@ namespace BeWo.View.Controls { public GkvAbrechnungVM GkvAbrechnungVM { get; set; } - public Window Window { get; private set; } - - public GkvAbrechnungDetailControl(GkvAbrechnungVM vm, Window window) + public GkvAbrechnungDetailControl(GkvAbrechnungVM vm) { InitializeComponent(); GkvAbrechnungVM = vm; DataContext = vm; - - Window = window; } private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e) @@ -67,7 +63,7 @@ namespace BeWo.View.Controls this.DoGkvAccountingServiceAsync( service => service.GetProtokollRawDataString(oid, BS.Shared.GkvRawDataType.Auftragsdatei), - callback => ShowTextViewer("Auftragsdatei", callback)); + callback => BeWoApp.MainControl.WindowService.ShowTextViewerWindow("Auftragsdatei", callback)); } private void btn_nutzdatendatei_Click(object sender, RoutedEventArgs e) @@ -78,16 +74,7 @@ namespace BeWo.View.Controls this.DoGkvAccountingServiceAsync( service => service.GetProtokollRawDataString(oid, BS.Shared.GkvRawDataType.Nutzdatendatei), - callback => ShowTextViewer("Nutzdatendatei", callback)); - } - - private void ShowTextViewer(string title, string text) - { - var window = BeWoWindowBuilder.GetTextViewer(title, text); - - window.Owner = Window; - - window.ShowDialog(); + callback => BeWoApp.MainControl.WindowService.ShowTextViewerWindow("Nutzdatendatei", callback)); } private void gridView_CellValueChanging(object sender, CellValueChangedEventArgs e) diff --git a/BeWo/View/Detail/Accounting/GkvAbrechnungOverview.xaml.cs b/BeWo/View/Detail/Accounting/GkvAbrechnungOverview.xaml.cs index 2f8cec288..2bfee5680 100644 --- a/BeWo/View/Detail/Accounting/GkvAbrechnungOverview.xaml.cs +++ b/BeWo/View/Detail/Accounting/GkvAbrechnungOverview.xaml.cs @@ -1,6 +1,7 @@ using System; using System.Activities.Statements; using System.Collections.Generic; +using System.ComponentModel; using System.IO; using System.Linq; using System.Security.Cryptography; @@ -215,11 +216,7 @@ namespace BeWo.View.Detail.Accounting { var vm = this.datagrid_gkvAbrechnungen.GetCurrentValue(); - var window = BeWoWindowBuilder.GetGkvAbrechnungDetailWindow(vm); - - window.Closing += Detail_Window_Closing; - - window.ShowDialog(); + BeWoApp.MainControl.WindowService.ShowGkvAbrechnungDetailWindow(vm, Detail_Window_Closing); } private void Detail_Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) diff --git a/BeWo/View/Detail/Accounting/InvoiceOverview.xaml.cs b/BeWo/View/Detail/Accounting/InvoiceOverview.xaml.cs index 7d7c08ee1..f847146a6 100644 --- a/BeWo/View/Detail/Accounting/InvoiceOverview.xaml.cs +++ b/BeWo/View/Detail/Accounting/InvoiceOverview.xaml.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Security.Policy; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; @@ -11,6 +12,7 @@ using System.Windows.Threading; using BeWo.Core; using BeWo.ServiceProxy; using BeWo.View.Controls; +using BeWo.View.Windows; using BeWo.ViewModel; using BeWo.ViewModel.ListViewModel; @@ -26,84 +28,84 @@ using Newtonsoft.Json; namespace BeWo.View.Detail.Accounting { - public partial class InvoiceOverview : BeWoView - { - private readonly EquityInvoiceItemEditView _EquityInvoiceItemEditView; + public partial class InvoiceOverview : BeWoView + { + private readonly EquityInvoiceItemEditView _EquityInvoiceItemEditView; - private readonly GeneralInvoiceItemEditView _GeneralInvoiceItemEditView; + private readonly GeneralInvoiceItemEditView _GeneralInvoiceItemEditView; - private readonly SettlementInvoiceItemEditView _SettlementInvoiceItemEditView; + private readonly SettlementInvoiceItemEditView _SettlementInvoiceItemEditView; - private readonly SettlementInvoiceItemEditView2 _SettlementInvoiceItemEditView2; + private readonly SettlementInvoiceItemEditView2 _SettlementInvoiceItemEditView2; - private readonly ServiceInvoiceItemEditView _ServiceInvoiceItemEditView; + private readonly ServiceInvoiceItemEditView _ServiceInvoiceItemEditView; - private InvoiceBaseListVM _Viewmodel; + private InvoiceBaseListVM _Viewmodel; - private bool mIgnoreCheckChanges = false; + private bool mIgnoreCheckChanges = false; - public InvoiceOverview(InvoiceBaseListVM vm) - { - this.InitializeComponent(); - this.ViewModel = vm; - this.DownloadLinkEngine = new DownloadLinkEngine(); - this.linkExcelExport.NavigateUri = this.DownloadLinkEngine.GenerateNewExcelLink(); - this.linkPdfExport.NavigateUri = new Uri("http://www.ownsoft.de"); + public InvoiceOverview(InvoiceBaseListVM vm) + { + this.InitializeComponent(); + this.ViewModel = vm; + this.DownloadLinkEngine = new DownloadLinkEngine(); + this.linkExcelExport.NavigateUri = this.DownloadLinkEngine.GenerateNewExcelLink(); + this.linkPdfExport.NavigateUri = new Uri("http://www.ownsoft.de"); - this.gridView.ShownEditor += this.gridView_ShownEditor; - //this.gridView.HiddenEditor += new EditorEventHandler(gridView_HiddenEditor); - this._EquityInvoiceItemEditView = new EquityInvoiceItemEditView(); - this._GeneralInvoiceItemEditView = new GeneralInvoiceItemEditView(); - this._SettlementInvoiceItemEditView = new SettlementInvoiceItemEditView(); - this._SettlementInvoiceItemEditView2 = new SettlementInvoiceItemEditView2(); - this._ServiceInvoiceItemEditView = new ServiceInvoiceItemEditView(); + this.gridView.ShownEditor += this.gridView_ShownEditor; + //this.gridView.HiddenEditor += new EditorEventHandler(gridView_HiddenEditor); + this._EquityInvoiceItemEditView = new EquityInvoiceItemEditView(); + this._GeneralInvoiceItemEditView = new GeneralInvoiceItemEditView(); + this._SettlementInvoiceItemEditView = new SettlementInvoiceItemEditView(); + this._SettlementInvoiceItemEditView2 = new SettlementInvoiceItemEditView2(); + this._ServiceInvoiceItemEditView = new ServiceInvoiceItemEditView(); - this.ViewModel.DateTimeSpanFilter = this.yearMonthFilter.FilterSpan; - RefreshInvoiceList(); + this.ViewModel.DateTimeSpanFilter = this.yearMonthFilter.FilterSpan; + RefreshInvoiceList(); - CheckRights(); + CheckRights(); - this._EquityInvoiceItemEditView.EditingFinished += (s, e) => - { - this.MainControl.CloseCurrentPopUp(); - ServiceFacade.DoAccountingServiceAsync(se => se.LoadInvoiceBaseByOid(this._EquityInvoiceItemEditView.ViewModel.DataContract.InvoiceBaseOid.Value), cb => this.RefreshItemInList(cb)); - }; + this._EquityInvoiceItemEditView.EditingFinished += (s, e) => + { + this.MainControl.CloseCurrentPopUp(); + ServiceFacade.DoAccountingServiceAsync(se => se.LoadInvoiceBaseByOid(this._EquityInvoiceItemEditView.ViewModel.DataContract.InvoiceBaseOid.Value), cb => this.RefreshItemInList(cb)); + }; - this._GeneralInvoiceItemEditView.EditingFinished += (s, e) => - { - this.MainControl.CloseCurrentPopUp(); - ServiceFacade.DoAccountingServiceAsync(se => se.LoadInvoiceBaseByOid(this._GeneralInvoiceItemEditView.ViewModel.DataContract.InvoiceBaseOid.Value), cb => this.RefreshItemInList(cb)); - }; + this._GeneralInvoiceItemEditView.EditingFinished += (s, e) => + { + this.MainControl.CloseCurrentPopUp(); + ServiceFacade.DoAccountingServiceAsync(se => se.LoadInvoiceBaseByOid(this._GeneralInvoiceItemEditView.ViewModel.DataContract.InvoiceBaseOid.Value), cb => this.RefreshItemInList(cb)); + }; - this._SettlementInvoiceItemEditView.EditingFinished += (s, e) => - { - this.MainControl.CloseCurrentPopUp(); - ServiceFacade.DoAccountingServiceAsync(se => se.LoadInvoiceBaseByOid(this._SettlementInvoiceItemEditView.ViewModel.DataContract.InvoiceBaseOid.Value), cb => this.RefreshItemInList(cb)); - }; + this._SettlementInvoiceItemEditView.EditingFinished += (s, e) => + { + this.MainControl.CloseCurrentPopUp(); + ServiceFacade.DoAccountingServiceAsync(se => se.LoadInvoiceBaseByOid(this._SettlementInvoiceItemEditView.ViewModel.DataContract.InvoiceBaseOid.Value), cb => this.RefreshItemInList(cb)); + }; - this._SettlementInvoiceItemEditView2.EditingFinished += (s, e) => - { - this.MainControl.CloseCurrentPopUp(); - ServiceFacade.DoAccountingServiceAsync(se => se.LoadInvoiceBaseByOid(this._SettlementInvoiceItemEditView2.ViewModel.DataContract.InvoiceBaseOid.Value), cb => this.RefreshItemInList(cb)); - }; + this._SettlementInvoiceItemEditView2.EditingFinished += (s, e) => + { + this.MainControl.CloseCurrentPopUp(); + ServiceFacade.DoAccountingServiceAsync(se => se.LoadInvoiceBaseByOid(this._SettlementInvoiceItemEditView2.ViewModel.DataContract.InvoiceBaseOid.Value), cb => this.RefreshItemInList(cb)); + }; - this._ServiceInvoiceItemEditView.EditingFinished += (s, e) => - { - this.MainControl.CloseCurrentPopUp(); - ServiceFacade.DoAccountingServiceAsync(se => se.LoadInvoiceBaseByOid(this._ServiceInvoiceItemEditView.ViewModel.DataContract.InvoiceBase.InvoiceBaseOid.Value), cb => this.RefreshItemInList(cb)); - }; - } + this._ServiceInvoiceItemEditView.EditingFinished += (s, e) => + { + this.MainControl.CloseCurrentPopUp(); + ServiceFacade.DoAccountingServiceAsync(se => se.LoadInvoiceBaseByOid(this._ServiceInvoiceItemEditView.ViewModel.DataContract.InvoiceBase.InvoiceBaseOid.Value), cb => this.RefreshItemInList(cb)); + }; + } - private void CheckRights() - { - if (!BeWoApp.AppSettings.AllowStorno) - { - ColumnButtons.MinWidth = 67; - } - - } + private void CheckRights() + { + if (!BeWoApp.AppSettings.AllowStorno) + { + ColumnButtons.MinWidth = 67; + } - private void RefreshInvoiceList() + } + + private void RefreshInvoiceList() { DateTime? start = null; DateTime? end = null; @@ -112,534 +114,550 @@ namespace BeWo.View.Detail.Accounting start = ViewModel.DateTimeSpanFilter.StartDate; end = ViewModel.DateTimeSpanFilter.EndDate; } - bool filterByInvoiceDate = radioFilterByInvoiceDate.IsChecked.Value; - + bool filterByInvoiceDate = radioFilterByInvoiceDate.IsChecked.Value; + ServiceFacade.DoAccountingServiceAsync(s => s.GetInvoiceBases2(start, end, filterByInvoiceDate), UpdateInvoiceList); - } + } - private void UpdateInvoiceList(IList dcList) - { - this.Dispatcher.BeginInvoke( - DispatcherPriority.Normal, - (Action)delegate - { - ViewModel.UpdateList(dcList); - this.gridView.BestFitColumns(); - }); - } + private void UpdateInvoiceList(IList dcList) + { + this.Dispatcher.BeginInvoke( + DispatcherPriority.Normal, + (Action)delegate + { + ViewModel.UpdateList(dcList); + this.gridView.BestFitColumns(); + }); + } - public DownloadLinkEngine DownloadLinkEngine { get; set; } + public DownloadLinkEngine DownloadLinkEngine { get; set; } - private InvoiceBaseListVM ViewModel - { - get - { - return this._Viewmodel; - } + private InvoiceBaseListVM ViewModel + { + get + { + return this._Viewmodel; + } - set - { - this.DataContext = value; - this._Viewmodel = value; - } - } + set + { + this.DataContext = value; + this._Viewmodel = value; + } + } - private void RefreshItemInList(InvoiceBaseDC cb) - { - this.Dispatch( - delegate - { - var old = this.ViewModel.VMList.Single(i => i.DataContract.InvoiceBaseOid.Equals(cb.InvoiceBaseOid)); - var lNew = new InvoiceBaseVM(cb); + private void RefreshItemInList(InvoiceBaseDC cb) + { + this.Dispatch( + delegate + { + var old = this.ViewModel.VMList.Single(i => i.DataContract.InvoiceBaseOid.Equals(cb.InvoiceBaseOid)); + var lNew = new InvoiceBaseVM(cb); - this.ViewModel.VMList.Remove(old); - this.ViewModel.VMList.Add(lNew); - this.datagrid_invoices.RefreshData(); - this.gridView.FocusedRow = lNew; - }); - } + this.ViewModel.VMList.Remove(old); + this.ViewModel.VMList.Add(lNew); + this.datagrid_invoices.RefreshData(); + this.gridView.FocusedRow = lNew; + }); + } - private void YearMonthFilter_FilterSpanChanged(object sender, EventArgs e) - { - mIgnoreCheckChanges = true; - this.ViewModel.DateTimeSpanFilter = e.Data; + private void YearMonthFilter_FilterSpanChanged(object sender, EventArgs e) + { + mIgnoreCheckChanges = true; + this.ViewModel.DateTimeSpanFilter = e.Data; RefreshInvoiceList(); - mIgnoreCheckChanges = false; - } + mIgnoreCheckChanges = false; + } - private void btn_delete_Click(object sender, RoutedEventArgs e) - { - var vm = this.datagrid_invoices.GetCurrentValue(); - if (vm.IsSent && !BeWoApp.LoggedOnUser.HasRight(UserRightType.FinanzenRechnungenNachVersandBearbeiten)) - { - MessageBox.Show(Translator.Translate("Sie besitzen nicht das Recht Rechnungen nach Versand zu bearbeiten. Bitte wenden Sie sich an den Administrator!"), "BeWoPlaner", MessageBoxButton.OK, MessageBoxImage.Exclamation); - return; - } - mIgnoreCheckChanges = true; + private void btn_delete_Click(object sender, RoutedEventArgs e) + { + var vm = this.datagrid_invoices.GetCurrentValue(); + if (vm.IsSent && !BeWoApp.LoggedOnUser.HasRight(UserRightType.FinanzenRechnungenNachVersandBearbeiten)) + { + MessageBox.Show(Translator.Translate("Sie besitzen nicht das Recht Rechnungen nach Versand zu bearbeiten. Bitte wenden Sie sich an den Administrator!"), "BeWoPlaner", MessageBoxButton.OK, MessageBoxImage.Exclamation); + return; + } + mIgnoreCheckChanges = true; - if (MessageBox.Show("Sind Sie sicher, dass Sie die gewählte Rechnung löschen möchten?", "Rechnung löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) - { - if (vm.DataContract.Type == InvoiceType.Settlement) - { - this.ViewModel.VMList.Remove(vm); - ServiceFacade.DoAccountingServiceAsync(s => s.GetSettlementByInvoiceBaseOid(vm.DataContract.InvoiceBaseOid.Value), cb => ServiceFacade.DoAccountingServiceAsync(s1 => s1.DeactivateSettlementInvoice(new[] { cb }.ToList()))); - } - else - { - this.ViewModel.VMList.Remove(vm); - ServiceFacade.DoAccountingServiceAsync(s => s.DeactivateInvoiceBases(new[] { vm.DataContract }.ToList())); - } - } - mIgnoreCheckChanges = false; - } + if (MessageBox.Show("Sind Sie sicher, dass Sie die gewählte Rechnung löschen möchten?", "Rechnung löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) + { + if (vm.DataContract.Type == InvoiceType.Settlement) + { + this.ViewModel.VMList.Remove(vm); + ServiceFacade.DoAccountingServiceAsync(s => s.GetSettlementByInvoiceBaseOid(vm.DataContract.InvoiceBaseOid.Value), cb => ServiceFacade.DoAccountingServiceAsync(s1 => s1.DeactivateSettlementInvoice(new[] { cb }.ToList()))); + } + else + { + this.ViewModel.VMList.Remove(vm); + ServiceFacade.DoAccountingServiceAsync(s => s.DeactivateInvoiceBases(new[] { vm.DataContract }.ToList())); + } + } + mIgnoreCheckChanges = false; + } - private void btn_storno_Click(object sender, RoutedEventArgs e) - { - mIgnoreCheckChanges = true; - var vm = this.datagrid_invoices.GetCurrentValue(); + private void btn_storno_Click(object sender, RoutedEventArgs e) + { + mIgnoreCheckChanges = true; + var vm = this.datagrid_invoices.GetCurrentValue(); - if (MessageBox.Show("Sind Sie sicher, dass Sie die gewählte Rechnung stornieren möchten?", "Rechnung stornieren", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) - { - ServiceFacade.DoAccountingServiceAsync(s => s.StorniereInvoiceBases(new[] { vm.DataContract }.ToList()), - () => this.Dispatch( - delegate - { - RefreshInvoiceList(); - })); - } + if (MessageBox.Show("Sind Sie sicher, dass Sie die gewählte Rechnung stornieren möchten?", "Rechnung stornieren", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) + { + ServiceFacade.DoAccountingServiceAsync(s => s.StorniereInvoiceBases(new[] { vm.DataContract }.ToList()), + () => this.Dispatch( + delegate + { + RefreshInvoiceList(); + })); + } - mIgnoreCheckChanges = false; - } + mIgnoreCheckChanges = false; + } - private void btn_edit_Click(object sender, RoutedEventArgs e) - { - var vm = this.datagrid_invoices.GetCurrentValue(); - if (vm.IsSent && !BeWoApp.LoggedOnUser.HasRight(UserRightType.FinanzenRechnungenNachVersandBearbeiten)) - { - MessageBox.Show(Translator.Translate("Sie besitzen nicht das Recht Rechnungen nach Versand zu bearbeiten. Bitte wenden Sie sich an den Administrator!"), "BeWoPlaner", MessageBoxButton.OK, MessageBoxImage.Exclamation); - return; - } - switch (vm.DataContract.Type) - { - case InvoiceType.CustomerEquity: - this._EquityInvoiceItemEditView.ViewModel = vm; - this.MainControl.ShowControlAsModalPopup(this._EquityInvoiceItemEditView); - break; + private void btn_edit_Click(object sender, RoutedEventArgs e) + { + var vm = this.datagrid_invoices.GetCurrentValue(); + if (vm.IsSent && !BeWoApp.LoggedOnUser.HasRight(UserRightType.FinanzenRechnungenNachVersandBearbeiten)) + { + MessageBox.Show(Translator.Translate("Sie besitzen nicht das Recht Rechnungen nach Versand zu bearbeiten. Bitte wenden Sie sich an den Administrator!"), "BeWoPlaner", MessageBoxButton.OK, MessageBoxImage.Exclamation); + return; + } + switch (vm.DataContract.Type) + { + case InvoiceType.CustomerEquity: + this._EquityInvoiceItemEditView.ViewModel = vm; + this.MainControl.ShowControlAsModalPopup(this._EquityInvoiceItemEditView); + break; - case InvoiceType.General: - this._GeneralInvoiceItemEditView.ViewModel = vm; - this.MainControl.ShowControlAsModalPopup(this._GeneralInvoiceItemEditView); - break; + case InvoiceType.General: + this._GeneralInvoiceItemEditView.ViewModel = vm; + this.MainControl.ShowControlAsModalPopup(this._GeneralInvoiceItemEditView); + break; - case InvoiceType.Settlement: - ServiceFacade.DoAccountingServiceAsync( - s => s.GetSettlementByInvoiceBaseOid(vm.DataContract.InvoiceBaseOid.Value), - cb => this.Dispatch( - delegate - { - if (cb.InvoiceItems == null || cb.InvoiceItems.Count == 0 || cb.DifferentHourlyRateCount > 0) - { - this._SettlementInvoiceItemEditView.ViewModel = new SettlementVM(cb); - this.MainControl.ShowControlAsModalPopup(this._SettlementInvoiceItemEditView); - } - else - { - this._SettlementInvoiceItemEditView2.ViewModel = new SettlementVM(cb); - this.MainControl.ShowControlAsModalPopup(this._SettlementInvoiceItemEditView2); - } - })); - break; + case InvoiceType.Settlement: + ServiceFacade.DoAccountingServiceAsync( + s => s.GetSettlementByInvoiceBaseOid(vm.DataContract.InvoiceBaseOid.Value), + cb => this.Dispatch( + delegate + { + if (cb.InvoiceItems == null || cb.InvoiceItems.Count == 0 || cb.DifferentHourlyRateCount > 0) + { + this._SettlementInvoiceItemEditView.ViewModel = new SettlementVM(cb); + this.MainControl.ShowControlAsModalPopup(this._SettlementInvoiceItemEditView); + } + else + { + this._SettlementInvoiceItemEditView2.ViewModel = new SettlementVM(cb); + this.MainControl.ShowControlAsModalPopup(this._SettlementInvoiceItemEditView2); + } + })); + break; - case InvoiceType.Service: - ServiceFacade.DoAccountingServiceAsync( - s => s.GetServiceInvoiceByInvoiceBaseOid(vm.DataContract.InvoiceBaseOid.Value), - cb => this.Dispatch( - delegate - { - this._ServiceInvoiceItemEditView.ViewModel = new ServiceInvoiceVM(cb); - this.MainControl.ShowControlAsModalPopup(this._ServiceInvoiceItemEditView); - })); - break; - } - } - - private void gridView_Loaded(object sender, RoutedEventArgs e) - { - this.gridView.BestFitColumns(); - } + case InvoiceType.Service: + ServiceFacade.DoAccountingServiceAsync( + s => s.GetServiceInvoiceByInvoiceBaseOid(vm.DataContract.InvoiceBaseOid.Value), + cb => this.Dispatch( + delegate + { + this._ServiceInvoiceItemEditView.ViewModel = new ServiceInvoiceVM(cb); + this.MainControl.ShowControlAsModalPopup(this._ServiceInvoiceItemEditView); + })); + break; + } + } - private void gridView_ShownEditor(object sender, EditorEventArgs e) - { - if (e.Editor is CheckEdit) - { - var ed = (CheckEdit)e.Editor; - ed.Tag = e.Row; + private void gridView_Loaded(object sender, RoutedEventArgs e) + { + this.gridView.BestFitColumns(); + } - //ed.Unchecked -= this.checked_changed; - //ed.Unchecked += this.checked_changed; - //ed.Checked -= this.checked_changed; - //ed.Checked += this.checked_changed; - } - } + private void gridView_ShownEditor(object sender, EditorEventArgs e) + { + if (e.Editor is CheckEdit) + { + var ed = (CheckEdit)e.Editor; + ed.Tag = e.Row; - //void gridView_HiddenEditor(object sender, EditorEventArgs e) - //{ - // //if (e.Column != null && e.Column.FieldName == "IsPaid") - // //{ - // // if (e.Value is bool b && e.Row is InvoiceBaseVM vm) - // // { - // // SaveIsPaidChange(vm, b); - // // } - // //} - //} + //ed.Unchecked -= this.checked_changed; + //ed.Unchecked += this.checked_changed; + //ed.Checked -= this.checked_changed; + //ed.Checked += this.checked_changed; + } + } - private void linkExcelExport_RequestNavigate(object sender, RequestNavigateEventArgs e) - { - var list = ViewModel.VMList; - var lHeaderCaptions = new List(); - var lContent = new List>(); + //void gridView_HiddenEditor(object sender, EditorEventArgs e) + //{ + // //if (e.Column != null && e.Column.FieldName == "IsPaid") + // //{ + // // if (e.Value is bool b && e.Row is InvoiceBaseVM vm) + // // { + // // SaveIsPaidChange(vm, b); + // // } + // //} + //} - lHeaderCaptions.Add("Art der Rechnung"); - lHeaderCaptions.Add("Klient/in"); - lHeaderCaptions.Add("Zeitraum"); - lHeaderCaptions.Add("Nummer"); - lHeaderCaptions.Add("Datum"); - lHeaderCaptions.Add(BS.Shared.Translation.Translator.Translate("EmpfängerSingular")); - lHeaderCaptions.Add("Betrag"); - lHeaderCaptions.Add("Bemerkung"); - lHeaderCaptions.Add("Geprüft"); - lHeaderCaptions.Add("Versendet"); - lHeaderCaptions.Add("Exportiert"); - lHeaderCaptions.Add("Bezahlt"); - lHeaderCaptions.Add("Teilzahlung"); + private void linkExcelExport_RequestNavigate(object sender, RequestNavigateEventArgs e) + { + var list = ViewModel.VMList; + var lHeaderCaptions = new List(); + var lContent = new List>(); - if (list != null) - { - lContent.AddRange(list.Select(vm => new List - { - vm.TypeString, vm.CustomerName, vm.AccountingPeriodString, vm.InvoiceNumber, vm.InvoiceDate.Value.ToShortDateString(), - vm.RecipientString, string.Format("{0:0.00}", vm.TotalAmount), vm.Notice, vm.IsReviewed ? "Ja" : "", vm.IsSent ? "Ja" : "", - vm.IsExported ? "Ja" : "", vm.IsPaid ? "Ja" : "", vm.PartialPayment - })); - } - var path = BeWoApp.GetAndCreateUserAppDataPath() + "\\Rechnungen.xls"; + lHeaderCaptions.Add("Art der Rechnung"); + lHeaderCaptions.Add("Klient/in"); + lHeaderCaptions.Add("Zeitraum"); + lHeaderCaptions.Add("Nummer"); + lHeaderCaptions.Add("Datum"); + lHeaderCaptions.Add(BS.Shared.Translation.Translator.Translate("EmpfängerSingular")); + lHeaderCaptions.Add("Betrag"); + lHeaderCaptions.Add("Bemerkung"); + lHeaderCaptions.Add("Geprüft"); + lHeaderCaptions.Add("Versendet"); + lHeaderCaptions.Add("Exportiert"); + lHeaderCaptions.Add("Bezahlt"); + lHeaderCaptions.Add("Teilzahlung"); - var sf = new SaveFileDialog { FileName = Path.GetFileName(path), Filter = "Microsoft Excel 97-2003-Arbeitsblatt|*.xls|Alle Dateien|*.*" }; - if (sf.ShowDialog() != true) - return; - ServiceFacade.DoDownloadServiceSync(s => BeWoUtils.WriteExcelFile(s.PrepareExcelFile(DownloadLinkEngine.ExcelFileId, lHeaderCaptions, lContent), sf.FileName)); - } + if (list != null) + { + lContent.AddRange(list.Select(vm => new List + { + vm.TypeString, vm.CustomerName, vm.AccountingPeriodString, vm.InvoiceNumber, vm.InvoiceDate.Value.ToShortDateString(), + vm.RecipientString, string.Format("{0:0.00}", vm.TotalAmount), vm.Notice, vm.IsReviewed ? "Ja" : "", vm.IsSent ? "Ja" : "", + vm.IsExported ? "Ja" : "", vm.IsPaid ? "Ja" : "", vm.PartialPayment + })); + } + var path = BeWoApp.GetAndCreateUserAppDataPath() + "\\Rechnungen.xls"; - private void linkPdfExport_RequestNavigate(object sender, RequestNavigateEventArgs e) - { - var list = ViewModel.VMList; - var oids = list.Select(r => r.DataContract.InvoiceBaseOid.Value).ToList(); + var sf = new SaveFileDialog { FileName = Path.GetFileName(path), Filter = "Microsoft Excel 97-2003-Arbeitsblatt|*.xls|Alle Dateien|*.*" }; + if (sf.ShowDialog() != true) + return; + ServiceFacade.DoDownloadServiceSync(s => BeWoUtils.WriteExcelFile(s.PrepareExcelFile(DownloadLinkEngine.ExcelFileId, lHeaderCaptions, lContent), sf.FileName)); + } - ServiceFacade.DoReportServiceAsync(s => s.CreateInvoiceOverviewReport(oids), r => - { - this.Dispatch(() => - { - BeWoUtils.ShowReportWindow(r, Translator.Translate("Rechnungen")); - }); - }); - } + private void linkPdfExport_RequestNavigate(object sender, RequestNavigateEventArgs e) + { + var list = ViewModel.VMList; + var oids = list.Select(r => r.DataContract.InvoiceBaseOid.Value).ToList(); - private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e) - { - BeWoUtils.NavigateToReportUri(((Hyperlink)sender).NavigateUri.ToString(), "Druckvorschau"); - } + ServiceFacade.DoReportServiceAsync(s => s.CreateInvoiceOverviewReport(oids), r => + { + this.Dispatch(() => + { + BeWoUtils.ShowReportWindow(r, Translator.Translate("Rechnungen")); + }); + }); + } + + private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e) + { + BeWoUtils.NavigateToReportUri(((Hyperlink)sender).NavigateUri.ToString(), "Druckvorschau"); + } private void ReloadButton_OnClick(object sender, RoutedEventArgs e) { RefreshInvoiceList(); - } + } - private void btn_storno_Initialized(object sender, EventArgs e) - { - if (!BeWoApp.AppSettings.AllowStorno) - { - Button btn = sender as Button; - btn.Visibility = Visibility.Collapsed; - } - } + private void btn_storno_Initialized(object sender, EventArgs e) + { + if (!BeWoApp.AppSettings.AllowStorno) + { + Button btn = sender as Button; + btn.Visibility = Visibility.Collapsed; + } + } - private void gridView_CellValueChanged(object sender, CellValueChangedEventArgs e) - { - var vm = e.Row as InvoiceBaseVM; + private void gridView_CellValueChanged(object sender, CellValueChangedEventArgs e) + { + var vm = e.Row as InvoiceBaseVM; - if (vm != null) - { - if (e.Column != null && e.Column.FieldName == "PartialPayment") - { - var dc = vm.CommitToDataContract(); - dc.PartialPayment = (String)e.Value; - ServiceFacade.DoAccountingServiceAsync(s => s.UpdateInvoiceBases(new[] { dc }.ToList()), cb => vm.DataContract.InvoiceBaseVersion = cb[0], false); - } - } - } + if (vm != null) + { + if (e.Column != null && e.Column.FieldName == "PartialPayment") + { + var dc = vm.CommitToDataContract(); + dc.PartialPayment = (String)e.Value; + ServiceFacade.DoAccountingServiceAsync(s => s.UpdateInvoiceBases(new[] { dc }.ToList()), cb => vm.DataContract.InvoiceBaseVersion = cb[0], false); + } + } + } - private void gridView_CellValueChanging(object sender, CellValueChangedEventArgs e) - { - var vm = e.Row as InvoiceBaseVM; + private void gridView_CellValueChanging(object sender, CellValueChangedEventArgs e) + { + var vm = e.Row as InvoiceBaseVM; - if (vm != null) - { - bool save = false; - var dc = vm.CommitToDataContract(); + if (vm != null) + { + bool save = false; + var dc = vm.CommitToDataContract(); - if (e.Column != null && e.Column.FieldName == "IsPaid") - { - dc.IsPaid = (bool)e.Value; - save = true; - } + if (e.Column != null && e.Column.FieldName == "IsPaid") + { + dc.IsPaid = (bool)e.Value; + save = true; + } - if (e.Column != null && e.Column.FieldName == "IsReviewed") - { - dc.IsReviewed = (bool)e.Value; - save = true; - } + if (e.Column != null && e.Column.FieldName == "IsReviewed") + { + dc.IsReviewed = (bool)e.Value; + save = true; + } - if (e.Column != null && e.Column.FieldName == "IsSent") - { - if (vm.IsSent && (bool)e.Value == false && !BeWoApp.LoggedOnUser.HasRight(UserRightType.FinanzenRechnungenNachVersandBearbeiten)) - { - MessageBox.Show(Translator.Translate("Sie besitzen nicht das Recht Rechnungen nach Versand zu bearbeiten. Bitte wenden Sie sich an den Administrator!"), "BeWoPlaner", MessageBoxButton.OK, MessageBoxImage.Exclamation); - RefreshInvoiceList(); - return; - } - dc.IsSent = (bool)e.Value; - save = true; - } + if (e.Column != null && e.Column.FieldName == "IsSent") + { + if (vm.IsSent && (bool)e.Value == false && !BeWoApp.LoggedOnUser.HasRight(UserRightType.FinanzenRechnungenNachVersandBearbeiten)) + { + MessageBox.Show(Translator.Translate("Sie besitzen nicht das Recht Rechnungen nach Versand zu bearbeiten. Bitte wenden Sie sich an den Administrator!"), "BeWoPlaner", MessageBoxButton.OK, MessageBoxImage.Exclamation); + RefreshInvoiceList(); + return; + } + dc.IsSent = (bool)e.Value; + save = true; + } - if (e.Column != null && e.Column.FieldName == "IsExported") - { - dc.IsExported = (bool)e.Value; - save = true; - } + if (e.Column != null && e.Column.FieldName == "IsExported") + { + dc.IsExported = (bool)e.Value; + save = true; + } - if (save) - { - ServiceFacade.DoAccountingServiceAsync(s => s.UpdateInvoiceBases(new[] { dc }.ToList()), cb => vm.DataContract.InvoiceBaseVersion = cb[0], false); - } - } - } + if (save) + { + ServiceFacade.DoAccountingServiceAsync(s => s.UpdateInvoiceBases(new[] { dc }.ToList()), cb => vm.DataContract.InvoiceBaseVersion = cb[0], false); + } + } + } - private void TableView_OnCustomRowAppearance(object sender, CustomRowAppearanceEventArgs e) - { - if (e.Property != null && e.Property.Name == "Background") - { - var ib = datagrid_invoices.GetRow(e.RowHandle) as InvoiceBaseVM; - if (ib != null && !String.IsNullOrEmpty(ib.BackgroundColor)) - { - e.Result = new SolidColorBrush((Color)ColorConverter.ConvertFromString(ib.BackgroundColor)); - e.Handled = true; - } - } + private void TableView_OnCustomRowAppearance(object sender, CustomRowAppearanceEventArgs e) + { + if (e.Property != null && e.Property.Name == "Background") + { + var ib = datagrid_invoices.GetRow(e.RowHandle) as InvoiceBaseVM; + if (ib != null && !String.IsNullOrEmpty(ib.BackgroundColor)) + { + e.Result = new SolidColorBrush((Color)ColorConverter.ConvertFromString(ib.BackgroundColor)); + e.Handled = true; + } + } - //var data = srGridControl.rowhan - } + //var data = srGridControl.rowhan + } - private void button_checkAll_Click(object sender, RoutedEventArgs e) - { - var visible = GetVisibleVMs(); - foreach (var item in visible) - { - item.IsChecked = true; - } - } + private void button_checkAll_Click(object sender, RoutedEventArgs e) + { + var visible = GetVisibleVMs(); + foreach (var item in visible) + { + item.IsChecked = true; + } + } - private void button_uncheckAll_Click(object sender, RoutedEventArgs e) - { - var visible = GetVisibleVMs(); - foreach (var item in visible) - { - item.IsChecked = false; - } - } + private void button_uncheckAll_Click(object sender, RoutedEventArgs e) + { + var visible = GetVisibleVMs(); + foreach (var item in visible) + { + item.IsChecked = false; + } + } - private void button_printInvoices_Click(object sender, RoutedEventArgs e) - { - var list = new List(); + private void button_printInvoices_Click(object sender, RoutedEventArgs e) + { + var list = new List(); - var items = datagrid_invoices.ItemsSource as IList; + var items = datagrid_invoices.ItemsSource as IList; - if (items != null) - { - for (int i = 0; i < items.Count; i++) - { - var vm = datagrid_invoices.GetRow(i) as InvoiceBaseVM; - if (vm != null && vm.IsChecked) - { - list.Add(vm); - } - } - } + if (items != null) + { + for (int i = 0; i < items.Count; i++) + { + var vm = datagrid_invoices.GetRow(i) as InvoiceBaseVM; + if (vm != null && vm.IsChecked) + { + list.Add(vm); + } + } + } - PrintInvoices(list); - } + PrintInvoices(list); + } - private void button_reviewInvoices_Click(object sender, RoutedEventArgs e) - { - var list = new List(); - var items = datagrid_invoices.ItemsSource as IList; - if (items != null) - { - for (int i = 0; i < items.Count; i++) - { - var vm = datagrid_invoices.GetRow(i) as InvoiceBaseVM; - if (vm != null && vm.IsChecked) - { - list.Add(vm); - } - } - } + private void button_reviewInvoices_Click(object sender, RoutedEventArgs e) + { + var list = new List(); + var items = datagrid_invoices.ItemsSource as IList; + if (items != null) + { + for (int i = 0; i < items.Count; i++) + { + var vm = datagrid_invoices.GetRow(i) as InvoiceBaseVM; + if (vm != null && vm.IsChecked) + { + list.Add(vm); + } + } + } - ChangeAllInvoices(list, "reviewed"); - } + ChangeAllInvoices(list, "reviewed"); + } - private void button_sentInvoices_Click(object sender, RoutedEventArgs e) - { - var list = new List(); - var items = datagrid_invoices.ItemsSource as IList; - if (items != null) - { - for (int i = 0; i < items.Count; i++) - { - var vm = datagrid_invoices.GetRow(i) as InvoiceBaseVM; - if (vm != null && vm.IsChecked) - { - list.Add(vm); - } - } - } - ChangeAllInvoices(list, "sent"); - } + private void button_sentInvoices_Click(object sender, RoutedEventArgs e) + { + var list = new List(); + var items = datagrid_invoices.ItemsSource as IList; + if (items != null) + { + for (int i = 0; i < items.Count; i++) + { + var vm = datagrid_invoices.GetRow(i) as InvoiceBaseVM; + if (vm != null && vm.IsChecked) + { + list.Add(vm); + } + } + } + ChangeAllInvoices(list, "sent"); + } - private void button_exportedInvoices_Click(object sender, RoutedEventArgs e) - { - var list = new List(); - var items = datagrid_invoices.ItemsSource as IList; - if (items != null) - { - for (int i = 0; i < items.Count; i++) - { - var vm = datagrid_invoices.GetRow(i) as InvoiceBaseVM; - if (vm != null && vm.IsChecked) - { - list.Add(vm); - } - } - } - ChangeAllInvoices(list, "export"); - } + private void button_exportedInvoices_Click(object sender, RoutedEventArgs e) + { + var list = new List(); + var items = datagrid_invoices.ItemsSource as IList; + if (items != null) + { + for (int i = 0; i < items.Count; i++) + { + var vm = datagrid_invoices.GetRow(i) as InvoiceBaseVM; + if (vm != null && vm.IsChecked) + { + list.Add(vm); + } + } + } + ChangeAllInvoices(list, "export"); + } - private void button_paidInvoices_Click(object sender, RoutedEventArgs e) - { - var list = new List(); - var items = datagrid_invoices.ItemsSource as IList; - if (items != null) - { - for (int i = 0; i < items.Count; i++) - { - var vm = datagrid_invoices.GetRow(i) as InvoiceBaseVM; - if (vm != null && vm.IsChecked) - { - list.Add(vm); - } - } - } - ChangeAllInvoices(list, "paid"); - } + private void button_paidInvoices_Click(object sender, RoutedEventArgs e) + { + var list = new List(); + var items = datagrid_invoices.ItemsSource as IList; + if (items != null) + { + for (int i = 0; i < items.Count; i++) + { + var vm = datagrid_invoices.GetRow(i) as InvoiceBaseVM; + if (vm != null && vm.IsChecked) + { + list.Add(vm); + } + } + } + ChangeAllInvoices(list, "paid"); + } - private void ChangeAllInvoices(List list, String function) - { - var dcList = new List(); - foreach (var item in list) - { - if (function == "reviewed" && !item.IsReviewed) - { - item.IsReviewed = true; - var dc = item.CommitToDataContract(); - dc.IsReviewed = true; - dcList.Add(dc); - } - else if (function == "sent" && !item.IsSent) - { - item.IsSent = true; - var dc = item.CommitToDataContract(); - dc.IsSent = true; - dcList.Add(dc); - } - else if (function == "export" && !item.IsExported) - { - item.IsExported = true; - var dc = item.CommitToDataContract(); - dc.IsExported = true; - dcList.Add(dc); - } - else if (function == "paid" && !item.IsPaid) - { - item.IsPaid = true; - var dc = item.CommitToDataContract(); - dc.IsPaid = true; - dcList.Add(dc); - } - } - if (dcList.Count > 0) - { - ServiceFacade.DoAccountingServiceSync(s => s.UpdateInvoiceBases(dcList)); - foreach (var item in dcList) - { - item.InvoiceBaseVersion++; - } - } - } + private void ChangeAllInvoices(List list, String function) + { + var dcList = new List(); + foreach (var item in list) + { + if (function == "reviewed" && !item.IsReviewed) + { + item.IsReviewed = true; + var dc = item.CommitToDataContract(); + dc.IsReviewed = true; + dcList.Add(dc); + } + else if (function == "sent" && !item.IsSent) + { + item.IsSent = true; + var dc = item.CommitToDataContract(); + dc.IsSent = true; + dcList.Add(dc); + } + else if (function == "export" && !item.IsExported) + { + item.IsExported = true; + var dc = item.CommitToDataContract(); + dc.IsExported = true; + dcList.Add(dc); + } + else if (function == "paid" && !item.IsPaid) + { + item.IsPaid = true; + var dc = item.CommitToDataContract(); + dc.IsPaid = true; + dcList.Add(dc); + } + } + if (dcList.Count > 0) + { + ServiceFacade.DoAccountingServiceSync(s => s.UpdateInvoiceBases(dcList)); + foreach (var item in dcList) + { + item.InvoiceBaseVersion++; + } + } + } - private void PrintInvoices(List list) - { - var oidList = list.Select(i => i.DataContract.InvoiceBaseOid.Value).ToList(); - - ServiceFacade.DoReportServiceAsync(s => s.CreateInvoiceListReport(oidList), ms => BeWoApp.MainControl.Dispatch(() => BeWoUtils.ShowReportWindow(ms, "Rechnungen"))); + private void PrintInvoices(List list) + { + var oidList = list.Select(i => i.DataContract.InvoiceBaseOid.Value).ToList(); - } + ServiceFacade.DoReportServiceAsync(s => s.CreateInvoiceListReport(oidList), ms => BeWoApp.MainControl.Dispatch(() => BeWoUtils.ShowReportWindow(ms, "Rechnungen"))); - private IList GetVisibleVMs() - { - var list = new List(); + } - var items = datagrid_invoices.ItemsSource as IList; + private IList GetVisibleVMs() + { + var list = new List(); - if (items != null) - { - for (int i = 0; i < items.Count; i++) - { - if (datagrid_invoices.IsRowVisible(i)) - { - var vm = datagrid_invoices.GetRow(i) as InvoiceBaseVM; - if (vm != null) - { - list.Add(vm); - } - } - } - } + var items = datagrid_invoices.ItemsSource as IList; - return list; - } + if (items != null) + { + for (int i = 0; i < items.Count; i++) + { + if (datagrid_invoices.IsRowVisible(i)) + { + var vm = datagrid_invoices.GetRow(i) as InvoiceBaseVM; + if (vm != null) + { + list.Add(vm); + } + } + } + } - private void button_eRechnung_Click(object sender, RoutedEventArgs e) - { - var res = ServiceFacade.DoAccountingServiceSync(x => x.GetXRechnung(null)); + return list; + } - if (res.HasErrors) - BeWoApp.ShowErrorMessage("Fehler: " + res.ResponseString); - else - MainControl.WindowService.ShowERechnungModalViewWindow(new MemoryStream(res.ResponseBytes)); - } + private void button_eRechnung_Click(object sender, RoutedEventArgs e) + { + ServiceFacade.DoOperationsEnhancedServiceSnyc(x => x.CreateXRechnung(0, 0, null)); + + //var res = ServiceFacade.DoAccountingServiceSync(x => x.GetXRechnung(null)); + + //if (res.HasErrors) + // BeWoApp.ShowErrorMessage("Fehler: " + res.ResponseString); + //else + // MainControl.WindowService.ShowERechnungModalViewWindow(new MemoryStream(res.ResponseBytes)); + } private void btn_xRechnung_Click(object sender, RoutedEventArgs e) { + var vm = this.datagrid_invoices.GetCurrentValue(); + if (vm is null) + { + MessageBox.Show("vm is null"); + return; + } + + var invoice_base_oid = vm.DataContract.InvoiceBaseOid ?? -1; + var invoice_type = (int)vm.DataContract.Type; + var report_link = vm.ReportLink; + + ServiceFacade.DoOperationsEnhancedServiceAsnyc( + x => x.CreateXRechnung(invoice_base_oid, invoice_type, report_link), + cb => BeWoApp.MainControl.WindowService.ShowTextViewerWindow("Debug", cb as string)); } } } \ No newline at end of file diff --git a/BeWo/View/Master/ReportView.xaml b/BeWo/View/Master/ReportView.xaml index d52aa32f7..c2148bbe8 100644 --- a/BeWo/View/Master/ReportView.xaml +++ b/BeWo/View/Master/ReportView.xaml @@ -1,70 +1,158 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - -