Articoli: model + controller con metodi CRUD + pagine web + aggiunto link Articoli in layout area riservata

This commit is contained in:
michele 2025-02-13 16:13:40 +01:00
parent 963d0af4ad
commit b99fbbd77f
8 changed files with 1125 additions and 0 deletions

View File

@ -0,0 +1,344 @@
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System.Diagnostics;
using System.Text;
using VirtualTask.Models;
using X.PagedList;
namespace VirtualTask.Controllers
{
public class ArticoliController : 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 ArticoliController(IConfiguration configuration)
{
client = new HttpClient();
_configuration = configuration;
var key = _configuration["ApplicationInsights:rootUrlApi"];
apiUrl = key;
}
#region INDEX
public IActionResult Index(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 + "articoliList";
urlBase = urlBase + "?token=" + token;
Uri baseAddress = new Uri(urlBase);
client = new HttpClient();
client.BaseAddress = baseAddress;
List<Articoli> modelList = new List<Articoli>();
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
if (response.IsSuccessStatusCode)
{
string data = response.Content.ReadAsStringAsync().Result;
modelList = JsonConvert.DeserializeObject<List<Articoli>>(data);
//modelList = modelList.Where(x => x.tcdatobs == null).ToList();
if (!string.IsNullOrEmpty(searchString))
{
modelList = modelList.Where(s => s.ArDesArt.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.SlCodice)
.ToPagedList(page ?? 1, pageSize);
return View(shortLinks);
}
else
{
errMes = response.Content.ReadAsStringAsync().Result;
helper.SetStringValue("errMsg", errMes);
return RedirectToAction("Error");
}
}
#endregion INDEX
#region CREATE
public IActionResult Create()
{
SessionHelper helper = new SessionHelper(this);
admin = helper.GetStringValue("admin");
ViewBag.Admin = admin;
return View();
}
[HttpPost]
public IActionResult Create(Articoli model)
{
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
tenant = helper.GetStringValue("tenant");
if (string.IsNullOrEmpty(token))
{
return RedirectToAction("Login2", "Login");
}
model.Azienda = tenant;
apiUrl = helper.GetStringValue("apiUrl");
admin = helper.GetStringValue("admin");
ViewBag.Admin = admin;
urlBase = apiUrl + "articolo/add";
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;
if (response.IsSuccessStatusCode)
{
return RedirectToAction("Index");
}
else
{
errMes = response.Content.ReadAsStringAsync().Result;
helper.SetStringValue("errMsg", errMes);
return RedirectToAction("Error");
}
}
#endregion CREATE
#region DETAIL
public IActionResult Details(string id)
{
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
apiUrl = helper.GetStringValue("apiUrl");
admin = helper.GetStringValue("admin");
ViewBag.Admin = admin;
urlBase = apiUrl + "articoliList";
urlBase = urlBase + "?token=" + token;
Uri baseAddress = new Uri(urlBase);
client = new HttpClient();
client.BaseAddress = baseAddress;
Articoli chiusura = new Articoli();
List<Articoli> modelList = new List<Articoli>();
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
if (response.IsSuccessStatusCode)
{
string data = response.Content.ReadAsStringAsync().Result;
modelList = JsonConvert.DeserializeObject<List<Articoli>>(data);
chiusura = modelList.Where(x => x.SlCodice.Equals(id)).First();
}
else
{
errMes = response.Content.ReadAsStringAsync().Result;
helper.SetStringValue("errMsg", errMes);
return RedirectToAction("Error");
}
return View(chiusura);
}
#endregion DETAIL
#region EDIT
public IActionResult Edit(string id)
{
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
apiUrl = helper.GetStringValue("apiUrl");
admin = helper.GetStringValue("admin");
ViewBag.Admin = admin;
urlBase = apiUrl + "articoliList";
urlBase = urlBase + "?token=" + token;
Uri baseAddress = new Uri(urlBase);
client = new HttpClient();
client.BaseAddress = baseAddress;
Articoli ele = new Articoli();
List<Articoli> modelList = new List<Articoli>();
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
if (response.IsSuccessStatusCode)
{
string data = response.Content.ReadAsStringAsync().Result;
modelList = JsonConvert.DeserializeObject<List<Articoli>>(data);
var el = modelList.Where(t => t.SlCodice.Equals(id)).First();
ele = el;
}
else
{
errMes = response.Content.ReadAsStringAsync().Result;
helper.SetStringValue("errMsg", errMes);
return RedirectToAction("Error");
}
return View(ele);
}
[HttpPost]
public IActionResult Edit(Articoli model)
{
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
tenant = helper.GetStringValue("tenant");
if (string.IsNullOrEmpty(token))
{
return RedirectToAction("Index", "Login");
}
model.Azienda = tenant;
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;
if (response.IsSuccessStatusCode)
{
return RedirectToAction("Index");
}
else
{
errMes = response.Content.ReadAsStringAsync().Result;
helper.SetStringValue("errMsg", errMes);
return RedirectToAction("Error");
}
}
#endregion EDIT
#region DELETE
[HttpGet]
public IActionResult Delete(string id)
{
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
apiUrl = helper.GetStringValue("apiUrl");
admin = helper.GetStringValue("admin");
ViewBag.Admin = admin;
urlBase = apiUrl + "articoliList";
urlBase = urlBase + "?token=" + token;
Uri baseAddress = new Uri(urlBase);
client = new HttpClient();
client.BaseAddress = baseAddress;
Articoli elem = new Articoli();
List<Articoli> modelList = new List<Articoli>();
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
if (response.IsSuccessStatusCode)
{
string data = response.Content.ReadAsStringAsync().Result;
modelList = JsonConvert.DeserializeObject<List<Articoli>>(data);
elem = modelList.Where(t => t.SlCodice.Equals(id)).First();
return View(elem);
}
else
{
errMes = response.Content.ReadAsStringAsync().Result;
helper.SetStringValue("errMsg", errMes);
return RedirectToAction("Error");
}
}
[HttpPost, ActionName("DeleteConfirmed")]
public IActionResult DeleteConfirmed(string id)
{
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
apiUrl = helper.GetStringValue("apiUrl");
admin = helper.GetStringValue("admin");
ViewBag.Admin = admin;
urlBase = apiUrl + "articolo/del?" + "artcodice=" + id + "&";
urlBase = urlBase + "token=" + token;
Uri baseAddress = new Uri(urlBase);
client = new HttpClient();
client.BaseAddress = baseAddress;
string data = JsonConvert.SerializeObject(id);
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
HttpResponseMessage response = client.PostAsync(baseAddress, content).Result;
if (response.IsSuccessStatusCode)
{
return RedirectToAction("Index");
}
else
{
errMes = response.Content.ReadAsStringAsync().Result;
helper.SetStringValue("errMsg", errMes);
return RedirectToAction("Error");
}
}
#endregion DELETE
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
SessionHelper helper = new SessionHelper(this);
string e = helper.GetStringValue("errMsg");
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier, ErrMsg = e });
}
}
}

