diff --git a/Gremlin_BlazorServer/Gremlin_BlazorServer.csproj b/Gremlin_BlazorServer/Gremlin_BlazorServer.csproj
index d925daf..c92ac2d 100644
--- a/Gremlin_BlazorServer/Gremlin_BlazorServer.csproj
+++ b/Gremlin_BlazorServer/Gremlin_BlazorServer.csproj
@@ -25,6 +25,7 @@
You're not signed in. Please click on the upper right to either register or log in. You're not signed in. Please click on the upper right to either register or log in. You're not signed in. Please click on the upper right to either register or log in. You're not signed in. Please click on the upper right to either register or log in. You're not signed in. Please click on the upper right to either register or log in. You're not signed in. Please click on the upper right to either register or log in.Authentication Failure!
- Authentication Failure!
- CustomDescriptions
- Import
- Authentication Failure!
- Authentication Failure!
- Authentication Failure!
- Authentication Failure!
-
().QuoteId + 1; - if (quote.SalesRep != null) { - quote.QuotationNumber = quote.SalesRep.LastName switch - { - "Woitschetzki" => $"DE-83PE89-{DateTime.Now:My}-{quote.QuoteId}", - "Welsch" => $"DE-83RE32-{DateTime.Now:My}-{quote.QuoteId}", - _ => $"DE-XXYYXX-{DateTime.Now:My}-{quote.QuoteId}" - }; +@inject ILoadingIndicatorService ApplicationLoadingIndicatorService + ++ + +@code { + [CascadingParameter] private Task+ + ++ ++ +Recipient ++ ++ + ++ + + + + + + + + + ++ + @if (quote.LineItems != null) { +Quote Details ++ ++
++ + + @if (quote.Recipient != null && quote.Recipient.Account != null) + { ++ +Angebotsname ++ ++ + +Angebotsnummer ++ ++ + +Angebotspfad ++ +" + + +Gewährleistung (Monate) ++ ++ + +Angebotsgültigkeit (Tage) ++ ++ + +Mehrwertsteuer (%) ++ ++ + +Versandkosten (%) ++ ++ + + } + ++ +FirstName +@quote.Recipient.FirstName ++ +LastName +@quote.Recipient.LastName ++ +AccountName +@quote.Recipient.Account.AccountName ++ +Street +@quote.Recipient.Account.Street ++ +Zip +@quote.Recipient.Account.Zip.ToString() ++ +City +@quote.Recipient.Account.City ++ + +Preisinformation +Bruttopreise anzeigen +Einzelpreise ausweisen +Discounts ausweisen ++ ++ +Listenpreis netto ++ ++ + +Summe netto ++ ++ + +Versandkosten ++ ++ + +Gesamtsumme netto ++ ++ + +Mehrwertsteuer ++ ++ + +Gesamtsumme brutto ++ ++ + ++ + @if (selectedLineItem != null && customDescriptionOfSelectedLineItem != null) { +LineItems ++ + ++ ++ + + + + + + + + + ++ } } - quote.Description = "Gerät"; - } - private async Task SelectQuoteOnChanged(FileChangedEventArgs e) { - try { - foreach (IFileEntry? file in e.Files) { - using MemoryStream stream = new(); - await file.WriteToStreamAsync(stream); - stream.Seek(0, SeekOrigin.Begin); - using StreamReader reader = new(stream); - string fileContent = await reader.ReadToEndAsync(); - quote = QuoteHandling.ReadLineItems(quote, fileContent); - - if (quote.Recipient?.Account?.AccountName != null) - { - quote = HostingService.SetPath(quote); //Set path to wwwroot/quotes folder - } - - FileService.WriteQuoteToTsv(fileContent, quote); - } + @if (quote.LineItems == null) { +CustomDescription ++ ++ ++ +ProductNumber +@customDescriptionOfSelectedLineItem.ProductNumber ++ +OptionNumber +@customDescriptionOfSelectedLineItem.OptionNumber ++ +Heading +@customDescriptionOfSelectedLineItem.Heading ++ +DescriptionText +@customDescriptionOfSelectedLineItem.DescriptionText ++ +} - catch (Exception exc) { - Console.WriteLine(exc.Message); + +Upload PriceSurfer Quote ++ ++ +Please select PriceSurfer quote as TSV ++ + ++ + @if (!pdfNotReady && url != null && debug) { +Create Quote ++ + + + + + + ++ +} - finally { - Console.WriteLine("LineItems successfull read"); - lineItemsNotReady = false; - StateHasChanged(); + + @if (quote.Tex != null && debug) { ++ + ++ +} + +Tex ++ ++ + ++ ++Authentication Failure! +You're not signed in. Please click on the upper right to either register or log in. +? authenticationStateTask { get; set; } + + private IList ? contacts; + private Quote quote = new(); + private Contact? selectedContact; + private LineItem? selectedLineItem; + private CustomDescription? customDescriptionOfSelectedLineItem; + private readonly CultureInfo cultureInfo = new("de-DE"); + private bool pdfNotReady = true; + private bool isCreatingPdf; + private bool texNotReady = true; + private bool isCreatingTex; + private bool lineItemsNotReady = true; + private string? url; + private bool debug; + + protected override async Task OnParametersSetAsync() { + if (authenticationStateTask != null) { + ClaimsPrincipal user = (await authenticationStateTask).User; + + if (user.Identity is { IsAuthenticated: true }) { + await ApplicationLoadingIndicatorService.Show(); + contacts = await genericController.GetAllAsync (); + await ApplicationLoadingIndicatorService.Hide(); + quote = await GenerateNewQuote(quote, "Woitschetzki"); + } } + await base.OnInitializedAsync(); + } + + private async Task GenerateNewQuote(Quote _quote, string salesRepLastName) { + if (_quote == null) return new(); + + _quote.SalesRep = await genericController.GetAsync(c => c.LastName.Equals(salesRepLastName), "Account"); - private static void SelectQuoteOnWritten(FileWrittenEventArgs e) { - Console.WriteLine($"File: {e.File.Name} Position: {e.Position} Data: {Convert.ToBase64String(e.Data)}"); + Quote? lastQuote = genericController.GetLast (); + if (lastQuote != null) + { + _quote.QuoteId = lastQuote.QuoteId + 1; + } + else + { + _quote.QuoteId = 1; } - private static void SelectQuoteOnProgressed(FileProgressedEventArgs e) { - Console.WriteLine($"File: {e.File.Name} Progress: {e.Percentage}"); + if (_quote.SalesRep != null) { + _quote.QuotationNumber = _quote.SalesRep.LastName switch + { + "Woitschetzki" => $"DE-83PE89-{DateTime.Now:My}-{_quote.QuoteId}", + "Welsch" => $"DE-83RE32-{DateTime.Now:My}-{_quote.QuoteId}", + _ => $"DE-XXYYXX-{DateTime.Now:My}-{_quote.QuoteId}" + }; } + else { + _quote.QuotationNumber = $"DE-XXYYXX-{DateTime.Now:My}-{_quote.QuoteId}"; + } + _quote.Description = "Gerät"; + return _quote; + } + + private async Task SelectQuoteOnChanged(FileChangedEventArgs e) { + try { + foreach (IFileEntry? file in e.Files) { + using MemoryStream stream = new(); + await file.WriteToStreamAsync(stream); + stream.Seek(0, SeekOrigin.Begin); + using StreamReader reader = new(stream); + string fileContent = await reader.ReadToEndAsync(); + quote = QuoteHandling.ReadLineItems(quote, fileContent); + + if (quote.Recipient?.Account?.AccountName != null) + { + quote = hostingService.SetPath(quote); //Set path to wwwroot/quotes folder + } - private Task OnSelectedContactChanged(Contact sC) { - selectedContact = sC; - quote.Recipient = selectedContact; - quote.Recipient.Account = GenericController.Get(account => account.AccountId == quote.Recipient.AccountId); - return Task.CompletedTask; + FileService.WriteQuoteToTsv(fileContent, quote); + } + } + catch (Exception exc) { + Console.WriteLine(exc.Message); + } + finally { + lineItemsNotReady = false; + StateHasChanged(); } + } - private Task OnSave() { - if (GenericController.Insert(quote) > 0) - NavigationManager.NavigateTo("Quotes/QuoteIndex"); + private static void SelectQuoteOnWritten(FileWrittenEventArgs e) { + Console.WriteLine($"File: {e.File.Name} Position: {e.Position} Data: {Convert.ToBase64String(e.Data)}"); + } - return Task.CompletedTask; + private static void SelectQuoteOnProgressed(FileProgressedEventArgs e) { + Console.WriteLine($"File: {e.File.Name} Progress: {e.Percentage}"); + } + + private async Task OnSelectedContactChanged(Contact _selectedContact) { + selectedContact = _selectedContact; + quote.Recipient = selectedContact; + quote.Recipient.Account = await genericController.GetAsync (account => account.AccountId.Equals(quote.Recipient.AccountId)); + return; + } + + private async Task OnSave() { + if (await genericController.InsertAsync(quote) > 0) + navigationManager.NavigateTo("Quotes/QuoteIndex"); + + return; } private async Task OnCreateTex() { isCreatingTex = true; - quote.Tex = (await QuoteHandling.CreateTex(quote))?.ToString(); + quote.Tex = (await QuoteHandling.CreateTexAsync(quote))?.ToString(); if (quote.Tex == null) return; await FileService.WriteTexFile(quote); isCreatingTex = false; @@ -351,15 +486,21 @@ return Task.CompletedTask; } + private Task OnWarrantyChanged(string warranty) { + quote.Warranty = int.Parse(warranty); + return Task.CompletedTask; + } + private Task OnCancel() { - NavigationManager.NavigateTo("Quotes/QuoteIndex"); + navigationManager.NavigateTo("Quotes/QuoteIndex"); return Task.CompletedTask; } - private Task OnSelectedLineItemChanged(LineItem lI) { + private async Task OnSelectedLineItemChanged(LineItem lI) { selectedLineItem = lI; - customDescriptionOfSelectedLineItem = GenericController.Get (cD => cD.ProductNumber == lI.ProductNumber && cD.OptionNumber == lI.OptionNumber); - return Task.CompletedTask; + customDescriptionOfSelectedLineItem = + await genericController.GetAsync (cD => cD.ProductNumber.Equals(lI.ProductNumber) && cD.OptionNumber.Equals(lI.OptionNumber)); + return; } } \ No newline at end of file diff --git a/Gremlin_BlazorServer/Pages/Quotes/QuoteIndex.razor b/Gremlin_BlazorServer/Pages/Quotes/QuoteIndex.razor index a6e87f4..d284850 100644 --- a/Gremlin_BlazorServer/Pages/Quotes/QuoteIndex.razor +++ b/Gremlin_BlazorServer/Pages/Quotes/QuoteIndex.razor @@ -2,220 +2,220 @@ @using Gremlin_BlazorServer.Services @using Gremlin_BlazorServer.Data.EntityClasses @using System.Globalization +@using System.Security.Claims; -@inject GenericController GenericController -@inject NavigationManager NavigationManager - - Quotes
- - +@inject GenericController genericController +@inject NavigationManager navigationManager@code { - private IList - @if (quotes != null) { - +- - } - - @if (selectedQuote != null) { -- - - - - - - - - - - -Details -LineItems -- - -
- - - -Angebotsname: -- -- - Angebotsnummer: -- +- + ++ + @if (selectedQuote != null) + { +Quotes ++ + @if (quotes != null) { + ++ + } ++ + + + + + + + + + ++ }Quote #@selectedQuote.QuoteId: @selectedQuote.QuotationNumber ++ ++ - } - + + + ++ +Details +LineItems ++ -+ -+
-+ - -+ -Angebotsname +@selectedQuote.Description - Angebotspfad: -- +- + -Angebotsnummer +@selectedQuote.QuotationNumber - Gewährleistung (Monate): @selectedQuote.Warranty.ToString(CultureInfo.CurrentCulture) +@*+ *@ +Angebotspfad +@selectedQuote.Path ++ -Gewährleistung (Monate) +@selectedQuote.Warranty.ToString(CultureInfo.CurrentCulture) - Angebotsgültigkeit (Tage): -- +- + -Angebotsgültigkeit (Tage) +@selectedQuote.ValidFor.ToString(CultureInfo.CurrentCulture) - Mehrwertsteuer (%): -- +- + -Mehrwertsteuer (%) +@selectedQuote.Vat.ToString(CultureInfo.CurrentCulture) - Versandkosten (%): -- +- + - -Versandkosten (%) +@selectedQuote.Freight.ToString(CultureInfo.CurrentCulture) - + + @if (selectedQuote.Recipient != null && selectedQuote.Recipient.Account != null) + { +- - FirstName: -- +- + + } ++ +FirstName +@selectedQuote.Recipient.FirstName ++ +LastName +@selectedQuote.Recipient.LastName ++ +AccountName +@selectedQuote.Recipient.Account.AccountName ++ +Street +@selectedQuote.Recipient.Account.Street ++ +Zip +@selectedQuote.Recipient.Account.Zip.ToString() ++ +City +@selectedQuote.Recipient.Account.City ++ + +Preisinformation +Bruttopreise anzeigen +Einzelpreise ausweisen +Discounts ausweisen ++ - -+ -Listenpreis (netto) +@selectedQuote.TotalListprice.ToString("C", CultureInfo.CurrentCulture) - LastName: -- +- + -Summe (netto) +@selectedQuote.TotalNet.ToString("C", CultureInfo.CurrentCulture) - AccountName: -- +- + -Versandkosten +@selectedQuote.TotalFreightOnly.ToString("C", CultureInfo.CurrentCulture) - Street: -- +- + -Gesamtsumme (netto) +@selectedQuote.TotalFreight.ToString("C", CultureInfo.CurrentCulture) - Zip: -- +- + -Mehrwertsteuer +@selectedQuote.TotalVat.ToString("C", CultureInfo.CurrentCulture) - City: -- +- + - -Gesamtsumme (brutto) +@selectedQuote.TotalGross.ToString("C", CultureInfo.CurrentCulture) - - -Preisinformation -Bruttopreise anzeigen -Einzelpreise ausweisen -Discounts ausweisen -- -- -Listenpreis netto: -- -- - -Summe netto: -- -- - -Versandkosten: -- -- - -Gesamtsumme netto: -- -- - -Mehrwertsteuer: -- -- - -Gesamtsumme brutto: -- -- - -- -- - - - - - - - - + + + ++ ++ + + + + + + + + - Authentication Failure!
-You're not signed in. Please click on the upper right to either register or log in.
++ +Authentication Failure! +You're not signed in. Please click on the upper right to either register or log in. +? quotes; - private Quote? selectedQuote; - private readonly CultureInfo cultureInfo = new("de-DE"); - private string selectedTab = "details"; + [CascadingParameter] private Task? authenticationStateTask { get; set; } - protected override Task OnInitializedAsync() { - quotes = GenericController.GetAll ("Recipient"); - return Task.CompletedTask; + private IList? quotes; + private Quote? selectedQuote; + private readonly CultureInfo cultureInfo = new("de-DE"); + private string selectedTab = "details"; + + protected override async Task OnInitializedAsync() + { + if (authenticationStateTask != null) + { + ClaimsPrincipal user = (await authenticationStateTask).User; + + if (user.Identity is { IsAuthenticated: true }) + { + quotes = await genericController.GetAllAsync(); + } } + await base.OnInitializedAsync(); + } - private void OnSelectedQuoteChanged(Quote sQ) { - selectedQuote = sQ; - if (selectedQuote.Recipient != null) { - selectedQuote.Recipient.Account = GenericController.Get(a => a.AccountId == sQ.Recipient?.AccountId); - } - selectedQuote.LineItems = GenericController.GetAll (lineItem => lineItem.Quote == selectedQuote); + private async Task OnSelectedQuoteChanged(Quote _selectedQuote) { + selectedQuote = _selectedQuote; + selectedQuote.Recipient = await genericController.GetAsync (c => c.ContactId.Equals(selectedQuote.ContactId)); + if (selectedQuote.Recipient != null) { + selectedQuote = await genericController.GetAsync (c => c.QuoteId.Equals(_selectedQuote.QuoteId), "Recipient", "LineItems"); + selectedQuote.Recipient.Account = await genericController.GetAsync(a => a.AccountId.Equals(selectedQuote.Recipient.AccountId)); } + //selectedQuote.LineItems = await genericController.GetAllAsync (lI => lI.Quote.Equals(selectedQuote)); + return; + } private void OnCreateNewQuote() { - NavigationManager.NavigateTo("Quotes/QuoteAdd"); + navigationManager.NavigateTo("Quotes/QuoteAdd"); } - private Task OnSelectedTabChanged(string sT) { - selectedTab = sT; + private Task OnSelectedTabChanged(string _selectedTab) { + selectedTab = _selectedTab; return Task.CompletedTask; } diff --git a/Gremlin_BlazorServer/Pages/_Host.cshtml b/Gremlin_BlazorServer/Pages/_Host.cshtml index 9e503df..dd61c32 100644 --- a/Gremlin_BlazorServer/Pages/_Host.cshtml +++ b/Gremlin_BlazorServer/Pages/_Host.cshtml @@ -37,6 +37,9 @@ + + + diff --git a/Gremlin_BlazorServer/Program.cs b/Gremlin_BlazorServer/Program.cs index 48c0911..b3ed39d 100644 --- a/Gremlin_BlazorServer/Program.cs +++ b/Gremlin_BlazorServer/Program.cs @@ -1,5 +1,6 @@ using Blazorise; using Blazorise.Icons.Material; +using Blazorise.LoadingIndicator; using Blazorise.Material; //using Blazorise.Bootstrap; @@ -30,6 +31,7 @@ builder.Services.AddBlazorise(options => { options.Immediate = true; }) .AddMaterialProviders() .AddMaterialIcons(); builder.Services.AddOptions(); +builder.Services.AddLoadingIndicator(); //Auth const string connection = "server0"; diff --git a/Gremlin_BlazorServer/Services/GenericController.cs b/Gremlin_BlazorServer/Services/GenericController.cs index cbbf86e..9855127 100644 --- a/Gremlin_BlazorServer/Services/GenericController.cs +++ b/Gremlin_BlazorServer/Services/GenericController.cs @@ -183,14 +183,30 @@ public class GenericController } } - public async Task GetAsync (Predicate search, string include) where TResult : class, IMetadata + public async Task GetAsync (Predicate search, string include1) where TResult : class, IMetadata { try { using (GremlinDb gremlinDb = new()) { - return await Task.Run(() => gremlinDb.Set ().Include(include).AsEnumerable().FirstOrDefault(t => search(t))); + return await Task.Run(() => gremlinDb.Set ().Include(include1).AsEnumerable().FirstOrDefault(t => search(t))); + } + } + catch (Exception exception) + { + Console.WriteLine(exception.InnerException); + return null; + } + } + public async Task GetAsync (Predicate search, string include1, string include2) where TResult : class, IMetadata + { + try + { + using (GremlinDb gremlinDb = new()) + { + + return await Task.Run(() => gremlinDb.Set ().Include(include1).Include(include2).AsEnumerable().FirstOrDefault(t => search(t))); } } catch (Exception exception) diff --git a/Gremlin_BlazorServer/Services/QuoteHandling.cs b/Gremlin_BlazorServer/Services/QuoteHandling.cs index 805826c..3f45321 100644 --- a/Gremlin_BlazorServer/Services/QuoteHandling.cs +++ b/Gremlin_BlazorServer/Services/QuoteHandling.cs @@ -6,7 +6,7 @@ namespace Gremlin_BlazorServer.Services; public static class QuoteHandling { - public static async Task CreateTex(Quote quote) + public static async Task CreateTexAsync(Quote quote) { StringBuilder? texString = await TexService.CreateTex(quote); if (texString == null) diff --git a/Gremlin_BlazorServer/_Imports.razor b/Gremlin_BlazorServer/_Imports.razor index 085eeef..4bc0da3 100644 --- a/Gremlin_BlazorServer/_Imports.razor +++ b/Gremlin_BlazorServer/_Imports.razor @@ -9,4 +9,5 @@ @using Gremlin_BlazorServer @using Gremlin_BlazorServer.Shared @using Blazorise -@using Blazorise.DataGrid \ No newline at end of file +@using Blazorise.DataGrid +@using Blazorise.LoadingIndicator \ No newline at end of file diff --git a/Gremlin_BlazorServer/wwwroot/quotes/Grünenthal_GmbH/2023-3-Bürgel-Gerät/DE-83PE89-323-223.tsv b/Gremlin_BlazorServer/wwwroot/quotes/Grünenthal_GmbH/2023-3-Bürgel-Gerät/DE-83PE89-323-223.tsv new file mode 100644 index 0000000..8cc3d20 --- /dev/null +++ b/Gremlin_BlazorServer/wwwroot/quotes/Grünenthal_GmbH/2023-3-Bürgel-Gerät/DE-83PE89-323-223.tsv @@ -0,0 +1,16 @@ +# Part Number Opt PL Description Qty Price EUR Breaks EUR Uplift % Total Discount % Net EUR Total EUR Sales Discount YA9% Contractual Discount Y99% Promotion Discount Y07% Demo Discount Y04% PH Code PH Description YMax +1 G7112B 29 1260 Infinity II Binaere Pumpe 1 30307 0 0 30 21214.9 21214.9 30 0 0 0 ISL100P1 Pumps +2 G7112B 001 29 HPLC Sys.-Tool-K. Agil. 1260 Infinity II 1 390 0 0 30 273 273 30 0 0 0 +3 G7112B 007 29 Kit fuer Maximale Betriebszeit 1 1783 0 0 30 1248.1 1248.1 30 0 0 0 +4 G7112B 030 29 Aktive Kolbenhinterspuelung 1 1982 0 0 30 1387.4 1387.4 30 0 0 0 +5 G7112B 094 29 Poroshell 120 EC-C18 3,0 x 150mm, 2,7 um 1 1 0 0 30 0.7 0.7 30 0 0 0 +6 G7129A 29 1260 Inf. II Fluessigprobengeber 1 19905 0 0 30 13933.5 13933.5 30 0 0 0 ISL100A1 Autosamplers +7 G7129A 012 29 Klass. Schubladenkit (10 x 10 Pr.-Fl.) 1 525 0 0 30 367.5 367.5 30 0 0 0 +8 G7129A 060 29 Nutzung vorhandene Lizenz 1 -1793 0 0 30 -1255.1 -1255.1 30 0 0 0 +9 G7129A 101 29 Agilent InfinityLab Proben-Thermostat 1 6077 0 0 30 4253.9 4253.9 30 0 0 0 +10 G7116A 29 1260 Infinity II Therm. f. mehr. Saeulen 1 6494 0 0 30 4545.8 4545.8 30 0 0 0 ISL100LC1 LC Hardware +11 G7114A 29 1260 Infinity II VW-Detektor 1 9307 0 0 30 6514.9 6514.9 30 0 0 0 ISL100D1 Detectors +12 G7114A 018 29 Standarddurchflusszelle VWD 1 1612 0 0 30 1128.4 1128.4 30 0 0 0 +13 SYS-LC-1260II 74 LC 1260 Infinity II System 1 0 0 0 20 0 0 20 0 0 0 TSSYS0SYLC Service Systems - Liquid Chromatography +14 SYS-LC-1260II 2A9 74 Standard-Einweisung 1 1034 0 0 20 827.2 827.2 20 0 0 0 TSSTRN Training Services +15 SYS-LC-1260II 6H9 74 Analysegeraet-Qualifizierung-auf Wunsch 1 4561 0 0 20 3648.8 3648.8 20 0 0 0 TSSYS1 Serviced As Systems - 1 YR