89 lines
3.6 KiB
Plaintext
Raw Normal View History

2024-05-29 22:26:31 +04:00
@using ServiceStationContracts.ViewModels
@model List<SparePartViewModel>
2024-04-30 20:36:13 +04:00
@{
ViewData["Title"] = "UpdateRepair";
}
<form method="post">
<div class="container d-flex justify-content-center align-items-center w-50">
<div class="card-body ">
<div class="form-group">
<label>Ремонт: </label>
<select id="repair" name="repair" class="form-control" asp-items="@(new SelectList(@ViewBag.Repairs, "Id", "RepairName", "RepairPrice"))"></select>
2024-04-30 20:36:13 +04:00
</div>
<div class="form-group">
<label>Название ремонта</label>
<input type="text" id="repairName" placeholder="Введите название ремонта" name="repairName" class="form-control" />
</div>
<div class="form-group">
<label>Стоимость ремонта</label>
<input type="number" min="0" step="100" id="repairPrice" placeholder="Введите стоимость ремонта" name="repairPrice" class="form-control" />
2024-04-30 20:36:13 +04:00
</div>
2024-05-29 22:26:31 +04:00
<h5>Уже привязанные запчасти</h5>
2024-04-30 20:36:13 +04:00
<table class="table">
<thead>
<tr>
<th scope="col">Название запчасти</th>
2024-05-29 22:26:31 +04:00
<th scope="col">Цена запчасти</th>
2024-04-30 20:36:13 +04:00
</tr>
</thead>
<tbody id="table-elements">
2024-05-29 22:26:31 +04:00
</tbody>
</table>
<h5>Изменить запчасти</h5>
<table class="table">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">Название запчасти</th>
<th scope="col">Цена запчасти</th>
</tr>
</thead>
<tbody>
@foreach (var sparepart in Model)
{
<tr>
<td class="align-middle">
<div class="form-check">
<input type="checkbox" class="form-check-input" name="sparepart[]" value="@sparepart.Id" id="@sparepart.Id">
</div>
</td>
<td class="align-middle">@Html.DisplayFor(modelItem => sparepart.SparePartName)</td>
<td class="align-middle">@Html.DisplayFor(modelItem => sparepart.SparePartPrice)</td>
</tr>
}
2024-04-30 20:36:13 +04:00
</tbody>
</table>
<br>
<div class="text-center pb-3">
<input type="submit" value="Сохранить" class="btn btn-outline-dark text-center w-100" />
</div>
</div>
</div>
</form>
@section Scripts
{
<script>
function check() {
var repair = $('#repair').val();
if (repair) {
$.ajax({
method: "GET",
url: "/Home/GetRepair",
data: { repairId: repair },
success: function (result) {
$('#repairName').val(result.item1.repairName);
$('#repairPrice').val(result.item1.repairPrice);
$('#table-elements').html(result.item2);
}
});
};
}
check();
$('#repair').on('change', function () {
check();
});
</script>
}