change byte Gender in ViewModels to Enum.Gender

pull/1/head
Sascha Woitschetzki 2021-07-16 12:36:25 +07:00
parent 612411ca34
commit c206b84b73
22 changed files with 114 additions and 125 deletions

@ -1119,7 +1119,7 @@ namespace Gremlin.GremlinData.DBClasses
ImportedCD.Supplier = new();
ImportedCD.Supplier.AccountName = fields[2] is "" or "RB" ? "Agilent Technologies" : fields[2];
MetaDataSetter.ForImport(ImportedCD, "Importer", "Initial Importer by CD-ImporterFomCsv");
CDsReadFromFile.Add(ImportedCD);
}
@ -1361,7 +1361,7 @@ namespace Gremlin.GremlinData.DBClasses
.Where(p => p.DataStatus == Status.Active.ToString())
.Include(p => p.ProductLine)
.ToList();
//Neue CPL einlesen...
List<Product> ProductsReadFromFile = new(ParseProductFile(filepath, separator, dataHasHeading));
@ -1915,7 +1915,7 @@ namespace Gremlin.GremlinData.DBClasses
public static Product ResolveProduct(GremlinContext context, string productNumber, string option)
{
try {return context.Products.Where(product => product.ProductNumber == productNumber && product.OptionNumber == option).First(); }
try { return context.Products.Where(product => product.ProductNumber == productNumber && product.OptionNumber == option).First(); }
catch { return null; }
}

