@ -1,6 +1,7 @@
using Caliburn.Micro ;
using Microsoft.Win32 ;
using System ;
using System.Collections.Generic ;
using System.Collections.ObjectModel ;
using System.Diagnostics ;
using System.IO ;
@ -12,7 +13,7 @@ namespace Gremlin.MVVM
{
private string quoteType = "ein Analysegerät" ;
private string quotePath = AppDomain . CurrentDomain . BaseDirectory ;
private LineItemViewModel selectedLineItem VM = new ( ) ;
private LineItemViewModel selectedLineItem ;
private ObservableCollection < LineItemViewModel > lineItemsVM = new ( ) ;
private ContactViewModel recipient = new ( ) ;
private ContactViewModel salesRep = new ( ) ;
@ -36,7 +37,9 @@ namespace Gremlin.MVVM
private decimal totalVAT ;
private decimal totalGross ;
public LineItemViewModel SelectedLineItemVM { get = > selectedLineItemVM ; set { selectedLineItemVM = value ; NotifyOfPropertyChange ( ( ) = > SelectedLineItemVM ) ; } }
private List < LineItemViewModel > lineItemsWithoutCustomDescription = new ( ) ;
public LineItemViewModel SelectedLineItem { get = > selectedLineItem ; set { selectedLineItem = value ; NotifyOfPropertyChange ( ( ) = > SelectedLineItem ) ; DebugSelectedLineItem ( ) ; } }
public ObservableCollection < LineItemViewModel > LineItemsVM { get = > lineItemsVM ; set { lineItemsVM = value ; NotifyOfPropertyChange ( ( ) = > LineItemsVM ) ; } }
public ContactViewModel Recipient { get = > recipient ; set { recipient = value ; NotifyOfPropertyChange ( ( ) = > Recipient ) ; } }
public ContactViewModel SalesRep { get = > salesRep ; set { salesRep = value ; NotifyOfPropertyChange ( ( ) = > SalesRep ) ; } }
@ -84,16 +87,25 @@ namespace Gremlin.MVVM
} ;
}
private void DebugSelectedLineItem ( )
{
Debug . WriteLine ( $"{SelectedLineItem.ProductNumber}#{SelectedLineItem.OptionNumber}:\n{SelectedLineItem.CustomDescriptionVM.Heading}\n{SelectedLineItem.CustomDescriptionVM.DescriptionText}" ) ;
}
public bool ReadLineItems ( )
{
ResetTotals ( ) ;
LineItemsVM = LineItemViewModel . ReadLineItemsFromClipboard ( ) ;
if ( LineItemsVM = = null )
{
return false ;
}
else
{
SelectedLineItem = LineItemsVM [ 0 ] ;
}
foreach ( LineItemViewModel lineItemVM in LineItemsVM )
{
@ -115,12 +127,29 @@ namespace Gremlin.MVVM
Warranty = 36 ;
}
//Checke auf fehlende CustomDescriptions
if ( ! lineItemVM . CustomDescriptionVM . IsAvailable )
{
lineItemsWithoutCustomDescription . Add ( lineItemVM ) ;
}
//AddToTotal
TotalListprice + = lineItemVM . ListPrice ;
TotalNet + = lineItemVM . CalcTotalNet ;
}
CalculateTotals ( ) ;
if ( lineItemsWithoutCustomDescription . Count ! = 0 )
{
string fehlendeCustomDescriptions = "Folgende LineItems haben keine CustomDescription:\n" ;
foreach ( LineItemViewModel lineItemWithoutCustomDescription in lineItemsWithoutCustomDescription )
{
fehlendeCustomDescriptions + = lineItemWithoutCustomDescription . ProductNumber + "#" + lineItemWithoutCustomDescription . OptionNumber + ": " + lineItemWithoutCustomDescription . CustomDescriptionVM . Heading + "\n" ;
}
ErrorHandler . ShowErrorMessage ( fehlendeCustomDescriptions ) ;
}
return LineItemsVM . Count ! = 0 & & Recipient . LastName ! = "lastName" ;
}