67
Models/Articoli.cs Normal file
View File

@ -0,0 +1,67 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace VirtualTask.Models
{
public class Articoli
{
[Display(Name = "Azienda")]
public string Azienda { get; set; }
[Display(Name = "Cod. Articolo")]
public string SlCodice { get; set; }
[Display(Name = "Descrizione")]
public string? ArDesArt { get; set; }
[Display(Name = "Magazzino")]
public string? SlCodMag { get; set; }
[Display(Name = "Quantità")]
[Column(TypeName = "decimal(13,3)")]
public decimal? SlQtAper { get; set; }
public string? AmCodice { get; set; }
public string? LoCodice { get; set; }
public string? LiCodLis { get; set; }
public string? LiCodArt { get; set; }
public DateTime? LiDatAtt { get; set; }
[Column(TypeName = "decimal(12,3)")]
public decimal? LiQuanti { get; set; }
[Display(Name = "Prezzo")]
[Column(TypeName = "decimal(18,5)")]
public decimal? LiPrezzo { get; set; }
[Display(Name = "Sconto 1")]
[Column(TypeName = "decimal(6,2)")]
public decimal? LiScont1 { get; set; }
[Display(Name = "Sconto 2")]
[Column(TypeName = "decimal(6,2)")]
public decimal? LiScont2 { get; set; }
[Display(Name = "Sconto 3")]
[Column(TypeName = "decimal(6,2)")]
public decimal? LiScont3 { get; set; }
[Display(Name = "Sconto 4")]
[Column(TypeName = "decimal(6,2)")]
public decimal? LiScont4 { get; set; }
[Display(Name = "Gestione matricole")]
public string? Gest_Matr { get; set; }
[Display(Name = "Gestione Lotti")]
public string? Gest_Lotti { get; set; }
[Display(Name = "Descrizione suppl.")]
public string? Desc_sup { get; set; }
}
}

