reload of ContactsVM possible

pull/1/head
Sascha Woitschetzki 2021-06-15 12:34:32 +07:00 committed by Sascha Woitschetzki
parent 03a8d9e070
commit 4cbd84bb43
3 changed files with 40 additions and 11 deletions

@ -10,8 +10,8 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="96.08"/>
<RowDefinition Height="423.88"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
@ -24,7 +24,20 @@
</Grid.ColumnDefinitions>
<StackPanel x:Name="Contact" Grid.Row="0" Grid.Column="0" Orientation="Vertical">
<TextBox x:Name="tbContactSearch" TextWrapping="NoWrap" Margin="10,5,10,5" TextAlignment="Center" TextChanged="TbContactSearch_TextChanged"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<TextBox x:Name="tbContactSearch" TextWrapping="NoWrap" Margin="10,5,10,5" TextAlignment="Center" TextChanged="TbContactSearch_TextChanged"/>
</StackPanel>
<StackPanel Grid.Column="1">
<Button x:Name="butReloadContacts" Content="Kontakte laden" Margin="10,5,10,5" Click="ButReloadContacts_Click" />
</StackPanel>
</Grid>
<DataGrid x:Name="dgFoundContacts"
ItemsSource="{Binding Source=foundContacts}"
AutoGenerateColumns="True"
@ -82,9 +95,9 @@
<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" />
<Button x:Name="butPasteQuote" Content="Angebot aus PriceSurfer erstellen" Margin="10,5,10,5" Click="ButPasteQuote_Click" />
<TextBlock x:Name="lblQuote" Text="Bitte Angebot einfügen." Height="150" Margin="10,5,10,5"/>
<DataGrid x:Name="dgLineItems" AutoGenerateColumns="True" Height="280" Margin="10,5,10,5" />
<DataGrid x:Name="dgLineItems" AutoGenerateColumns="True" Height="300" Margin="10,5,10,5" />
</StackPanel>
</Grid>

@ -17,10 +17,7 @@ namespace Gremlin.GremlinUI
public QuoteUI()
{
InitializeComponent();
listCollectionContacts = new(ContactVM.GetContacts());
listCollectionContacts.Filter = ContactVM.SearchContact(listCollectionContacts, tbContactSearch.Text);
dgFoundContacts.ItemsSource = listCollectionContacts;
UpdateUI();
LoadContacts();
}
private void UpdateUI()
@ -29,6 +26,14 @@ namespace Gremlin.GremlinUI
lblQuote.Text = quoteVM.ToString();
}
private void LoadContacts()
{
listCollectionContacts = new(ContactVM.GetContacts());
listCollectionContacts.Filter = ContactVM.SearchContact(listCollectionContacts, tbContactSearch.Text);
dgFoundContacts.ItemsSource = listCollectionContacts;
UpdateUI();
}
private void TbContactSearch_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
listCollectionContacts.Filter = ContactVM.SearchContact(listCollectionContacts, tbContactSearch.Text);
@ -42,7 +47,12 @@ namespace Gremlin.GremlinUI
private void ButPasteQuote_Click(object sender, RoutedEventArgs e)
{
quoteVM = QuoteVM.CreateQuoteFromClipboard(tbQuotationNumber.Text, ContactVM.ConvertObjectToContactVM(dgFoundContacts.SelectedItem), ContactVM.GetSalesRepAsContact(-1), 19f, tbAngebotsname.Text);
quoteVM = QuoteVM.CreateQuote(tbQuotationNumber.Text,
ContactVM.ConvertObjectToContactVM(dgFoundContacts.SelectedItem),
ContactVM.GetSalesRepAsContact(-1),
19f,
tbAngebotsname.Text);
ObservableCollection<LineItemVM> lineItemsViewModel = new(quoteVM.LineItemsVM);
lineItems = new(lineItemsViewModel);
UpdateUI();
@ -62,5 +72,11 @@ namespace Gremlin.GremlinUI
{
}
private void ButReloadContacts_Click(object sender, RoutedEventArgs e)
{
LoadContacts();
MessageBox.Show($"Es wurden {listCollectionContacts.Count} Kontakte geladen.");
}
}
}

@ -52,7 +52,7 @@ namespace Gremlin.GremlinUI.ViewModels
+ $"QuoteContainsRB: {QuoteContainsRB}";
}
internal static QuoteVM CreateQuoteFromClipboard(string quotationNumber, ContactVM recipient, ContactVM salesRep, float vAT = 19f, string quotationType = "ein Analysegerät")
internal static QuoteVM CreateQuote(string quotationNumber, ContactVM recipient, ContactVM salesRep, float vAT = 19f, string quotationType = "ein Analysegerät", bool? brutto = true, )
{
QuoteVM quoteVM = new();