From 21b32c2c7177bbddaf70cc80905b5e457ee2eb40 Mon Sep 17 00:00:00 2001 From: michele Date: Tue, 9 Apr 2024 16:28:15 +0200 Subject: [PATCH] Michele: modifica estrazione excel (controllo null), modifica model rapportini + Modifica Display name Dati azienda --- Controllers/RapportiniController.cs | 15 +++-- Models/DatiAzienda.cs | 4 +- Models/DatiAziendaTable.cs | 4 +- Models/Rapportini.cs | 94 ++++++++++++++++++++++++++++- 4 files changed, 108 insertions(+), 9 deletions(-) diff --git a/Controllers/RapportiniController.cs b/Controllers/RapportiniController.cs index 71b7313..d2de355 100644 --- a/Controllers/RapportiniController.cs +++ b/Controllers/RapportiniController.cs @@ -163,7 +163,6 @@ namespace VirtualTask.Controllers modelList = modelList.Where(x => x.data_rapportino.GetValueOrDefault().Date >= dataIni.Date).ToList(); } } - var workbook = new XLWorkbook(); workbook.AddWorksheet("sheetName"); @@ -186,11 +185,19 @@ namespace VirtualTask.Controllers { var colonna = 1; - //righe per ogni elemento nel modelList + //righe per ogni item nel modelList foreach (var prop in item.GetType().GetProperties()) { - ws.Cell(row + 2, colonna).Value = prop.GetValue(item).ToString(); - + //controllo se item null assegno stringa vuota + //perchè se null da errore quando scrive l'excel + if (prop.GetValue(item) != null) + { + ws.Cell(row + 2, colonna).Value = prop.GetValue(item).ToString(); + } + else + { + ws.Cell(row + 2, colonna).Value = string.Empty; + } colonna++; } diff --git a/Models/DatiAzienda.cs b/Models/DatiAzienda.cs index 1706b21..d4bd19d 100644 --- a/Models/DatiAzienda.cs +++ b/Models/DatiAzienda.cs @@ -18,11 +18,11 @@ namespace VirtualTask.Models /// url del logo esposto public string? url_logo { get; set; } - [Display(Name = "Intestazione Logo")] + [Display(Name = "Logo")] /// logo public IFormFile? logo { get; set; } - [Display(Name = "Testo")] + [Display(Name = "Intestazione")] /// testo azienda rapportino public string? testo_buono { get; set; } } diff --git a/Models/DatiAziendaTable.cs b/Models/DatiAziendaTable.cs index a2b45aa..16d2461 100644 --- a/Models/DatiAziendaTable.cs +++ b/Models/DatiAziendaTable.cs @@ -21,12 +21,12 @@ namespace VirtualTask.Models public string? url_logo { get; set; } [Required] - [Display(Name = "Intestazione Logo")] + [Display(Name = "Logo")] /// logo public byte[]? logo { get; set; } [Required] - [Display(Name = "Testo")] + [Display(Name = "Intestazione")] /// testo azienda rapportino public string? testo_buono { get; set; } diff --git a/Models/Rapportini.cs b/Models/Rapportini.cs index 46db912..aaffe10 100644 --- a/Models/Rapportini.cs +++ b/Models/Rapportini.cs @@ -17,7 +17,6 @@ namespace VirtualTask.Models /// /// Codice Impianto /// - [Display(Name = "Impianto")] public string? codice_impianto { get; set; } @@ -35,5 +34,98 @@ namespace VirtualTask.Models /// Data rapportino /// public DateTime? data_rapportino { get; set; } + + /// + /// Codice Cliente + /// + public string? ancodice { get; set; } + + /// Ragione Sociale + public string? andescri { get; set; } + + /// ora inizio rapportino + public string? ora_ini_rapportino { get; set; } + + /// ora inizio rapportino + public string? ora_fin_rapportino { get; set; } + + /// min inizio rapportino + public string? min_ini_rapportino { get; set; } + + /// min inizio rapportino + public string? min_fin_rapportino { get; set; } + + /// codice chiusura 1 + public string? codice_chiusura_1 { get; set; } + + /// codice chiusura 2 + public string? codice_chiusura_2 { get; set; } + + /// codice chiusura 3 + public string? codice_chiusura_3 { get; set; } + + /// codice chiusura 4 + public string? codice_chiusura_4 { get; set; } + + /// codice chiusura 5 + public string? codice_chiusura_5 { get; set; } + + /// codice chiusura 6 + public string? codice_chiusura_6 { get; set; } + + /// codice chiusura 7 + public string? codice_chiusura_7 { get; set; } + + /// codice chiusura 8 + public string? codice_chiusura_8 { get; set; } + + /// codice chiusura 9 + public string? codice_chiusura_9 { get; set; } + + /// codice chiusura 10 + public string? codice_chiusura_10 { get; set; } + + /// descrizione int + public string? descrizione_intervento { get; set; } + + /// tecnico + public string? codice_tecnico { get; set; } + + /// firma + public string? firma { get; set; } + + /// cod intervento + public string? codice_intervento { get; set; } + + /// + public string? note_intervento { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? ore_lavoro { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? materiale { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? diritto_chiamata { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? manodopera { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? spese_viaggio { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? anticipo { get; set; } + + /// + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(9, 2)")] + public decimal? totale { get; set; } } }