Hi All,
I created this view. Here it has columns Item, Description, Qty and again I get some data from the model and generate the other Columns with the model count.
So as an example if there are 2 records in the list, Design created as Item Description, Qty, Sup 01, Sup 02 likewise.
Then I load the values to that columns from the model. Also, there is a switch button to check that line is approved or not.
There is for Ajax code in the script to pass that ID and the switch value to the control.
Additionally, I want to add another column at the end as Total Value. User switch the value as true I want to get that sup value and multiply with the column and need to show the amount on that column.
This is what I have tried. But it won't work
<div class="card-body">
<div class="row">
<div class="col-md-3 col-sm-3">
<strong>Item Description</strong>
</div>
<div class="col-md-1 col-sm-1">
<strong>Quantity</strong>
</div>
@foreach (var item in Model.ToList().First().PurchasingDetailsSup) //new coloumns will be created with the supplier count that user added earlier
{
<div class="col-md-2 col-sm-2">
<strong> @Suppliers.Find(x => x.Value == item.Supp_Id.ToString()).Text</strong>
</div>
}
</div>
@foreach (Asp_PASMVC.Models.PurchasingDetails item in Model)
{
<div class="row">
<div class="col-md-3">
@item.Item_Description
</div>
<div class="col-md-1">
@item.Qty
</div>
@for (int i = 0; i < item.PurchasingDetailsSup.Count; i++)
{
<div class="col-md-2">
@item.PurchasingDetailsSup[i].Unit_Amount
<input type="checkbox" value="@item.PurchasingDetailsSup[i].IsApproved" class="bootstrap-switch bwitch" data-style="ios" data-id="@item.PurchasingDetailsSup[i].Id" data-onstyle="success" data-offstyle="danger" />
</div>
}
</div>
}
</div>
<script>
$(".bootstrap-switch").change(function () {
var Checked = this.checked;
var Id = $(this).data('id');
var Qty = document.getElementById('Qty').value;
var Amount = document.getElementById('Amount').value;
IsApproved(Id, Checked);
calculate(Qty, Amount);
});
function IsApproved(id, chkValue) {
//alert(chkValue);
$.ajax({
url: '../UpdateApproveStatus',
type: 'POST',
dataType: 'json',
cache: false,
async: false,
data: { Id: id, IsChecked: chkValue },
success: function (data) {
if (data.Success != true) {
console.log('Error In IsApprove');
}
}
});
function calculate(qty,amount) {
var myResult = qty * amount;
alert(myResult)
}
}
</script>
So I want If user select item 1 ewis is access, then at the end it shows 5x200 = total amount to Total Column.
If he denied it again then it should 0, and again, he grant access to JKW it should 5x250 = should show the value there.
Line wise it should be calculated.