View File

@ -0,0 +1,140 @@
@model VirtualTask.Models.Articoli
@{
ViewData["Title"] = "Nuovo articolo";
Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml";
}
<div class="agy-project-wrapper agy-project-page-wrapper">
<div class="container">
<div class="row">
<div class="row">
<div class="col-md-4">
<form asp-action="Create">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
@Html.HiddenFor(x => x.Azienda)
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="SlCodice" class="control-label"></label></h5>
<input asp-for="SlCodice" class="form-control" />
<span asp-validation-for="SlCodice" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="ArDesArt" class="control-label"></label></h5>
<input asp-for="ArDesArt" class="form-control" />
<span asp-validation-for="ArDesArt" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="SlCodMag" class="control-label"></label></h5>
<input asp-for="SlCodMag" class="form-control" />
<span asp-validation-for="SlCodMag" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="SlQtAper" class="control-label"></label></h5>
<input asp-for="SlQtAper" class="form-control" />
<span asp-validation-for="SlQtAper" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="AmCodice" class="control-label"></label></h5>
<input asp-for="AmCodice" class="form-control" />
<span asp-validation-for="AmCodice" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LoCodice" class="control-label"></label></h5>
<input asp-for="LoCodice" class="form-control" />
<span asp-validation-for="LoCodice" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiCodLis" class="control-label"></label></h5>
<input asp-for="LiCodLis" class="form-control" />
<span asp-validation-for="LiCodLis" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiCodArt" class="control-label"></label></h5>
<input asp-for="LiCodArt" class="form-control" />
<span asp-validation-for="LiCodArt" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiDatAtt" class="control-label"></label></h5>
<input asp-for="LiDatAtt" class="form-control" />
<span asp-validation-for="LiDatAtt" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiQuanti" class="control-label"></label></h5>
<input asp-for="LiQuanti" class="form-control" />
<span asp-validation-for="LiQuanti" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiPrezzo" class="control-label"></label></h5>
<input asp-for="LiPrezzo" class="form-control" />
<span asp-validation-for="LiPrezzo" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiScont1" class="control-label"></label></h5>
<input asp-for="LiScont1" class="form-control" />
<span asp-validation-for="LiScont1" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiScont2" class="control-label"></label></h5>
<input asp-for="LiScont2" class="form-control" />
<span asp-validation-for="LiScont2" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiScont3" class="control-label"></label></h5>
<input asp-for="LiScont3" class="form-control" />
<span asp-validation-for="LiScont3" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiScont4" class="control-label"></label></h5>
<input asp-for="LiScont4" class="form-control" />
<span asp-validation-for="LiScont4" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="Gest_Matr" class="control-label"></label></h5>
<input asp-for="Gest_Matr" class="form-control" />
<span asp-validation-for="Gest_Matr" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="Gest_Lotti" class="control-label"></label></h5>
<input asp-for="Gest_Lotti" class="form-control" />
<span asp-validation-for="Gest_Lotti" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="Desc_sup" class="control-label"></label></h5>
<input asp-for="Desc_sup" class="form-control" />
<span asp-validation-for="Desc_sup" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<input type="submit" value="Salva" class="agy-btn submitForm" />
<a asp-action="Index" value="Torna alla lista" class="agy-btn submitForm">Torna alla lista</a>
</div>
</form>
</div>
</div>
@section Scripts {
@{
await Html.RenderPartialAsync("_ValidationScriptsPartial");
}
}
</div>
</div>
</div>

