62 lines
2.1 KiB
Plaintext
62 lines
2.1 KiB
Plaintext
@{
|
|
ViewData["Title"] = "Привязка статьи затрат к сделке";
|
|
|
|
var costs = new SelectList(ViewBag.Costs, "Id", "NameOfCost");
|
|
costs.Where(x => Convert.ToInt32(x.Value) == ViewBag.SelectedId).ToList().ForEach(x => x.Selected = true);
|
|
}
|
|
<div>
|
|
<h2 class="display-4">@ViewData["Title"]</h2>
|
|
</div>
|
|
<form method="post">
|
|
<div class="row mb-2">
|
|
<div class="col-2">Статья затрат:</div>
|
|
<div class="col-sm-10">
|
|
<select id="cost" name="cost" class="form-control" asp-items="@costs"></select>
|
|
</div>
|
|
</div>
|
|
<div class="row mb-2">
|
|
<div class="col-2">Сделки:</div>
|
|
<div class="col-sm-10">
|
|
<select id="purchase" name="purchase" class="form-control" asp-items="@(new SelectList(@ViewBag.Purchases, "Id", "Id"))"></select>
|
|
</div>
|
|
</div>
|
|
<div class="row mb-2">
|
|
<div class="col-2">Количество:</div>
|
|
<div class="col-sm-10">
|
|
<input type="text" class="form-control" name ="count" id="count" placeholder="Количество">
|
|
</div>
|
|
</div>
|
|
<div class="row mb-2">
|
|
<div class="col-2">Итоговая сумма:</div>
|
|
<div class="col-sm-10">
|
|
<input type="text" class="form-control" id="resultSum" placeholder="Итоговая сумма" readonly>
|
|
</div>
|
|
</div>
|
|
<div class="text-center mb-2">
|
|
<input type="submit" value="Привязать" class="btn btn-primary" id="submit" />
|
|
</div>
|
|
</form>
|
|
|
|
@section Scripts
|
|
{
|
|
<script>
|
|
$('#cost').on('change', check);
|
|
$('#count').on('change', check);
|
|
|
|
function check() {
|
|
var count = $('#count').val();
|
|
var cost = $('#cost').val();
|
|
if (count && cost) {
|
|
$.ajax({
|
|
method: "POST",
|
|
url: "/Home/CalcCostSum",
|
|
data: { count: count, cost: cost },
|
|
success: function (result) {
|
|
$("#resultSum").val(result);
|
|
}
|
|
});
|
|
};
|
|
}
|
|
</script>
|
|
</script>
|
|
} |