多条件查询

文献种类:专题技术文献;
开发工具与关键技术:Visual Studio
作者:吴新洋 ;年级:1801 ;撰写时间:2019 年 6 月 3 日
文献编号: 归档时间: 年 月 日
多条件查询

开发工具与关键技术:Visual Studio 
作者: 吴新洋
撰写时间:2019年6月3日

在这里插入图片描述
在这里插入图片描述
$(function () {
createSelect(“SupplierName”, “selSupplier”)下拉框绑定查询
createSelect(“EmployeeName”, “selectEmployee”)
createSelect(“Entrepot”, “selectEntrepot”)
layui.use([‘layer’, ‘table’], function () {
layer = layui.layer,
layuiTable = layui.table;
//初始化配送信息表
tabDelivery = layuiTable.render({
elem: ‘#tabDelivery’,
cols: [[//表头
{ type: “checkbox”, fixed: “left” },
{ type: “numbers”, title: “序号” },
{ field: “IndentID”, title: “IndentID”, hide: true },
{ field: “EntrepotID”, title: “EntrepotID”, hide: true },
{ field: “SupplierName”, title: “供应商”, align: “center” },
{ field: “EmployeeName”, title: “审核员”, align: “center” },
{ field: “DeliveryWay”, title: “配送方式”, align: “center” },
{ field: “ReleaseTimeStrOne”, title: “配送时间”, align: “center” },
{ field: “PSDH”, title: “配送单号”, align: “center” },
{ field: “CargoName”, title: “原料名称”, align: “center” },
{ field: “CargoNum”, title: “原料编号”, align: “center” },
{ field: “Count”, title: “配送数量”, align: “center” },
{ field: “Remark”, title: “备注”, align: “center” },
]],
page: {
limit: 10,
limits: [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],
},
data: [],
}); searchTabDelivery();
});
});
在这里插入图片描述
连表查询
public ActionResult selectDeliveryAll(LayuiTablePage layuiTablePage, int SupplierID, int EmployeeID, int EntrepotID, string PSDH, string PSRQ) {
List listDelivery = (from tbDelivery in myModels.S_Delivery
join tbIndent in myModels.S_Indent on tbDelivery.IndentID equals tbIndent.IndentID
join tbRowCargo in myModels.S_Cargo on tbIndent.RowCargoID equals tbRowCargo.RowCargoID
join tbEmployee in myModels.P_Employee on tbIndent.EmployeeID equals tbEmployee.EmployeeID
join tbSupplier in myModels.S_Supplier on tbIndent.SupplierID equals tbSupplier.SupplierID
join tbEntrepot in myModels.S_Entrepot on tbIndent.EntrepotID equals tbEntrepot.EntrepotID
orderby tbDelivery.DeliveryID descending
select new DeliveryVo {
创建DeliveryVo:存放需要查询的外键字段,
CargoName = tbRowCargo.CargoName,//原料名称
CargoNum = tbRowCargo.CargoNum,//原料编号
CargoP = tbRowCargo.CargoP,//原料单价
Remark = tbDelivery.Remark,//备注
Count = tbIndent.Count,//进货数量
CargoUnit = tbRowCargo.CargoUnit,//原料单位
DeliveryWay = tbDelivery.DeliveryWay,
PSDH = tbDelivery.PSDH,
PSRQ = tbDelivery.PSRQ,
ReleaseTimeStrOne = tbDelivery.PSRQ.ToString(),
SupplierName = tbSupplier.SupplierName,
EmployeeName = tbEmployee.EmployeeName,//员工姓名
EmployeeID = tbEmployee.EmployeeID,//审核员ID
SupplierID = tbSupplier.SupplierID,//供应商ID
EntrepotID = tbEntrepot.EntrepotID, //仓库ID
}).ToList();
条件判断:
if (SupplierID > 0) {
listDelivery = listDelivery.Where(m => m.SupplierID == SupplierID).ToList();}
if (EmployeeID > 0) {
listDelivery = listDelivery.Where(m => m.EmployeeID == EmployeeID).ToList();}
if (EntrepotID > 0){
listDelivery = listDelivery.Where(m => m.EntrepotID == EntrepotID).ToList();}
if (!string.IsNullOrEmpty(PSDH)){
listDelivery = listDelivery.Where(m => m.PSDH.Contains(PSDH)).ToList();}
if (!string.IsNullOrEmpty(PSRQ)){
listDelivery = listDelivery.Where(m => m.ReleaseTimeStrOne.Contains(PSRQ)).ToList(); }
//总行数
int totalRow = listDelivery.Count();
//分页查询
List dbIndent = listDelivery
.Skip(layuiTablePage.GetStartIndex())
.Take(layuiTablePage.limit)
.ToList();
LayuiTableData layuiTableData = new LayuiTableData();
layuiTableData.count = totalRow;
layuiTableData.data = dbIndent;
return Json(layuiTableData, JsonRequestBehavior.AllowGet);
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值