From 0ad15c90c3b158ff2a00dec1d2bede94c7f777b8 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Sat, 23 Jul 2022 16:05:38 +0200 Subject: [PATCH] Articoli - completato fix editing lista valori ammissibili x tipo - ok editing --- MP.Data/Controllers/MpSpecController.cs | 112 +++++++++++++++--------- MP.Data/DatabaseModels/ListValues.cs | 29 +++--- MP.Data/MoonProContext.cs | 25 ++++++ MP.SPEC/Data/MpDataService.cs | 10 ++- MP.SPEC/Pages/Articoli.razor | 42 +++++---- MP.SPEC/Pages/Articoli.razor.cs | 2 + 6 files changed, 147 insertions(+), 73 deletions(-) diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index a6517d56..0009b2bb 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -32,8 +32,6 @@ namespace MP.Data.Controllers return AnagGruppiGetTipo("AZIENDA"); } - - /// /// Elenco Gruppi /// @@ -73,28 +71,14 @@ namespace MP.Data.Controllers } /// - /// Elenco tabella Articoli da filtro + /// Elenco valori ammessi x Tipo articoli /// - /// - /// /// - public List ArticoliGetSearch(int numRecord, string searchVal = "") + public List AnagTipoArtLV() { - List dbResult = new List(); - using (var dbCtx = new MoonProContext(_configuration)) - { - dbResult = dbCtx - .DbSetArticoli - .AsNoTracking() - .Where(x => x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal) || string.IsNullOrEmpty(searchVal)) - .OrderBy(x => x.CodArticolo) - .Take(numRecord) - .ToList(); - } - return dbResult; + return ListValuesFilt("AnagArticoli", "Tipo"); } - /// /// Eliminazione Record /// @@ -124,6 +108,52 @@ namespace MP.Data.Controllers } return fatto; } + + /// + /// Elenco tabella Articoli da filtro + /// + /// + /// + /// + public List ArticoliGetSearch(int numRecord, string searchVal = "") + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetArticoli + .AsNoTracking() + .Where(x => x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal) || string.IsNullOrEmpty(searchVal)) + .OrderBy(x => x.CodArticolo) + .Take(numRecord) + .ToList(); + } + return dbResult; + } + + /// + /// Elenco tabella Articoli da filtro + /// + /// + /// + /// + /// + public List ArticoliGetSearch(int numRecord, string azienda = "*", string searchVal = "") + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetArticoli + .AsNoTracking() + .Where(x => (x.Azienda == azienda || azienda == "*") && (x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal) || string.IsNullOrEmpty(searchVal))) + .OrderBy(x => x.CodArticolo) + .Take(numRecord) + .ToList(); + } + return dbResult; + } + /// /// Update Record /// @@ -165,29 +195,6 @@ namespace MP.Data.Controllers return fatto; } - /// - /// Elenco tabella Articoli da filtro - /// - /// - /// - /// - /// - public List ArticoliGetSearch(int numRecord, string azienda = "*", string searchVal = "") - { - List dbResult = new List(); - using (var dbCtx = new MoonProContext(_configuration)) - { - dbResult = dbCtx - .DbSetArticoli - .AsNoTracking() - .Where(x => (x.Azienda == azienda || azienda == "*") && (x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal) || string.IsNullOrEmpty(searchVal))) - .OrderBy(x => x.CodArticolo) - .Take(numRecord) - .ToList(); - } - return dbResult; - } - /// /// Elenco da tabella Macchine /// @@ -210,6 +217,27 @@ namespace MP.Data.Controllers { } + /// + /// Elenco valori ammessi x tabella/colonna + /// + /// + /// + /// + public List ListValuesFilt(string tabName, string fieldName) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetListValues + .Where(x => x.TableName == tabName && x.FieldName == fieldName) + .AsNoTracking() + .OrderBy(x => x.ordinal) + .ToList(); + } + return dbResult; + } + /// /// Elenco da tabella Macchine /// diff --git a/MP.Data/DatabaseModels/ListValues.cs b/MP.Data/DatabaseModels/ListValues.cs index bab7168a..75a6f12c 100644 --- a/MP.Data/DatabaseModels/ListValues.cs +++ b/MP.Data/DatabaseModels/ListValues.cs @@ -1,27 +1,28 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; #nullable disable namespace MP.Data.DatabaseModels { - [Table("AnagraficaGruppi")] - public partial class AnagGruppi + [Table("ListValues")] + public partial class ListValues { #region Public Properties - //[Key, DatabaseGenerated(DatabaseGeneratedOption.None), MaxLength(50)] - public string CodGruppo { get; set; } - - //[MaxLength(50)] - public string TipoGruppo { get; set; } - - //[MaxLength(250)] - public string DescrGruppo { get; set; } + [MaxLength(50)] + public string TableName { get; set; } - public bool SelEnabled { get; set; } + [MaxLength(50)] + public string FieldName { get; set; } + + [MaxLength(50)] + public string value { get; set; } + + [MaxLength(50)] + public string label { get; set; } + + public int ordinal { get; set; } #endregion Public Properties } diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs index 2b58026a..d695c05b 100644 --- a/MP.Data/MoonProContext.cs +++ b/MP.Data/MoonProContext.cs @@ -40,6 +40,7 @@ namespace MP.Data public virtual DbSet DbSetMSE { get; set; } public virtual DbSet DbSetConfig { get; set; } public virtual DbSet DbSetAnagGruppi { get; set; } + public virtual DbSet DbSetListValues { get; set; } #endregion Public Properties @@ -278,6 +279,30 @@ namespace MP.Data entity.Property(e => e.SelEnabled) .HasColumnName("SelEnabled"); + }); + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.TableName, e.FieldName, e.value}); + + //entity.Property(e => e.TableName) + // .HasMaxLength(50) + // .HasColumnName("TableName"); + + //entity.Property(e => e.FieldName) + // .HasMaxLength(50) + // .HasColumnName("FieldName"); + + //entity.Property(e => e.value) + // .HasMaxLength(50) + // .HasColumnName("value"); + + //entity.Property(e => e.label) + // .HasMaxLength(50) + // .HasColumnName("label"); + + //entity.Property(e => e.ordinal) + // .HasColumnName("ordinal"); + }); OnModelCreatingPartial(modelBuilder); diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index 73f01326..ead6f768 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -78,9 +78,15 @@ namespace MP.SPEC.Data /// /// /// - public Task> ArticoliGetSearch(int numRecord, string azienda, string searchVal) + public async Task> ArticoliGetSearch(int numRecord, string azienda, string searchVal) { - return Task.FromResult(dbController.ArticoliGetSearch(numRecord, azienda, searchVal)); + return await Task.FromResult(dbController.ArticoliGetSearch(numRecord, azienda, searchVal)); + } + + + public async Task> AnagTipoArtLV() + { + return await Task.FromResult(dbController.AnagTipoArtLV()); } /// diff --git a/MP.SPEC/Pages/Articoli.razor b/MP.SPEC/Pages/Articoli.razor index 65d23538..d2772860 100644 --- a/MP.SPEC/Pages/Articoli.razor +++ b/MP.SPEC/Pages/Articoli.razor @@ -49,16 +49,24 @@ -
-
- Tipo - +
+
+ @*T*@ +
-
-
- @*Azienda*@ - @if (ListAziende != null) { foreach (var item in ListAziende.Where(x => x.CodGruppo != "*").ToList()) @@ -71,15 +79,19 @@
-
-
- +
+
+
-
- +
+
+ +
-
- +
+
+ +
diff --git a/MP.SPEC/Pages/Articoli.razor.cs b/MP.SPEC/Pages/Articoli.razor.cs index ded45767..76f811ed 100644 --- a/MP.SPEC/Pages/Articoli.razor.cs +++ b/MP.SPEC/Pages/Articoli.razor.cs @@ -48,6 +48,7 @@ namespace MP.SPEC.Pages private List? ListRecords; private List? SearchRecords; private List? ListAziende; + private List? ListTipoArt; #endregion Private Fields @@ -199,6 +200,7 @@ namespace MP.SPEC.Pages MessageService.ShowSearch = false; MessageService.EA_SearchUpdated += OnSeachUpdated; ListAziende = await MDService.ElencoAziende(); + ListTipoArt = await MDService.AnagTipoArtLV(); await reloadData(); }