cleanup structure to fullfill MVVM criteria

pull/1/head
Sascha Woitschetzki 2021-07-01 20:42:03 +07:00
parent 11c13b0b91
commit a4f8b2e85c
29 changed files with 112 additions and 83 deletions

@ -1,8 +1,13 @@
<Application x:Class="Gremlin.GremlinData.App" <Application x:Class="Gremlin.GremlinData.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="GremlinUI/MainWindow.xaml"> xmlns:local="clr-namespace:Gremlin.MVVM">
<Application.Resources> <Application.Resources>
<ResourceDictionary>
</Application.Resources> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<local:AppBootstrapper x:Key="bootstrapper" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </Application.Resources>
</Application> </Application>

@ -1,5 +1,5 @@
using Gremlin.GremlinData.EntityClasses; using Gremlin.GremlinData.EntityClasses;
using Gremlin.GremlinUI; using Gremlin.MVVM;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System; using System;

@ -7,7 +7,7 @@ namespace Gremlin.GremlinUtilities.GUClasses
{ {
class DataIdentificator class DataIdentificator
{ {
private readonly string _source; //Qualifier-Liste //private readonly string _source; //Qualifier-Liste
private readonly Dictionary<string, int> _mappingTable; //Mapping Spaltenzahl <-> Property/(übersetzte) Spaltenüberschrift private readonly Dictionary<string, int> _mappingTable; //Mapping Spaltenzahl <-> Property/(übersetzte) Spaltenüberschrift
public List<DataIdType> DataTypes { get; set; } public List<DataIdType> DataTypes { get; set; }

@ -0,0 +1,17 @@
using Caliburn.Micro;
namespace Gremlin.MVVM
{
public class AppBootstrapper : BootstrapperBase
{
public AppBootstrapper()
{
Initialize();
}
protected override void OnStartup(object sender, System.Windows.StartupEventArgs e)
{
DisplayRootViewFor<QuoteViewModel>();
}
}
}

@ -1,4 +1,4 @@
<Window x:Class="Gremlin.GremlinUI.ChooseDB" <Window x:Class="Gremlin.MVVM.ChooseDB"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

@ -2,7 +2,7 @@
using Microsoft.Win32; using Microsoft.Win32;
using System.Windows; using System.Windows;
namespace Gremlin.GremlinUI namespace Gremlin.MVVM
{ {
public partial class ChooseDB : Window public partial class ChooseDB : Window
{ {

@ -1,9 +1,9 @@
<Window x:Class="Gremlin.GremlinUI.DataImport" <Window x:Class="Gremlin.MVVM.DataImport"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Gremlin.GremlinUI" xmlns:local="clr-namespace:Gremlin.MVVM"
mc:Ignorable="d" mc:Ignorable="d"
Title="DataImport" Height="220" Width="500" MinHeight="220" MaxHeight="300" MinWidth="350"> Title="DataImport" Height="220" Width="500" MinHeight="220" MaxHeight="300" MinWidth="350">
<Grid> <Grid>

@ -14,7 +14,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
namespace Gremlin.GremlinUI namespace Gremlin.MVVM
{ {
/// <summary> /// <summary>
/// Interaktionslogik für DataImport.xaml /// Interaktionslogik für DataImport.xaml

@ -1,4 +1,4 @@
<Window x:Class="Gremlin.GremlinUI.Login" <Window x:Class="Gremlin.MVVM.Login"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

@ -1,7 +1,7 @@
using Gremlin.Models; using Gremlin.Models;
using System.Windows; using System.Windows;
namespace Gremlin.GremlinUI namespace Gremlin.MVVM
{ {
public partial class Login : Window public partial class Login : Window
{ {

@ -1,4 +1,4 @@
<Window x:Class="Gremlin.GremlinUI.MainWindow" <Window x:Class="Gremlin.MVVM.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

@ -1,19 +1,9 @@
using Gremlin.GremlinData.DBClasses; using Gremlin.GremlinData.DBClasses;
using Gremlin.GremlinUtilities;
using Gremlin.GremlinData.EntityClasses;
using Gremlin.GremlinUI.ViewModels;
using Gremlin.Models; using Gremlin.Models;
using Gremlin.ViewModels;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows; using System.Windows;
using static Gremlin.GremlinData.DBClasses.GremlinContext;
namespace Gremlin.GremlinUI namespace Gremlin.MVVM
{ {
public partial class MainWindow : Window public partial class MainWindow : Window
{ {

@ -1,6 +1,6 @@
using Gremlin.GremlinData.DBClasses; using Gremlin.GremlinData.DBClasses;
using Gremlin.GremlinData.EntityClasses; using Gremlin.GremlinData.EntityClasses;
using Gremlin.GremlinUI; using Gremlin.MVVM;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;

@ -1,6 +1,4 @@
using Gremlin.GremlinUI.ViewModels; using Gremlin.Models;
using Gremlin.Models;
using Gremlin.ViewModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -8,11 +6,11 @@ using System.Linq;
using System.Text; using System.Text;
using static Gremlin.GremlinData.EntityClasses.Enums; using static Gremlin.GremlinData.EntityClasses.Enums;
namespace Gremlin.Operations namespace Gremlin.MVVM
{ {
internal class TexHandler internal class TexHandler
{ {
internal static void CreateTexAndOpen(QuoteVM quoteVM) internal static void CreateTexAndOpen(QuoteViewModel quoteVM)
{ {
StringBuilder texStringBuilder = CreateTexFile(quoteVM); StringBuilder texStringBuilder = CreateTexFile(quoteVM);
WriteTextToFile(texStringBuilder, $"{quoteVM.QuoteNumber}.tex"); WriteTextToFile(texStringBuilder, $"{quoteVM.QuoteNumber}.tex");
@ -27,7 +25,7 @@ namespace Gremlin.Operations
} }
} }
private static StringBuilder CreateTexFile(QuoteVM quoteVM) private static StringBuilder CreateTexFile(QuoteViewModel quoteVM)
{ {
string rand = RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "texRand"); string rand = RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "texRand");
@ -96,23 +94,23 @@ namespace Gremlin.Operations
{ {
//mit Einzelpreisen //mit Einzelpreisen
lineItemTex = lI.OptionNumber != "" lineItemTex = lI.OptionNumber != ""
? $"{lI.Position} &\\textbf{{{lI.CustomDescription.Heading}}} ({lI.ProductNumber}\\#{lI.OptionNumber})\\newline {lI.CustomDescription.DescriptionText}&{lI.Amount}&\\SI{{{lI.CalcTotalNet}}}{{\\sieuro}}\\\\" ? $"{lI.Position} &\\textbf{{{lI.CustomDescriptionVM.Heading}}} ({lI.ProductNumber}\\#{lI.OptionNumber})\\newline {lI.CustomDescriptionVM.DescriptionText}&{lI.Amount}&\\SI{{{lI.CalcTotalNet}}}{{\\sieuro}}\\\\"
: $"{lI.Position} &\\textbf{{{lI.CustomDescription.Heading}}} ({lI.ProductNumber})\\newline {lI.CustomDescription.DescriptionText}&{lI.Amount}&\\SI{{{lI.CalcTotalNet}}}{{\\sieuro}}\\\\"; : $"{lI.Position} &\\textbf{{{lI.CustomDescriptionVM.Heading}}} ({lI.ProductNumber})\\newline {lI.CustomDescriptionVM.DescriptionText}&{lI.Amount}&\\SI{{{lI.CalcTotalNet}}}{{\\sieuro}}\\\\";
} }
else if (quoteVM.ShowDiscounts == true) else if (quoteVM.ShowDiscounts == true)
{ {
//mit Einzelpreisen und Discounts //mit Einzelpreisen und Discounts
lineItemTex = lI.OptionNumber != "" lineItemTex = lI.OptionNumber != ""
? $"{lI.Position} &\\textbf{{{lI.CustomDescription.Heading}}} ({lI.ProductNumber}\\#{lI.OptionNumber})\\newline {lI.CustomDescription.DescriptionText}\\newline Listenpreis: \\SI{{{lI.ListPrice}}}{{\\sieuro}}&{lI.Amount}&\\SI{{{lI.TotalDiscount}}}{{\\%}}&\\SI{{{lI.CalcTotalNet}}}{{\\sieuro}}\\\\" ? $"{lI.Position} &\\textbf{{{lI.CustomDescriptionVM.Heading}}} ({lI.ProductNumber}\\#{lI.OptionNumber})\\newline {lI.CustomDescriptionVM.DescriptionText}\\newline Listenpreis: \\SI{{{lI.ListPrice}}}{{\\sieuro}}&{lI.Amount}&\\SI{{{lI.TotalDiscount}}}{{\\%}}&\\SI{{{lI.CalcTotalNet}}}{{\\sieuro}}\\\\"
: $"{lI.Position} &\\textbf{{{lI.CustomDescription.Heading}}} ({lI.ProductNumber})\\newline {lI.CustomDescription.DescriptionText}\\newline Listenpreis: \\SI{{{lI.ListPrice}}}{{\\sieuro}}&{lI.Amount}&\\SI{{{lI.TotalDiscount}}}{{\\%}}&\\SI{{{lI.CalcTotalNet}}}{{\\sieuro}}\\\\"; : $"{lI.Position} &\\textbf{{{lI.CustomDescriptionVM.Heading}}} ({lI.ProductNumber})\\newline {lI.CustomDescriptionVM.DescriptionText}\\newline Listenpreis: \\SI{{{lI.ListPrice}}}{{\\sieuro}}&{lI.Amount}&\\SI{{{lI.TotalDiscount}}}{{\\%}}&\\SI{{{lI.CalcTotalNet}}}{{\\sieuro}}\\\\";
} }
} }
else if (quoteVM.SinglePrices == false) else if (quoteVM.SinglePrices == false)
{ {
//ohne Einzelpreise //ohne Einzelpreise
lineItemTex = lI.OptionNumber != "" lineItemTex = lI.OptionNumber != ""
? $"{lI.Position} &\\textbf{{{lI.CustomDescription.Heading}}} ({lI.ProductNumber}\\#{lI.OptionNumber})\\newline {lI.CustomDescription.DescriptionText}&{lI.Amount}\\\\" ? $"{lI.Position} &\\textbf{{{lI.CustomDescriptionVM.Heading}}} ({lI.ProductNumber}\\#{lI.OptionNumber})\\newline {lI.CustomDescriptionVM.DescriptionText}&{lI.Amount}\\\\"
: $"{lI.Position} &\\textbf{{{lI.CustomDescription.Heading}}} ({lI.ProductNumber})\\newline {lI.CustomDescription.DescriptionText}&{lI.Amount}\\\\"; : $"{lI.Position} &\\textbf{{{lI.CustomDescriptionVM.Heading}}} ({lI.ProductNumber})\\newline {lI.CustomDescriptionVM.DescriptionText}&{lI.Amount}\\\\";
} }
_ = texFile.Append(lineItemTex + "\n"); _ = texFile.Append(lineItemTex + "\n");
@ -131,7 +129,7 @@ namespace Gremlin.Operations
_ = texFile.AppendLine($"\\textbf{{Gesamtsumme netto}} & \\SI{{{quoteVM.TotalNet}}}{{\\sieuro}}\\\\"); _ = texFile.AppendLine($"\\textbf{{Gesamtsumme netto}} & \\SI{{{quoteVM.TotalNet}}}{{\\sieuro}}\\\\");
//mit Mehrwertsteuer //mit Mehrwertsteuer
if (quoteVM.Brutto == true) if (quoteVM.ShowBrutto == true)
{ {
_ = texFile.AppendLine($"\\textbf{{Mehrwertsteuer {quoteVM.VAT}\\%}} & \\SI{{{(float)quoteVM.TotalNet * quoteVM.VAT / 100}}}{{\\sieuro}}\\\\"); _ = texFile.AppendLine($"\\textbf{{Mehrwertsteuer {quoteVM.VAT}\\%}} & \\SI{{{(float)quoteVM.TotalNet * quoteVM.VAT / 100}}}{{\\sieuro}}\\\\");
_ = texFile.AppendLine($"\\textbf{{Gesamtsumme brutto}} & \\SI{{{(float)quoteVM.TotalNet * (1 + (quoteVM.VAT / 100))}}}{{\\sieuro}}\\\\"); _ = texFile.AppendLine($"\\textbf{{Gesamtsumme brutto}} & \\SI{{{(float)quoteVM.TotalNet * (1 + (quoteVM.VAT / 100))}}}{{\\sieuro}}\\\\");
@ -151,7 +149,7 @@ namespace Gremlin.Operations
return texFile; return texFile;
} }
private static string CreateRBDisclaimer(QuoteVM quoteVM) private static string CreateRBDisclaimer(QuoteViewModel quoteVM)
{ {
Random r = new(); Random r = new();
@ -165,14 +163,14 @@ namespace Gremlin.Operations
foreach (LineItemVM lineItemWithRB in lineItemsWithRB) foreach (LineItemVM lineItemWithRB in lineItemsWithRB)
{ {
int rbcount = r.Next(20) - 5; //Get count of RB? int rbcount = r.Next(20) - 5; //Get count of RB?
rbDisclaimer += $"{lineItemWithRB.ProductNumber} & {lineItemWithRB.CustomDescription.Heading} & {rbcount}\\\\ \n"; rbDisclaimer += $"{lineItemWithRB.ProductNumber} & {lineItemWithRB.CustomDescriptionVM.Heading} & {rbcount}\\\\ \n";
} }
rbDisclaimer += "\\end{tabular}\n\\end{center}\n"; rbDisclaimer += "\\end{tabular}\n\\end{center}\n";
return rbDisclaimer; return rbDisclaimer;
} }
private static string Create3PPDisclaimer(QuoteVM quoteVM) private static string Create3PPDisclaimer(QuoteViewModel quoteVM)
{ {
string dreipp = "\\textbf{Hinweis zu Non-Agilent-Produkten}\\\\ \n" string dreipp = "\\textbf{Hinweis zu Non-Agilent-Produkten}\\\\ \n"
+ $"Bitte beachten Sie, dass das/die o.g. Produkt/e "; + $"Bitte beachten Sie, dass das/die o.g. Produkt/e ";
@ -200,12 +198,12 @@ namespace Gremlin.Operations
private static string GetCoverletterRow(LineItemVM lineItemVM) private static string GetCoverletterRow(LineItemVM lineItemVM)
{ {
return lineItemVM.CustomDescription.CoverletterText is null or "" return lineItemVM.CustomDescriptionVM.CoverletterText is null or ""
? $"\\item {lineItemVM.CustomDescription.Heading} (\\#{lineItemVM.Position})\n" ? $"\\item {lineItemVM.CustomDescriptionVM.Heading} (\\#{lineItemVM.Position})\n"
: $"\\item {lineItemVM.CustomDescription.CoverletterText} (\\#{lineItemVM.Position})\n"; : $"\\item {lineItemVM.CustomDescriptionVM.CoverletterText} (\\#{lineItemVM.Position})\n";
} }
private static string CreateCoverletter(QuoteVM quoteVM) private static string CreateCoverletter(QuoteViewModel quoteVM)
{ {
bool subitem = false; bool subitem = false;

@ -1,14 +1,14 @@
<Window x:Class="Gremlin.GremlinUI.QuoteUI" <Window x:Class="Gremlin.MVVM.QuoteUI"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:viewmodels="clr-namespace:Gremlin.GremlinUI.ViewModels" d:DataContext="{d:DesignInstance Type=viewmodels:QuoteVM}" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:viewmodels="clr-namespace:Gremlin.MVVM" d:DataContext="{d:DesignInstance Type=viewmodels:QuoteViewModel}"
mc:Ignorable="d" mc:Ignorable="d"
ResizeMode="NoResize" ResizeMode="NoResize"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
Title="Gremlin QuoteUI" Height="1024" Width="1280"> Title="Gremlin QuoteUI" Height="1024" Width="1280">
<Window.Resources> <Window.Resources>
<viewmodels:QuoteVM x:Key="m" ></viewmodels:QuoteVM> <viewmodels:QuoteViewModel x:Key="m" ></viewmodels:QuoteViewModel>
</Window.Resources> </Window.Resources>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@ -85,7 +85,7 @@
</StackPanel> </StackPanel>
<StackPanel x:Name="Opp" Grid.Row="0" Grid.Column="2" Orientation="Vertical"> <StackPanel x:Name="Opp" Grid.Row="0" Grid.Column="2" Orientation="Vertical">
<CheckBox d:DataContext="{d:DesignInstance Type=viewmodels:QuoteVM}" x:Name="cbBrutto" Content="Brutto anzeigen" Margin="10,5,10,5" IsChecked="{Binding Path=Brutto, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Click="CbBrutto_Click"/> <CheckBox d:DataContext="{d:DesignInstance Type=viewmodels:QuoteViewModel}" x:Name="cbBrutto" Content="Brutto anzeigen" Margin="10,5,10,5" IsChecked="{Binding Path=Brutto, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Click="CbBrutto_Click"/>
<CheckBox x:Name="cbSinglePrices" Content="Einzelpreise ausweisen" Margin="10,5,10,5" IsChecked="{Binding Path=SinglePrices, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Click="CbSinglePrices_Click" /> <CheckBox x:Name="cbSinglePrices" Content="Einzelpreise ausweisen" Margin="10,5,10,5" IsChecked="{Binding Path=SinglePrices, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Click="CbSinglePrices_Click" />
<CheckBox x:Name="cbShowDiscounts" Content="Discounts ausweisen" Margin="10,5,10,5" IsChecked="{Binding Path=ShowDiscounts, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Click="CbShowDiscounts_Click"/> <CheckBox x:Name="cbShowDiscounts" Content="Discounts ausweisen" Margin="10,5,10,5" IsChecked="{Binding Path=ShowDiscounts, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Click="CbShowDiscounts_Click"/>
<CheckBox x:Name="cbBrochure" Content="Broschüren anhängen" Margin="10,5,10,5" IsChecked="{Binding Path=Brochures, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Click="CbBrochure_Click" /> <CheckBox x:Name="cbBrochure" Content="Broschüren anhängen" Margin="10,5,10,5" IsChecked="{Binding Path=Brochures, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Click="CbBrochure_Click" />

@ -1,20 +1,16 @@
using Gremlin.GremlinData.EntityClasses; using Gremlin.GremlinData.EntityClasses;
using Gremlin.GremlinUI.ViewModels;
using Gremlin.Operations; using Gremlin.Operations;
using Gremlin.ViewModels;
using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Windows; using System.Windows;
using System.Windows.Data; using System.Windows.Data;
namespace Gremlin.GremlinUI namespace Gremlin.MVVM
{ {
public partial class QuoteUI : Window public partial class QuoteUI : Window
{ {
private static ListCollectionView listCollectionContacts = new(new ObservableCollection<Contact>()); private static ListCollectionView listCollectionContacts = new(new ObservableCollection<Contact>());
private static ListCollectionView lineItems = new(new ObservableCollection<LineItemVM>()); private static ListCollectionView lineItems = new(new ObservableCollection<LineItemVM>());
private QuoteVM quoteVM = new(ContactVM.GetSalesRepAsContact(1)); private QuoteViewModel quoteVM = new(ContactVM.GetSalesRepAsContact(1));
public QuoteUI() public QuoteUI()
{ {
@ -51,7 +47,7 @@ namespace Gremlin.GremlinUI
int warranty = int.TryParse(tbWarranty.Text, out int defaultWarranty) ? defaultWarranty : 12; int warranty = int.TryParse(tbWarranty.Text, out int defaultWarranty) ? defaultWarranty : 12;
int validity = int.TryParse(tbValidity.Text, out int defaultValidity) ? defaultValidity : 60; int validity = int.TryParse(tbValidity.Text, out int defaultValidity) ? defaultValidity : 60;
quoteVM = QuoteVM.CreateQuote(tbQuoteNumber.Text, quoteVM = QuoteViewModel.CreateQuote(tbQuoteNumber.Text,
ContactVM.ConvertObjectToContactVM(dgFoundContacts.SelectedItem), ContactVM.ConvertObjectToContactVM(dgFoundContacts.SelectedItem),
quoteVM.SalesRep, quoteVM.SalesRep,
vat, vat,
@ -104,7 +100,7 @@ namespace Gremlin.GremlinUI
private void TbQuoteType_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) private void TbQuoteType_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{ {
quoteVM.OnPropertyChanged("QuoteType"); //quoteVM.OnPropertyChanged("QuoteType");
} }
private void TbQuotePath(object sender, System.Windows.Controls.TextChangedEventArgs e) private void TbQuotePath(object sender, System.Windows.Controls.TextChangedEventArgs e)
@ -129,7 +125,7 @@ namespace Gremlin.GremlinUI
private void CbBrutto_Click(object sender, RoutedEventArgs e) private void CbBrutto_Click(object sender, RoutedEventArgs e)
{ {
quoteVM.Brutto = cbBrutto.IsChecked; quoteVM.ShowBrutto = cbBrutto.IsChecked;
} }
private void CbSinglePrices_Click(object sender, RoutedEventArgs e) private void CbSinglePrices_Click(object sender, RoutedEventArgs e)

@ -1,13 +1,12 @@
using Gremlin.GremlinData.DBClasses; using Gremlin.GremlinData.DBClasses;
using Gremlin.GremlinData.EntityClasses; using Gremlin.GremlinData.EntityClasses;
using Gremlin.ViewModels;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
namespace Gremlin.GremlinUI.ViewModels namespace Gremlin.MVVM
{ {
internal class AccountVM : BaseVM internal class AccountVM : BaseVM
{ {

@ -2,7 +2,7 @@
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
namespace Gremlin.GremlinUI.ViewModels namespace Gremlin.MVVM
{ {
internal class BaseVM : INotifyPropertyChanged internal class BaseVM : INotifyPropertyChanged
{ {

@ -1,5 +1,4 @@
using Gremlin.GremlinData.DBClasses; using Gremlin.GremlinData.DBClasses;
using Gremlin.GremlinUI.ViewModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@ -9,7 +8,7 @@ using System.Windows.Data;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Gremlin.GremlinData.EntityClasses; using Gremlin.GremlinData.EntityClasses;
namespace Gremlin.ViewModels namespace Gremlin.MVVM
{ {
internal class ContactVM : BaseVM internal class ContactVM : BaseVM
{ {

@ -3,9 +3,9 @@ using Gremlin.GremlinData.EntityClasses;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
namespace Gremlin.GremlinUI.ViewModels namespace Gremlin.MVVM
{ {
internal class CustomDescriptionVM internal class CustomDescriptionViewModel
{ {
public string Heading { get; set; } public string Heading { get; set; }
public string DescriptionText { get; set; } public string DescriptionText { get; set; }
@ -14,13 +14,13 @@ namespace Gremlin.GremlinUI.ViewModels
public override string ToString() => $"{Heading}"; public override string ToString() => $"{Heading}";
internal static CustomDescriptionVM GetCustomDescription(LineItemVM lineItemVM) internal static CustomDescriptionViewModel GetCustomDescription(LineItemVM lineItemVM)
{ {
string tempOptionNumber; string tempOptionNumber;
using (GremlinContext gremlinContext = new()) using (GremlinContext gremlinContext = new())
{ {
tempOptionNumber = lineItemVM.OptionNumber == "" ? null : lineItemVM.OptionNumber; tempOptionNumber = lineItemVM.OptionNumber == "" ? null : lineItemVM.OptionNumber;
CustomDescriptionVM customDescriptionVM = new(); CustomDescriptionViewModel customDescriptionVM = new();
CustomDescription customDescription = gremlinContext.CustomDescriptions.Where(cD => cD.ProductNumber == lineItemVM.ProductNumber && cD.OptionNumber == tempOptionNumber) CustomDescription customDescription = gremlinContext.CustomDescriptions.Where(cD => cD.ProductNumber == lineItemVM.ProductNumber && cD.OptionNumber == tempOptionNumber)
.FirstOrDefault(); .FirstOrDefault();

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Windows; using System.Windows;
namespace Gremlin.GremlinUI.ViewModels namespace Gremlin.MVVM
{ {
internal class LineItemVM : BaseVM internal class LineItemVM : BaseVM
{ {
@ -12,7 +12,7 @@ namespace Gremlin.GremlinUI.ViewModels
public string ProductNumber { get; private set; } public string ProductNumber { get; private set; }
public string OptionNumber { get; private set; } public string OptionNumber { get; private set; }
public string SapShortDescription { get; private set; } public string SapShortDescription { get; private set; }
public CustomDescriptionVM CustomDescription { get; private set; } public CustomDescriptionViewModel CustomDescriptionVM { get; private set; }
public string ProductLine { get; private set; } public string ProductLine { get; private set; }
public decimal TotalDiscount { get; internal set; } public decimal TotalDiscount { get; internal set; }
public decimal CalcNetPrice { get; private set; } public decimal CalcNetPrice { get; private set; }
@ -91,7 +91,7 @@ namespace Gremlin.GremlinUI.ViewModels
//lineItem.PromotionalDiscount = decimal.Parse(lineItemString[14]); //lineItem.PromotionalDiscount = decimal.Parse(lineItemString[14]);
//lineItem.DemoDiscount = decimal.Parse(lineItemString[15]); //lineItem.DemoDiscount = decimal.Parse(lineItemString[15]);
lineItem.CustomDescription = CustomDescriptionVM.GetCustomDescription(lineItem); lineItem.CustomDescriptionVM = CustomDescriptionViewModel.GetCustomDescription(lineItem);
lineItems.Add(lineItem); lineItems.Add(lineItem);
} }

@ -1,12 +1,12 @@
using Gremlin.ViewModels; using Caliburn.Micro;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
namespace Gremlin.GremlinUI.ViewModels namespace Gremlin.MVVM
{ {
internal class QuoteVM : BaseVM internal class QuoteViewModel : PropertyChangedBase
{ {
private string _quoteType = "ein Analysegerät"; private string _quoteType = "ein Analysegerät";
private string _quotePath; private string _quotePath;
@ -20,7 +20,7 @@ namespace Gremlin.GremlinUI.ViewModels
private decimal _averageDiscount; private decimal _averageDiscount;
private decimal _totalNet; private decimal _totalNet;
private float _vAT = 19f; private float _vAT = 19f;
private bool? _brutto = true; private bool? _showBrutto = true;
private bool? _singlePrices = true; private bool? _singlePrices = true;
private bool? _brochures = false; private bool? _brochures = false;
private bool? _dataSheets = false; private bool? _dataSheets = false;
@ -36,20 +36,23 @@ namespace Gremlin.GremlinUI.ViewModels
internal set internal set
{ {
_quoteType = value; _quoteType = value;
OnPropertyChanged("QuoteType"); NotifyOfPropertyChange(() => QuoteType);
} }
} }
public string QuotePath public string QuotePath
{ {
get => _quotePath; get => _quotePath;
internal set internal set
{ {
_quotePath = value; _quotePath = value;
OnPropertyChanged("QuotePath"); NotifyOfPropertyChange(() => QuotePath);
} }
} }
public bool? ShowBrutto { get => _showBrutto; internal set { _showBrutto = value; NotifyOfPropertyChange(() => ShowBrutto); } }
public List<LineItemVM> LineItemsVM { get => _lineItemsVM; private set => _lineItemsVM = value; } public List<LineItemVM> LineItemsVM { get => _lineItemsVM; private set => _lineItemsVM = value; }
public ContactVM Recipient { get => _recipient; internal set => _recipient = value; } public ContactVM Recipient { get => _recipient; internal set => _recipient = value; }
public ContactVM SalesRep { get => _salesRep; private set => _salesRep = value; } public ContactVM SalesRep { get => _salesRep; private set => _salesRep = value; }
@ -60,7 +63,6 @@ namespace Gremlin.GremlinUI.ViewModels
public decimal AverageDiscount { get => _averageDiscount; private set => _averageDiscount = value; } public decimal AverageDiscount { get => _averageDiscount; private set => _averageDiscount = value; }
public decimal TotalNet { get => _totalNet; private set => _totalNet = value; } public decimal TotalNet { get => _totalNet; private set => _totalNet = value; }
public float VAT { get => _vAT; private set => _vAT = value; } public float VAT { get => _vAT; private set => _vAT = value; }
public bool? Brutto { get => _brutto; internal set => _brutto = value; }
public bool? SinglePrices { get => _singlePrices; internal set => _singlePrices = value; } public bool? SinglePrices { get => _singlePrices; internal set => _singlePrices = value; }
public bool? Brochures { get => _brochures; internal set => _brochures = value; } public bool? Brochures { get => _brochures; internal set => _brochures = value; }
public bool? DataSheets { get => _dataSheets; internal set => _dataSheets = value; } public bool? DataSheets { get => _dataSheets; internal set => _dataSheets = value; }
@ -69,7 +71,7 @@ namespace Gremlin.GremlinUI.ViewModels
public bool QuoteContainsRB { get => _quoteContainsRB; private set => _quoteContainsRB = value; } public bool QuoteContainsRB { get => _quoteContainsRB; private set => _quoteContainsRB = value; }
public bool? ShowDiscounts { get => _showDiscounts; internal set => _showDiscounts = value; } public bool? ShowDiscounts { get => _showDiscounts; internal set => _showDiscounts = value; }
internal QuoteVM(ContactVM salesRep) internal QuoteViewModel(ContactVM salesRep)
{ {
Random random = new(); Random random = new();
SalesRep = salesRep; SalesRep = salesRep;
@ -81,15 +83,15 @@ namespace Gremlin.GremlinUI.ViewModels
}; };
} }
public QuoteVM() { } public QuoteViewModel() { }
private QuoteVM(string quoteNumber, string quoteType, ContactVM recipient, ContactVM salesRep, bool? brutto, float vAT, int warranty, int validity, string quotePath, bool? singlePrices, bool? brochures, bool? dataSheets, bool? mailTemplate, bool? showDiscounts) private QuoteViewModel(string quoteNumber, string quoteType, ContactVM recipient, ContactVM salesRep, bool? brutto, float vAT, int warranty, int validity, string quotePath, bool? singlePrices, bool? brochures, bool? dataSheets, bool? mailTemplate, bool? showDiscounts)
{ {
QuoteNumber = quoteNumber; QuoteNumber = quoteNumber;
QuoteType = quoteType; QuoteType = quoteType;
Recipient = recipient; Recipient = recipient;
SalesRep = salesRep; SalesRep = salesRep;
Brutto = brutto; ShowBrutto = brutto;
VAT = vAT; VAT = vAT;
Warranty = warranty; Warranty = warranty;
Validity = validity; Validity = validity;
@ -101,12 +103,12 @@ namespace Gremlin.GremlinUI.ViewModels
ShowDiscounts = showDiscounts; ShowDiscounts = showDiscounts;
} }
internal static QuoteVM CreateQuote(string quoteNumber, ContactVM recipient, ContactVM salesRep, float vAT = 19f, string quoteType = "ein Analysegerät", bool? brutto = true, int warranty = 12, bool? singlePrices = true, bool? brochures = true, bool? dataSheets = true, bool? mailTemplate = true, string quotePath = "", int validity = 60, bool? showDiscounts = true) internal static QuoteViewModel CreateQuote(string quoteNumber, ContactVM recipient, ContactVM salesRep, float vAT = 19f, string quoteType = "ein Analysegerät", bool? brutto = true, int warranty = 12, bool? singlePrices = true, bool? brochures = true, bool? dataSheets = true, bool? mailTemplate = true, string quotePath = "", int validity = 60, bool? showDiscounts = true)
{ {
decimal totalListprice = 0, totalDiscount = 0, calcTotalNet = 0; decimal totalListprice = 0, totalDiscount = 0, calcTotalNet = 0;
bool quoteContains3PP = false, quoteContainsRB = false; bool quoteContains3PP = false, quoteContainsRB = false;
QuoteVM quoteVM = new(quoteNumber, quoteType, recipient, salesRep, brutto, vAT, warranty, validity, quotePath, singlePrices, brochures, dataSheets, mailTemplate, showDiscounts); QuoteViewModel quoteVM = new(quoteNumber, quoteType, recipient, salesRep, brutto, vAT, warranty, validity, quotePath, singlePrices, brochures, dataSheets, mailTemplate, showDiscounts);
quoteVM.LineItemsVM = new(); quoteVM.LineItemsVM = new();
ObservableCollection<LineItemVM> lineItemsVM = LineItemVM.ReadLineItemsFromClipboard(); ObservableCollection<LineItemVM> lineItemsVM = LineItemVM.ReadLineItemsFromClipboard();

@ -0,0 +1,11 @@
<UserControl x:Class="Gremlin.MVVM.QuoteView"
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"
mc:Ignorable="d"
Width="100" Height="100">
<Grid>
</Grid>
</UserControl>

@ -0,0 +1,12 @@
using System.Windows.Controls;
namespace Gremlin.MVVM
{
public partial class QuoteView : UserControl
{
public QuoteView()
{
InitializeComponent();
}
}
}