View File

@ -0,0 +1,81 @@
@model VirtualTask.Models.Articoli
@{
ViewData["Title"] = "Elimina";
Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml";
}
<div class="agy-project-wrapper agy-project-page-wrapper">
<div class="container">
<div class="row">
<div class="row">
<div class="col-md-4">
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.Azienda)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.Azienda)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.SlCodice)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.SlCodice)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.ArDesArt)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.ArDesArt)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.SlCodMag)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.SlCodMag)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.AmCodice)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.AmCodice)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LoCodice)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.LoCodice)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiCodLis)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.LiCodLis)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiCodArt)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.LiCodArt)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiDatAtt)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.LiDatAtt)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiQuanti)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.LiQuanti)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiPrezzo)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.LiPrezzo)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiScont1)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.LiScont1)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiScont2)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.LiScont2)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiScont3)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.LiScont3)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiScont4)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.LiScont4)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.Gest_Matr)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.Gest_Matr)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.Gest_Lotti)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.Gest_Lotti)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.Desc_sup)</b>&nbsp;&nbsp;&nbsp;@Html.DisplayFor(model => model.Desc_sup)
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<form asp-action="DeleteConfirmed">
<div class="form-group">
<input type="submit" value="Elimina" class="agy-btn submitForm" />
<input type="hidden" id="id" value=@Html.DisplayFor(model => model.SlCodice) name="id" />
<a asp-action="Index" value="Torna alla lista" class="agy-btn submitForm">Torna alla lista</a>
</div>
</form>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,75 @@
@model VirtualTask.Models.Articoli
@{
ViewData["Title"] = "Dettaglio articolo";
Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml";
}
<div class="agy-project-wrapper agy-project-page-wrapper">
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.Azienda)</b> @Html.DisplayFor(model => model.Azienda)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.SlCodice)</b> @Html.DisplayFor(model => model.SlCodice)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.ArDesArt)</b> @Html.DisplayFor(model => model.ArDesArt)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.SlCodMag)</b> @Html.DisplayFor(model => model.SlCodMag)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.SlQtAper)</b> @Html.DisplayFor(model => model.SlQtAper)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.AmCodice)</b> @Html.DisplayFor(model => model.AmCodice)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LoCodice)</b> @Html.DisplayFor(model => model.LoCodice)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiCodLis)</b> @Html.DisplayFor(model => model.LiCodLis)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiCodArt)</b> @Html.DisplayFor(model => model.LiCodArt)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiDatAtt)</b> @Html.DisplayFor(model => model.LiDatAtt)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiQuanti)</b> @Html.DisplayFor(model => model.LiQuanti)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiPrezzo)</b> @Html.DisplayFor(model => model.LiPrezzo)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiScont1)</b> @Html.DisplayFor(model => model.LiScont1)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiScont2)</b> @Html.DisplayFor(model => model.LiScont2)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiScont3)</b> @Html.DisplayFor(model => model.LiScont3)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.LiScont4)</b> @Html.DisplayFor(model => model.LiScont4)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.Gest_Matr)</b> @Html.DisplayFor(model => model.Gest_Matr)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.Gest_Lotti)</b> @Html.DisplayFor(model => model.Gest_Lotti)
</div>
<div class="col-md-10">
<b>@Html.DisplayNameFor(model => model.Desc_sup)</b> @Html.DisplayFor(model => model.Desc_sup)
</div>
<div>
<a asp-action="Index" value="Torna alla lista" class="agy-btn submitForm">Torna alla lista</a>
</div>
</div>
</div>
</div>
</div>

146
Views/Articoli/Edit.cshtml Normal file
View File

