From bf5fde25988afdf011da1aeff565057d711a120d Mon Sep 17 00:00:00 2001 From: michele Date: Wed, 5 Mar 2025 14:54:39 +0100 Subject: [PATCH] michele: aggiunta mag_new --- Controllers/ArticoliController.cs | 7 +- Controllers/MagNewVTController.cs | 95 +++++++ Models/MagNewVT.cs | 33 +++ Views/Articoli/Index.cshtml | 3 +- Views/MagNewVT/Index.cshtml | 152 ++++++++++++ Views/Rapp_New/Details.cshtml | 394 +----------------------------- 6 files changed, 297 insertions(+), 387 deletions(-) create mode 100644 Controllers/MagNewVTController.cs create mode 100644 Models/MagNewVT.cs create mode 100644 Views/MagNewVT/Index.cshtml diff --git a/Controllers/ArticoliController.cs b/Controllers/ArticoliController.cs index 43bc943..ca836e0 100644 --- a/Controllers/ArticoliController.cs +++ b/Controllers/ArticoliController.cs @@ -122,6 +122,8 @@ namespace VirtualTask.Controllers } model.Azienda = tenant; + model.Desc_sup = model.ArDesArt; + apiUrl = helper.GetStringValue("apiUrl"); admin = helper.GetStringValue("admin"); ViewBag.Admin = admin; @@ -219,6 +221,7 @@ namespace VirtualTask.Controllers modelList = JsonConvert.DeserializeObject>(data); var el = modelList.Where(t => t.SlCodice.Equals(id)).First(); ele = el; + } else { @@ -242,14 +245,16 @@ namespace VirtualTask.Controllers { return RedirectToAction("Index", "Login"); } + model.Azienda = tenant; + model.Desc_sup = model.ArDesArt; + apiUrl = helper.GetStringValue("apiUrl"); urlBase = apiUrl + "articolo/mod"; urlBase = urlBase + "?token=" + token; Uri baseAddress = new Uri(urlBase); client = new HttpClient(); client.BaseAddress = baseAddress; - string data = JsonConvert.SerializeObject(model); StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync(baseAddress, content).Result; diff --git a/Controllers/MagNewVTController.cs b/Controllers/MagNewVTController.cs new file mode 100644 index 0000000..b5be991 --- /dev/null +++ b/Controllers/MagNewVTController.cs @@ -0,0 +1,95 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Office.Interop.Excel; +using Newtonsoft.Json; +using static VirtualTask.Controllers.LoginController; +using System.Runtime.Intrinsics.Arm; +using VirtualTask.Models; +using X.PagedList; + +namespace VirtualTask.Controllers +{ + public class MagNewVTController : Controller + { + string apiUrl = string.Empty; + string urlBase = string.Empty; + string token = string.Empty; + string tenant = string.Empty; + string errMes = string.Empty; + string admin = string.Empty; + string time_sheet = string.Empty; + HttpClient client; + + private readonly IConfiguration _configuration; + + public MagNewVTController(IConfiguration configuration) + { + client = new HttpClient(); + _configuration = configuration; + var key = _configuration["ApplicationInsights:rootUrlApi"]; + apiUrl = key; + } + + public IActionResult Index(string serRapp, string searchString, int? page = 1) + { + SessionHelper helper = new SessionHelper(this); + + token = helper.GetStringValue("tok"); + + if (string.IsNullOrEmpty(token)) + { + return RedirectToAction("Login2", "Login"); + } + + apiUrl = helper.GetStringValue("apiUrl"); + admin = helper.GetStringValue("admin"); + ViewBag.Admin = admin; + + urlBase = apiUrl + "VTMagNewList"; + urlBase = urlBase + "?token=" + token; + Uri baseAddress = new Uri(urlBase); + client = new HttpClient(); + client.BaseAddress = baseAddress; + + List modelList = new List(); + HttpResponseMessage response = client.GetAsync(baseAddress).Result; + + if (response.IsSuccessStatusCode) + { + string data = response.Content.ReadAsStringAsync().Result; + modelList = JsonConvert.DeserializeObject>(data); + modelList = modelList.Where(x => x.Seriale_Rapportino.Equals(serRapp)).ToList(); + + if (!string.IsNullOrEmpty(searchString)) + { + modelList = modelList.Where(s => s.Desc_Art.ToUpper().Contains(searchString.ToUpper())).ToList(); + + ViewData["CurrentFilter"] = searchString; + } + else + ViewData["CurrentFilter"] = null; + + if (page != null && page < 1) + { + page = 1; + } + + var pageSize = 10; + + var shortLinks = modelList + .OrderByDescending(s => s.Seriale_Rapportino) + .ToPagedList(page ?? 1, pageSize); + + + return View(shortLinks); + + //return View(modelList.ToPagedList()); + } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } + } + } +} diff --git a/Models/MagNewVT.cs b/Models/MagNewVT.cs new file mode 100644 index 0000000..3801df8 --- /dev/null +++ b/Models/MagNewVT.cs @@ -0,0 +1,33 @@ +using System.ComponentModel.DataAnnotations; + +namespace VirtualTask.Models +{ + public class MagNewVT + { + public string? Azienda { get; set; } + [Display(Name = "Seriale Rapportino")] + public string? Seriale_Rapportino { get; set; } + public int? Riga { get; set; } + public string? Magazzino { get; set; } + public string? Articolo { get; set; } + [Display(Name = "Tipo movimento")] + public string? Tipo_Movimento { get; set; } + [Display(Name = "Quantità")] + public decimal? Quantita { get; set; } + public decimal? Prezzo { get; set; } + [Display(Name = "Cod. Tecnico")] + public string? Codice_Tecnico { get; set; } + public string? Generato { get; set; } + public string? Note { get; set; } + [Display(Name = "Cod. Lotto")] + public string? CodLotto { get; set; } + public string? Matricola { get; set; } + public int? Cprownum { get; set; } + [Display(Name = "Articolo descrizione")] + public string? Desc_Art { get; set; } + [Display(Name = "Cod. Impianto")] + public string? CodImp { get; set; } + [Display(Name = "Descrizione suppl.")] + public string? Desc_Sup { get; set; } + } +} diff --git a/Views/Articoli/Index.cshtml b/Views/Articoli/Index.cshtml index e5462be..17e4379 100644 --- a/Views/Articoli/Index.cshtml +++ b/Views/Articoli/Index.cshtml @@ -73,6 +73,7 @@ @Html.DisplayFor(modelItem => item.LiPrezzo) + @Html.HiddenFor(modelItem => item.Azienda) @Html.HiddenFor(modelItem => item.AmCodice) @Html.HiddenFor(modelItem => item.LoCodice) @@ -87,7 +88,7 @@ @Html.HiddenFor(modelItem => item.Gest_Matr) @Html.HiddenFor(modelItem => item.Gest_Lotti) @Html.HiddenFor(modelItem => item.Desc_sup) - + Modifica diff --git a/Views/MagNewVT/Index.cshtml b/Views/MagNewVT/Index.cshtml new file mode 100644 index 0000000..68a4a90 --- /dev/null +++ b/Views/MagNewVT/Index.cshtml @@ -0,0 +1,152 @@ +@using X.PagedList.Mvc.Core; +@using X.PagedList.Web.Common; +@using X.PagedList; +@model IPagedList + + +@{ + ViewData["Title"] = "Articoli buoni intervento"; + + + Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml"; +} + +
+
+
+ @*

+ Crea un nuovo elemento +

*@ + + @using (Html.BeginForm()) + { +
+
Ricerca
+ + + + + + + +
+ @Html.TextBox("SearchString", null, new { placeholder = "Cerca per descrizione", @class = "agy-form-field require" }) + +   + +
+
+ } + +
+   +
+ +
+
Articoli
+
+ + + + + + + + + + + + @* *@ + @* *@ + + @* *@ + + + + + + + + @foreach (var item in Model) + { + + + + + + + + + + + + + + + @Html.HiddenFor(modelItem => item.Azienda) + @Html.HiddenFor(modelItem => item.Note) + @Html.HiddenFor(modelItem => item.CodLotto) + @Html.HiddenFor(modelItem => item.Cprownum) + + + + } + +
Seriale rapportinoRigaMagazzinoArticoloTipo movimentoQuantitàPrezzoCod. TecnicoMatricolaArticolo descrizioneCod. ImpiantoDescrizione suppl.
+ @Html.DisplayFor(modelItem => item.Seriale_Rapportino) + + @Html.DisplayFor(modelItem => item.Riga) + + @Html.DisplayFor(modelItem => item.Magazzino) + + @Html.DisplayFor(modelItem => item.Articolo) + + @Html.DisplayFor(modelItem => item.Tipo_Movimento) + + @Html.DisplayFor(modelItem => item.Quantita) + + @Html.DisplayFor(modelItem => item.Prezzo) + + @Html.DisplayFor(modelItem => item.Codice_Tecnico) + + @Html.DisplayFor(modelItem => item.Matricola) + + @Html.DisplayFor(modelItem => item.Desc_Art) + + @Html.DisplayFor(modelItem => item.CodImp) + + @Html.DisplayFor(modelItem => item.Desc_Sup) + + @* + Modifica + + | + + Dettaglio + + | + + Elimina + *@ +
+
+
+ +
+ +
+
+
\ No newline at end of file diff --git a/Views/Rapp_New/Details.cshtml b/Views/Rapp_New/Details.cshtml index f851ad0..f160112 100644 --- a/Views/Rapp_New/Details.cshtml +++ b/Views/Rapp_New/Details.cshtml @@ -13,6 +13,12 @@ + + @using (Html.BeginForm("index", "MagNewVT", FormMethod.Post)) + { + Mag New + } +
@Html.DisplayNameFor(model => model.azienda_impianto) @Html.DisplayFor(model => model.azienda_impianto)
@@ -383,7 +389,7 @@ @Html.DisplayNameFor(model => model.tipo_rapportino) @Html.DisplayFor(model => model.tipo_rapportino) *@ -@*