protected void HandelValidSubmit(EditContext context) { using (var transaction = PinhuaContext.Database.BeginTransaction()) { var bSuccess1 = PinhuaContext.TryRecordEdit <dto付款单, tb_收付表>(main, creating => { creating.类型 = base.category; creating.往来 = PinhuaContext.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == creating.往来号)?.简称; }); if (bSuccess1) { var bSuccess2 = PinhuaContext.TryRecordDetailsEdit <dto付款单, dto付款单D, tb_收付表, tb_收付表D>(main, currentDetails, adding => { if (string.IsNullOrWhiteSpace(adding.子单号)) { adding.子单号 = PinhuaContext.funcAutoCode("子单号"); } }); if (bSuccess2) { transaction.Commit(); } } Navigation.NavigateTo(routeA); } }
protected void ValidSubmit(EditContext context) { using (var transaction = PinhuaContext.Database.BeginTransaction()) { var bEdit = PinhuaContext.TryRecordEdit <dto销售报价, tb_报价表>(main, editing => { editing.业务类型 = base.category; editing.往来 = PinhuaContext.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == main.往来号)?.简称; }); if (bEdit) { var bEdit2 = PinhuaContext.TryRecordDetailsEdit <dto销售报价, dto销售报价D, tb_报价表, tb_报价表D>(main, detailsTableDataSource, adding => { adding.子单号 = PinhuaContext.funcAutoCode("子单号"); }); if (bEdit2) { transaction.Commit(); } } Navigation.NavigateTo(routeA); } }
protected void HandleValidSubmit(EditContext context) { using (var transaction = PinhuaContext.Database.BeginTransaction()) { var bAdd = PinhuaContext.TryRecordEdit <dto采购申请, tb_需求表>(main, adding => { adding.业务类型 = base.category; }); if (bAdd) { var bAdd2 = PinhuaContext.TryRecordDetailsEdit <dto采购申请, dto采购申请D, tb_需求表, tb_需求表D>(main, detailsTableDataSource, adding => { if (string.IsNullOrWhiteSpace(adding.子单号)) { adding.子单号 = PinhuaContext.funcAutoCode("子单号"); } }); if (bAdd2) { transaction.Commit(); } } Navigation.NavigateTo("/采购/申请"); } }
protected void ValidSubmit(EditContext context) { using (var transaction = PinhuaContext.Database.BeginTransaction()) { var bEdit = PinhuaContext.TryRecordEdit <dto商品, tb_商品表>(main); if (bEdit) { transaction.Commit(); } Navigation.NavigateTo(routeA); } }
protected void HandleValidSubmit(EditContext context) { using (var transaction = PinhuaContext.Database.BeginTransaction()) { var affected = new List <string>(); var bEdit = PinhuaContext.TryRecordEdit <dto采购订单, tb_订单表>(main, adding => { adding.业务类型 = base.category; adding.往来 = PinhuaContext.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == adding.往来号)?.简称; }); if (bEdit) { Action <dto采购订单D> Adding = item => { if (string.IsNullOrWhiteSpace(item.子单号)) // 子单号为空的,表示新插入 { item.子单号 = PinhuaContext.funcAutoCode("子单号"); } else // 子单号不为空,表示从报价单引入,插入 { affected.Add(item.子单号); var baojiaD = PinhuaContext.Set <tb_报价表D>().FirstOrDefault(d => d.子单号 == item.子单号); if (baojiaD != null) { baojiaD.状态 = "已下单"; } } }; Action <dto采购订单D> Updating = item => { affected.Add(item.子单号); var baojiaD = PinhuaContext.Set <tb_报价表D>().FirstOrDefault(d => d.子单号 == item.子单号); if (baojiaD != null) { baojiaD.状态 = "已下单"; } }; Action <tb_订单表D> Deleting = item => { affected.Add(item.子单号); var tb_报价D = PinhuaContext.Set <tb_报价表D>().FirstOrDefault(d => d.子单号 == item.子单号); if (tb_报价D != null) { tb_报价D.状态 = ""; } }; var bEdit2 = PinhuaContext.TryRecordDetailsEdit <dto采购订单, dto采购订单D, tb_订单表, tb_订单表D>(main, detailsTableDataSource, Adding, Updating, Deleting); if (bEdit2) { var mains = from m in PinhuaContext.tb_报价表 join d in PinhuaContext.tb_报价表D on m.RecordId equals d.RecordId where affected.Contains(d.子单号) select m; foreach (var m in mains) { var bRet = PinhuaContext.tb_报价表D.Where(d => d.RecordId == m.RecordId).Any(d => d.状态.Contains("已")); if (bRet) { m.LockStatus = 1; } else { m.LockStatus = 0; } } ; PinhuaContext.SaveChanges(); transaction.Commit(); } } Navigation.NavigateTo(routeA); } }
protected void ValidSubmit(EditContext context) { using (var transaction = PinhuaContext.Database.BeginTransaction()) { var affected = new List <string>(); var bEdit = PinhuaContext.TryRecordEdit <dto销售出库, tb_IO>(main, adding => { adding.类型 = base.category; adding.往来 = PinhuaContext.Set <tb_往来表>().FirstOrDefault(p => p.往来号 == adding.往来号)?.简称; }); if (bEdit) { Action <dto销售出库D> Adding = item => { if (string.IsNullOrEmpty(item.子单号)) // 子单号为空的,表示新插入 { item.子单号 = PinhuaContext.funcAutoCode("子单号"); } else // 子单号不为空,表示从报价单引入,插入 { affected.Add(item.子单号); } }; Action <dto销售出库D> Updating = item => affected.Add(item.子单号); Action <tb_IOD> Deleting = item => affected.Add(item.子单号); var bEdit2 = PinhuaContext.TryRecordDetailsEdit <dto销售出库, dto销售出库D, tb_IO, tb_IOD>(main, detailsTableDataSource, Adding, Updating, Deleting); if (bEdit2) { var childIds1 = PinhuaContext.View订单数量收发().Where(d => (d.已发 ?? 0) > 0 && affected.Contains(d.子单号)).Select(d => d.子单号); var childIds2 = PinhuaContext.View订单数量收发().Where(d => (d.已发 ?? 0) == 0 && affected.Contains(d.子单号)).Select(d => d.子单号); var result1 = PinhuaContext.tb_订单表D.Where(d => childIds1.Contains(d.子单号)); var result2 = PinhuaContext.tb_订单表D.Where(d => childIds2.Contains(d.子单号)); foreach (var item in result1) { item.状态 = "已出库"; } ; foreach (var item in result2) { item.状态 = ""; } ; PinhuaContext.SaveChanges(); var mains = from m in PinhuaContext.tb_订单表 join d in PinhuaContext.tb_订单表D on m.RecordId equals d.RecordId where affected.Contains(d.子单号) select m; foreach (var m in mains) { var bRet = PinhuaContext.tb_订单表D.Where(d => d.RecordId == m.RecordId).Any(d => d.状态.Contains("已")); if (bRet) { m.LockStatus = 1; } else { m.LockStatus = 0; } } ; PinhuaContext.SaveChanges(); transaction.Commit(); } } Navigation.NavigateTo(routeA); } }