bug of AccountFinding

pull/1/head
DJh2o2 2022-12-06 12:00:57 +07:00
parent 66600bfaff
commit 1e62719332
8 changed files with 84 additions and 41 deletions

@ -1284,27 +1284,18 @@ namespace Gremlin_BlazorServer.Data.DBClasses
Account agilent = db.Accounts.Where(a => a.AccountName == "Agilent Technologies").Single();
foreach (CustomDescription CD in CDsReadFromFile)
{
if (CD.Products == null) { continue; }
//Skip Desciptions, if it has been already imported above (as part from 3PP)
if (thirdPartyProductsFromImportedCDs.Intersect(CD.Products).Any())
{
continue;
}
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();
if (CD.Products == null)
{
CDsWithoutEFReferences.Add(CD);
continue;
}
if (CD.Products == null) { CDsWithoutEFReferences.Add(CD); continue; }
//Establish EF Reference: If no Supplier-Account found, then skip this custom description (shouldn't happen), else set Supplier to Agilent (3PP-Supplier have been processed before and their products should not be part of this list).
if (CD.Supplier == null)
{
CDsWithoutEFReferences.Add(CD);
continue;
}
if (CD.Supplier == null) { CDsWithoutEFReferences.Add(CD); continue; }
CD.Supplier = agilent;
_ = MetaDataSetter.ForImport(CD, "CSVImporter", "Initial import by CSV Importer (Function DbHelper.ImportCustomDescriptionsFromCsv)");

@ -20,8 +20,8 @@
public uint ZIP { get; set; }
public string City { get; set; } = string.Empty;
public string FloorOrBuilding { get; set; } = string.Empty;
public float Longitude { get; set; }
public float Latitude { get; set; }
public float Longitude { get; set; } = 0;
public float Latitude { get; set; } = 0;
public string PhoneNumber { get; set; } = string.Empty;
public string FaxNumber { get; set; } = string.Empty;
public string Webpage { get; set; } = string.Empty;

@ -22,7 +22,7 @@
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.0" />
<PackageReference Include="morelinq" Version="3.3.2" />
<PackageReference Include="MySqlConnector" Version="2.2.1" />
<PackageReference Include="MySqlConnector" Version="2.2.2" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0-alpha.1" />
</ItemGroup>

@ -5,6 +5,7 @@
@inject ContactService contactService
@inject NavigationManager navigationManager
@inject AccountService accountService
<h2>Add Contact</h2>
<hr />

@ -7,8 +7,7 @@
@inject QuoteService quoteService
<h1>Quotes</h1>
<Divider DividerType="DividerType.TextContent" Text="Quotes"/>
<NavLink class="nav-link" href="Quotes/Add">
<span class="oi oi-plus" aria-hidden="true">Create New Quotes</span>
</NavLink>
@ -36,25 +35,57 @@
<DataGridColumn Field="@nameof(Quote.QuoteContainsRB)" Caption="RB" Filterable Sortable/>
</DataGrid>
<h2>@selectedQuote.QuotationNumber</h2>
<DataGrid
TItem="LineItem"
Data="@lineItemsInSelectedQuote"
Bordered
Hoverable
Sortable
Striped
Responsive>
<DataGridCommandColumn />
<DataGridColumn Field="@nameof(LineItem.Position)" Caption="#"/>
<DataGridColumn Field="@nameof(LineItem.Amount)" Caption="Amount" Editable />
<DataGridColumn Field="@nameof(LineItem.ProductNumber)" Caption="ProductNumber" Editable />
<DataGridColumn Field="@nameof(LineItem.OptionNumber)" Caption="OptionNumber" Editable />
<DataGridColumn Field="@nameof(LineItem.ProductLine)" Caption="ProductLine" Editable />
<DataGridColumn Field="@nameof(LineItem.ListPrice)" Caption="ListPrice" DisplayFormat="{0:C}" DisplayFormatProvider=cultureInfo Editable />
<DataGridColumn Field="@nameof(LineItem.TotalDiscount)" Caption="TotalDiscount" DisplayFormat="{0:C}" DisplayFormatProvider=cultureInfo Editable />
<DataGridColumn Field="@nameof(LineItem.Total)" Caption="Total" DisplayFormat="{0:C}" DisplayFormatProvider=cultureInfo Editable />
</DataGrid>
<Divider DividerType="DividerType.TextContent" Text="Quote Details"/>
<Fields>
<Field>
<FieldLabel ColumnSize="ColumnSize.Is2">SalesRep:</FieldLabel>
<FieldBody>@selectedQuote.SalesRep.LastName</FieldBody>
</Field>
<Field>
<FieldLabel ColumnSize="ColumnSize.Is2">QuotationDate:</FieldLabel>
<FieldBody>@selectedQuote.QuotationDate</FieldBody>
</Field>
<Field Horizontal>
<FieldLabel ColumnSize="ColumnSize.Is2">QuotationNumber:</FieldLabel>
<FieldBody>@selectedQuote.QuotationNumber</FieldBody>
</Field>
<Field Horizontal>
<FieldLabel ColumnSize="ColumnSize.Is2">ValidFor:</FieldLabel>
<FieldBody>@selectedQuote.ValidFor.ToString()</FieldBody>
</Field>
<Field Horizontal>
<FieldLabel ColumnSize="ColumnSize.Is2">TotalNet:</FieldLabel>
<FieldBody>@selectedQuote.TotalNet</FieldBody>
</Field>
<Field Horizontal>
<FieldLabel ColumnSize="ColumnSize.Is2">TotalVAT:</FieldLabel>
<FieldBody>@selectedQuote.TotalVAT</FieldBody>
</Field>
<Field Horizontal>
<FieldLabel ColumnSize="ColumnSize.Is2">TotalGross:</FieldLabel>
<FieldBody>@selectedQuote.TotalGross</FieldBody>
</Field>
</Fields>
<Divider DividerType="DividerType.TextContent" Text="Line Items"/>
<DataGrid
TItem="LineItem"
Data="@lineItemsInSelectedQuote"
Bordered
Hoverable
Sortable
Striped
Responsive>
<DataGridCommandColumn />
<DataGridColumn Field="@nameof(LineItem.Position)" Caption="#"/>
<DataGridColumn Field="@nameof(LineItem.Amount)" Caption="Amount" Editable />
<DataGridColumn Field="@nameof(LineItem.ProductNumber)" Caption="ProductNumber" Editable />
<DataGridColumn Field="@nameof(LineItem.OptionNumber)" Caption="OptionNumber" Editable />
<DataGridColumn Field="@nameof(LineItem.ProductLine)" Caption="ProductLine" Editable />
<DataGridColumn Field="@nameof(LineItem.ListPrice)" Caption="ListPrice" DisplayFormat="{0:C}" DisplayFormatProvider=cultureInfo Editable />
<DataGridColumn Field="@nameof(LineItem.TotalDiscount)" Caption="TotalDiscount" DisplayFormat="{0:C}" DisplayFormatProvider=cultureInfo Editable />
<DataGridColumn Field="@nameof(LineItem.Total)" Caption="Total" DisplayFormat="{0:C}" DisplayFormatProvider=cultureInfo Editable />
</DataGrid>
@code {
public string searchQuote = "";

@ -32,7 +32,19 @@ namespace Gremlin_BlazorServer.Services
public async Task<Account> GetAccountAsync(uint accountId)
{
return await gremlinContext.Accounts.FirstOrDefaultAsync(account => account.AccountId.Equals(accountId)) ?? new Account();
Account? account = new();
if (accountId != 0)
{
try
{
account = await gremlinContext.Accounts.FirstOrDefaultAsync(account => account.AccountId.Equals(accountId));
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
}
}
return account ?? new Account();
}
public async Task<bool> UpdateAccountAsync(Account account)

@ -1,13 +1,16 @@
using Gremlin_BlazorServer.Data.DBClasses;
using Gremlin_BlazorServer.Data.EntityClasses;
using Microsoft.EntityFrameworkCore;
using Microsoft.VisualStudio.Web.CodeGenerators.Mvc.Controller;
using System.Diagnostics;
namespace Gremlin_BlazorServer.Services
{
public class ContactService
{
private readonly GremlinContext gremlinContext;
private static GremlinContext gremlinContext = new();
private readonly AccountService accountService = new(gremlinContext);
private readonly AccountTypeService accountTypeService = new(gremlinContext);
public ContactService(GremlinContext gC) => gremlinContext = gC;
@ -20,6 +23,8 @@ namespace Gremlin_BlazorServer.Services
public async Task<bool> InsertContactAsync(Contact contact)
{
contact.Account = await accountService.GetAccountAsync(contact.AccountId);
contact.Account.AccountType = await accountTypeService.GetAccountTypeAsync("FPC") ?? new AccountType();
try
{
_ = await gremlinContext.Contacts.AddAsync(contact);

@ -124,9 +124,12 @@ namespace Gremlin_BlazorServer.Services
_ = texFile.AppendLine("&\\\\\n&\\\\\n\\end{tabular}\n\\vspace{1cm}\\par ");
//Anrede
_ = quote.Recipient.Gender == (byte)Gender.Male
if (quote.Recipient != null)
{
_ = quote.Recipient.Gender == (byte)Gender.Male
? texFile.AppendLine($"Sehr geehrter Herr {quote.Recipient.LastName},\\par ")
: texFile.AppendLine($"Sehr geehrte Frau {quote.Recipient.LastName},\\par ");
}
//Anschreiben
_ = texFile.AppendLine(await CreateCoverletterAsync(quote));