move LineItemsViewModel inside QuoteViewModel

pull/1/head
Sascha Woitschetzki 2021-07-09 11:21:03 +07:00
parent 27702728d6
commit 683171cb1a
7 changed files with 25 additions and 40 deletions

@ -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<LineItemViewModel> ReadLineItemsFromClipboard () internal static ObservableCollection<LineItemViewModel> ReadLineItemsFromClipboard()
{ {
if (Clipboard.GetText() != "") if (Clipboard.GetText() != "")
{ {

@ -1,6 +1,5 @@
using Caliburn.Micro; using Caliburn.Micro;
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
@ -10,9 +9,9 @@ namespace Gremlin.MVVM
{ {
private string _quoteType = "ein Analysegerät"; private string _quoteType = "ein Analysegerät";
private string _quotePath; private string _quotePath;
private List<LineItemViewModel> _lineItemsVM; private ObservableCollection<LineItemViewModel> _lineItemsVM = new();
private ContactViewModel _recipient; private ContactViewModel _recipient = new();
private ContactViewModel _salesRep; private ContactViewModel _salesRep = new();
private string _quoteNumber; private string _quoteNumber;
private int _warranty = 12; private int _warranty = 12;
private int _validity = 60; private int _validity = 60;
@ -41,7 +40,7 @@ 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<LineItemViewModel> LineItemsViewModel { get => _lineItemsVM; internal set { _lineItemsVM = value; NotifyOfPropertyChange(() => LineItemsViewModel); } } public ObservableCollection<LineItemViewModel> LineItemsViewModel { get => _lineItemsVM; internal set { _lineItemsVM = value; NotifyOfPropertyChange(() => LineItemsViewModel); } }
public ContactViewModel Recipient { get => _recipient; internal set { _recipient = value; NotifyOfPropertyChange(() => Recipient); } } public ContactViewModel Recipient { get => _recipient; internal set { _recipient = value; NotifyOfPropertyChange(() => Recipient); } }
public ContactViewModel SalesRep { get => _salesRep; internal set { _salesRep = value; NotifyOfPropertyChange(() => SalesRep); } } public ContactViewModel SalesRep { get => _salesRep; internal set { _salesRep = value; NotifyOfPropertyChange(() => SalesRep); } }
public decimal TotalListprice { get => _totalListprice; internal set { _totalListprice = value; NotifyOfPropertyChange(() => TotalListprice); } } public decimal TotalListprice { get => _totalListprice; internal set { _totalListprice = value; NotifyOfPropertyChange(() => TotalListprice); } }
@ -137,7 +136,18 @@ namespace Gremlin.MVVM
public void GenerateQuoteNumber() public void GenerateQuoteNumber()
{ {
Random random = new(); Random random = new();
QuoteNumber = $"DE-83PE89-{DateTime.Now:My}-{random.Next(999999)}"; QuoteNumber = SalesRep.LastName switch
{
"Woitschetzki" => $"DE-83PE89-{DateTime.Now:My}-{random.Next(999999)}",
"Welsch" => $"DE-83RE32-{DateTime.Now:My}-{random.Next(999999)}",
_ => $"DE-XXYYXX-{DateTime.Now:My}-{random.Next(999999)}",
};
}
public void ReadLineItems()
{
LineItemsViewModel = LineItemViewModel.ReadLineItemsFromClipboard();
} }
} }
} }

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

@ -1,14 +0,0 @@
<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>

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

@ -45,7 +45,13 @@
</StackPanel> </StackPanel>
</Grid> </Grid>
<Grid Grid.Row="1" Grid.Column="1"> <Grid Grid.Row="1" Grid.Column="1">
<Button x:Name="GenerateQuoteNumber" Content="Angebotsnummer generieren"/> <StackPanel>
<Button x:Name="GenerateQuoteNumber" Content="Angebotsnummer generieren"/>
<Button x:Name="ReadLineItems" Content="Angebot aus PriceSurfer einfügen"/>
</StackPanel>
</Grid> </Grid>
<StackPanel>
<DataGrid x:Name="LineItemsViewModel" AutoGenerateColumns="True" Height="600" Margin="10,5,10,5" />
</StackPanel>
</Grid> </Grid>
</UserControl> </UserControl>

@ -5,6 +5,5 @@
xmlns:local="clr-namespace:Gremlin.MVVM"> xmlns:local="clr-namespace:Gremlin.MVVM">
<StackPanel Orientation="Vertical"> <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>