@ -0,0 +1,146 @@
@model VirtualTask.Models.Articoli
@{
ViewData["Title"] = "Modifica articolo";
Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml";
}
<div class="agy-project-wrapper agy-project-page-wrapper">
<div class="container">
<div class="row">
<div class="col-md-4">
<form asp-action="Edit">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
@Html.HiddenFor(x => x.Azienda)
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="SlCodice" class="agy-client-quote"></label></h5>
<input asp-for="SlCodice" class="agy-form-field require" class="form-control"/>
<span asp-validation-for="SlCodice" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="ArDesArt" class="agy-client-quote"></label></h5>
<input asp-for="ArDesArt" class="agy-form-field require" class="form-control"/>
<span asp-validation-for="ArDesArt" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="SlCodMag" class="agy-client-quote"></label></h5>
<input asp-for="SlCodMag" class="agy-form-field require" class="form-control"/>
<span asp-validation-for="SlCodMag" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="SlQtAper" class="agy-client-quote"></label></h5>
<input asp-for="SlQtAper" class="agy-form-field require" class="form-control" />
<span asp-validation-for="SlQtAper" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="AmCodice" class="agy-client-quote"></label></h5>
<input asp-for="AmCodice" class="agy-form-field require" class="form-control" />
<span asp-validation-for="AmCodice" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LoCodice" class="agy-client-quote"></label></h5>
<input asp-for="LoCodice" class="agy-form-field require" class="form-control" />
<span asp-validation-for="LoCodice" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiCodLis" class="agy-client-quote"></label></h5>
<input asp-for="LiCodLis" class="agy-form-field require" class="form-control" />
<span asp-validation-for="LiCodLis" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiCodArt" class="agy-client-quote"></label></h5>
<input asp-for="LiCodArt" class="agy-form-field require" class="form-control" />
<span asp-validation-for="LiCodArt" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiDatAtt" class="agy-client-quote"></label></h5>
<input asp-for="LiDatAtt" class="agy-form-field require" class="form-control" />
<span asp-validation-for="LiDatAtt" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiQuanti" class="agy-client-quote"></label></h5>
<input asp-for="LiQuanti" class="agy-form-field require" class="form-control" />
<span asp-validation-for="LiQuanti" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiPrezzo" class="agy-client-quote"></label></h5>
<input asp-for="LiPrezzo" class="agy-form-field require" class="form-control" />
<span asp-validation-for="LiPrezzo" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiScont1" class="agy-client-quote"></label></h5>
<input asp-for="LiScont1" class="agy-form-field require" class="form-control" />
<span asp-validation-for="LiScont1" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiScont2" class="agy-client-quote"></label></h5>
<input asp-for="LiScont2" class="agy-form-field require" class="form-control" />
<span asp-validation-for="LiScont2" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiScont3" class="agy-client-quote"></label></h5>
<input asp-for="LiScont3" class="agy-form-field require" class="form-control" />
<span asp-validation-for="LiScont3" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="LiScont4" class="agy-client-quote"></label></h5>
<input asp-for="LiScont4" class="agy-form-field require" class="form-control" />
<span asp-validation-for="LiScont4" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="Gest_Matr" class="agy-client-quote"></label></h5>
<input asp-for="Gest_Matr" class="agy-form-field require" class="form-control" />
<span asp-validation-for="Gest_Matr" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="Gest_Lotti" class="agy-client-quote"></label></h5>
<input asp-for="Gest_Lotti" class="agy-form-field require" class="form-control" />
<span asp-validation-for="Gest_Lotti" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<h5><label asp-for="Desc_sup" class="agy-client-quote"></label></h5>
<input asp-for="Desc_sup" class="agy-form-field require" class="form-control" />
<span asp-validation-for="Desc_sup" class="text-danger"></span>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-12">&nbsp;</div>
<div class="form-group">
<input type="submit" value="Salva" class="agy-btn submitForm" />
<a asp-action="Index" value="Torna alla lista" class="agy-btn submitForm">Torna alla lista</a>
</div>
</form>
</div>
</div>
</div>
</div>
@* <script type="text/javascript">
$(function () {
$("#imultcli").select2();
});
</script>
@section Scripts {
@{
await Html.RenderPartialAsync("_ValidationScriptsPartial");
}
} *@

271
Views/Articoli/Index.cshtml Normal file
View File

