开发工具与关键技术: vs 多表数据连接
作者: 周乐献
撰写时间: 2019 年 7 月 8 日
public ActionResult CommodityCategoryOne(LayuiTablePage layuiTablePage)
{
var listCommodity = (from tbParts in myModel.R_Parts
join tbpartsDagMold in myModel.R__partsDagMold on tbParts.partsDagMoldID equals tbpartsDagMold.partsDagMoldID
join tbUnit in myModel.R_Unit on tbParts.UnitID equals tbUnit.UnitID
join tbSupplier in myModel.R_Supplier on tbParts.SupplierID equals tbSupplier.SupplierID
join tbVehicleModel in myModel.R_VehicleModel on tbParts.VehicleModelID equals tbVehicleModel.VehicleModelID
orderby tbParts.PartsID descending
select new Parts
{
PartsID = tbParts.PartsID,
PaetsName = tbParts.PaetsName,
PartsNumber = tbParts.PartsNumber,
PartsImg = tbParts.PartsImg,
PartsUsit = tbParts.PartsUsit,
EnterMoney = tbParts.EnterMoney,
SellMoney = tbParts.SellMoney,
PartsRemark = tbParts.PartsRemark,
partsDagMoldID = tbpartsDagMold.partsDagMoldID,
partsDagMoldName = tbpartsDagMold.partsDagMoldName,
UnitID = tbUnit.UnitID,
UnitName = tbUnit.UnitName,
SupplierID = tbSupplier.SupplierID,
SupplierName = tbSupplier.SupplierName,
VehicleModelID = tbVehicleModel.VehicleModelID,
VehicleModelName = tbVehicleModel.VehicleModelName,
}).ToList();
int intTotalRow = listCommodity.Count();
List<Parts> list = listCommodity
.Skip(layuiTablePage.GetStartIndex())
.Take(layuiTablePage.limit)
.ToList();
//调用分页封装类
LayuiTableData<Parts> layuiTableData = new LayuiTableData<Parts>();
layuiTableData.count = intTotalRow;//行总数
layuiTableData.data = list;//具体显示数据
return Json(layuiTableData, JsonRequestBehavior.AllowGet);
}
var Commodity_one;
var layerIndex = 0;//加s载层
var layer, layuiTable;//保存layui模块以便全局使用
$(function () {
layui.use(['layer', 'table'], function () {
//赋值
layer = layui.layer, layuiTable = layui.table;
//执行渲染
Commodity_one = layuiTable.render({
elem: "#Commodity_one",//html table id
url: '/AccessoriesPurchase/PartsStock/CommodityCategoryOne',
cols: [[ //表头
{ type: 'checkbox', title: '选中' },//序号列,title设定标题名称
{ field: 'PartsID', title: 'PartsID', hide: true },
{ field: 'partsDagMoldName', title: '商品类型' },
{ field: 'PartsNumber', title: '配件编码' },
{ field: 'PaetsName', title: '配件名称' },
{ field: 'PartsUsit', title: '配件规格' },
{ field: 'VehicleModelName', title: '所属车型' },
{ field: 'UnitName', title: '单位' },
{ field: 'EnterMoney', title: '进价' },
{ field: 'SellMoney', title: '销售价格' },
{ field: 'SupplierName', title: '供应商' },
{ field: 'PartsRemark', title: '备注' },
]],
page: {
limit: 10,//指定每页显示的条数
limits: [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],//每页条数的选择项
},
})
});
})