create QuoteVM before loading lineItemsVM into it

pull/1/head
Sascha Woitschetzki 2021-06-10 18:21:51 +07:00
parent d9ebc29841
commit 1251e28eef
40 changed files with 238 additions and 201 deletions

@ -1,4 +1,4 @@
<Application x:Class="Gremlin.App"
<Application x:Class="Gremlin.Gremlin.GremlinData.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="GremlinUI/QuoteUI.xaml">

@ -11,8 +11,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using static Gremlin.Enums;
using static Gremlin.GremlinData.EntityClasses.Enums;
using Gremlin.GremlinUtilities;
using Gremlin.GremlinData.EntityClasses;
namespace Gremlin.GremlinData.DBClasses
{

@ -1,7 +1,7 @@
using System;
using System.Security;
namespace Gremlin
namespace Gremlin.GremlinData.DBClasses
{
internal class Encryption
{

@ -1,7 +1,8 @@
using Microsoft.EntityFrameworkCore;
using Gremlin.GremlinData.EntityClasses;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Gremlin
namespace Gremlin.GremlinData.DBClasses
{
public class AccountConfiguration : IEntityTypeConfiguration<Account>
{

@ -1,3 +1,4 @@
using Gremlin.GremlinData.EntityClasses;
using Gremlin.GremlinUI;
using Microsoft.EntityFrameworkCore;
using System;

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
namespace Gremlin
namespace Gremlin.GremlinData.EntityClasses
{
public class Account : IMetadata
//: IEquatable<Account>

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Gremlin
namespace Gremlin.GremlinData.EntityClasses
{
public class AccountType : IMetadata
{

@ -1,7 +1,6 @@
using Gremlin.GremlinData.DBClasses;
using System;
using System;
namespace Gremlin
namespace Gremlin.GremlinData.EntityClasses
{
public class Contact : IMetadata
{

@ -1,6 +1,6 @@
using System;
namespace Gremlin
namespace Gremlin.GremlinData.EntityClasses
{
public class CustomDescription : IMetadata
{

@ -1,6 +1,6 @@
namespace Gremlin
namespace Gremlin.GremlinData.EntityClasses
{
class Enums
internal class Enums
{
public enum Status : byte
{

@ -1,6 +1,6 @@
using System;
namespace Gremlin
namespace Gremlin.GremlinData.EntityClasses
{
public interface IMetadata
{

@ -1,6 +1,6 @@
using System;
namespace Gremlin
namespace Gremlin.GremlinData.EntityClasses
{
public class LineItem
{

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
namespace Gremlin
namespace Gremlin.GremlinData.EntityClasses
{
public class LoggedInUser
{

@ -1,6 +1,6 @@
using System;
namespace Gremlin
namespace Gremlin.GremlinData.EntityClasses
{
public class LoggedInUserSettings
{

@ -1,6 +1,6 @@
using System;
namespace Gremlin
namespace Gremlin.GremlinData.EntityClasses
{
public class Product : IMetadata
{

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
namespace Gremlin
namespace Gremlin.GremlinData.EntityClasses
{
public class ProductLine : IMetadata
{

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
namespace Gremlin
namespace Gremlin.GremlinData.EntityClasses
{
public class Quote
{
@ -34,18 +34,17 @@ namespace Gremlin
public bool QuoteContainsRB { get; set; }
public string QuoteTemplate { get; set; }
internal Quote()
{
//Initialize
QuotationDate = DateTime.Now;
//LineItems = new List<LineItem>();
TotalGross = 0;
TotalListprice = 0;
TotalDiscount = 0;
TotalNet = 0;
QuoteContains3PP = false;
QuoteContainsRB = false;
////Initialize
//QuotationDate = DateTime.Now;
////LineItems = new List<LineItem>();
//TotalGross = 0;
//TotalListprice = 0;
//TotalDiscount = 0;
//TotalNet = 0;
//QuoteContains3PP = false;
//QuoteContainsRB = false;
// set quote number
// set validity depending on account classification

@ -1,6 +1,6 @@
using System;
namespace Gremlin
namespace Gremlin.GremlinData.EntityClasses
{
public class RUSetting
{

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
namespace Gremlin
namespace Gremlin.GremlinData.EntityClasses
{
public class RegisteredUser
{

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Gremlin
namespace Gremlin.GremlinData.EntityClasses
{
public class SubMarket : IMetadata
{

@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using Gremlin.GremlinData.EntityClasses;
using System.Collections.ObjectModel;
namespace Gremlin.DataAccessLayer
{

@ -4,7 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="ChooseDB" Height="309" Width="600"
Title="Datenbank auswählen" Height="309" Width="600"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
SizeToContent="Height"

@ -1,4 +1,5 @@
using Gremlin.GremlinData.DBClasses;
using Gremlin.GremlinData.EntityClasses;
using Gremlin.GremlinUI.ViewModels;
using Gremlin.Models;
using Microsoft.Win32;
@ -85,7 +86,7 @@ namespace Gremlin.GremlinUI
private void BtnRefreshAccountList_Click(object sender, RoutedEventArgs e)
{
ObservableCollection<Account> accounts = new(AccountViewModel.GetAccounts());
ObservableCollection<Account> accounts = new(AcountVM.GetAccounts());
dg_Test.ItemsSource = accounts;
}

@ -1,4 +1,5 @@
using Gremlin.DataAccessLayer;
using Gremlin.GremlinData.EntityClasses;
using System.Collections.ObjectModel;
namespace Gremlin.Models

@ -1,4 +1,5 @@
using Gremlin.GremlinData.DBClasses;
using Gremlin.GremlinData.EntityClasses;
using Gremlin.GremlinUI;
using System;
using System.Collections.Generic;

@ -1,4 +1,5 @@
using Gremlin.GremlinData.DBClasses;
using Gremlin.GremlinData.EntityClasses;
using System.Linq;
namespace Gremlin.Models

@ -1,4 +1,5 @@
using System.Collections.Generic;
using Gremlin.GremlinData.EntityClasses;
using System.Collections.Generic;
namespace Gremlin.Operations
{

@ -1,4 +1,6 @@
namespace Gremlin.Operations
using Gremlin.GremlinData.EntityClasses;
namespace Gremlin.Operations
{
public class LineItemOperations
{

@ -1,4 +1,5 @@
using System.Collections.Generic;
using Gremlin.GremlinData.EntityClasses;
using System.Collections.Generic;
namespace Gremlin.Operations
{

@ -1,9 +1,9 @@
using Gremlin.Models;
using Gremlin.ViewModels;
using Gremlin.GremlinData.EntityClasses;
using Gremlin.Models;
using System.Collections.Generic;
using System.IO;
using System.Text;
using static Gremlin.Enums;
using static Gremlin.GremlinData.EntityClasses.Enums;
namespace Gremlin.Operations
{

@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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:AccountViewModel}"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
@ -81,7 +81,8 @@
<Grid Grid.Row="1" Height="Auto" x:Name="gridMitte" Margin="10,5,10,5" Grid.RowSpan="2">
<StackPanel>
<Button x:Name="butPasteQuote" Content="Angebot aus PriceSurfer einfügen" Margin="10,5,10,5" Click="ButPasteQuote_Click" />
<DataGrid x:Name="dgQuote" AutoGenerateColumns="True" Height="470" Margin="10,5,10,5" />
<DataGrid x:Name="dgLineItems" AutoGenerateColumns="True" Height="370" Margin="10,5,10,5" />
<TextBlock x:Name="lblQuote" Height="100" Margin="10,5,10,5" />
</StackPanel>
</Grid>

@ -1,6 +1,6 @@
using Gremlin.GremlinUI.ViewModels;
using Gremlin.GremlinData.EntityClasses;
using Gremlin.GremlinUI.ViewModels;
using Gremlin.ViewModels;
using Gremlin.Views;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Data;
@ -10,33 +10,37 @@ namespace Gremlin.GremlinUI
public partial class QuoteUI : Window
{
private static ListCollectionView listCollectionContacts = new(new ObservableCollection<Contact>());
private static ListCollectionView lineItems = new(new ObservableCollection<LineItemViewModel>());
private static ListCollectionView lineItems = new(new ObservableCollection<LineItemVM>());
public QuoteUI()
{
InitializeComponent();
listCollectionContacts = new(ContactViewModel.GetContacts());
listCollectionContacts.Filter = ContactViewModel.SearchContact(listCollectionContacts, tbContactSearch.Text);
listCollectionContacts = new(ContactVM.GetContacts());
listCollectionContacts.Filter = ContactVM.SearchContact(listCollectionContacts, tbContactSearch.Text);
dgFoundContacts.ItemsSource = listCollectionContacts;
dgQuote.ItemsSource = lineItems;
dgLineItems.ItemsSource = lineItems;
}
private void TbContactSearch_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
listCollectionContacts.Filter = ContactViewModel.SearchContact(listCollectionContacts, tbContactSearch.Text);
listCollectionContacts.Filter = ContactVM.SearchContact(listCollectionContacts, tbContactSearch.Text);
}
private void DgFoundContacts_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
txAnschreiben.Text = QuoteView.FilterContacts(dgFoundContacts.SelectedItem);
txAnschreiben.Text = ContactVM.FilterContacts(dgFoundContacts.SelectedItem);
}
private void ButPasteQuote_Click(object sender, RoutedEventArgs e)
{
ObservableCollection<LineItemViewModel> lineItemsViewModel = QuoteView.ReadLineItemsFromClipboard();
QuoteVM quoteVM = QuoteVM.CreateQuoteFromClipboard(tbQuotationNumber.Text, (ContactVM)dgFoundContacts.SelectedItem, null);
ObservableCollection<LineItemVM> lineItemsViewModel = LineItemVM.ReadLineItemsFromClipboard();
lblQuote.Text = $"{quoteVM.QuotationNumber}, {quoteVM.Recipient}, {quoteVM.SalesRep}, {quoteVM.TotalListprice}, {quoteVM.TotalDiscount}, {quoteVM.TotalNet}, {quoteVM.VAT}, {quoteVM.QuoteContains3PP}, {quoteVM.QuoteContainsRB}";
lineItems = new(lineItemsViewModel);
dgQuote.ItemsSource = lineItems;
QuoteViewModel quoteViewModel = QuoteView.CreateQuote(tbQuotationNumber.Text, (ContactViewModel)dgFoundContacts.SelectedItem, null, LineItemViewModel.GetTotalListprice(lineItemsViewModel), LineItemViewModel.GetTotalDiscount(lineItemsViewModel), LineItemViewModel.GetTotalNet(lineItemsViewModel), 19f, false, false);
dgLineItems.ItemsSource = lineItems;
}
}
}

@ -1,27 +0,0 @@
using Gremlin.GremlinData.DBClasses;
using System;
using System.Collections.ObjectModel;
using System.Linq;
namespace Gremlin.GremlinUI.ViewModels
{
internal class AccountViewModel : BaseViewModel
{
public static ObservableCollection<Account> GetAccounts()
{
try
{
using (GremlinContext gremlinContext = new())
{
return new ObservableCollection<Account>(gremlinContext.Accounts.ToList());
}
}
catch (Exception ex)
{
ErrorHandler.ShowErrorInMessageBox(ex);
return null;
throw;
}
}
}
}

@ -2,7 +2,7 @@
namespace Gremlin.GremlinUI.ViewModels
{
internal class BaseViewModel : INotifyPropertyChanged
internal class BaseVM : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;

@ -7,10 +7,11 @@ using System.Linq;
using System.Text;
using System.Windows.Data;
using Microsoft.EntityFrameworkCore;
using Gremlin.GremlinData.EntityClasses;
namespace Gremlin.ViewModels
{
internal class ContactViewModel : BaseViewModel
internal class ContactVM : BaseVM
{
public byte Gender { get; private set; }
public string FirstName { get; private set; }
@ -21,11 +22,25 @@ namespace Gremlin.ViewModels
public uint AccountZIP { get; private set; }
public string AccountCity { get; private set; }
public ContactVM() { }
public ContactVM(byte gender, string firstName, string lastName, string eMail, string accountName, string accountStreet, uint accountZIP, string accountCity)
{
Gender = gender;
FirstName = firstName ?? throw new ArgumentNullException(nameof(firstName));
LastName = lastName ?? throw new ArgumentNullException(nameof(lastName));
EMail = eMail ?? throw new ArgumentNullException(nameof(eMail));
AccountName = accountName ?? throw new ArgumentNullException(nameof(accountName));
AccountStreet = accountStreet ?? throw new ArgumentNullException(nameof(accountStreet));
AccountZIP = accountZIP;
AccountCity = accountCity ?? throw new ArgumentNullException(nameof(accountCity));
}
internal static Predicate<object> SearchContact(ListCollectionView listCollectionContacts, string search)
{
return listCollectionContacts.Filter = (c) =>
{
ContactViewModel contact = c as ContactViewModel;
ContactVM contact = c as ContactVM;
return contact.LastName.ToLower().Contains(search.ToLower())
|| contact.FirstName.ToLower().Contains(search.ToLower())
|| contact.AccountName.ToLower().Contains(search.ToLower())
@ -33,18 +48,45 @@ namespace Gremlin.ViewModels
};
}
public static ObservableCollection<ContactViewModel> GetContacts()
internal static string FilterContacts(object selectedItem)
{
return selectedItem == null
? "Kein Kontakt gefunden!"
: selectedItem == CollectionView.NewItemPlaceholder
? "Bitte neuen Kontakt erstellen"
: CreateBriefkopf(selectedItem as ContactVM).ToString();
}
internal static ContactVM GetSalesRepAsContact()
{
//Get SalesRep Contact Details from logged-in User
//TODO
//Standard SalesRep
ContactVM salesRep = new((byte)Enums.Gender.Male,
"Sascha",
"Woitschetzki",
"sascha.woitschetzki@non.agilent.com",
"Handelsvertretung Sascha Woitschetzki",
"Parsevalstr. 58",
45470,
"Mülheim an der Ruhr");
return salesRep;
}
public static ObservableCollection<ContactVM> GetContacts()
{
try
{
using (GremlinContext gremlinContext = new())
{
List<Contact> contacts = gremlinContext.Contacts.Include(contact => contact.Account).ToList();
ObservableCollection<ContactViewModel> contactsViewModel = new();
ObservableCollection<ContactVM> contactsViewModel = new();
foreach (Contact contact in contacts)
{
ContactViewModel contactViewModel = new();
ContactVM contactViewModel = new();
contactViewModel.Gender = contact.Gender;
contactViewModel.LastName = contact.LastName;
contactViewModel.FirstName = contact.FirstName;
@ -70,7 +112,7 @@ namespace Gremlin.ViewModels
}
}
internal static StringBuilder CreateBriefkopf(ContactViewModel contactViewModel)
internal static StringBuilder CreateBriefkopf(ContactVM contactViewModel)
{
StringBuilder briefkopf = new();

@ -2,11 +2,10 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Data;
namespace Gremlin.GremlinUI.ViewModels
{
internal class LineItemViewModel : BaseViewModel
internal class LineItemVM : BaseVM
{
public ushort Position { get; set; }
public ushort Amount { get; set; }
@ -22,11 +21,41 @@ namespace Gremlin.GremlinUI.ViewModels
//public decimal DemoDiscount { get; set; }
public decimal ListPrice { get; set; }
public decimal NetPrice { get; set; }
public decimal Total { get; set; }
public decimal TotalNet { get; set; }
public static ObservableCollection<LineItemViewModel> ParseClipboardList(IEnumerable<string[]> lineItemStrings)
internal static ObservableCollection<LineItemVM> ReadLineItemsFromClipboard()
{
ObservableCollection<LineItemViewModel> lineItems = new();
if (Clipboard.GetText() != "")
{
//Clipboard einlesen
string clipboard = Clipboard.GetText();
//Zeilen aufteilen
IEnumerable<string> clipboardLines = clipboard.Split(Environment.NewLine.ToCharArray());
List<string[]> clipboardList = new();
foreach (string clipboardLine in clipboardLines)
{
if (clipboardLine != "")
{
//Nach Trennzeichen trennen
string[] clipboardLineSplit = clipboardLine.Split('\t');
clipboardList.Add(clipboardLineSplit);
}
}
return LineItemVM.ParseClipboardList(clipboardList);
}
else
{
_ = MessageBox.Show("Clipboard ist leer!");
return null;
}
}
public static ObservableCollection<LineItemVM> ParseClipboardList(IEnumerable<string[]> lineItemStrings)
{
ObservableCollection<LineItemVM> lineItems = new();
int countError = 0;
int countEmpty = 0;
@ -43,7 +72,7 @@ namespace Gremlin.GremlinUI.ViewModels
}
//Dateiinhalt in Klasse schreiben
LineItemViewModel lineItem = new();
LineItemVM lineItem = new();
lineItem.Position = ushort.Parse(lineItemString[0]);
lineItem.ProductNumber = lineItemString[1];
lineItem.OptionNumber = lineItemString[2];
@ -53,7 +82,7 @@ namespace Gremlin.GremlinUI.ViewModels
lineItem.ListPrice = decimal.Parse(lineItemString[6]);
lineItem.TotalDiscount = decimal.Parse(lineItemString[9]);
lineItem.NetPrice = decimal.Parse(lineItemString[10]);
lineItem.Total = decimal.Parse(lineItemString[11]);
lineItem.TotalNet = decimal.Parse(lineItemString[11]);
//lineItem.SalesDiscount = decimal.Parse(lineItemString[12]);
//lineItem.ContractualDiscount = decimal.Parse(lineItemString[13]);
//lineItem.PromotionalDiscount = decimal.Parse(lineItemString[14]);
@ -72,30 +101,30 @@ namespace Gremlin.GremlinUI.ViewModels
return lineItems;
}
internal static decimal GetTotalNet(ObservableCollection<LineItemViewModel> lineItems)
internal static decimal GetTotalNet(ObservableCollection<LineItemVM> lineItems)
{
decimal totalNet = 0;
foreach (LineItemViewModel lineItem in lineItems)
foreach (LineItemVM lineItem in lineItems)
{
totalNet += lineItem.NetPrice;
}
return totalNet;
}
internal static decimal GetTotalDiscount(ObservableCollection<LineItemViewModel> lineItems)
internal static decimal GetTotalDiscount(ObservableCollection<LineItemVM> lineItems)
{
decimal totalDiscount = 0;
foreach (LineItemViewModel lineItem in lineItems)
foreach (LineItemVM lineItem in lineItems)
{
totalDiscount += lineItem.TotalDiscount;
}
return totalDiscount;
}
internal static decimal GetTotalListprice(ObservableCollection<LineItemViewModel> lineItems)
internal static decimal GetTotalListprice(ObservableCollection<LineItemVM> lineItems)
{
decimal totalListprice = 0;
foreach (LineItemViewModel lineItem in lineItems)
foreach (LineItemVM lineItem in lineItems)
{
totalListprice += lineItem.ListPrice;
}

@ -0,0 +1,76 @@
using Gremlin.ViewModels;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Gremlin.GremlinUI.ViewModels
{
internal class QuoteVM : BaseVM
{
public string QuotationNumber { get; set; }
public ContactVM Recipient { get; set; }
public ContactVM SalesRep { get; set; }
public ICollection<LineItemVM> LineItemsVM { get; set; }
public decimal TotalListprice { get; set; }
public decimal TotalDiscount { get; set; }
public decimal TotalNet { get; set; }
public float VAT { get; set; }
public bool QuoteContains3PP { get; set; }
public bool QuoteContainsRB { get; set; }
internal QuoteVM() { }
internal QuoteVM(string quotationNumber, ContactVM recipient, ContactVM salesRep, decimal totalListprice, decimal totalDiscount, decimal totalNet, float vAT, bool quoteContains3PP, bool quoteContainsRB)
{
QuotationNumber = quotationNumber ?? throw new ArgumentNullException(nameof(quotationNumber));
Recipient = recipient ?? throw new ArgumentNullException(nameof(recipient));
SalesRep = salesRep ?? throw new ArgumentNullException(nameof(salesRep));
TotalListprice = totalListprice;
TotalDiscount = totalDiscount;
TotalNet = totalNet;
VAT = vAT;
QuoteContains3PP = quoteContains3PP;
QuoteContainsRB = quoteContainsRB;
}
internal static QuoteVM CreateQuoteFromClipboard(string quotationNumber, ContactVM recipient, ContactVM salesRep, float vAT = 19f)
{
QuoteVM quoteVM = new();
decimal totalListprice = 0, totalDiscount = 0, totalNet = 0;
bool quoteContains3PP = false, quoteContainsRB = false;
quoteVM.QuotationNumber = quotationNumber;
quoteVM.Recipient = recipient;
quoteVM.SalesRep = salesRep;
quoteVM.VAT = vAT;
ObservableCollection<LineItemVM> lineItemsVM = LineItemVM.ReadLineItemsFromClipboard();
foreach (LineItemVM lineItemVM in lineItemsVM)
{
totalListprice += lineItemVM.ListPrice;
totalDiscount += lineItemVM.TotalDiscount;
totalNet += lineItemVM.TotalNet;
if (lineItemVM.ProductLine == "RB")
{
quoteContainsRB = true;
}
else if (lineItemVM.ProductLine == "3PP")
{
quoteContains3PP = true;
}
quoteVM.LineItemsVM.Add(lineItemVM);
}
quoteVM.TotalListprice = totalListprice;
quoteVM.TotalDiscount = totalDiscount;
quoteVM.TotalNet = totalNet;
quoteVM.QuoteContainsRB = quoteContainsRB;
quoteVM.QuoteContains3PP = quoteContains3PP;
return quoteVM;
}
}
}

@ -1,35 +0,0 @@
using Gremlin.ViewModels;
using System;
namespace Gremlin.GremlinUI.ViewModels
{
internal class QuoteViewModel : BaseViewModel
{
public string QuotationNumber { get; set; }
public ContactViewModel Recipient { get; set; }
public ContactViewModel SalesRep { get; set; }
public decimal TotalListprice { get; set; }
public decimal TotalDiscount { get; set; }
public decimal TotalNet { get; set; }
public float VAT { get; set; }
public bool QuoteContains3PP { get; set; }
public bool QuoteContainsRB { get; set; }
internal QuoteViewModel()
{
}
internal QuoteViewModel(string quotationNumber, ContactViewModel recipient, ContactViewModel salesRep, decimal totalListprice, decimal totalDiscount, decimal totalNet, float vAT, bool quoteContains3PP, bool quoteContainsRB)
{
QuotationNumber = quotationNumber ?? throw new ArgumentNullException(nameof(quotationNumber));
Recipient = recipient ?? throw new ArgumentNullException(nameof(recipient));
SalesRep = salesRep;
TotalListprice = totalListprice;
TotalDiscount = totalDiscount;
TotalNet = totalNet;
VAT = vAT;
QuoteContains3PP = quoteContains3PP;
QuoteContainsRB = quoteContainsRB;
}
}
}

@ -1,63 +0,0 @@
using Gremlin.GremlinData.DBClasses;
using Gremlin.GremlinUI.ViewModels;
using Gremlin.ViewModels;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Data;
namespace Gremlin.Views
{
internal class QuoteView
{
internal static ObservableCollection<LineItemViewModel> ReadLineItemsFromClipboard()
{
if (Clipboard.GetText() != "")
{
//Clipboard einlesen
string clipboard = Clipboard.GetText();
//Zeilen aufteilen
IEnumerable<string> clipboardLines = clipboard.Split(Environment.NewLine.ToCharArray());
List<string[]> clipboardList = new();
foreach (string clipboardLine in clipboardLines)
{
if (clipboardLine != "")
{
//Nach Trennzeichen trennen
string[] clipboardLineSplit = clipboardLine.Split('\t');
clipboardList.Add(clipboardLineSplit);
}
}
return LineItemViewModel.ParseClipboardList(clipboardList);
}
else
{
_ = MessageBox.Show("Clipboard ist leer!");
return null;
}
}
internal static string FilterContacts(object selectedItem)
{
return selectedItem == null
? "Kein Kontakt gefunden!"
: selectedItem == CollectionView.NewItemPlaceholder
? "Bitte neuen Kontakt erstellen"
: ContactViewModel.CreateBriefkopf(selectedItem as ContactViewModel).ToString();
}
internal static QuoteViewModel CreateQuote(string quotationNumber, ContactViewModel recipient, ContactViewModel salesRep, decimal totalListprice, decimal totalDiscount, decimal totalNet, float vAT, bool quoteContains3PP, bool quoteContainsRB)
{
QuoteViewModel quoteViewModel = new(quotationNumber, recipient, salesRep, totalListprice, totalDiscount, totalNet, vAT, quoteContains3PP, quoteContainsRB);
using (GremlinContext gremlinContext = new())
{
//write qoteViewModel into Quote in DB
}
return quoteViewModel;
}
}
}

@ -3,7 +3,7 @@
"Gremlin": {
"commandName": "Project",
"sqlDebugging": true,
"nativeDebugging": true
"nativeDebugging": false
}
}
}