show a summary of LineItems without CustomDescription

pull/1/head
DJh2o2 2022-03-22 09:55:42 +07:00
parent 0fa161fc3b
commit b61686e0d5
4 changed files with 56 additions and 15 deletions

@ -1,20 +1,28 @@
using Gremlin.GremlinData.DBClasses;
using Caliburn.Micro;
using Gremlin.GremlinData.DBClasses;
using Gremlin.GremlinData.EntityClasses;
using System.Linq;
using System.Windows;
namespace Gremlin.MVVM
{
public class CustomDescriptionViewModel
public class CustomDescriptionViewModel : PropertyChangedBase
{
public string Heading { get; set; }
public string DescriptionText { get; set; }
public string CoverletterText { get; set; }
public string Notes { get; set; } //Hinweise, Tipps, Caveats, etc. für Konfiguration, Verwendung, Best Practice usw.
private string heading;
private string descriptionText;
private string coverletterText;
private string notes;
private bool isAvailable;
public string Heading { get => heading; set { heading = value; NotifyOfPropertyChange(() => Heading); } }
public string DescriptionText { get => descriptionText; set { descriptionText = value; NotifyOfPropertyChange(() => Heading); }}
public string CoverletterText { get => coverletterText; set { coverletterText = value; NotifyOfPropertyChange(() => Heading); } }
public string Notes { get => notes; set { notes = value; NotifyOfPropertyChange(() => Heading); } }
public bool IsAvailable { get => isAvailable; set { isAvailable = value; NotifyOfPropertyChange(() => Heading); } }
public override string ToString()
{
return $"{Heading}";
return $"{Heading}\n{DescriptionText}";
}
public static CustomDescriptionViewModel GetCustomDescription(LineItemViewModel lineItemVM)
@ -34,12 +42,14 @@ namespace Gremlin.MVVM
customDescriptionVM.DescriptionText = TexReplace(customDescription.DescriptionText);
customDescriptionVM.CoverletterText = TexReplace(customDescription.CoverletterText);
customDescriptionVM.Notes = TexReplace(customDescription.Notes);
customDescriptionVM.IsAvailable = true;
}
else
{
MessageBox.Show($"CustomDescription für \"{lineItemVM.ProductNumber}#{lineItemVM.OptionNumber}\" nicht vorhanden! Verwende (vorläufig) Standardbeschreibung \"{lineItemVM.SapShortDescription}\"!");
//MessageBox.Show($"CustomDescription für \"{lineItemVM.ProductNumber}#{lineItemVM.OptionNumber}\" nicht vorhanden! Verwende (vorläufig) Standardbeschreibung \"{lineItemVM.SapShortDescription}\"!");
customDescriptionVM.DescriptionText = TexReplace(lineItemVM.SapShortDescription);
customDescriptionVM.Heading = TexReplace(lineItemVM.SapShortDescription);
customDescriptionVM.IsAvailable = false;
}
return customDescriptionVM;

@ -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 selectedLineItemVM = 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";
}

@ -88,18 +88,20 @@
<DataGrid
x:Name="LineItemsVM"
AutoGenerateColumns="True"
MaxColumnWidth="500"
CanUserAddRows="False"
MinHeight="100"
MaxHeight="400"
Margin="10,5,10,5"
AlternatingRowBackground="LightGray"
SelectedItem="SelectedLineItemVM"
SelectedItem="SelectedLineItem"
SelectionMode="Single"
/>
</Grid>
<!--CustomDescription-->
<!--SelectedLineItem-->
<Grid Grid.Row="3" Grid.ColumnSpan="5" Height="Auto">
<TextBlock Name="CustomDescription" Text="{Binding Path=SelectedLineItemVM.CustomDescriptionVM.Heading}" />
<TextBox Name="SelectedLineItem" Text="{Binding Path=SelectedLineItem.CustomDescriptionVM.DescriptionText}" Margin="10,5,10,5"/>
</Grid>
</Grid>
</UserControl>

@ -13,7 +13,7 @@
<TextBlock x:Name="SelectedContactFirstName" Text="{Binding Path=SelectedContact.FirstName}" Margin="10,5,10,5"/>
<TextBlock x:Name="SelectedContactLastName" Text="{Binding Path=SelectedContact.LastName}" Margin="10,5,10,5"/>
</StackPanel>
<DataGrid x:Name="Contacts" AutoGenerateColumns="True" FrozenColumnCount="3" SelectionMode="Single" SelectedItem="SelectedContact" MaxHeight="200" Margin="10,5,10,5" />
<DataGrid x:Name="Contacts" AutoGenerateColumns="True" CanUserAddRows="True" FrozenColumnCount="3" SelectionMode="Single" SelectedItem="SelectedContact" MaxHeight="200" Margin="10,5,10,5" />
</StackPanel>
<!--Quote-->