added LineItemViewModel to ShellView

pull/1/head
Sascha Woitschetzki 2021-07-01 21:27:57 +07:00
parent ef0baf4169
commit fc2718c81e
13 changed files with 98 additions and 73 deletions

@ -109,13 +109,13 @@ namespace Gremlin.MVVM
private void BtnShowAccountList_Click(object sender, RoutedEventArgs e) private void BtnShowAccountList_Click(object sender, RoutedEventArgs e)
{ {
ObservableCollection<AccountVM> accounts = new(AccountVM.GetAllAccountsVM()); ObservableCollection<AccountViewModel> accounts = new(AccountViewModel.GetAllAccountsVM());
dg_Test.ItemsSource = accounts; dg_Test.ItemsSource = accounts;
} }
private void BtnShowContactList_Click(object sender, RoutedEventArgs e) private void BtnShowContactList_Click(object sender, RoutedEventArgs e)
{ {
ObservableCollection<ContactVM> contacts = new(ContactVM.GetAllContactsVM()); ObservableCollection<ContactViewModel> contacts = new(ContactViewModel.GetAllContactsVM());
dg_Test.ItemsSource = contacts; dg_Test.ItemsSource = contacts;
} }
} }

@ -41,7 +41,7 @@ namespace Gremlin.MVVM
_ = texFile.AppendLine($"Mobil:&{RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "userMobile")}\\\\"); _ = texFile.AppendLine($"Mobil:&{RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "userMobile")}\\\\");
_ = texFile.AppendLine($"E-Mail:&\\href{{mailto:{RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "userMail")}}}{{{RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "userMail")}}}\\\\"); _ = texFile.AppendLine($"E-Mail:&\\href{{mailto:{RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "userMail")}}}{{{RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "userMail")}}}\\\\");
_ = texFile.AppendLine("\\textbf{Auftragsannahme:}&\\href{mailto:salesservices\\_germany@agilent.com}{salesservices\\_germany@agilent.com}\\\\\n\\hline\n\\end{tabular}\n}\\\\"); _ = texFile.AppendLine("\\textbf{Auftragsannahme:}&\\href{mailto:salesservices\\_germany@agilent.com}{salesservices\\_germany@agilent.com}\\\\\n\\hline\n\\end{tabular}\n}\\\\");
if (quoteVM.Recipient != null) _ = texFile.Append(ContactVM.CreateBriefkopf(quoteVM.Recipient, true)); if (quoteVM.Recipient != null) _ = texFile.Append(ContactViewModel.CreateBriefkopf(quoteVM.Recipient, true));
_ = texFile.AppendLine("&\\\\\n&\\\\\n\\end{tabular}\n\\vspace{1cm}\\par "); _ = texFile.AppendLine("&\\\\\n&\\\\\n\\end{tabular}\n\\vspace{1cm}\\par ");
//Anrede //Anrede
@ -84,7 +84,7 @@ namespace Gremlin.MVVM
_ = texFile.AppendLine(@"\textbf{\#} & \textbf{Produktbeschreibung} (Produktnummer) & \textbf{Menge}\\ \hline \endhead"); _ = texFile.AppendLine(@"\textbf{\#} & \textbf{Produktbeschreibung} (Produktnummer) & \textbf{Menge}\\ \hline \endhead");
} }
foreach (LineItemVM lI in quoteVM.LineItemsVM) foreach (LineItemViewModel lI in quoteVM.LineItemsVM)
{ {
string lineItemTex = ""; string lineItemTex = "";
@ -156,11 +156,11 @@ namespace Gremlin.MVVM
string rbDisclaimer = "\\textbf{Wichtiger Hinweis zur Bestellung von überholten Geräten}\\\\\n"; 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"; 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<LineItemVM> lineItemsWithRB = quoteVM.LineItemsVM.Where(lI => lI.ProductLine == "RB").ToList(); List<LineItemViewModel> lineItemsWithRB = quoteVM.LineItemsVM.Where(lI => lI.ProductLine == "RB").ToList();
rbDisclaimer += "\\begin{center}\n\\begin{tabular}{clc}\n"; rbDisclaimer += "\\begin{center}\n\\begin{tabular}{clc}\n";
rbDisclaimer += "\\textbf{Modul} & \\textbf{Beschreibung} &\\textbf{Bestand}\\\\ \\hline \n"; rbDisclaimer += "\\textbf{Modul} & \\textbf{Beschreibung} &\\textbf{Bestand}\\\\ \\hline \n";
foreach (LineItemVM lineItemWithRB in lineItemsWithRB) foreach (LineItemViewModel 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.CustomDescriptionVM.Heading} & {rbcount}\\\\ \n"; rbDisclaimer += $"{lineItemWithRB.ProductNumber} & {lineItemWithRB.CustomDescriptionVM.Heading} & {rbcount}\\\\ \n";
@ -176,7 +176,7 @@ namespace Gremlin.MVVM
+ $"Bitte beachten Sie, dass das/die o.g. Produkt/e "; + $"Bitte beachten Sie, dass das/die o.g. Produkt/e ";
//List all 3PP product numbers //List all 3PP product numbers
List<LineItemVM> lineItemsWith3PP = quoteVM.LineItemsVM.Where(lI => lI.ProductLine == "3PP").ToList(); List<LineItemViewModel> lineItemsWith3PP = quoteVM.LineItemsVM.Where(lI => lI.ProductLine == "3PP").ToList();
for (int i = 0; i < lineItemsWith3PP.Count; i++) for (int i = 0; i < lineItemsWith3PP.Count; i++)
{ {
_ = i < lineItemsWith3PP.Count - 1 _ = i < lineItemsWith3PP.Count - 1
@ -196,7 +196,7 @@ namespace Gremlin.MVVM
return dreipp; return dreipp;
} }
private static string GetCoverletterRow(LineItemVM lineItemVM) private static string GetCoverletterRow(LineItemViewModel lineItemVM)
{ {
return lineItemVM.CustomDescriptionVM.CoverletterText is null or "" return lineItemVM.CustomDescriptionVM.CoverletterText is null or ""
? $"\\item {lineItemVM.CustomDescriptionVM.Heading} (\\#{lineItemVM.Position})\n" ? $"\\item {lineItemVM.CustomDescriptionVM.Heading} (\\#{lineItemVM.Position})\n"
@ -211,7 +211,7 @@ namespace Gremlin.MVVM
+ "Es umfasst im Einzelnen:\n" + "Es umfasst im Einzelnen:\n"
+ "\\begin{itemize}\n"; + "\\begin{itemize}\n";
foreach (LineItemVM lineItemVM in quoteVM.LineItemsVM) foreach (LineItemViewModel lineItemVM in quoteVM.LineItemsVM)
{ {
if (lineItemVM.OptionNumber == "") if (lineItemVM.OptionNumber == "")
{ {

@ -9,8 +9,8 @@ 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<LineItemViewModel>());
private QuoteViewModel quoteVM = new(ContactVM.GetSalesRepAsContact(1)); private QuoteViewModel quoteVM = new(ContactViewModel.GetSalesRepAsContact(1));
public QuoteUI() public QuoteUI()
{ {
@ -25,20 +25,20 @@ namespace Gremlin.MVVM
private void LoadContacts() private void LoadContacts()
{ {
listCollectionContacts = new(ContactVM.GetAllContactsVM()); listCollectionContacts = new(ContactViewModel.GetAllContactsVM());
listCollectionContacts.Filter = ContactVM.SearchContact(listCollectionContacts, tbContactSearch.Text); listCollectionContacts.Filter = ContactViewModel.SearchContact(listCollectionContacts, tbContactSearch.Text);
dgFoundContacts.ItemsSource = listCollectionContacts; dgFoundContacts.ItemsSource = listCollectionContacts;
UpdateUI(); UpdateUI();
} }
private void TbContactSearch_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) private void TbContactSearch_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{ {
listCollectionContacts.Filter = ContactVM.SearchContact(listCollectionContacts, tbContactSearch.Text); listCollectionContacts.Filter = ContactViewModel.SearchContact(listCollectionContacts, tbContactSearch.Text);
} }
private void DgFoundContacts_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) private void DgFoundContacts_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{ {
quoteVM.Recipient = ContactVM.ConvertObjectToContactVM(dgFoundContacts.SelectedItem); quoteVM.Recipient = ContactViewModel.ConvertObjectToContactVM(dgFoundContacts.SelectedItem);
} }
private void BtnPasteQuote_Click(object sender, RoutedEventArgs e) private void BtnPasteQuote_Click(object sender, RoutedEventArgs e)
@ -48,7 +48,7 @@ namespace Gremlin.MVVM
int validity = int.TryParse(tbValidity.Text, out int defaultValidity) ? defaultValidity : 60; int validity = int.TryParse(tbValidity.Text, out int defaultValidity) ? defaultValidity : 60;
quoteVM = QuoteViewModel.CreateQuote(tbQuoteNumber.Text, quoteVM = QuoteViewModel.CreateQuote(tbQuoteNumber.Text,
ContactVM.ConvertObjectToContactVM(dgFoundContacts.SelectedItem), ContactViewModel.ConvertObjectToContactVM(dgFoundContacts.SelectedItem),
quoteVM.SalesRep, quoteVM.SalesRep,
vat, vat,
tbQuoteType.Text, tbQuoteType.Text,
@ -65,7 +65,7 @@ namespace Gremlin.MVVM
if (quoteVM == null) return; if (quoteVM == null) return;
ObservableCollection<LineItemVM> lineItemsViewModel = new(quoteVM.LineItemsVM); ObservableCollection<LineItemViewModel> lineItemsViewModel = new(quoteVM.LineItemsVM);
lineItems = new(lineItemsViewModel); lineItems = new(lineItemsViewModel);
UpdateUI(); UpdateUI();
} }

@ -8,7 +8,7 @@ using System.Linq;
namespace Gremlin.MVVM namespace Gremlin.MVVM
{ {
internal class AccountVM : BaseVM internal class AccountViewModel : BaseViewModel
{ {
public uint SAPAccountNumber { get; set; } public uint SAPAccountNumber { get; set; }
public string AccountName { get; set; } public string AccountName { get; set; }
@ -19,18 +19,18 @@ namespace Gremlin.MVVM
public string FaxNumber { get; set; } public string FaxNumber { get; set; }
public string Webpage { get; set; } public string Webpage { get; set; }
public string EMail { get; set; } public string EMail { get; set; }
public ICollection<ContactVM> Contacts { get; set; } public ICollection<ContactViewModel> Contacts { get; set; }
public AccountType AccountType { get; set; } public AccountType AccountType { get; set; }
public SubMarket SubMarket { get; set; } public SubMarket SubMarket { get; set; }
public static ObservableCollection<AccountVM> GetAllAccountsVM() public static ObservableCollection<AccountViewModel> GetAllAccountsVM()
{ {
try try
{ {
using (GremlinContext gremlinContext = new()) using (GremlinContext gremlinContext = new())
{ {
List<Account> accounts = gremlinContext.Accounts.Include(account => account.Contacts).ToList(); List<Account> accounts = gremlinContext.Accounts.Include(account => account.Contacts).ToList();
ObservableCollection<AccountVM> accountsVM = new(); ObservableCollection<AccountViewModel> accountsVM = new();
foreach (Account account in accounts) foreach (Account account in accounts)
{ {
@ -48,9 +48,9 @@ namespace Gremlin.MVVM
} }
} }
public static AccountVM ConvertAccountToVM(Account account) public static AccountViewModel ConvertAccountToVM(Account account)
{ {
AccountVM accountVM = new(); AccountViewModel accountVM = new();
accountVM.AccountType = account.AccountType; accountVM.AccountType = account.AccountType;
accountVM.SubMarket = account.SubMarket; accountVM.SubMarket = account.SubMarket;
@ -64,10 +64,10 @@ namespace Gremlin.MVVM
accountVM.EMail = account.EMail; accountVM.EMail = account.EMail;
accountVM.SAPAccountNumber = account.SAPAccountNumber; accountVM.SAPAccountNumber = account.SAPAccountNumber;
List<ContactVM> contactsVM = new(); List<ContactViewModel> contactsVM = new();
foreach (Contact contact in account.Contacts) foreach (Contact contact in account.Contacts)
{ {
contactsVM.Add(ContactVM.ConvertContactToVM(contact)); contactsVM.Add(ContactViewModel.ConvertContactToVM(contact));
} }
accountVM.Contacts = contactsVM; accountVM.Contacts = contactsVM;

@ -4,7 +4,7 @@ using System.Runtime.CompilerServices;
namespace Gremlin.MVVM namespace Gremlin.MVVM
{ {
public class BaseVM : INotifyPropertyChanged public class BaseViewModel : INotifyPropertyChanged
{ {
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;

@ -10,7 +10,7 @@ using Gremlin.GremlinData.EntityClasses;
namespace Gremlin.MVVM namespace Gremlin.MVVM
{ {
public class ContactVM : BaseVM public class ContactViewModel : BaseViewModel
{ {
public byte Gender { get; private set; } public byte Gender { get; private set; }
public string FirstName { get; private set; } public string FirstName { get; private set; }
@ -21,9 +21,9 @@ namespace Gremlin.MVVM
public uint AccountZIP { get; private set; } public uint AccountZIP { get; private set; }
public string AccountCity { get; private set; } public string AccountCity { get; private set; }
public ContactVM() { } public ContactViewModel() { }
public ContactVM(byte gender, string firstName, string lastName, string eMail, string accountName, string accountStreet, uint accountZIP, string accountCity) public ContactViewModel(byte gender, string firstName, string lastName, string eMail, string accountName, string accountStreet, uint accountZIP, string accountCity)
{ {
Gender = gender; Gender = gender;
FirstName = firstName ?? throw new ArgumentNullException(nameof(firstName)); FirstName = firstName ?? throw new ArgumentNullException(nameof(firstName));
@ -35,14 +35,14 @@ namespace Gremlin.MVVM
AccountCity = accountCity ?? throw new ArgumentNullException(nameof(accountCity)); AccountCity = accountCity ?? throw new ArgumentNullException(nameof(accountCity));
} }
internal static ContactVM ConvertObjectToContactVM(object selectedItem) internal static ContactViewModel ConvertObjectToContactVM(object selectedItem)
{ {
ContactVM selectedContact = new(); ContactViewModel selectedContact = new();
if (selectedItem != CollectionView.NewItemPlaceholder) if (selectedItem != CollectionView.NewItemPlaceholder)
{ {
//TryCast //TryCast
selectedContact = selectedItem as ContactVM; selectedContact = selectedItem as ContactViewModel;
//if failed == null //if failed == null
if (selectedContact == null) if (selectedContact == null)
@ -65,7 +65,7 @@ namespace Gremlin.MVVM
{ {
return listCollectionContacts.Filter = (c) => return listCollectionContacts.Filter = (c) =>
{ {
ContactVM contact = c as ContactVM; ContactViewModel contact = c as ContactViewModel;
return contact.LastName.ToLower().Contains(search.ToLower()) return contact.LastName.ToLower().Contains(search.ToLower())
|| contact.FirstName.ToLower().Contains(search.ToLower()) || contact.FirstName.ToLower().Contains(search.ToLower())
|| contact.AccountName.ToLower().Contains(search.ToLower()) || contact.AccountName.ToLower().Contains(search.ToLower())
@ -78,17 +78,17 @@ namespace Gremlin.MVVM
return selectedItem != null return selectedItem != null
? selectedItem == CollectionView.NewItemPlaceholder ? selectedItem == CollectionView.NewItemPlaceholder
? "Bitte neuen Kontakt erstellen" ? "Bitte neuen Kontakt erstellen"
: CreateBriefkopf(selectedItem as ContactVM).ToString() : CreateBriefkopf(selectedItem as ContactViewModel).ToString()
: "Kein Kontakt gefunden!"; : "Kein Kontakt gefunden!";
} }
internal static ContactVM GetSalesRepAsContact(int SalesRepCode) internal static ContactViewModel GetSalesRepAsContact(int SalesRepCode)
{ {
switch (SalesRepCode) switch (SalesRepCode)
{ {
case 1: case 1:
{ {
ContactVM salesRepWoitschetzki = new((byte)Enums.Gender.Male, ContactViewModel salesRepWoitschetzki = new((byte)Enums.Gender.Male,
"Sascha", "Sascha",
"Woitschetzki", "Woitschetzki",
"sascha.woitschetzki@non.agilent.com", "sascha.woitschetzki@non.agilent.com",
@ -101,7 +101,7 @@ namespace Gremlin.MVVM
case 2: case 2:
{ {
ContactVM salesRepWelsch = new((byte)Enums.Gender.Male, ContactViewModel salesRepWelsch = new((byte)Enums.Gender.Male,
"Sebastian", "Sebastian",
"Welsch", "Welsch",
"sebastian.welsch@non.agilent.com", "sebastian.welsch@non.agilent.com",
@ -114,20 +114,20 @@ namespace Gremlin.MVVM
default: default:
{ {
ContactVM salesRep = new(); ContactViewModel salesRep = new();
return salesRep; return salesRep;
} }
} }
} }
public static ObservableCollection<ContactVM> GetAllContactsVM() public static ObservableCollection<ContactViewModel> GetAllContactsVM()
{ {
try try
{ {
using (GremlinContext gremlinContext = new()) using (GremlinContext gremlinContext = new())
{ {
List<Contact> contacts = gremlinContext.Contacts.Include(contact => contact.Account).ToList(); List<Contact> contacts = gremlinContext.Contacts.Include(contact => contact.Account).ToList();
ObservableCollection<ContactVM> contactsVM = new(); ObservableCollection<ContactViewModel> contactsVM = new();
foreach (Contact contact in contacts) foreach (Contact contact in contacts)
{ {
@ -145,9 +145,9 @@ namespace Gremlin.MVVM
} }
} }
public static ContactVM ConvertContactToVM(Contact contact) public static ContactViewModel ConvertContactToVM(Contact contact)
{ {
ContactVM contactVM = new(); ContactViewModel contactVM = new();
contactVM.Gender = contact.Gender; contactVM.Gender = contact.Gender;
contactVM.LastName = contact.LastName; contactVM.LastName = contact.LastName;
contactVM.FirstName = contact.FirstName; contactVM.FirstName = contact.FirstName;
@ -162,7 +162,7 @@ namespace Gremlin.MVVM
return contactVM; return contactVM;
} }
internal static StringBuilder CreateBriefkopf(ContactVM contactVM, bool tex = false) internal static StringBuilder CreateBriefkopf(ContactViewModel contactVM, bool tex = false)
{ {
StringBuilder briefkopf = new(); StringBuilder briefkopf = new();

@ -14,7 +14,7 @@ namespace Gremlin.MVVM
public override string ToString() => $"{Heading}"; public override string ToString() => $"{Heading}";
internal static CustomDescriptionViewModel GetCustomDescription(LineItemVM lineItemVM) internal static CustomDescriptionViewModel GetCustomDescription(LineItemViewModel lineItemVM)
{ {
string tempOptionNumber; string tempOptionNumber;
using (GremlinContext gremlinContext = new()) using (GremlinContext gremlinContext = new())

@ -5,7 +5,7 @@ using System.Windows;
namespace Gremlin.MVVM namespace Gremlin.MVVM
{ {
public class LineItemVM : BaseVM public class LineItemViewModel : BaseViewModel
{ {
public ushort Position { get; private set; } public ushort Position { get; private set; }
public ushort Amount { get; internal set; } public ushort Amount { get; internal set; }
@ -19,7 +19,7 @@ namespace Gremlin.MVVM
public decimal CalcTotalNet { get; private set; } public decimal CalcTotalNet { get; private set; }
public decimal ListPrice { get; private set; } public decimal ListPrice { get; private set; }
internal static ObservableCollection<LineItemVM> ReadLineItemsFromClipboard () internal static ObservableCollection<LineItemViewModel> ReadLineItemsFromClipboard ()
{ {
if (Clipboard.GetText() != "") if (Clipboard.GetText() != "")
{ {
@ -48,9 +48,9 @@ namespace Gremlin.MVVM
} }
} }
public static ObservableCollection<LineItemVM> ParseClipboardList(IEnumerable<string[]> lineItemStrings) public static ObservableCollection<LineItemViewModel> ParseClipboardList(IEnumerable<string[]> lineItemStrings)
{ {
ObservableCollection<LineItemVM> lineItems = new(); ObservableCollection<LineItemViewModel> lineItems = new();
int countError = 0; int countError = 0;
int countEmpty = 0; int countEmpty = 0;
@ -67,7 +67,7 @@ namespace Gremlin.MVVM
} }
//Dateiinhalt in Klasse schreiben //Dateiinhalt in Klasse schreiben
LineItemVM lineItem = new(); LineItemViewModel lineItem = new();
lineItem.Position = ushort.Parse(lineItemString[0]); lineItem.Position = ushort.Parse(lineItemString[0]);
lineItem.ProductNumber = lineItemString[1]; lineItem.ProductNumber = lineItemString[1];
lineItem.OptionNumber = lineItemString[2]; lineItem.OptionNumber = lineItemString[2];
@ -105,30 +105,30 @@ namespace Gremlin.MVVM
return lineItems; return lineItems;
} }
internal static decimal GetTotalNet(ObservableCollection<LineItemVM> lineItems) internal static decimal GetTotalNet(ObservableCollection<LineItemViewModel> lineItems)
{ {
decimal totalNet = 0; decimal totalNet = 0;
foreach (LineItemVM lineItem in lineItems) foreach (LineItemViewModel lineItem in lineItems)
{ {
totalNet += lineItem.CalcNetPrice; totalNet += lineItem.CalcNetPrice;
} }
return totalNet; return totalNet;
} }
internal static decimal GetTotalDiscount(ObservableCollection<LineItemVM> lineItems) internal static decimal GetTotalDiscount(ObservableCollection<LineItemViewModel> lineItems)
{ {
decimal totalDiscount = 0; decimal totalDiscount = 0;
foreach (LineItemVM lineItem in lineItems) foreach (LineItemViewModel lineItem in lineItems)
{ {
totalDiscount += lineItem.TotalDiscount; totalDiscount += lineItem.TotalDiscount;
} }
return totalDiscount; return totalDiscount;
} }
internal static decimal GetTotalListprice(ObservableCollection<LineItemVM> lineItems) internal static decimal GetTotalListprice(ObservableCollection<LineItemViewModel> lineItems)
{ {
decimal totalListprice = 0; decimal totalListprice = 0;
foreach (LineItemVM lineItem in lineItems) foreach (LineItemViewModel lineItem in lineItems)
{ {
totalListprice += lineItem.ListPrice; totalListprice += lineItem.ListPrice;
} }

@ -10,9 +10,9 @@ namespace Gremlin.MVVM
{ {
private string _quoteType = "ein Analysegerät"; private string _quoteType = "ein Analysegerät";
private string _quotePath; private string _quotePath;
private List<LineItemVM> _lineItemsVM; private List<LineItemViewModel> _lineItemsVM;
private ContactVM _recipient; private ContactViewModel _recipient;
private ContactVM _salesRep; private ContactViewModel _salesRep;
private string _quoteNumber; private string _quoteNumber;
private int _warranty = 12; private int _warranty = 12;
private int _validity = 60; private int _validity = 60;
@ -41,9 +41,9 @@ namespace Gremlin.MVVM
public bool? UseMailTemplate { get => _useMailTemplate; internal set { _useMailTemplate = value; NotifyOfPropertyChange(() => UseMailTemplate); } } public bool? UseMailTemplate { get => _useMailTemplate; internal set { _useMailTemplate = value; NotifyOfPropertyChange(() => UseMailTemplate); } }
public bool? ShowDiscounts { get => _showDiscounts; internal set { _showDiscounts = value; NotifyOfPropertyChange(() => ShowDiscounts); } } public bool? ShowDiscounts { get => _showDiscounts; internal set { _showDiscounts = value; NotifyOfPropertyChange(() => ShowDiscounts); } }
public List<LineItemVM> LineItemsVM { get => _lineItemsVM; private set => _lineItemsVM = value; } public List<LineItemViewModel> LineItemsVM { get => _lineItemsVM; private set => _lineItemsVM = value; }
public ContactVM Recipient { get => _recipient; internal set => _recipient = value; } public ContactViewModel Recipient { get => _recipient; internal set => _recipient = value; }
public ContactVM SalesRep { get => _salesRep; private set => _salesRep = value; } public ContactViewModel SalesRep { get => _salesRep; private set => _salesRep = value; }
public decimal TotalListprice { get => _totalListprice; private set => _totalListprice = value; } public decimal TotalListprice { get => _totalListprice; private set => _totalListprice = value; }
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; }
@ -51,7 +51,7 @@ namespace Gremlin.MVVM
public bool QuoteContains3PP { get => _quoteContains3PP; private set => _quoteContains3PP = value; } public bool QuoteContains3PP { get => _quoteContains3PP; private set => _quoteContains3PP = value; }
public bool QuoteContainsRB { get => _quoteContainsRB; private set => _quoteContainsRB = value; } public bool QuoteContainsRB { get => _quoteContainsRB; private set => _quoteContainsRB = value; }
internal QuoteViewModel(ContactVM salesRep) internal QuoteViewModel(ContactViewModel salesRep)
{ {
Random random = new(); Random random = new();
SalesRep = salesRep; SalesRep = salesRep;
@ -65,7 +65,7 @@ namespace Gremlin.MVVM
public QuoteViewModel() { } public QuoteViewModel() { }
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) private QuoteViewModel(string quoteNumber, string quoteType, ContactViewModel recipient, ContactViewModel 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;
@ -83,7 +83,7 @@ namespace Gremlin.MVVM
ShowDiscounts = showDiscounts; ShowDiscounts = showDiscounts;
} }
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) internal static QuoteViewModel CreateQuote(string quoteNumber, ContactViewModel recipient, ContactViewModel 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;
@ -91,11 +91,11 @@ namespace Gremlin.MVVM
QuoteViewModel 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<LineItemViewModel> lineItemsVM = LineItemViewModel.ReadLineItemsFromClipboard();
if (lineItemsVM == null) return null; if (lineItemsVM == null) return null;
foreach (LineItemVM lineItemVM in lineItemsVM) foreach (LineItemViewModel lineItemVM in lineItemsVM)
{ {
totalListprice += lineItemVM.ListPrice; totalListprice += lineItemVM.ListPrice;
totalDiscount += lineItemVM.TotalDiscount; totalDiscount += lineItemVM.TotalDiscount;

@ -2,15 +2,13 @@
{ {
public class ShellViewModel public class ShellViewModel
{ {
public QuoteViewModel QuoteVM public QuoteViewModel QuoteVM { get; set; }
{ public LineItemViewModel LineVM { get; set; }
get;
set;
}
public ShellViewModel() public ShellViewModel()
{ {
QuoteVM = new QuoteViewModel(); QuoteVM = new QuoteViewModel();
LineVM = new LineItemViewModel();
} }
} }
} }

@ -0,0 +1,14 @@
<UserControl x:Class="Gremlin.MVVM.LineItemView"
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"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<StackPanel>
<DataGrid x:Name="LineItemViewModel" AutoGenerateColumns="True" Height="600" Margin="10,5,10,5" >
</DataGrid>
</StackPanel>
</Grid>
</UserControl>

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

@ -6,7 +6,8 @@
xmlns:cal="http://www.caliburnproject.org" xmlns:cal="http://www.caliburnproject.org"
xmlns:local="clr-namespace:Gremlin.MVVM" xmlns:local="clr-namespace:Gremlin.MVVM"
mc:Ignorable="d" > mc:Ignorable="d" >
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Vertical">
<local:QuoteView cal:Bind.Model="{Binding QuoteVM}" /> <local:QuoteView cal:Bind.Model="{Binding QuoteVM}" />
<!--<local:LineItemView cal:Bind.Model="{Binding LineItemVM}" />-->
</StackPanel> </StackPanel>
</UserControl> </UserControl>