C
- 1. public List<Products> GetData()
{
List<Products> LP = new List<Products>();
DataSet DS = new DataSet();
DS = MenuAccessDAL.MenuConn();
LP = DS.Tables[0].AsEnumerable()
.Select(dataRow => new Models.Products
{
Name = dataRow.Field<string>("Name"),
Price = dataRow.Field<string>("price"),
Description = dataRow.Field<string>("description"),
Calories = dataRow.Field<string>("calories")
}).ToList();
return LP;
}
MenuAccessBO MAB = new MenuAccessBO();
public ActionResult ShowMainPage()
{
List<Products> LFP = MAB.GetData();
return View("ShowMainPage", LFP);
}
<script type="text/javascript">
function CalculateAmount()
{
//debugger;
var totalamount = 0;
var ordertable = document.getElementById("menulist");
for(var r=1, row; row= ordertable.rows[r]; r++)
{
var qty = row.cells[4].childNodes[1].value;
if (qty != "") {
totalamount = totalamount + row.cells[1].innerText * qty;
}
}
document.getElementById("Tot").value = Math.round(totalamount, 2);
}
</script>
<table id="menulist" class="table" style="border-style:solid; border-
color:yellowgreen; border-width:thick;">
<td style="border-style:solid; border-color:blue; border-width:thick; font-
size:medium">
<input type="text"
name="Quantity" />
</td>
<p>
<button id="orderbtn" onclick="CalculateAmount();">Order</button>
</p>
<p>
Total
<input type="text"
id="Tot" disabled />
</p>