2024-05-25 17:47:14 +04:00
|
|
|
@{
|
2024-05-29 15:31:22 +04:00
|
|
|
ViewData["Title"] = "Create";
|
2024-05-25 17:47:14 +04:00
|
|
|
}
|
2024-05-29 15:31:22 +04:00
|
|
|
<div class="text-center">
|
|
|
|
<h2 class="display-4">Создание заказа</h2>
|
|
|
|
</div>
|
|
|
|
<form method="post">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-4">Product:</div>
|
|
|
|
<div class="col-8">
|
|
|
|
<select id="product" name="product" class="form-control">
|
|
|
|
@foreach (var product in ViewBag.Products)
|
|
|
|
{
|
|
|
|
<option value="@product.ID">@product.ProductName</option>
|
|
|
|
}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-4">Количество:</div>
|
|
|
|
<div class="col-8">
|
|
|
|
<input type="text" name="count" id="count" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-4">Сумма:</div>
|
|
|
|
<div class="col-8">
|
|
|
|
<input type="text" id="sum" name="sum" readonly />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-8"></div>
|
|
|
|
<div class="col-4">
|
|
|
|
<input type="submit" value="Создать" class="btn btn-primary" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<script>
|
|
|
|
$('#product').on('change', function () {
|
|
|
|
check();
|
|
|
|
});
|
|
|
|
$('#count').on('change', function () {
|
|
|
|
check();
|
|
|
|
});
|
|
|
|
function check() {
|
|
|
|
var count = $('#count').val();
|
|
|
|
var product = $('#product').val();
|
|
|
|
if (count && product) {
|
|
|
|
$.ajax({
|
|
|
|
method: "POST",
|
|
|
|
url: "/Home/Calc",
|
|
|
|
data: { count: count, product: product },
|
|
|
|
success: function (result) {
|
|
|
|
var roundedResult = parseFloat(result).toFixed(2);
|
|
|
|
$("#sum").val(roundedResult);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
</script>
|