optimize ShellViewModel

pull/1/head
Sascha Woitschetzki 2021-07-09 11:05:59 +07:00
parent 46adcf0087
commit 27702728d6
8 changed files with 31 additions and 44 deletions

@ -1,18 +1,7 @@
using Gremlin.GremlinData.DBClasses;
using Gremlin.GremlinUtilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Gremlin.MVVM
{

@ -1,5 +1,4 @@
using Gremlin.GremlinUtilities;
using System;
using System;
using System.Diagnostics;
using System.IO;

@ -84,7 +84,7 @@ namespace Gremlin.MVVM
_ = texFile.AppendLine(@"\textbf{\#} & \textbf{Produktbeschreibung} (Produktnummer) & \textbf{Menge}\\ \hline \endhead");
}
foreach (LineItemViewModel lI in quoteVM.LineItemsVM)
foreach (LineItemViewModel lI in quoteVM.LineItemsViewModel)
{
string lineItemTex = "";
@ -156,7 +156,7 @@ namespace Gremlin.MVVM
string rbDisclaimer = "\\textbf{Wichtiger Hinweis zur Bestellung von überholten Geräten}\\\\\n";
rbDisclaimer += "Bitte beachten Sie, dass in der Regel nur wenige gebrauchte Geräte auf Lager sind und diese ohne die Möglichkeit einer Reservierung auf „first come, first serve“-Basis verkauft werden. Um lange Lieferzeiten zu vermeiden, sollte daher bei konkretem Interesse zunächst der Lagerstand überprüft werden. Die aktuellen Lagerbestände sind:\n";
List<LineItemViewModel> lineItemsWithRB = quoteVM.LineItemsVM.Where(lI => lI.ProductLine == "RB").ToList();
List<LineItemViewModel> lineItemsWithRB = quoteVM.LineItemsViewModel.Where(lI => lI.ProductLine == "RB").ToList();
rbDisclaimer += "\\begin{center}\n\\begin{tabular}{clc}\n";
rbDisclaimer += "\\textbf{Modul} & \\textbf{Beschreibung} &\\textbf{Bestand}\\\\ \\hline \n";
@ -176,7 +176,7 @@ namespace Gremlin.MVVM
+ $"Bitte beachten Sie, dass das/die o.g. Produkt/e ";
//List all 3PP product numbers
List<LineItemViewModel> lineItemsWith3PP = quoteVM.LineItemsVM.Where(lI => lI.ProductLine == "3PP").ToList();
List<LineItemViewModel> lineItemsWith3PP = quoteVM.LineItemsViewModel.Where(lI => lI.ProductLine == "3PP").ToList();
for (int i = 0; i < lineItemsWith3PP.Count; i++)
{
_ = i < lineItemsWith3PP.Count - 1
@ -211,7 +211,7 @@ namespace Gremlin.MVVM
+ "Es umfasst im Einzelnen:\n"
+ "\\begin{itemize}\n";
foreach (LineItemViewModel lineItemVM in quoteVM.LineItemsVM)
foreach (LineItemViewModel lineItemVM in quoteVM.LineItemsViewModel)
{
if (lineItemVM.OptionNumber == "")
{

@ -65,14 +65,14 @@ namespace Gremlin.MVVM
if (quoteVM == null) return;
ObservableCollection<LineItemViewModel> lineItemsViewModel = new(quoteVM.LineItemsVM);
ObservableCollection<LineItemViewModel> lineItemsViewModel = new(quoteVM.LineItemsViewModel);
lineItems = new(lineItemsViewModel);
UpdateUI();
}
private void BtnCreateTex_Click(object sender, RoutedEventArgs e)
{
if (quoteVM.LineItemsVM == null || quoteVM.LineItemsVM.Count == 0)
if (quoteVM.LineItemsViewModel == null || quoteVM.LineItemsViewModel.Count == 0)
{
ErrorHandler.ShowMessageBox("Bitte zuerst ein Angebot einfügen");
}

@ -22,11 +22,11 @@ namespace Gremlin.MVVM
private float _vAT = 19f;
private bool? _showBrutto = true;
private bool? _singlePrices = true;
private bool? _attachBrochures = false;
private bool? _attachDataSheets = false;
private bool? _useMailTemplate = false;
private bool _quoteContains3PP = false;
private bool _quoteContainsRB = false;
private bool? _attachBrochures;
private bool? _attachDataSheets;
private bool? _useMailTemplate;
private bool _quoteContains3PP;
private bool _quoteContainsRB;
private bool? _showDiscounts = true;
public string QuoteType { get => _quoteType; internal set { _quoteType = value; NotifyOfPropertyChange(() => QuoteType); } }
@ -41,15 +41,15 @@ namespace Gremlin.MVVM
public bool? UseMailTemplate { get => _useMailTemplate; internal set { _useMailTemplate = value; NotifyOfPropertyChange(() => UseMailTemplate); } }
public bool? ShowDiscounts { get => _showDiscounts; internal set { _showDiscounts = value; NotifyOfPropertyChange(() => ShowDiscounts); } }
public List<LineItemViewModel> LineItemsVM { get => _lineItemsVM; private set => _lineItemsVM = value; }
public ContactViewModel Recipient { get => _recipient; internal set => _recipient = value; }
public ContactViewModel SalesRep { get => _salesRep; private set => _salesRep = value; }
public decimal TotalListprice { get => _totalListprice; private set => _totalListprice = value; }
public decimal AverageDiscount { get => _averageDiscount; private set => _averageDiscount = value; }
public decimal TotalNet { get => _totalNet; private set => _totalNet = value; }
public float VAT { get => _vAT; private set => _vAT = value; }
public bool QuoteContains3PP { get => _quoteContains3PP; private set => _quoteContains3PP = value; }
public bool QuoteContainsRB { get => _quoteContainsRB; private set => _quoteContainsRB = value; }
public List<LineItemViewModel> LineItemsViewModel { get => _lineItemsVM; internal set { _lineItemsVM = value; NotifyOfPropertyChange(() => LineItemsViewModel); } }
public ContactViewModel Recipient { get => _recipient; internal set { _recipient = value; NotifyOfPropertyChange(() => Recipient); } }
public ContactViewModel SalesRep { get => _salesRep; internal set { _salesRep = value; NotifyOfPropertyChange(() => SalesRep); } }
public decimal TotalListprice { get => _totalListprice; internal set { _totalListprice = value; NotifyOfPropertyChange(() => TotalListprice); } }
public decimal AverageDiscount { get => _averageDiscount; internal set { _averageDiscount = value; NotifyOfPropertyChange(() => AverageDiscount); } }
public decimal TotalNet { get => _totalNet; internal set { _totalNet = value; NotifyOfPropertyChange(() => TotalNet); } }
public float VAT { get => _vAT; internal set { _vAT = value; NotifyOfPropertyChange(() => VAT); } }
public bool QuoteContains3PP { get => _quoteContains3PP; internal set { _quoteContains3PP = value; NotifyOfPropertyChange(() => QuoteContains3PP); } }
public bool QuoteContainsRB { get => _quoteContainsRB; internal set { _quoteContainsRB = value; NotifyOfPropertyChange(() => QuoteContainsRB); } }
internal QuoteViewModel(ContactViewModel salesRep)
{
@ -89,7 +89,7 @@ namespace Gremlin.MVVM
bool quoteContains3PP = false, quoteContainsRB = false;
QuoteViewModel quoteVM = new(quoteNumber, quoteType, recipient, salesRep, brutto, vAT, warranty, validity, quotePath, singlePrices, brochures, dataSheets, mailTemplate, showDiscounts);
quoteVM.LineItemsVM = new();
quoteVM.LineItemsViewModel = new();
ObservableCollection<LineItemViewModel> lineItemsVM = LineItemViewModel.ReadLineItemsFromClipboard();
@ -119,7 +119,7 @@ namespace Gremlin.MVVM
quoteVM.Warranty = int.Parse(lineItemVM.OptionNumber.Last().ToString()) * 12;
}
quoteVM.LineItemsVM.Add(lineItemVM);
quoteVM.LineItemsViewModel.Add(lineItemVM);
}
quoteVM.TotalListprice = totalListprice;

@ -1,14 +1,16 @@
namespace Gremlin.MVVM
using System.Collections.Generic;
namespace Gremlin.MVVM
{
public class ShellViewModel
{
public QuoteViewModel QuoteVM { get; set; }
public LineItemViewModel LineVM { get; set; }
public List<LineItemViewModel> LineVMs { get; set; }
public ShellViewModel()
{
QuoteVM = new QuoteViewModel();
LineVM = new LineItemViewModel();
LineVMs = QuoteVM.LineItemsViewModel;
}
}
}

@ -1,13 +1,10 @@
<UserControl x:Class="Gremlin.MVVM.ShellView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:cal="http://www.caliburnproject.org"
xmlns:local="clr-namespace:Gremlin.MVVM"
mc:Ignorable="d" >
xmlns:local="clr-namespace:Gremlin.MVVM">
<StackPanel Orientation="Vertical">
<local:QuoteView cal:Bind.Model="{Binding QuoteVM}" />
<!--<local:LineItemView cal:Bind.Model="{Binding LineItemVM}" />-->
<local:LineItemView cal:Bind.Model="{Binding LineItemVM}" />
</StackPanel>
</UserControl>

@ -1,6 +1,6 @@
using System.Windows.Controls;
namespace Gremlin.MVVM
namespace Gremlin.MVVM.Views
{
public partial class ShellView : UserControl
{