showing of Totals possible

pull/1/head
DJh2o2 2022-03-09 14:15:56 +07:00
parent 3452de2b9b
commit fcb8b04292
7 changed files with 55 additions and 323 deletions

@ -154,7 +154,7 @@ namespace Gremlin.GremlinUtilities.GUClasses
return winners;
}
public List<DataIdentifier> ReadDataIdentifierFromFile()
public static List<DataIdentifier> ReadDataIdentifierFromFile()
{
List<DataIdentifier> result = new(50);
string fileInput = FileIO.ReadResource("DataIdentifier.txt");

@ -103,8 +103,8 @@ namespace Gremlin.MVVM
private void BtnQuoteUI_Click(object sender, RoutedEventArgs e)
{
QuoteUI quoteUI = new();
_ = quoteUI.ShowDialog();
//ShellView shellView = new();
//shellView.ShowDialog();
}
private void BtnShowAccountList_Click(object sender, RoutedEventArgs e)

@ -1,113 +0,0 @@
<Window x:Class="Gremlin.MVVM.QuoteUI"
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.MVVM" d:DataContext="{d:DesignInstance Type=viewmodels:QuoteViewModel}"
mc:Ignorable="d"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
Title="Gremlin QuoteUI" Height="1024" Width="1280">
<Window.Resources>
<viewmodels:QuoteViewModel x:Key="m" ></viewmodels:QuoteViewModel>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Height="Auto" x:Name="gridOben" Margin="10,5,10,5" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel x:Name="Contact" Grid.Row="0" Grid.Column="0" Orientation="Vertical">
<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="btnReloadContacts" Content="Kontakte laden" Margin="10,5,10,5" Click="BtnReloadContacts_Click" />
</StackPanel>
</Grid>
<DataGrid x:Name="dgFoundContacts"
ItemsSource="{Binding Source=foundContacts}"
AutoGenerateColumns="True"
Height="250"
Margin="10,5,10,5"
AlternatingRowBackground="LightGray" SelectionChanged="DgFoundContacts_SelectionChanged"/>
</StackPanel>
<StackPanel x:Name="Angebotskonfig" Grid.Row="0" Grid.Column="1" Orientation="Vertical">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Column="0" Height="Auto">
<StackPanel>
<TextBlock x:Name="lblAngebotsname" Text="Angebotsname" TextAlignment="Right" Margin="10,5,10,5"/>
<TextBlock x:Name="lblAngebotsnummer" Text="Angebotsnummer" TextAlignment="Right" Margin="10,5,10,5"/>
<TextBlock x:Name="lblQuotingPath" Text="Angebotspfad" TextAlignment="Right" Margin="10,5,10,5"/>
<TextBlock x:Name="lblGewaehrleistung" Text="Gewährleistung (Monate)" TextAlignment="Right" Margin="10,5,10,5"/>
<TextBlock x:Name="lblAngebotsgueltigkeit" Text="Angebotsgültigkeit (Tage)" TextAlignment="Right" Margin="10,5,10,5"/>
<TextBlock x:Name="lblOppID" Text="SAP Opp ID" TextAlignment="Right" Margin="10,5,10,5"/>
</StackPanel>
</Grid>
<Grid Grid.Column="1" Height="Auto">
<StackPanel>
<TextBox x:Name="tbQuoteType" Text="{Binding Path=QuoteType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="10,4,10,4" TextChanged="TbQuoteType_TextChanged" />
<TextBox x:Name="tbQuoteNumber" Text="{Binding Path=QuoteNumber, UpdateSourceTrigger=PropertyChanged}" Margin="10,4,10,4" TextChanged="TbQuoteNumber_TextChanged" />
<TextBox x:Name="tbQuotePath" Text="{Binding Path=QuotePath, UpdateSourceTrigger=PropertyChanged}" Margin="10,4,10,4" TextChanged="TbQuotePath" />
<TextBox x:Name="tbWarranty" Text="{Binding Path=Warranty, UpdateSourceTrigger=PropertyChanged}" Margin="10,4,10,4" TextChanged="TbWarranty_TextChanged" />
<TextBox x:Name="tbValidity" Text="{Binding Path=Validity, UpdateSourceTrigger=PropertyChanged}" Margin="10,5,10,5" TextChanged="TbValidity_TextChanged" />
<TextBox x:Name="tbOppID" Text="3003541659" Margin="10,4,10,4" />
</StackPanel>
</Grid>
</Grid>
</StackPanel>
<StackPanel x:Name="Opp" Grid.Row="0" Grid.Column="2" Orientation="Vertical">
<CheckBox d:DataContext="{d:DesignInstance Type=viewmodels:QuoteViewModel}" x:Name="cbBrutto" Content="Brutto anzeigen" Margin="10,5,10,5" IsChecked="{Binding Path=Brutto, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Click="CbBrutto_Click"/>
<CheckBox x:Name="cbSinglePrices" Content="Einzelpreise ausweisen" Margin="10,5,10,5" IsChecked="{Binding Path=SinglePrices, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Click="CbSinglePrices_Click" />
<CheckBox x:Name="cbShowDiscounts" Content="Discounts ausweisen" Margin="10,5,10,5" IsChecked="{Binding Path=ShowDiscounts, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Click="CbShowDiscounts_Click"/>
<CheckBox x:Name="cbBrochure" Content="Broschüren anhängen" Margin="10,5,10,5" IsChecked="{Binding Path=Brochures, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Click="CbBrochure_Click" />
<CheckBox x:Name="cbDataSheets" Content="Datenblätter anhängen" Margin="10,5,10,5" IsChecked="{Binding Path=DataSheets, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Click="CbDataSheets_Click" />
<CheckBox x:Name="cbMailTemplate" Content="Mail aus Template erstellen" Margin="10,5,10,5" IsChecked="{Binding Path=MailTemplate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Click="CbMailTemplate_Click" />
</StackPanel>
</Grid>
<Grid Grid.Row="1" Height="Auto" x:Name="gridMitte" Margin="10,5,10,5">
<StackPanel>
<DataGrid x:Name="dgLineItems" AutoGenerateColumns="True" Height="600" Margin="10,5,10,5" >
</DataGrid>
</StackPanel>
</Grid>
<Grid Grid.Row="3" Height="Auto" x:Name="gridUnten" Margin="10,5,10,5">
<StackPanel Orientation="Horizontal" Margin="10,5,10,5" HorizontalAlignment="Center">
<Button x:Name="btnPasteQuote" Content="Angebot aus PriceSurfer erstellen" Margin="10,5,10,5" Click="BtnPasteQuote_Click" MinWidth="280" />
<Button x:Name="btnCreateTex" Content="Tex erstellen" Margin="10,5,10,5" Click="BtnCreateTex_Click" MinWidth="280" />
<Button x:Name="btnCreateQuote" Content="Angebot als PDF erstellen" Margin="10,5,10,5" Click="BtnCreateQuote_Click" MinWidth="280" />
<Button x:Name="btnSendQuote" Content="Angebot als Anhang in Mail-Entwurf erstellen" Margin="10,5,10,5" Click="BtnSendQuote_Click" MinWidth="280" />
</StackPanel>
</Grid>
</Grid>
</Window>

@ -1,159 +0,0 @@
using Gremlin.GremlinData.EntityClasses;
using Gremlin.Operations;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Data;
namespace Gremlin.MVVM
{
public partial class QuoteUI : Window
{
private static ListCollectionView listCollectionContacts = new(new ObservableCollection<Contact>());
private static ListCollectionView lineItems = new(new ObservableCollection<LineItemViewModel>());
private QuoteViewModel quoteVM = new(ContactViewModel.GetSalesRepAsContact(1));
public QuoteUI()
{
InitializeComponent();
LoadContacts();
}
private void UpdateUI()
{
dgLineItems.ItemsSource = lineItems;
}
private void LoadContacts()
{
listCollectionContacts = new(ShellViewModel.GetContactsVM(""));
listCollectionContacts.Filter = ContactViewModel.SearchContact(listCollectionContacts, tbContactSearch.Text);
dgFoundContacts.ItemsSource = listCollectionContacts;
UpdateUI();
}
private void TbContactSearch_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
listCollectionContacts.Filter = ContactViewModel.SearchContact(listCollectionContacts, tbContactSearch.Text);
}
private void DgFoundContacts_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
quoteVM.Recipient = ContactViewModel.ConvertObjectToContactVM(dgFoundContacts.SelectedItem);
}
private void BtnPasteQuote_Click(object sender, RoutedEventArgs e)
{
decimal vat = 19;
int warranty = int.TryParse(tbWarranty.Text, out int defaultWarranty) ? defaultWarranty : 12;
int validity = int.TryParse(tbValidity.Text, out int defaultValidity) ? defaultValidity : 60;
quoteVM = QuoteViewModel.CreateQuote(tbQuoteNumber.Text,
ContactViewModel.ConvertObjectToContactVM(dgFoundContacts.SelectedItem),
quoteVM.SalesRep,
vat,
tbQuoteType.Text,
cbBrutto.IsChecked,
warranty,
cbSinglePrices.IsChecked,
cbBrochure.IsChecked,
cbDataSheets.IsChecked,
cbMailTemplate.IsChecked,
tbQuotePath.Text,
validity,
cbShowDiscounts.IsChecked
);
if (quoteVM == null)
{
return;
}
ObservableCollection<LineItemViewModel> lineItemsViewModel = new(quoteVM.LineItemsViewModel);
lineItems = new(lineItemsViewModel);
UpdateUI();
}
private void BtnCreateTex_Click(object sender, RoutedEventArgs e)
{
if (quoteVM.LineItemsViewModel == null || quoteVM.LineItemsViewModel.Count == 0)
{
ErrorHandler.ShowMessageBox("Bitte zuerst ein Angebot einfügen");
}
else
{
TexHandler.CreateTexAndOpen(quoteVM);
}
}
private void BtnCreateQuote_Click(object sender, RoutedEventArgs e)
{
PDFHandler.CreatePDF(quoteVM);
}
private void BtnSendQuote_Click(object sender, RoutedEventArgs e)
{
//FileIO.SendQuoteViaMail(quoteVM);
}
private void BtnReloadContacts_Click(object sender, RoutedEventArgs e)
{
LoadContacts();
_ = MessageBox.Show($"Es wurden {listCollectionContacts.Count} Kontakte geladen.");
}
private void TbQuoteType_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
//quoteVM.OnPropertyChanged("QuoteType");
}
private void TbQuotePath(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
quoteVM.QuotePath = tbQuotePath.Text;
}
private void TbQuoteNumber_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
quoteVM.QuoteNumber = tbQuoteNumber.Text;
}
private void TbWarranty_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
quoteVM.Warranty = int.TryParse(tbWarranty.Text, out int defaultWarranty) ? defaultWarranty : 12;
}
private void TbValidity_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
quoteVM.Validity = int.TryParse(tbValidity.Text, out int defaultValidity) ? defaultValidity : 60;
}
private void CbBrutto_Click(object sender, RoutedEventArgs e)
{
quoteVM.ShowBrutto = cbBrutto.IsChecked;
}
private void CbSinglePrices_Click(object sender, RoutedEventArgs e)
{
quoteVM.SinglePrices = cbSinglePrices.IsChecked;
}
private void CbBrochure_Click(object sender, RoutedEventArgs e)
{
quoteVM.AttachBrochures = cbBrochure.IsChecked;
}
private void CbDataSheets_Click(object sender, RoutedEventArgs e)
{
quoteVM.AttachDataSheets = cbDataSheets.IsChecked;
}
private void CbMailTemplate_Click(object sender, RoutedEventArgs e)
{
quoteVM.UseMailTemplate = cbMailTemplate.IsChecked;
}
private void CbShowDiscounts_Click(object sender, RoutedEventArgs e)
{
quoteVM.ShowDiscounts = cbMailTemplate.IsChecked;
}
}
}