@ -14,11 +14,11 @@ namespace Gremlin.GremlinData.DBClasses
entity.HasOne(d => d.AccountType).WithMany(p => p.Accounts).IsRequired(true).OnDelete(DeleteBehavior.Restrict);
entity.HasOne(d => d.SubMarket).WithMany(p => p.Accounts).IsRequired(true).OnDelete(DeleteBehavior.Restrict);
entity.HasAlternateKey(e => e.SAPAccountNumber); // =Unique
entity.Property(e => e.AccountId).ValueGeneratedOnAdd();
entity.Property(e => e.ParentAccountId);
entity.Property(e => e.AccountName).IsRequired(true).HasMaxLength(250);
//.HasColumnType("VARCHAR(250)") ist überflüssig, da .HasMaxLength(250) VARCHAR(250) impliziert.
//.HasColumnType("VARCHAR(250)") ist überflüssig, da .HasMaxLength(250) VARCHAR(250) impliziert.
entity.Property(e => e.Notes);
entity.Property(e => e.Street).IsRequired(true).HasMaxLength(100);
entity.Property(e => e.ZIP).IsRequired(true).HasColumnType("Char(5)");
@ -32,16 +32,16 @@ namespace Gremlin.GremlinData.DBClasses
entity.Property(e => e.EMail).HasMaxLength(150);
entity.Property(e => e.SAPAccountNumber).IsRequired(true);
entity.Property(e => e.AccountCreatedInSAPOn).IsRequired(true);
entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
entity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
entity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
entity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true);
entity.Property(e => e.DataVersionComment).HasDefaultValue("");
entity.Property(e => e.DataStatus).IsRequired(true);
//.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core?
//.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core?
entity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
//.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true)
//.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true)
entity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
}
}
@ -53,7 +53,7 @@ namespace Gremlin.GremlinData.DBClasses
entity.HasKey(e => e.ContactId);
entity.HasOne(p => p.Account).WithMany(d => d.Contacts).IsRequired(true);
//entity.HasAlternateKey(e => e.SAPContactNumber);
entity.Property(e => e.ContactId);
entity.Property(e => e.SAPContactNumber).IsRequired(true);
entity.Property(e => e.AcademicTitle);
@ -65,7 +65,7 @@ namespace Gremlin.GremlinData.DBClasses
entity.Property(e => e.IsReference).HasDefaultValue(false);
entity.Property(e => e.Notes);
entity.Property(e => e.ValidatedContact).HasDefaultValue(false);
entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
entity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
entity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
@ -86,12 +86,12 @@ namespace Gremlin.GremlinData.DBClasses
{
entity.HasKey(e => e.QuoteId);
entity.HasMany(d => d.LineItems).WithOne(p => p.Quote).IsRequired(false).OnDelete(DeleteBehavior.Cascade);
entity.Property(e => e.QuotationNumber).HasColumnType("VARCHAR(255)").IsRequired(true).ValueGeneratedOnAdd();
entity.Property(e => e.QuotationDate).IsRequired(true).ValueGeneratedOnAdd();
entity.Property(e => e.ValidUntil);
entity.Property(e => e.ValidFor).IsRequired(true);
entity.Ignore("SalesRep");
entity.Property(e => e.TotalListprice);
@ -102,7 +102,7 @@ namespace Gremlin.GremlinData.DBClasses
entity.Property(e => e.QuoteContains3PP).HasDefaultValue(false);
entity.Property(e => e.QuoteContainsRB).HasDefaultValue(false);
entity.Property(e => e.QuoteTemplate);
entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
entity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
entity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
@ -122,7 +122,7 @@ namespace Gremlin.GremlinData.DBClasses
{
entity.HasKey(e => e.LineItemId);
entity.HasOne(p => p.Quote).WithMany(d => d.LineItems).HasForeignKey(fk => fk.QuoteId).IsRequired(true).OnDelete(DeleteBehavior.Cascade);
entity.Property(e => e.Position).IsRequired(true);
entity.Property(e => e.Amount).IsRequired(true);
entity.Property(e => e.ProductNumber).IsRequired(true);
@ -139,7 +139,7 @@ namespace Gremlin.GremlinData.DBClasses
entity.Property(e => e.ExtendedListPrice).IsRequired(true);
entity.Property(e => e.NetPrice).IsRequired(true);
entity.Property(e => e.Total).IsRequired(true);
entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
entity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
entity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
@ -162,7 +162,7 @@ namespace Gremlin.GremlinData.DBClasses
entity.HasOne(p => p.ProductLine).WithMany(d => d.Products).HasForeignKey("ProductLineCode").IsRequired(true).OnDelete(DeleteBehavior.Restrict);
entity.Property(e => e.CustomDescriptionId).IsRequired(false);
entity.Property(e => e.ProductNumber).IsRequired(true);
entity.Property(e => e.OptionNumber);
entity.Property(e => e.SapShortDescription);
@ -171,7 +171,7 @@ namespace Gremlin.GremlinData.DBClasses
entity.Property(e => e.ProductStatus);
entity.Property(e => e.IntroductionDate);
entity.Property(e => e.ListPrice).IsRequired(true);
entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
entity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
entity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
@ -192,7 +192,7 @@ namespace Gremlin.GremlinData.DBClasses
entity.HasKey(e => e.CustomDescriptionId);
entity.HasMany(p => p.Products).WithOne(d => d.CustomDescription).IsRequired(false);
entity.HasOne(p => p.Supplier).WithMany(d => d.CustomDescriptions).IsRequired(true);
entity.Property(e => e.ProductNumber).IsRequired(true);
entity.Property(e => e.OptionNumber);
entity.Property(e => e.Heading).IsRequired(true);
@ -218,7 +218,7 @@ namespace Gremlin.GremlinData.DBClasses
public void Configure(EntityTypeBuilder<ProductLine> entity)
{
entity.HasMany(p => p.Products).WithOne(d => d.ProductLine).IsRequired(true).OnDelete(DeleteBehavior.Restrict);
entity.Property(e => e.ProductLineDescription).IsRequired(true);
entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
@ -242,7 +242,7 @@ namespace Gremlin.GremlinData.DBClasses
//entity.HasMany(p => p.Accounts).WithOne(d => d.AccountType); //already defined in class Account
entity.Property(e => e.AccountTypeCode).IsRequired(true).HasColumnType("Char(3)");
entity.Property(e => e.AccountTypeDescription).HasColumnType("Varchar(1000)").IsRequired(true);
entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
entity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
entity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
@ -264,7 +264,7 @@ namespace Gremlin.GremlinData.DBClasses
//entity.HasMany(p => p.Accounts).WithOne(d => d.SubMarket); //already defined in class Account
entity.Property(e => e.SubMarketCode).HasColumnType("Char(3)");
entity.Property(e => e.SubMarketDescription).HasColumnType("Varchar(1000)").IsRequired(true);
entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
entity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
entity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();

@ -18,16 +18,16 @@ namespace Gremlin.GremlinData.DBClasses
{
//Private members
private static readonly DateTime FarInTheFuture = DateTime.Parse("2050-12-31t00:00:00.000000z", CultureInfo.CurrentCulture);
private static TextFieldParser _csvParser;
private static string _filepath;
private static bool _dataHasHeadings;
private static Encoding _encoding = default;
private static Encoding _encoding;
internal static GremlinContext db = new();
//Public properties
public static string Filepath
{
public static string Filepath
{
get => _filepath;
set
{
@ -52,7 +52,7 @@ namespace Gremlin.GremlinData.DBClasses
}
}
}
public static bool DataHasHeadings
{
get => _dataHasHeadings;
@ -139,7 +139,7 @@ namespace Gremlin.GremlinData.DBClasses
Encoding = FileIO.GetEncoding(_filepath);
}
Separators = new string[] { separator };
ImportFile();
return true;
}
@ -195,7 +195,7 @@ namespace Gremlin.GremlinData.DBClasses
score[i, j] = line.Split(candidates[j]).Length;
}
}
}
}
}
List<(string, int, float)> scoreBoard = new(); //Item1 = Separator, Item2 = Score (Anzahl aufeinanderfolgender Zeilen mit gleicher Anzahl von Fields), Item3 = Count (durchschnittliche Anzahl von Fields in Zeile)
@ -207,7 +207,7 @@ namespace Gremlin.GremlinData.DBClasses
average = 0;
for (int i = 0; i < numberOfLinesToEvaluate - 1; i++)
{
if (score[i,j] == score[i+1,j] && score[i,j] > 1)
if (score[i, j] == score[i + 1, j] && score[i, j] > 1)
{
x++;
}
@ -217,11 +217,11 @@ namespace Gremlin.GremlinData.DBClasses
average /= numberOfLinesToEvaluate;
scoreBoard.Add((candidates[j], x, average));
}
ResetParser();
return scoreBoard.Find(f => f.Item2 == scoreBoard.Max(x => x.Item2) && f.Item3 == scoreBoard.Max(x => x.Item3)).Item1;
}
public static bool ImportFile()
//Ein (möglichst) generischer Importer
//1. Dateipfad erfassen
@ -235,11 +235,11 @@ namespace Gremlin.GremlinData.DBClasses
using (_csvParser)
{
//für geneerischen Code:
//für geneerischen Code:
//int numberOfLines = File.ReadAllLines(filepath).Length;
//Assembly Gremlin = Assembly.GetExecutingAssembly();
//dynamische Spaltenzuordnung in Dictonary speichern
string[] fields = _csvParser.ReadFields();
Dictionary<string, string> MappingDictionary = ReadMappingDictionaryFromFile();
@ -294,7 +294,7 @@ namespace Gremlin.GremlinData.DBClasses
_filepath = filepath;
return ImportFile();
}
private static bool ImportCustomDescriptions(Dictionary<string, int> mappingTable)
{
List<CustomDescription> CDsReadFromFile = new(2500);
@ -379,7 +379,7 @@ namespace Gremlin.GremlinData.DBClasses
{
//Skip Desciptions, if it has been already imported above (as part from 3PP)
if (thirdPartyProductsFromImportedCDs.Intersect(CD.Products).Any()) continue;
//Establish EF Reference. If no PN/Opt found, then skip this custom description.
//CD.Product = GetProduct(db, CD.ProductNumber, CD.OptionNumber); //ResolveXY-functions return null, if no match is found in db.
CD.Products = productsInDb.Where(product => product.ProductNumber == CD.ProductNumber && product.OptionNumber == CD.OptionNumber).ToList();
@ -399,7 +399,7 @@ namespace Gremlin.GremlinData.DBClasses
//prepare properties
_ = MetaDataSetter.ForImport(CD, "GenericImporter-Method", "Initial import by CSV Importer (Function GenericImporter.ImportCustomDescriptions)");
//add to final list of CDs, that will go into the db.
importedCDsWithEFReferences.Add(CD);
}
@ -412,7 +412,7 @@ namespace Gremlin.GremlinData.DBClasses
return true;
}
}
private static bool ImportProducts(Dictionary<string, int> mappingTable)
{
List<Product> ProductsReadFromFile = new(ParseProductFile(mappingTable));
@ -611,10 +611,10 @@ namespace Gremlin.GremlinData.DBClasses
ImportedContact.MobileNumber = fields[columnNumberOf["MobileNumber"]];
//Convert Gender
ImportedContact.Gender = fields[columnNumberOf["Gender"]] == "M"
? (byte)Gender.Male
: fields[columnNumberOf["Gender"]] == "F"
? (byte)Gender.Female
ImportedContact.Gender = fields[columnNumberOf["Gender"]] == "M"
? (byte)Gender.Male
: fields[columnNumberOf["Gender"]] == "F"
? (byte)Gender.Female
: (byte)Gender.Unknown;
//Convert OptIn Status
@ -811,7 +811,7 @@ namespace Gremlin.GremlinData.DBClasses
//Validierten Account der Liste hinzufügen:
if (DataHasError == false) ImportedAccount.AddIfUniqueTo(AccountsReadFromFile);
}
}
//Eingelesenen Account in DB schreiben:
DateTime now = DateTime.Now;
@ -825,7 +825,7 @@ namespace Gremlin.GremlinData.DBClasses
account.AccountType = accountType;
account.AccountType = DbHelper.ResolveAccountType(db, account.AccountType.AccountTypeCode);
SubMarket subMarket = db.SubMarkets
.Where(a => a.SubMarketCode == account.SubMarket.SubMarketCode)
.First();
@ -842,7 +842,7 @@ namespace Gremlin.GremlinData.DBClasses
//Bestätigung senden
MessageBox.Show($"Es wurden {AccountsReadFromFile.Count} Accounts erfolgreich der Datenbank hinzugefügt.");
return true;
}
@ -858,7 +858,7 @@ namespace Gremlin.GremlinData.DBClasses
List<ProductLine> productLinesReadFromFile = new(50);
using (csvParser)
{
while (!csvParser.EndOfData)
while (!csvParser.EndOfData)
{
ProductLine importedProductLine = new();
string[] fields = csvParser.ReadFields();
@ -871,7 +871,7 @@ namespace Gremlin.GremlinData.DBClasses
db.ProductLines.AddRange(productLinesReadFromFile);
db.SaveChanges();
return true;
}
@ -898,7 +898,7 @@ namespace Gremlin.GremlinData.DBClasses
db.AccountTypes.AddRange(accountTypesReadFromFile);
db.SaveChanges();
return true;
}
@ -912,7 +912,7 @@ namespace Gremlin.GremlinData.DBClasses
List<SubMarket> subMarketsReadFromFile = new(20);
using (csvParser)
{
while (!csvParser.EndOfData)
while (!csvParser.EndOfData)
{
SubMarket importedSubMarket = new();
string[] fields = csvParser.ReadFields();
@ -925,7 +925,7 @@ namespace Gremlin.GremlinData.DBClasses
db.SubMarkets.AddRange(subMarketsReadFromFile);
db.SaveChanges();
return true;
}
@ -999,8 +999,8 @@ namespace Gremlin.GremlinData.DBClasses
{
//Unfertiger, generischer Code aus der ImportFile() Methode.
//Aufbewahren für später, wenn Zeit ist, das ordentlich zu machen.
//while (!csvParser.EndOfData)
//{
// //read

@ -9,12 +9,12 @@ namespace Gremlin.GremlinData.DBClasses
{
public static class MetaDataSetter
{
private static readonly DateTime FarInTheFuture = DateTime.Parse("2050-12-31t00:00:00.000000z", CultureInfo.CurrentCulture);
private static readonly DateTime FarInTheFuture = DateTime.Parse("2050-12-31t00:00:00.000000z", CultureInfo.CurrentCulture);
public static IMetadata ForImport(
IMetadata entity,
string datamodifiedby = "",
string dataversioncomment = "",
IMetadata entity,
string datamodifiedby = "",
string dataversioncomment = "",
[CallerMemberName] string callername = "")
{
SetMetaData(entity, datamodifiedby, dataversioncomment, callername);

@ -15,7 +15,7 @@ namespace Gremlin.GremlinData.EntityClasses
public AccountType AccountType { get; set; }
public SubMarket SubMarket { get; set; }
public IList<CustomDescription> CustomDescriptions { get; set; }
//class properties:
public string AccountName { get; set; }
public string Notes { get; set; }

@ -34,7 +34,7 @@ namespace Gremlin.GremlinData.EntityClasses
public bool EmailBounced { get; set; }
public bool NoHardcopyMailing { get; set; }
public bool ValidatedContact { get; set; }
//Agilent-specific Properties:
public int SAPContactNumber { get; set; }
public DateTime SAPContactCreationDate { get; set; }
@ -44,7 +44,7 @@ namespace Gremlin.GremlinData.EntityClasses
public string SAPApplicationInterest { get; set; }
public string SAPJobLevel { get; set; }
public string SAPCompetitiveIBase { get; set; }
//metadata:
public DateTime DataCreationDate { get; set; }
public DateTime DataModificationDate { get; set; }
@ -54,7 +54,7 @@ namespace Gremlin.GremlinData.EntityClasses
public uint DataVersionNumber { get; set; }
public string DataVersionComment { get; set; }
public string DataStatus { get; set; }
public Contact()
{
}

@ -7,7 +7,7 @@ namespace Gremlin.GremlinData.EntityClasses
{
//primary key:
public uint CustomDescriptionId { get; set; }
//foreign keys:
//public uint ProductId { get; set; }
public uint AccountId { get; set; }
@ -23,7 +23,7 @@ namespace Gremlin.GremlinData.EntityClasses
public string DescriptionText { get; set; }
public string CoverletterText { get; set; }
public string Notes { get; set; } //Hinweise, Tipps, Caveats, etc. für Konfiguration, Verwendung, Best Practice usw.
//Agilent-Specific properties:
//NONE

@ -1,6 +1,6 @@
namespace Gremlin.GremlinData.EntityClasses
{
internal class Enums
public class Enums
{
public enum Status : byte
{

@ -30,7 +30,7 @@ namespace Gremlin.GremlinData.EntityClasses
public decimal ExtendedListPrice { get; set; }
public decimal NetPrice { get; set; }
public decimal Total { get; set; }
//metadata:
public DateTime DataCreationDate { get; set; }
public string DataModificationByUser { get; set; }

@ -14,7 +14,7 @@ namespace Gremlin.GremlinData.EntityClasses
//foreign keys
public uint? CustomDescriptionId { get; set; }
public string ProductLineCode { get; set; }
//Agilent-specific properties:
public string ProductNumber { get; set; }
public string OptionNumber { get; set; }

@ -10,11 +10,11 @@ namespace Gremlin.GremlinData.EntityClasses
//foreign keys:
public uint? ContactId { get; set; }
//navigation properties:
public Contact Recipient { get; set; }
public IList<LineItem> LineItems { get; set; }
//class properties:
public Contact SalesRep { get; set; }
public string QuotationNumber { get; set; }

@ -14,7 +14,7 @@ namespace Gremlin.GremlinData.EntityClasses
//class properties
public string UserName { get; set; }
public string PasswordHash { get; set; }
//metadata (subset of IMetadata)
public DateTime DataCreationDate { get; set; }
public DateTime DataModificationDate { get; set; }

@ -77,7 +77,7 @@ namespace Gremlin.GremlinUtilities
// mail.Subject = quoteVM.QuoteNumber;
// Outlook.AddressEntry currentUser = application.Session.CurrentUser.AddressEntry;
// if (currentUser.Type == "EX")
// {
// Outlook.ExchangeUser manager = currentUser.GetExchangeUser().GetExchangeUserManager();

@ -13,21 +13,21 @@ namespace Gremlin.GremlinUtilities.GUClasses
private int _score = 0;
private bool _allQualifierMatched = false;
public string DataType
public string DataType
{
get => _dataType;
}
public List<string> Qualifiers
public List<string> Qualifiers
{
get => _qualifiers;
}
public int Score
{
get => _score;
}
public bool AllQualifierMatched
{
get => _allQualifierMatched;
@ -64,7 +64,7 @@ namespace Gremlin.GremlinUtilities.GUClasses
public override bool Equals(object obj)
{
return obj is DataIdType type
return obj is DataIdType type
&& _dataType == type._dataType;
}

@ -10,7 +10,7 @@ namespace Gremlin.GremlinUtilities.GUClasses
//private readonly string _source; //Qualifier-Liste
private readonly Dictionary<string, int> _mappingTable; //Mapping Spaltenzahl <-> Property/(übersetzte) Spaltenüberschrift
public List<DataIdType> DataTypes { get; set; }
public DataIdentificator(Dictionary<string, int> MappingTable)
{
@ -88,10 +88,10 @@ namespace Gremlin.GremlinUtilities.GUClasses
{
if (winners.Contains("ProductLine")) winners.Remove("ProductLine");
if (winners.Contains("AccountType")) winners.Remove("AccountType");
if (winners.Contains("SubMarket")) winners.Remove("SubMarket");
if (winners.Contains("Account")) winners.Remove("Account");
if (winners.Contains("Contact")) winners.Remove("Contact");
if (winners.Contains("SubMarket")) winners.Remove("SubMarket");
if (winners.Contains("Account")) winners.Remove("Account");
if (winners.Contains("Contact")) winners.Remove("Contact");
}
if (MustMatchAllQualifer == true && winners.Contains("Account"))

@ -12,7 +12,7 @@ namespace Gremlin.MVVM
{
private string _filepath;
private string _encodingName;
public DataImport()
{
InitializeComponent();

@ -1,7 +1,5 @@
using DocumentFormat.OpenXml.Office2010.ExcelAc;
using Gremlin.MVVM;
using Gremlin.MVVM;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@ -58,34 +56,18 @@ namespace Gremlin.Operations
process.StartInfo.WorkingDirectory = quoteVM.QuotePath;
process.StartInfo.FileName = "pdflatex";
process.StartInfo.Arguments = quoteVM.QuoteNumber;
process.StartInfo.UseShellExecute = false;
try { _ = process.Start(); }
process.StartInfo.UseShellExecute = true;
try { process.Start(); }
catch (Exception ex) { ErrorHandler.ShowErrorInMessageBox(ex); }
process.WaitForExit();
}
}
}
//private static void RunningPDFLaTeX(string quotePath, string fileName, int runs)
//{
// for (int i = 0; i < runs; i++)
// {
// using (Process process = new())
// {
// process.StartInfo.FileName = "pdflatex";
// process.StartInfo.Arguments = quotePath == "" ? $"{fileName}.tex" : $"{quotePath}\\{fileName}.tex";
// process.StartInfo.UseShellExecute = false;
// try
// {
// _ = process.Start();
// }
// catch (Exception ex)
// {
// ErrorHandler.ShowErrorInMessageBox(ex);
// }
// process.WaitForExit();
// }
// }
//}
public static void OpenPDF(QuoteViewModel quoteVM)
{
string pdfFile = $"explorer {quoteVM.QuotePath}";
Process.Start(pdfFile);
}
}
}

@ -52,7 +52,7 @@ namespace Gremlin.MVVM
_ = texFile.AppendLine("&\\\\\n&\\\\\n\\end{tabular}\n\\vspace{1cm}\\par ");
//Anrede
_ = quoteVM.Recipient.Gender == (byte)Gender.Male
_ = quoteVM.Recipient.Gender == Gender.Male
? texFile.AppendLine($"Sehr geehrter Herr {quoteVM.Recipient.LastName},\\par ")
: texFile.AppendLine($"Sehr geehrte Frau {quoteVM.Recipient.LastName},\\par ");

@ -11,7 +11,7 @@ namespace Gremlin.MVVM
{
public class ContactViewModel : PropertyChangedBase
{
private byte _gender = 1;
private Enums.Gender _gender = Enums.Gender.Male;
private string _firstName = "firstName";
private string _lastName = "lastName";
private string _eMail = "email@email.de";
@ -20,7 +20,7 @@ namespace Gremlin.MVVM
private uint _accountZIP;
private string _accountCity = "accountCity";
public byte Gender { get => _gender; set { _gender = value; NotifyOfPropertyChange(() => Gender); } }
public Enums.Gender Gender { get => _gender; set { _gender = value; NotifyOfPropertyChange(() => Gender); } }
public string FirstName { get => _firstName; set { _firstName = value; NotifyOfPropertyChange(() => FirstName); } }
public string LastName { get => _lastName; set { _lastName = value; NotifyOfPropertyChange(() => LastName); } }
public string EMail { get => _eMail; set { _eMail = value; NotifyOfPropertyChange(() => EMail); } }
@ -31,7 +31,7 @@ namespace Gremlin.MVVM
public ContactViewModel() { }
public ContactViewModel(byte gender, string firstName, string lastName, string eMail, string accountName, string accountStreet, uint accountZIP, string accountCity)
public ContactViewModel(Enums.Gender gender, string firstName, string lastName, string eMail, string accountName, string accountStreet, uint accountZIP, string accountCity)
{
Gender = gender;
FirstName = firstName ?? throw new ArgumentNullException(nameof(firstName));
@ -64,7 +64,7 @@ namespace Gremlin.MVVM
public override string ToString()
{
return Gender == (byte)Enums.Gender.Male
return Gender == Enums.Gender.Male
? $"Herr {FirstName} {LastName}; {AccountName}, {AccountStreet}, {AccountZIP} {AccountCity}"
: $"Frau {FirstName} {LastName}; {AccountName}, {AccountStreet}, {AccountZIP} {AccountCity}";
}
@ -98,7 +98,7 @@ namespace Gremlin.MVVM
{
case 1:
{
ContactViewModel salesRepWoitschetzki = new((byte)Enums.Gender.Male,
ContactViewModel salesRepWoitschetzki = new(Enums.Gender.Male,
"Sascha",
"Woitschetzki",
"sascha.woitschetzki@non.agilent.com",
@ -111,7 +111,7 @@ namespace Gremlin.MVVM
case 2:
{
ContactViewModel salesRepWelsch = new((byte)Enums.Gender.Male,
ContactViewModel salesRepWelsch = new(Enums.Gender.Male,
"Sebastian",
"Welsch",
"sebastian.welsch@non.agilent.com",
@ -133,7 +133,7 @@ namespace Gremlin.MVVM
internal static ContactViewModel ConvertContactToVM(Contact contact)
{
ContactViewModel contactVM = new();
contactVM.Gender = contact.Gender;
contactVM.Gender = (Enums.Gender)contact.Gender;
contactVM.LastName = contact.LastName;
contactVM.FirstName = contact.FirstName;
contactVM.EMail = contact.EMail;
@ -151,7 +151,7 @@ namespace Gremlin.MVVM
{
StringBuilder briefkopf = new();
_ = contactVM.Gender == (byte)Enums.Gender.Male
_ = contactVM.Gender == Enums.Gender.Male
? briefkopf.AppendLine($"Herr {contactVM.FirstName} {contactVM.LastName}")
: briefkopf.AppendLine($"Frau {contactVM.FirstName} {contactVM.LastName}");
if (tex) _ = briefkopf.AppendLine($"\\\\");

@ -22,15 +22,15 @@ namespace Gremlin.MVVM
public ushort Position { get => _position; set { _position = value; NotifyOfPropertyChange(() => Position); } }
public ushort Amount { get => _amount; set { _amount = value; NotifyOfPropertyChange(() => Amount); } }
public string ProductNumber { get => _productNumber; set { _productNumber = value; NotifyOfPropertyChange(() => ProductNumber); }}
public string OptionNumber { get => _optionNumber; set { _optionNumber = value; NotifyOfPropertyChange(() => OptionNumber); }}
public string SapShortDescription { get => _sapShortDescription; set { _sapShortDescription = value; NotifyOfPropertyChange(() => SapShortDescription); }}
public CustomDescriptionViewModel CustomDescriptionVM { get => _customDescriptionVM; set { _customDescriptionVM = value; NotifyOfPropertyChange(() => CustomDescriptionVM); }}
public string ProductLine { get => _productLine; set { _productLine = value; NotifyOfPropertyChange(() => ProductLine); }}
public decimal TotalDiscount { get => _totalDiscount; set { _totalDiscount = value; NotifyOfPropertyChange(() => TotalDiscount); }}
public decimal CalcNetPrice { get => _calcNetPrice; set { _calcNetPrice = value; NotifyOfPropertyChange(() => CalcNetPrice); }}
public decimal CalcTotalNet { get => _calcTotalNet; set { _calcTotalNet = value; NotifyOfPropertyChange(() => CalcTotalNet); }}
public decimal ListPrice { get => _listPrice; set { _listPrice = value; NotifyOfPropertyChange(() => ListPrice); }}
public string ProductNumber { get => _productNumber; set { _productNumber = value; NotifyOfPropertyChange(() => ProductNumber); } }
public string OptionNumber { get => _optionNumber; set { _optionNumber = value; NotifyOfPropertyChange(() => OptionNumber); } }
public string SapShortDescription { get => _sapShortDescription; set { _sapShortDescription = value; NotifyOfPropertyChange(() => SapShortDescription); } }
public CustomDescriptionViewModel CustomDescriptionVM { get => _customDescriptionVM; set { _customDescriptionVM = value; NotifyOfPropertyChange(() => CustomDescriptionVM); } }
public string ProductLine { get => _productLine; set { _productLine = value; NotifyOfPropertyChange(() => ProductLine); } }
public decimal TotalDiscount { get => _totalDiscount; set { _totalDiscount = value; NotifyOfPropertyChange(() => TotalDiscount); } }
public decimal CalcNetPrice { get => _calcNetPrice; set { _calcNetPrice = value; NotifyOfPropertyChange(() => CalcNetPrice); } }
public decimal CalcTotalNet { get => _calcTotalNet; set { _calcTotalNet = value; NotifyOfPropertyChange(() => CalcTotalNet); } }
public decimal ListPrice { get => _listPrice; set { _listPrice = value; NotifyOfPropertyChange(() => ListPrice); } }
internal static ObservableCollection<LineItemViewModel> ReadLineItemsFromClipboard()
{

@ -94,5 +94,10 @@ namespace Gremlin.MVVM
{
PDFHandler.CreatePDF(QuoteVM);
}
public void OpenPDF()
{
PDFHandler.OpenPDF(QuoteVM);
}
}
}

@ -7,6 +7,7 @@
<DataGrid
x:Name="Contacts"
AutoGenerateColumns="True"
FrozenColumnCount="3"
SelectionMode="Single"
SelectedItem="SelectedContact"
AlternatingRowBackground="LightGray"
@ -18,6 +19,7 @@
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
<Button x:Name="CreateTex" Content="TexFile erzeugen" Margin="10,5,10,5"/>
<Button x:Name="CreatePDF" Content="PDF erzeugen" Margin="10,5,10,5"/>
<Button x:Name="OpenPDF" Content="PDF öffnen" Margin="10,5,10,5"/>
</StackPanel>
</StackPanel>
</UserControl>