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 ListPrice { get; private set; }
internal static ObservableCollection<LineItemViewModel> ReadLineItemsFromClipboard ()
internal static ObservableCollection<LineItemViewModel> ReadLineItemsFromClipboard()
{
if (Clipboard.GetText() != "")
{

@ -1,6 +1,5 @@
using Caliburn.Micro;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
@ -10,9 +9,9 @@ namespace Gremlin.MVVM
{
private string _quoteType = "ein Analysegerät";
private string _quotePath;
private List<LineItemViewModel> _lineItemsVM;
private ContactViewModel _recipient;
private ContactViewModel _salesRep;
private ObservableCollection<LineItemViewModel> _lineItemsVM = new();
private ContactViewModel _recipient = new();
private ContactViewModel _salesRep = new();
private string _quoteNumber;
private int _warranty = 12;
private int _validity = 60;
@ -41,7 +40,7 @@ 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> 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 SalesRep { get => _salesRep; internal set { _salesRep = value; NotifyOfPropertyChange(() => SalesRep); } }
public decimal TotalListprice { get => _totalListprice; internal set { _totalListprice = value; NotifyOfPropertyChange(() => TotalListprice); } }
@ -137,7 +136,18 @@ namespace Gremlin.MVVM
public void GenerateQuoteNumber()
{
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 QuoteViewModel QuoteVM { get; set; }
public List<LineItemViewModel> LineVMs { get; set; }
public ShellViewModel()
{
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>
</Grid>
<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>
<StackPanel>
<DataGrid x:Name="LineItemsViewModel" AutoGenerateColumns="True" Height="600" Margin="10,5,10,5" />
</StackPanel>
</Grid>
</UserControl>

@ -5,6 +5,5 @@
xmlns:local="clr-namespace:Gremlin.MVVM">
<StackPanel Orientation="Vertical">
<local:QuoteView cal:Bind.Model="{Binding QuoteVM}" />
<local:LineItemView cal:Bind.Model="{Binding LineItemVM}" />
</StackPanel>
</UserControl>