refactor commesse
This commit is contained in:
parent
fa0df3841d
commit
49cfe5dc89
@ -233,7 +233,7 @@ namespace VirtualTask.Controllers
|
||||
return RedirectToAction("Error");
|
||||
}
|
||||
|
||||
ViewBag.Impianti = getImpianti();
|
||||
ViewBag.Impianti = getImpiantiCliente(commessa.lacodcli);
|
||||
ViewBag.Anag = getClienti();
|
||||
return View(commessa);
|
||||
}
|
||||
@ -352,7 +352,45 @@ namespace VirtualTask.Controllers
|
||||
#endregion DELETE
|
||||
|
||||
#region METODI INTERNI
|
||||
private List<SelectListItem> getImpiantiCliente(string codCli)
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
token = helper.GetStringValue("tok");
|
||||
//apiUrl = helper.GetStringValue("")
|
||||
urlBase = apiUrl + "impiantiListMngr";
|
||||
urlBase = urlBase + "?token=" + token;
|
||||
Uri baseAddress = new Uri(urlBase);
|
||||
client = new HttpClient();
|
||||
client.BaseAddress = baseAddress;
|
||||
|
||||
List<SelectListItem> selectItems = new List<SelectListItem>();
|
||||
List<Impianto> modelList = new List<Impianto>();
|
||||
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
string data = response.Content.ReadAsStringAsync().Result;
|
||||
modelList = JsonConvert.DeserializeObject<List<Impianto>>(data);
|
||||
modelList = modelList.Where(x => x.imfinatt == null && x.imultcli !=null && x.imultcli.Equals(codCli)).ToList();
|
||||
//per gestire primo elemento tendina (deve essere vuoto)
|
||||
SelectListItem listItemFirst = new SelectListItem();
|
||||
|
||||
listItemFirst.Value = string.Empty;
|
||||
listItemFirst.Text = " - Impianto";
|
||||
selectItems.Add(listItemFirst);
|
||||
|
||||
foreach (var item in modelList)
|
||||
{
|
||||
SelectListItem listItem = new SelectListItem();
|
||||
string s = item.imcodimp + " - " + item.imdescri;
|
||||
listItem.Value = item.imcodimp;
|
||||
listItem.Text = s;
|
||||
selectItems.Add(listItem);
|
||||
}
|
||||
}
|
||||
|
||||
return selectItems;
|
||||
}
|
||||
private List<SelectListItem> getImpianti()
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
|
||||
@ -9,6 +9,7 @@ namespace VirtualTask.Models
|
||||
[Display(Name = "Seriale commessa")]
|
||||
public string? laserial { get; set; }
|
||||
|
||||
[Display(Name = "Azienda")]
|
||||
public string? lacodazi { get; set; }
|
||||
|
||||
[Required]
|
||||
|
||||
@ -7,16 +7,71 @@
|
||||
|
||||
<div class="agy-project-wrapper agy-project-page-wrapper">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<form asp-action="Create">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
@Html.HiddenFor(x => x.laserial)
|
||||
@Html.HiddenFor(x => x.lacodazi)
|
||||
@Html.HiddenFor(x => x.ladatchi)
|
||||
@Html.HiddenFor(x => x.latipcli)
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-striped table-hover align-middle">
|
||||
<thead class="table-primary">
|
||||
<tr>
|
||||
<th scope="col"> </th>
|
||||
<th scope="col"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td class="fw-bold fs-5"><span class="badge bg-secondary"><label asp-for="lacodcom" class="agy-client-quote"></label></span></td>
|
||||
<td>
|
||||
<input asp-for="lacodcom" class="agy-form-field require" placeholder="Cod. commessa" />
|
||||
<span asp-validation-for="lacodcom" class="text-danger"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fw-bold fs-5"><span class="badge bg-secondary"><label asp-for="ladeslav" class="agy-client-quote"></label></span></td>
|
||||
<td>
|
||||
<input asp-for="ladeslav" class="agy-form-field require" placeholder="Cod. commessa" />
|
||||
<span asp-validation-for="ladeslav" class="text-danger"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fw-bold fs-5"><span class="badge bg-secondary"><label asp-for="lacodcli" class="agy-client-quote"></label></span></td>
|
||||
<td>
|
||||
@Html.DropDownListFor(x => x.lacodcli, (IEnumerable<SelectListItem>)ViewBag.Anag, "- Seleziona un cliente", new { @id = "ddlClienti", @class = "agy-form-field require" })
|
||||
<span asp-validation-for="lacodcli" class="text-danger"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fw-bold fs-5"><span class="badge bg-secondary"><label asp-for="lacodimp" class="agy-client-quote"></label></span></td>
|
||||
<td>
|
||||
<div id="District">
|
||||
@Html.DropDownListFor(x => x.lacodimp, new List<SelectListItem>(), "- Seleziona un impianto", new { @id = "ddlImpianti", @class = "agy-form-field require" })
|
||||
</div>
|
||||
<span asp-validation-for="lacodimp" class="text-danger"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<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>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
@* <div class="row">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form asp-action="Create">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
|
||||
@Html.HiddenFor(x => x.laserial)
|
||||
@Html.HiddenFor(x => x.lacodazi)
|
||||
@Html.HiddenFor(x => x.ladatchi)
|
||||
@Html.HiddenFor(x => x.latipcli)
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<h5><label asp-for="lacodcom" class="agy-client-quote"></label></h5>
|
||||
@ -31,14 +86,14 @@
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||
<div class="form-group">
|
||||
@* @Html.DropDownListFor(x => x.lacodcli,(IEnumerable<SelectListItem>)ViewBag.Anag, new{@class = "form-control"})*@
|
||||
|
||||
<h5><label asp-for="lacodcli" class="agy-client-quote"></label></h5>
|
||||
@Html.DropDownListFor(x => x.lacodcli, (IEnumerable<SelectListItem>)ViewBag.Anag, "- Seleziona un cliente", new { @id = "ddlClienti", @class = "agy-form-field require" })
|
||||
<span asp-validation-for="lacodcli" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||
<div class="form-group">
|
||||
@* @Html.DropDownListFor(x => x.lacodimp,(IEnumerable<SelectListItem>)ViewBag.Impianti, new{@class = "form-control"})*@
|
||||
|
||||
<h5><label asp-for="lacodimp" class="agy-client-quote"></label></h5>
|
||||
<div id="District">
|
||||
@Html.DropDownListFor(x => x.lacodimp, new List<SelectListItem>(), "- Seleziona un impianto", new { @id = "ddlImpianti", @class = "agy-form-field require" })
|
||||
@ -55,7 +110,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
@* <a asp-action="Index">Torna alla lista</a> *@
|
||||
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@ -64,7 +119,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
</div>
|
||||
</div> *@
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
@ -8,47 +8,67 @@
|
||||
|
||||
<div class="agy-project-wrapper agy-project-page-wrapper">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<form asp-action="DeleteConfirmed">
|
||||
<div class="row">
|
||||
@Html.HiddenFor(model => model.ladatchi)
|
||||
@Html.HiddenFor(model => model.lacodazi)
|
||||
@Html.HiddenFor(model => model.laserial)
|
||||
@Html.HiddenFor(model => model.lacodcom)
|
||||
@Html.HiddenFor(model => model.lacodimp)
|
||||
@Html.HiddenFor(model => model.ladeslav)
|
||||
@Html.HiddenFor(model => model.latipcli)
|
||||
@Html.HiddenFor(model => model.lacodcli)
|
||||
<div class="col-md-10">
|
||||
<b>@Html.DisplayNameFor(model => model.laserial)</b> @Html.DisplayFor(model => model.laserial)
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<b>@Html.DisplayNameFor(model => model.lacodazi)</b> @Html.DisplayFor(model => model.lacodazi)
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<b>@Html.DisplayNameFor(model => model.lacodcom)</b> @Html.DisplayFor(model => model.lacodcom)
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<b>@Html.DisplayNameFor(model => model.ladeslav)</b> @Html.DisplayFor(model => model.ladeslav)
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col-md-10">
|
||||
<b>@Html.DisplayNameFor(model => model.latipcli)</b> @Html.DisplayFor(model => model.latipcli)
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<b>@Html.DisplayNameFor(model => model.lacodcli)</b> @Html.DisplayFor(model => model.lacodcli)
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<b>@Html.DisplayNameFor(model => model.lacodimp)</b> @Html.DisplayFor(model => model.lacodimp)
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||
<input type="submit" value="Elimina" class="agy-btn submitForm" />
|
||||
<a asp-action="Index" value="Torna alla lista" class="agy-btn submitForm">Torna alla lista</a>
|
||||
<form asp-action="DeleteConfirmed">
|
||||
@Html.HiddenFor(model => model.ladatchi)
|
||||
@Html.HiddenFor(model => model.lacodazi)
|
||||
@Html.HiddenFor(model => model.laserial)
|
||||
@Html.HiddenFor(model => model.lacodcom)
|
||||
@Html.HiddenFor(model => model.lacodimp)
|
||||
@Html.HiddenFor(model => model.ladeslav)
|
||||
@Html.HiddenFor(model => model.latipcli)
|
||||
@Html.HiddenFor(model => model.lacodcli)
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-striped table-hover align-middle">
|
||||
<thead class="table-primary">
|
||||
<tr>
|
||||
<th scope="col"> </th>
|
||||
<th scope="col"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td class="fw-bold fs-5"><span class="badge bg-secondary"><label asp-for="laserial" class="agy-client-quote"></label></span></td>
|
||||
<td>
|
||||
@Html.DisplayFor(x => x.laserial)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fw-bold fs-5"><span class="badge bg-secondary"><label asp-for="lacodazi" class="agy-client-quote"></label></span></td>
|
||||
<td>
|
||||
@Html.DisplayFor(x => x.lacodazi)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fw-bold fs-5"><span class="badge bg-secondary"><label asp-for="lacodcom" class="agy-client-quote"></label></span></td>
|
||||
<td>
|
||||
@Html.DisplayFor(x => x.lacodcom)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fw-bold fs-5"><span class="badge bg-secondary"><label asp-for="ladeslav" class="agy-client-quote"></label></span></td>
|
||||
<td>
|
||||
@Html.DisplayFor(x => x.ladeslav)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fw-bold fs-5"><span class="badge bg-secondary"><label asp-for="lacodcli" class="agy-client-quote"></label></span></td>
|
||||
<td>
|
||||
@Html.DisplayFor(x => x.lacodcli)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fw-bold fs-5"><span class="badge bg-secondary"><label asp-for="lacodimp" class="agy-client-quote"></label></span></td>
|
||||
<td>
|
||||
@Html.DisplayFor(x => x.lacodimp)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input type="submit" value="Elimina" class="agy-btn submitForm" />
|
||||
<a asp-action="Index" value="Torna alla lista" class="agy-btn submitForm">Torna alla lista</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -8,81 +8,113 @@
|
||||
|
||||
<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="Edit">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
|
||||
<div class="form-group">
|
||||
<h5><label asp-for="laserial" class="control-label"></label></h5>
|
||||
@* <input asp-for="laserial" class="agy-form-field" class="form-control" placeholder="Seriale commessa"/> *@
|
||||
<form asp-action="Edit">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
@Html.HiddenFor(x => x.ladatchi)
|
||||
@Html.HiddenFor(x => x.latipcli)
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-striped table-hover align-middle">
|
||||
<thead class="table-primary">
|
||||
<tr>
|
||||
<th scope="col"> </th>
|
||||
<th scope="col"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td class="fw-bold fs-5"><span class="badge bg-secondary"><label asp-for="laserial" class="agy-client-quote"></label></span></td>
|
||||
<td>
|
||||
@Html.HiddenFor(x => x.laserial)
|
||||
@Html.DisplayFor(x => x.laserial)
|
||||
<span asp-validation-for="laserial" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||
@Html.HiddenFor(x => x.lacodazi)
|
||||
@Html.DisplayFor(x => x.lacodazi)
|
||||
@* <div class="form-group">
|
||||
<label asp-for="lacodazi" class="control-label"></label>
|
||||
<input asp-for="lacodazi" class="agy-form-field" class="form-control" placeholder="Codice azienda"/>
|
||||
<span asp-validation-for="lacodazi" class="text-danger"></span>
|
||||
</div> *@
|
||||
<div class="form-group">
|
||||
<h5><label asp-for="lacodcom" class="control-label"></label></h5>
|
||||
<input asp-for="lacodcom" class="agy-form-field" class="form-control" placeholder="Codice commessa"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fw-bold fs-5"><span class="badge bg-secondary"><label asp-for="lacodcom" class="agy-client-quote"></label></span></td>
|
||||
<td>
|
||||
@Html.HiddenFor(x => x.lacodcom)
|
||||
@Html.DisplayFor(x => x.lacodcom)
|
||||
<span asp-validation-for="lacodcom" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||
<div class="form-group">
|
||||
<h5><label asp-for="ladeslav" class="control-label"></label></h5>
|
||||
<input asp-for="ladeslav" class="agy-form-field" class="form-control" placeholder="Descr. lavoro"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fw-bold fs-5"><span class="badge bg-secondary"><label asp-for="ladeslav" class="control-label"></label></span></td>
|
||||
<td>
|
||||
<input asp-for="ladeslav" class="agy-form-field" class="form-control" placeholder="Descr. lavoro" />
|
||||
<span asp-validation-for="ladeslav" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||
@Html.HiddenFor(x => x.ladatchi)
|
||||
@* <div class="form-group">
|
||||
<label asp-for="ladatchi" class="control-label"></label>
|
||||
<input asp-for="ladatchi" class="agy-form-field" class="form-control" />
|
||||
<span asp-validation-for="ladatchi" class="text-danger"></span>
|
||||
</div> *@
|
||||
@Html.HiddenFor(x => x.latipcli)
|
||||
@* <div class="form-group">
|
||||
<label asp-for="latipcli" class="control-label"></label>
|
||||
<input asp-for="latipcli" class="agy-form-field" class="form-control" placeholder="Tipo cliente"/>
|
||||
<span asp-validation-for="latipcli" class="text-danger"></span>
|
||||
</div> *@
|
||||
<div class="form-group">
|
||||
<h5><label asp-for="lacodcli" class="control-label"></label></h5>
|
||||
@Html.DropDownListFor(x => x.lacodcli, (IEnumerable<SelectListItem>)ViewBag.Anag, new { @class = "agy-form-field require" })
|
||||
@* <input asp-for="lacodcli" class="agy-form-field" class="agy-form-field" class="form-control" /> *@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fw-bold fs-5"><span class="badge bg-secondary"><label asp-for="lacodcli" class="control-label"></label></span></td>
|
||||
<td>
|
||||
@Html.DropDownListFor(x => x.lacodcli, (IEnumerable<SelectListItem>)ViewBag.Anag, "- Seleziona un cliente", new { @id = "ddlClienti", @class = "agy-form-field require" })
|
||||
<span asp-validation-for="lacodcli" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||
<div class="form-group">
|
||||
<h5><label asp-for="lacodimp" class="control-label"></label></h5>
|
||||
@Html.DropDownListFor(x => x.lacodimp, (IEnumerable<SelectListItem>)ViewBag.Impianti, new { @class = "agy-form-field require" })
|
||||
@* <input asp-for="lacodcli" class="agy-form-field" class="agy-form-field" class="form-control" /> *@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fw-bold fs-5"><span class="badge bg-secondary"><label asp-for="lacodimp" class="control-label"></label></span></td>
|
||||
<td>
|
||||
<div id="District">
|
||||
@Html.DropDownListFor(x => x.lacodimp, (IEnumerable<SelectListItem>)ViewBag.Impianti, "- Seleziona un impianto", new { @id = "ddlImpianti", @class = "agy-form-field require" })
|
||||
</div>
|
||||
<span asp-validation-for="lacodimp" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||
<div class="form-group">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="fw-bold fs-5"><span class="badge bg-secondary"><label asp-for="lacodazi" class="agy-client-quote"></label></span></td>
|
||||
<td>
|
||||
@Html.HiddenFor(x => x.lacodazi)
|
||||
@Html.DisplayFor(x => x.lacodazi)
|
||||
<span asp-validation-for="lacodazi" class="text-danger"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<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>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@* <a asp-action="Index">Torna alla lista</a> *@
|
||||
</div>
|
||||
@section Scripts {
|
||||
@{
|
||||
await Html.RenderPartialAsync("_ValidationScriptsPartial");
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@section Scripts {
|
||||
@{
|
||||
await Html.RenderPartialAsync("_ValidationScriptsPartial");
|
||||
}
|
||||
}
|
||||
|
||||
<script src="~/assets/js/jquery.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$('#ddlClienti').change(function () {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "/CommesseVT/Cascading",
|
||||
data: { lacodcli: $('#ddlClienti').val() },
|
||||
datatype: "json",
|
||||
traditional: true,
|
||||
success: function (states) {
|
||||
|
||||
|
||||
|
||||
var district = "<select id='ddlImpianti' class='form-control' name='lacodimp'>";
|
||||
district = district + '<option value="">--Seleziona--</option>';
|
||||
for (var i = 0; i < states.length; i++) {
|
||||
district = district + '<option value="' + states[i].value + '">' + states[i].text + '</option>';
|
||||
|
||||
}
|
||||
|
||||
district = district + '</select>';
|
||||
|
||||
$('#District').html(district);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user