@ -0,0 +1,271 @@
@using X.PagedList.Mvc.Core;
@using X.PagedList.Web.Common;
@using X.PagedList;
@model IPagedList<VirtualTask.Models.Articoli>
<link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" />
@{
ViewData["Title"] = "Articoli";
Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml";
}
<div class="agy-project-wrapper agy-project-page-wrapper">
<div class="container">
<div class="row">
<p>
<a asp-action="Create" class="info-data"><img src="~/assets/images/icons8-nuovo-50.png" alt="Crea un nuovo elemento" /></a>
</p>
@using (Html.BeginForm())
{
<div class="card">
<h5 class="card-header">Ricerca</h5>
<table class="table">
<tbody class="table-border-bottom-0">
<tr>
<td>
<span class="fw-medium">@Html.TextBox("SearchString", null, new { placeholder = "Cerca per descrizione", @class = "agy-form-field require" })</span>
</td>
<td>
<i class="bx bxl-angular bx-sm text-black me-3">&nbsp;</i>
<span class="fw-medium"><input type="submit" value="Cerca" class="agy-btn submitForm" /></span>
</td>
</tr>
</tbody>
</table>
</div>
}
<div style="width:100%;height:30px;">
&nbsp;
</div>
<div class="card">
<h5 class="card-header">Articoli</h5>
<div class="table-responsive text-nowrap">
<table class="table table-striped">
<thead>
<tr>
<th hidden>Azienda</th>
<th>Cod. Articolo</th>
<th>Descrizione</th>
<th>Quantità</th>
<th>Prezzo</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.SlCodice)
</td>
<td>
@Html.DisplayFor(modelItem => item.ArDesArt)
</td>
<td>
@Html.DisplayFor(modelItem => item.SlQtAper)
</td>
<td>
@Html.DisplayFor(modelItem => item.LiPrezzo)
</td>
@Html.HiddenFor(modelItem => item.Azienda)
@Html.HiddenFor(modelItem => item.SlCodMag)
@Html.HiddenFor(modelItem => item.AmCodice)
@Html.HiddenFor(modelItem => item.LoCodice)
@Html.HiddenFor(modelItem => item.LiCodLis)
@Html.HiddenFor(modelItem => item.LiCodArt)
@Html.HiddenFor(modelItem => item.LiDatAtt)
@Html.HiddenFor(modelItem => item.LiQuanti)
@Html.HiddenFor(modelItem => item.LiScont1)
@Html.HiddenFor(modelItem => item.LiScont2)
@Html.HiddenFor(modelItem => item.LiScont3)
@Html.HiddenFor(modelItem => item.LiScont4)
@Html.HiddenFor(modelItem => item.Gest_Matr)
@Html.HiddenFor(modelItem => item.Gest_Lotti)
@Html.HiddenFor(modelItem => item.Desc_sup)
<td>
<a href="@Url.Action("Edit", "Articoli", new { id=item.SlCodice })" title="Modifica" class="links">
<img alt="Modifica" src="@Url.Content("~/assets/images/icons8-modificare-64.png")" style="width:30px;height:30px;">
</a>
|
<a href="@Url.Action("Details", "Articoli", new { id=item.SlCodice })" title="Dettaglio" class="links">
<img alt="Dettaglio" src="@Url.Content("~/assets/images/icons8-visualizza-file-64.png")" style="width:30px;height:30px;">
</a>
|
<a href="@Url.Action("Delete", "Articoli", new { id=item.SlCodice })" title="Elimina" class="links">
<img alt="Elimina" src="@Url.Content("~/assets/images/icons8-elimina-50.png")" style="width:30px;height:30px;">
</a>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
<br />
<nav>
@Html.PagedListPager(Model, page => Url.Action("index", new { page = page, searchString = @ViewData["CurrentFilter"] }), new PagedListRenderOptions()
{
ActiveLiElementClass = "active",
PageClasses = new[] { "page-link" },
LiElementClasses = new[] { "page-item" },
UlElementClasses = new[] { "pagination", "justify-content-center", "mt-3" },
LinkToNextPageFormat = "Successiva",
LinkToPreviousPageFormat = "Precedente",
MaximumPageNumbersToDisplay = 5,
DisplayLinkToPreviousPage = PagedListDisplayMode.Always,
DisplayLinkToNextPage = PagedListDisplayMode.Always
})
</nav>
</div>
</div>
</div>
@* @model IEnumerable<VirtualTask.Models.Articoli>
@{
ViewData["Title"] = "Index";
}
<h1>Index</h1>
<p>
<a asp-action="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Azienda)
</th>
<th>
@Html.DisplayNameFor(model => model.SlCodice)
</th>
<th>
@Html.DisplayNameFor(model => model.ArDesArt)
</th>
<th>
@Html.DisplayNameFor(model => model.SlCodMag)
</th>
<th>
@Html.DisplayNameFor(model => model.SlQtAper)
</th>
<th>
@Html.DisplayNameFor(model => model.AmCodice)
</th>
<th>
@Html.DisplayNameFor(model => model.LoCodice)
</th>
<th>
@Html.DisplayNameFor(model => model.LiCodLis)
</th>
<th>
@Html.DisplayNameFor(model => model.LiCodArt)
</th>
<th>
@Html.DisplayNameFor(model => model.LiDatAtt)
</th>
<th>
@Html.DisplayNameFor(model => model.LiQuanti)
</th>
<th>
@Html.DisplayNameFor(model => model.LiPrezzo)
</th>
<th>
@Html.DisplayNameFor(model => model.LiScont1)
</th>
<th>
@Html.DisplayNameFor(model => model.LiScont2)
</th>
<th>
@Html.DisplayNameFor(model => model.LiScont3)
</th>
<th>
@Html.DisplayNameFor(model => model.LiScont4)
</th>
<th>
@Html.DisplayNameFor(model => model.Gest_Matr)
</th>
<th>
@Html.DisplayNameFor(model => model.Gest_Lotti)
</th>
<th>
@Html.DisplayNameFor(model => model.Desc_sup)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Azienda)
</td>
<td>
@Html.DisplayFor(modelItem => item.SlCodice)
</td>
<td>
@Html.DisplayFor(modelItem => item.ArDesArt)
</td>
<td>
@Html.DisplayFor(modelItem => item.SlCodMag)
</td>
<td>
@Html.DisplayFor(modelItem => item.SlQtAper)
</td>
<td>
@Html.DisplayFor(modelItem => item.AmCodice)
</td>
<td>
@Html.DisplayFor(modelItem => item.LoCodice)
</td>
<td>
@Html.DisplayFor(modelItem => item.LiCodLis)
</td>
<td>
@Html.DisplayFor(modelItem => item.LiCodArt)
</td>
<td>
@Html.DisplayFor(modelItem => item.LiDatAtt)
</td>
<td>
@Html.DisplayFor(modelItem => item.LiQuanti)
</td>
<td>
@Html.DisplayFor(modelItem => item.LiPrezzo)
</td>
<td>
@Html.DisplayFor(modelItem => item.LiScont1)
</td>
<td>
@Html.DisplayFor(modelItem => item.LiScont2)
</td>
<td>
@Html.DisplayFor(modelItem => item.LiScont3)
</td>
<td>
@Html.DisplayFor(modelItem => item.LiScont4)
</td>
<td>
@Html.DisplayFor(modelItem => item.Gest_Matr)
</td>
<td>
@Html.DisplayFor(modelItem => item.Gest_Lotti)
</td>
<td>
@Html.DisplayFor(modelItem => item.Desc_sup)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
</td>
</tr>
}
</tbody>
</table>
*@

View File

@ -171,6 +171,7 @@ Purchase:
<li><a asp-area="" asp-controller="Chiusure" asp-action="Index">Tipi intervento</a></li>
<li><a asp-area="" asp-controller="Anag" asp-action="Index">Clienti</a></li>
<li><a asp-area="" asp-controller="Impianti" asp-action="Index">Impianti</a></li>
<li><a asp-area="" asp-controller="Articoli" asp-action="Index">Articoli</a></li>
<li><a asp-area="" asp-controller="Rapp_New" asp-action="Index">Buono intervento</a></li>
<li><a asp-area="" asp-controller="Chiamate" asp-action="Index">Chiamate</a></li>
<li><a asp-area="" asp-controller="Progressivi" asp-action="Index">Progressivi</a></li>