CSFrameworkV6-业务单据数据查询页面显示主从表关联数据解决方案
应客户要求,业务单据的数据查询页面要同时显示主从表数据,需要做以下调整:
1、查询条件,增加查询明细表字段的条件
查询结果显示一张单据对应多条明细记录。
DAL层查询方法 DAL.Query
C# 全选
//查询主从表
var qJoin = (from s in q
join b in q1 on s.PONO equals b.PONO into tmp //必须使用左连,避免无明细表出不了数据
from b in tmp.DefaultIfEmpty()
select new res_PO
{
isid = s.isid,
PONO = s.PONO,
DocDate = s.DocDate,
POUser = s.POUser,
DocType = s.DocType,
SupplierCode = s.SupplierCode,
SupplierName = s.SupplierName,
SupplierAddress = s.SupplierAddress,
SupplierTel = s.SupplierTel,
SupplierFax = s.SupplierFax,
SupplierContact = s.SupplierContact,
SupplierContactPhone = s.SupplierContactPhone,
PayType = s.PayType,
FlagStop = s.FlagStop,
FlagPrint = s.FlagPrint,
Remark = s.Remark,
CreationDate = s.CreationDate,
CreatedBy = s.CreatedBy,
LastUpdateDate = s.LastUpdateDate,
LastUpdatedBy = s.LastUpdatedBy,
FlagApp = s.FlagApp,
AppUser = s.AppUser,
AppDate = s.AppDate,
DeliveryDate = s.DeliveryDate,
TotalAmount = s.TotalAmount,
TotalSquar = s.TotalSquar,
TotalVolumn = s.TotalVolumn,
TotalWeight = s.TotalWeight,
//明细表字段
CustomerGoodsNo = b == null ? "" : b.GoodsNo,
CustomerOrderNo = b == null ? "" : b.CustomerOrderNo,
PaperLength = b == null ? 0 : b.PaperLength,
PaperName = b == null ? "" : b.PaperName,
PaperNameProduce = b == null ? "" : b.PaperNameSupplier,
PaperSpec = b == null ? "" : b.PaperSpec,
PaperSpecProduce = b == null ? "" : b.SupplierSpec,
PaperWidth = b == null ? 0 : b.PaperWidth,
}
).Distinct();
//返回查询结果
return qJoin.OrderByDescending(o => o.CreationDate).ToList();
2、删除记录 DoDelete方法
整单删除,要删除多条记录。
删除前要用户确认。
3、新增\修改 -> 保存
4、审核操作
审核:
C# 全选
public override void DoApproval(IButtonInfo button)
{
AssertFocusedRow();
var row = (res_SO)_SummaryView.GetFocusedRow();
if (row.FlagApp == "Y")
{
Msg.Warning($"单据 <{row.SONO}> 已经审核,不可重复操作!");
}
else
{
if (Msg.AskQuestion($"确定要审核单据 <{row.SONO}> 吗? "))
{
if (_BLL.ApprovalBusiness(row)) //审核单据
{
//更新表格缓存记录的审核状态
gvSummary.GetDataSource<res_SO>()
.Where(w => w.SONO == row.SONO).ToList().ForEach(i => i.FlagApp = "Y");
gvSummary.RefreshData();
if (this.IsShowDetailPage)
{
this.DoViewContent(null);//显示单据明细
}
}
}
}
}
反审:
5、测试场景
新增一张单据,多条明细,保存后查看表格数据是否正常
修改单据,修改一条明细,保存后查看表格数据是否更新正常
删除单据,查看表格里是否删除了整单记录。
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网