@ -67,9 +67,6 @@ namespace Gremlin.MVVM
Random random = new();
SalesRep = salesRep;
//Debug-Standard
SalesRep.LastName = "Woitschetzki";
QuoteNumber = SalesRep.LastName switch
{
"Woitschetzki" => $"DE-83PE89-{DateTime.Now:My}-{random.Next(999999)}",
@ -142,13 +139,17 @@ namespace Gremlin.MVVM
quoteVM.LineItemsViewModel.Add(lineItemVM);
}
return quoteVM;
}
public void GenerateQuoteNumber()
{
Random random = new();
//Debug-Standard
SalesRep.LastName = "Woitschetzki";
QuoteNumber = SalesRep.LastName switch
{
"Woitschetzki" => $"DE-83PE89-{DateTime.Now:My}-{random.Next(999999)}",
@ -160,6 +161,11 @@ namespace Gremlin.MVVM
public void ReadLineItems()
{
LineItemsViewModel = LineItemViewModel.ReadLineItemsFromClipboard();
NotifyOfPropertyChange(() => TotalNet);
NotifyOfPropertyChange(() => TotalFreightOnly);
NotifyOfPropertyChange(() => TotalFreight);
NotifyOfPropertyChange(() => TotalVAT);
NotifyOfPropertyChange(() => TotalGross);
}
private static string CorrectQuotePath(string quotePath)

@ -1,11 +1,13 @@
using Caliburn.Micro;
using Gremlin.GremlinData.DBClasses;
using Gremlin.GremlinData.EntityClasses;
using Gremlin.Models;
using Gremlin.Operations;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
namespace Gremlin.MVVM
@ -100,6 +102,7 @@ namespace Gremlin.MVVM
public void CreateTex()
{
TexHandler.CreateTexAndOpen(QuoteVM);
Debug.WriteLine(quoteVM.TotalListprice);
}
public void CreatePDF()

@ -3,17 +3,17 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<!--<ColumnDefinition Width="*"/>-->
</Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!--Recepient-->
<!--<Grid Grid.Row="0" Grid.Column="0" Height="Auto">
@ -59,7 +59,28 @@
<CheckBox x:Name="MailTemplate" Content="Mail aus Template erstellen" Margin="10,5,10,5"/>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Height="Auto">
<!--TotalTaxFreight-->
<Grid Grid.Row="0" Grid.Column="3" Height="Auto" Width="Auto">
<StackPanel>
<TextBlock x:Name="lblTotalNet" Text="Summe netto" Margin="10,5,10,5"/>
<TextBlock x:Name="lblTotalFreightOnly" Text="Frachtkosten" Margin="10,5,10,5"/>
<TextBlock x:Name="lblTotalFreight" Text="Gesamtsumme netto" Margin="10,5,10,5"/>
<TextBlock x:Name="lblTotalVAT" Text="Mehrwertsteuer" Margin="10,5,10,5"/>
<TextBlock x:Name="lblTotalGross" Text="Gesamtsumme brutto" Margin="10,5,10,5"/>
</StackPanel>
</Grid>
<Grid Grid.Row="0" Grid.Column="4" Height="Auto" Width="Auto">
<StackPanel>
<TextBlock x:Name="TotalNet" Margin="10,5,10,5" HorizontalAlignment="Right"/>
<TextBlock x:Name="TotalFreightOnly" Margin="10,5,10,5" HorizontalAlignment="Right"/>
<TextBlock x:Name="TotalFreight" Margin="10,5,10,5" HorizontalAlignment="Right"/>
<TextBlock x:Name="TotalVAT" Margin="10,5,10,5" HorizontalAlignment="Right"/>
<TextBlock x:Name="TotalGross" Margin="10,5,10,5" HorizontalAlignment="Right"/>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Height="Auto">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
<Button x:Name="GenerateQuoteNumber" Content="Angebotsnummer generieren" Margin="10,5,10,5"/>
<Button x:Name="GenerateOppID" Content="SAP Opp ID generieren" Margin="10,5,10,5"/>
@ -68,7 +89,7 @@
</Grid>
<!--LineItems-->
<Grid Grid.Row="2" Grid.ColumnSpan="3" Height="Auto">
<Grid Grid.Row="2" Grid.ColumnSpan="5" Height="Auto">
<DataGrid
x:Name="LineItemsViewModel"
AutoGenerateColumns="True"
@ -80,39 +101,13 @@
/>
</Grid>
<!--TotalTaxFreight-->
<Grid Grid.Row="3" Grid.ColumnSpan="3" Height="Auto">
<StackPanel Orientation="Vertical" HorizontalAlignment="Stretch">
<StackPanel Orientation="Horizontal" VerticalAlignment="Stretch">
<TextBlock x:Name="lblTotalNet" Text="Summe netto" Margin="10,5,10,5"/>
<TextBox x:Name="TotalListprice" Margin="10,5,10,5"/>
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Stretch">
<TextBlock x:Name="lblTotalFreightOnly" Text="Frachtkosten" Margin="10,5,10,5"/>
<TextBox x:Name="TotalFreightOnly" Margin="10,5,10,5"/>
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Stretch">
<TextBlock x:Name="lblTotalFreight" Text="Gesamtsumme netto" Margin="10,5,10,5"/>
<TextBox x:Name="TotalFreight" Margin="10,5,10,5"/>
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Stretch">
<TextBlock x:Name="lblTotalVAT" Text="Mehrwertsteuer" Margin="10,5,10,5"/>
<TextBox x:Name="TotalVAT" Margin="10,5,10,5"/>
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Stretch">
<TextBlock x:Name="lblTotalGross" Text="Gesamtsumme brutto" Margin="10,5,10,5"/>
<TextBox x:Name="TotalGross" Margin="10,5,10,5"/>
</StackPanel>
</StackPanel>
<!--SelectedLineItem-->
<!--<DataGrid x:Name="LineItemsViewModel1"
AutoGenerateColumns="True"
CanUserAddRows="False"
Height="300"
Width ="1280"
Margin="10,5,10,5"
AlternatingRowBackground="LightGray"/>-->
</Grid>
<!--SelectedLineItem-->
<!--<DataGrid x:Name="LineItemsViewModel1"
AutoGenerateColumns="True"
CanUserAddRows="False"
Height="300"
Width ="1280"
Margin="10,5,10,5"
AlternatingRowBackground="LightGray"/>-->
</Grid>
</UserControl>