diff --git a/Gremlin/GremlinUI/Models/RUSettingModel.cs b/Gremlin/GremlinUI/Models/RUSettingModel.cs index 766269f..1561ead 100644 --- a/Gremlin/GremlinUI/Models/RUSettingModel.cs +++ b/Gremlin/GremlinUI/Models/RUSettingModel.cs @@ -3,6 +3,7 @@ using Gremlin.GremlinData.EntityClasses; using Gremlin.GremlinUI; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; namespace Gremlin.Models @@ -41,7 +42,12 @@ namespace Gremlin.Models try { Dictionary rsfruid = ReadSettingsForRegisteredUserID(registeredUserID); - return rsfruid == null ? "RUSettings not valid" : rsfruid.ContainsKey(settingKey) ? rsfruid[settingKey] : "NotFound"; + if (!rsfruid.ContainsKey(settingKey) || rsfruid == null) + { + Debug.WriteLine($"SettingKey {settingKey} not found or null!"); + return "NotFound"; + } + return rsfruid[settingKey]; } catch (Exception ex) { diff --git a/Gremlin/GremlinUI/Operations/TexFileHandler.cs b/Gremlin/GremlinUI/Operations/TexFileHandler.cs index c147e7b..d908b16 100644 --- a/Gremlin/GremlinUI/Operations/TexFileHandler.cs +++ b/Gremlin/GremlinUI/Operations/TexFileHandler.cs @@ -1,5 +1,6 @@ using Gremlin.GremlinUI.ViewModels; using Gremlin.Models; +using Gremlin.ViewModels; using System.IO; using System.Text; using static Gremlin.GremlinData.EntityClasses.Enums; @@ -24,11 +25,9 @@ namespace Gremlin.Operations private static StringBuilder CreateTexFile(QuoteVM quoteVM, bool? brutto) { - float rand = Properties.Settings.Default.texRand; - //byte[] agilentLogo = Properties.Resources.agilentLogo; - //byte[] sign = Properties.Resources.signWoitschetzki; + string rand = RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "texRand"); - StringBuilder texFile = new($"\\documentclass[a4paper,ngerman,parskip,10pt]{{scrlttr2}}" + $"\\usepackage{{lmodern}}" + $"\\usepackage[T1]{{fontenc}}" + $"\\usepackage[utf8]{{inputenc}}" + $"\\usepackage{{babel}}" + $"\\usepackage[hidelinks]{{hyperref}}"); + StringBuilder texFile = new($"\\documentclass[a4paper,ngerman,parskip,10pt]{{scrlttr2}}" + $"\\usepackage{{lmodern}}" + $"\\usepackage[T1]{{fontenc}}" + $"\\usepackage[utf8]{{inputenc}}" + $"\\usepackage{{babel}}" + $"\\usepackage[hidelinks]{{hyperref}}\n"); _ = texFile.AppendLine($"\\usepackage[left={rand}cm, right={rand}cm, top={rand}cm, bottom={rand}cm]{{geometry}}"); _ = texFile.AppendLine($"\\usepackage[table]{{xcolor}}\r\n\\usepackage[right]{{eurosym}}\r\n\\usepackage[locale=DE]{{siunitx}}\r\n\\usepackage{{scrlayer-scrpage}}\r\n\\usepackage{{lastpage}}\r\n\\usepackage{{graphicx}}\r\n\\usepackage{{multirow}}\r\n\\usepackage{{longtable}}\r\n\\usepackage{{enumitem}}\r\n\\usepackage{{fp, xstring, spreadtab, numprint}}\r\n\\DeclareSIUnit{{\\sieuro}}{{\\mbox{{\\euro}}}}"); _ = texFile.AppendLine($"\\rohead{{{quoteVM.QuotationNumber}}}"); @@ -40,7 +39,7 @@ namespace Gremlin.Operations _ = texFile.AppendLine($"Mobil:&{RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "userMobile")}\\\\"); _ = texFile.AppendLine($"E-Mail:&\\href{{mailto:{RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "userMail")}}}{{{RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "userMail")}}}\\\\"); _ = texFile.AppendLine("\\textbf{Auftragsannahme:}&\\href{mailto:salesservices\\_germany@agilent.com}{salesservices\\_germany@agilent.com}\\\\\r\n\\hline\r\n\\end{tabular}\r\n}\\\\"); - //_ = texFile.Append(ContactViewModel.CreateBriefkopf(contact)); + _ = texFile.Append(ContactVM.CreateBriefkopf(quoteVM.Recipient, true)); _ = texFile.AppendLine("&\\\\\r\n&\\\\\r\n\\end{tabular}\r\n\\vspace{1cm}\\par "); //Anrede diff --git a/Gremlin/GremlinUI/QuoteUI.xaml.cs b/Gremlin/GremlinUI/QuoteUI.xaml.cs index eee1c93..eb27983 100644 --- a/Gremlin/GremlinUI/QuoteUI.xaml.cs +++ b/Gremlin/GremlinUI/QuoteUI.xaml.cs @@ -53,7 +53,7 @@ namespace Gremlin.GremlinUI string fileName = $"{quoteVM.QuotationNumber}"; string quotePath = tbQuotationPath.Text; TexFileHandler.CreateTexAndOpen(quoteVM, cbBrutto.IsChecked, fileName, quotePath); - PDFHandler.CreatePDF(fileName, quotePath); + //PDFHandler.CreatePDF(fileName, quotePath); } diff --git a/Gremlin/GremlinUI/ViewModels/ContactVM.cs b/Gremlin/GremlinUI/ViewModels/ContactVM.cs index 97d1b88..31787dc 100644 --- a/Gremlin/GremlinUI/ViewModels/ContactVM.cs +++ b/Gremlin/GremlinUI/ViewModels/ContactVM.cs @@ -8,7 +8,6 @@ using System.Text; using System.Windows.Data; using Microsoft.EntityFrameworkCore; using Gremlin.GremlinData.EntityClasses; -using System.ComponentModel; namespace Gremlin.ViewModels { @@ -145,17 +144,22 @@ namespace Gremlin.ViewModels } } - internal static StringBuilder CreateBriefkopf(ContactVM contactViewModel) + internal static StringBuilder CreateBriefkopf(ContactVM contactVM, bool tex = false) { StringBuilder briefkopf = new(); - _ = contactViewModel.Gender == (byte)Enums.Gender.Male - ? briefkopf.AppendLine($"Herr {contactViewModel.FirstName} {contactViewModel.LastName}") - : briefkopf.AppendLine($"Frau {contactViewModel.FirstName} {contactViewModel.LastName}"); - - _ = briefkopf.AppendLine($"{contactViewModel.AccountName}"); - _ = briefkopf.AppendLine($"{contactViewModel.AccountStreet}"); - _ = briefkopf.AppendLine($"{contactViewModel.AccountZIP} {contactViewModel.AccountCity}"); + _ = contactVM.Gender == (byte)Enums.Gender.Male + ? briefkopf.AppendLine($"Herr {contactVM.FirstName} {contactVM.LastName}") + : briefkopf.AppendLine($"Frau {contactVM.FirstName} {contactVM.LastName}"); + if (tex) + _ = briefkopf.AppendLine($"\\\\"); + + _ = briefkopf.AppendLine($"{contactVM.AccountName}"); + if (tex) { briefkopf.AppendLine($"\\\\"); } + _ = briefkopf.AppendLine($"{contactVM.AccountStreet}"); + if (tex) { briefkopf.AppendLine($"\\\\"); } + _ = briefkopf.AppendLine($"{contactVM.AccountZIP} {contactVM.AccountCity}"); + if (tex) { briefkopf.AppendLine($"\\\\"); } return briefkopf; } diff --git a/Gremlin/Properties/Settings.settings b/Gremlin/Properties/Settings.settings index 1338a6b..e8588a2 100644 --- a/Gremlin/Properties/Settings.settings +++ b/Gremlin/Properties/Settings.settings @@ -24,7 +24,7 @@ - 2.5 + 2 1