public IActionResult OnPost() { if (ModelState.IsValid) { var Rcid = _pinhuaContext.GetNewRcId(); var rtId = "165.1"; var repCase = new EsRepCase { RcId = Rcid, RtId = rtId, LstFiller = 2, LstFillerName = User.Identity.Name, LstFillDate = DateTime.Now, //fillDate = DateTime.Now, //wiId = "", //state = 1, }; var main = _mapper.Map <WarehouseDTO, Data.Entities.Pinhua.Warehouse>(WarehouseInfo.Main); main.ExcelServerRcid = Rcid; main.ExcelServerRtid = rtId; _pinhuaContext.EsRepCase.Add(repCase); _pinhuaContext.Warehouse.Add(main); _pinhuaContext.SaveChanges(); return(RedirectToPage("Index")); } else { return(Page()); } }
protected void ValidSubmit(EditContext context) { using (var transaction = PinhuaContext.Database.BeginTransaction()) { var affected = new List <string>(); var bAdd = PinhuaContext.TryRecordAdd <dto销售订单, tb_订单表>(main, adding => { adding.业务类型 = base.category; adding.单号 = PinhuaContext.funcAutoCode("订单号"); adding.往来 = PinhuaContext.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == adding.往来号)?.简称; }); if (bAdd) { var bAdd2 = PinhuaContext.TryRecordDetailsAdd <dto销售订单, dto销售订单D, tb_订单表, tb_订单表D>(main, detailsTableDataSource, item => { if (string.IsNullOrWhiteSpace(item.子单号)) { item.子单号 = PinhuaContext.funcAutoCode("子单号"); } else { affected.Add(item.子单号); var 报价D = PinhuaContext.tb_报价表D.FirstOrDefault(d => d.子单号 == item.子单号); if (报价D != null) { 报价D.状态 = "已下单"; } } }); if (bAdd2) { 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()) { try { PinhuaContext.RecordEdit <dto字典, tb_字典表>(main); Action <dto字典D> adding = item => { item.字典号 = main.字典号; item.组号 = main.组号; }; Action <dto字典D> updating = item => { item.字典号 = main.字典号; item.组号 = main.组号; }; var remote = PinhuaContext.RecordDetailsEdit <dto字典, dto字典D, tb_字典表, tb_字典表D>(main, detailsTableDataSource, adding, updating); PinhuaContext.SaveChanges(); transaction.Commit(); Navigation.NavigateTo(routeA); } catch (Exception) { transaction.Rollback(); } } }
public IActionResult OnPost(string rcId) { var a = _pinhuaContext.EsRepCase.Where(x => x.RcId == rcId); if (a != null) { _pinhuaContext.EsRepCase.RemoveRange(a); } var b = _pinhuaContext.人员档案.Where(x => x.ExcelServerRcid == rcId); if (b != null) { _pinhuaContext.人员档案.RemoveRange(b); } var c = _pinhuaContext.考勤卡号变动.Where(x => x.ExcelServerRcid == rcId); if (c != null) { _pinhuaContext.考勤卡号变动.RemoveRange(c); } _pinhuaContext.SaveChanges(); return(RedirectToPage("Index")); }
protected void HandelValidSubmit(EditContext context) { using (var transaction = PinhuaContext.Database.BeginTransaction()) { var remote = PinhuaContext.RecordAdd <dto收款单, tb_收付表>(main, creating => { creating.单号 = PinhuaContext.funcAutoCode("订单号"); creating.类型 = "收款"; creating.往来 = PinhuaContext.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == creating.往来号)?.简称; }); if (PinhuaContext.SaveChanges() > 0) { foreach (var localD in detailsTableDataSource) { PinhuaContext.RecordDetailAdd <dto收款单, dto收款单D, tb_收付表, tb_收付表D>(remote, localD, BeforeNewD: beforeD => { if (string.IsNullOrEmpty(beforeD.子单号)) { beforeD.子单号 = PinhuaContext.funcAutoCode("子单号"); } else { } }); } PinhuaContext.SaveChanges(); transaction.Commit(); } Navigation.NavigateTo(routeA); } }
public IActionResult OnPostUpdate(int Y, int M, string jsonStr) { var dto = Newtonsoft.Json.JsonConvert.DeserializeObject <IList <PayrollDetailsDTO> >(jsonStr); var payroll = _pinhuaContext.PayrollMain.FirstOrDefault(p => p.Y == Y && p.M == M); if (payroll == null) { return(NotFound()); } var details = _pinhuaContext.PayrollDetails.Where(d => d.ExcelServerRcid == payroll.ExcelServerRcid); _pinhuaContext.PayrollDetails.RemoveRange(details); var newDetails = _mapper.Map <IList <PayrollDetailsDTO>, IList <PayrollDetails> >(dto); foreach (var detail in newDetails) { detail.Y = Y; detail.M = M; detail.ExcelServerRcid = payroll.ExcelServerRcid; detail.ExcelServerRtid = payroll.ExcelServerRtid; } _pinhuaContext.PayrollDetails.AddRange(newDetails); _pinhuaContext.SaveChanges(); return(RedirectToPage("Index")); }
public IActionResult OnPost() { if (!ModelState.IsValid) { return(Page()); } PersonnelFile.Id = _pinhuaContext.CreatePersonnelFileId("PF", 4); var rcId = _pinhuaContext.GetNewRcId(); var rtId = _pinhuaContext.GetRtId("人员档案"); var repCase = new EsRepCase { RcId = rcId, RtId = rtId, LstFiller = 2, LstFillerName = User.Identity.Name, LstFillDate = DateTime.Now, FillDate = DateTime.Now, }; PersonnelFile.ExcelServerRcid = rcId; PersonnelFile.ExcelServerRtid = rtId; PersonnelFile.SignedDate = DateTime.Now; _pinhuaContext.EsRepCase.Add(repCase); _pinhuaContext.人员档案.Add(_mapper.Map <PersonnelFilesDTO, 人员档案>(PersonnelFile)); _pinhuaContext.SaveChanges(); return(RedirectToPage("Index")); }
public IActionResult OnPost() { if (ModelState.IsValid) { var Rcid = _pinhuaContext.GetNewRcId(); var rtId = "178.1"; var repCase = new EsRepCase { RcId = Rcid, RtId = rtId, LstFiller = 2, LstFillerName = User.Identity.Name, LstFillDate = DateTime.Now, //fillDate = DateTime.Now, //wiId = "", //state = 1, }; var main = _mapper.Map <ProductRegistrationDTO, ProductRegistrationMain>(ProductRegistrationInfo); main.ExcelServerRcid = Rcid; main.ExcelServerRtid = rtId; _pinhuaContext.EsRepCase.Add(repCase); _pinhuaContext.ProductRegistrationMain.Add(main); _pinhuaContext.SaveChanges(); return(RedirectToPage("Index")); } else { return(Page()); } }
public IActionResult OnPost() { if (ModelState.IsValid) { var Rcid = _pinhuaContext.GetNewRcId(); var rtId = "175.1"; var repCase = new EsRepCase { RcId = Rcid, RtId = rtId, LstFiller = 2, LstFillerName = User.Identity.Name, LstFillDate = DateTime.Now, //fillDate = DateTime.Now, //wiId = "", //state = 1, }; var main = _mapper.Map <ProductionStockInMainDTO, StockInMain>(Order.Main); main.ExcelServerRcid = Rcid; main.ExcelServerRtid = rtId; main.MovementType = "131"; var details = _mapper.Map <List <ProductionStockInDetailsDTO>, List <StockInDetails> >(Order.Details); details.ForEach(i => { i.ExcelServerRcid = Rcid; i.ExcelServerRtid = rtId; i.OrderId = main.OrderId; }); if (details.Count == 0) { ModelState.AddModelError("", "清单不可为空"); Order.MovementTypeList = BuildTypes(); Order.CustomerList = _pinhuaContext.GetCustomerSelectList(); Order.WarehouseList = _pinhuaContext.GetWarehouseSelectList(); return(Page()); } _pinhuaContext.EsRepCase.Add(repCase); _pinhuaContext.StockInMain.Add(main); _pinhuaContext.StockInDetails.AddRange(details); _pinhuaContext.SaveChanges(); return(RedirectToPage("Index")); } else { Order.MovementTypeList = BuildTypes(); Order.CustomerList = _pinhuaContext.GetCustomerSelectList(); Order.WarehouseList = _pinhuaContext.GetWarehouseSelectList(); return(Page()); } }
public IActionResult OnPost() { if (ModelState.IsValid) { var Rcid = _pinhuaContext.GetNewRcId(); var rtId = "157.1"; var repCase = new EsRepCase { RcId = Rcid, RtId = rtId, LstFiller = 2, LstFillerName = User.Identity.Name, LstFillDate = DateTime.Now, //fillDate = DateTime.Now, //wiId = "", //state = 1, }; var main = _mapper.Map <Gi2MainDTO, Gi2Main>(Order.Main); main.ExcelServerRcid = Rcid; main.ExcelServerRtid = rtId; main.CustomerName = _pinhuaContext.往来单位.AsNoTracking().FirstOrDefault(p => p.单位编号 == Order.Main.CustomerId).单位名称; var details = _mapper.Map <List <Gi2DetaislDTO>, List <Gi2Details> >(Order.Details); details.ForEach(i => { i.ExcelServerRcid = Rcid; i.ExcelServerRtid = rtId; i.DeliveryId = main.DeliveryId; }); if (details.Count == 0) { ModelState.AddModelError("", "出库清单不可为空"); DeliveryTypes = BuildTypes(); CustomerSelectList = _pinhuaContext.GetCustomerSelectList(); ContactsSelectList = _pinhuaContext.GetContactsSelectList(); return(Page()); } _pinhuaContext.EsRepCase.Add(repCase); _pinhuaContext.Gi2Main.Add(main); _pinhuaContext.Gi2Details.AddRange(details); _pinhuaContext.SaveChanges(); return(RedirectToPage("Index")); } else { DeliveryTypes = BuildTypes(); CustomerSelectList = _pinhuaContext.GetCustomerSelectList(); ContactsSelectList = _pinhuaContext.GetContactsSelectList(); return(Page()); } }
public IActionResult OnPost() { var result = _pinhuaContext.人员档案.FirstOrDefault(p => p.人员编号 == PersonnelFile.Id); //PersonnelFile.ExcelServerRcid = result.ExcelServerRcid; //PersonnelFile.ExcelServerRtid = result.ExcelServerRtid; _mapper.Map <PersonnelFilesDTO, 人员档案>(PersonnelFile, result); _pinhuaContext.SaveChanges(); return(RedirectToPage("Index")); }
public IActionResult OnPost() { var order = _pinhuaContext.付款单.FirstOrDefault(x => x.ExcelServerRcid == Payment.ExcelServerRcid); Payment.付款单位 = _pinhuaContext.往来单位.FirstOrDefault(x => x.单位编号 == Payment.单位编号)?.单位名称; PinhuaContextExtensions.Copy.ShadowCopy(Payment, order); _pinhuaContext.SaveChanges(); return(RedirectToPage("Index")); }
public IActionResult OnPost() { var result = _pinhuaContext.人员档案.FirstOrDefault(p => p.人员编号 == PersonnelFile.Id); result.状态 = "辞退"; result.离职时间 = PersonnelFile.InServiceEnd; result.离职或辞退原因 = PersonnelFile.ReasonOfLeave; _pinhuaContext.SaveChanges(); return(RedirectToPage("Index")); }
public IActionResult OnPost() { if (ModelState.IsValid) { var Rcid = _pinhuaContext.GetNewRcId(); var rtId = _pinhuaContext.GetRtId("入库简易版"); var repCase = new EsRepCase { RcId = Rcid, RtId = rtId, LstFiller = 2, LstFillerName = User.Identity.Name, LstFillDate = DateTime.Now, //fillDate = DateTime.Now, //wiId = "", //state = 1, }; var main = _mapper.Map <Gr2MainDto, Gr2Main>(Purchasing.Main); main.ExcelServerRcid = Rcid; main.ExcelServerRtid = rtId; main.SupplierName = _pinhuaContext.往来单位.AsNoTracking().FirstOrDefault(p => p.单位编号 == main.Supplier).单位名称; var details = _mapper.Map <List <Gr2DetailsDto>, List <Gr2Details> >(Purchasing.Details); details.ForEach(i => { i.ExcelServerRcid = Rcid; i.ExcelServerRtid = rtId; i.PurchasingId = main.PurchasingId; }); if (Purchasing.Details.Count == 0) { ModelState.AddModelError("", "采购清单不可为空"); PurchasingTypes = buildPurchasingTypes(); SupplierList = _pinhuaContext.GetCustomerSelectList(); return(Page()); } _pinhuaContext.EsRepCase.Add(repCase); _pinhuaContext.Gr2Main.Add(main); _pinhuaContext.Gr2Details.AddRange(details); _pinhuaContext.SaveChanges(); return(RedirectToPage("Index")); } else { PurchasingTypes = buildPurchasingTypes(); SupplierList = _pinhuaContext.GetCustomerSelectList(); return(Page()); } }
protected void HandleValidSubmit(EditContext context) { using (var transaction = PinhuaContext.Database.BeginTransaction()) { try { var remote = PinhuaContext.RecordAdd <dto往来, tb_往来表>(main, adding => { adding.往来号 = PinhuaContext.funcAutoCode("往来号"); }); PinhuaContext.SaveChanges(); transaction.Commit(); Navigation.NavigateTo(routeA); } catch (Exception) { transaction.Rollback(); } } }
public IActionResult OnPost() { var year = DateTime.Now.ToString("yy"); var exsistedIds = (from p in _pinhuaContext.收款单 where p.收款单号.Substring(0, 4) == "SK" + year orderby p.收款单号 descending select p.收款单号) .ToList(); var orderIndex = int.Parse(exsistedIds.Count() == 0 ? "0" : exsistedIds.First().Substring(4, 6)) + 1; var name = _pinhuaContext.往来单位.FirstOrDefault(x => x.单位编号 == Collection.单位编号)?.单位名称; Collection.收款单号 = "SK" + year + orderIndex.ToString("D6"); Collection.收款单位 = name; var rcId = _pinhuaContext.GetNewRcId(); var rtId = _pinhuaContext.GetRtId("收款单"); var repCase = new EsRepCase { RcId = rcId, RtId = rtId, LstFiller = 2, LstFillerName = User.Identity.Name, LstFillDate = DateTime.Now, FillDate = DateTime.Now, }; Collection.ExcelServerRcid = rcId; Collection.ExcelServerRtid = rtId; _pinhuaContext.EsRepCase.Add(repCase); _pinhuaContext.收款单.Add(Collection); _pinhuaContext.SaveChanges(); return(RedirectToPage("Index")); }
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); } }
public IActionResult OnPost() { if (ModelState.IsValid) { var Rcid = _pinhuaContext.GetNewRcId(); var rtId = "179.1"; var repCase = new EsRepCase { RcId = Rcid, RtId = rtId, LstFiller = 2, LstFillerName = "*****@*****.**", LstFillDate = DateTime.Now, //fillDate = DateTime.Now, //wiId = "", //state = 1, }; var main = _mapper.Map <dto生产单M, 生产单>(Order.M); main.单号 = _pinhuaContext.GetZkyAutoId(181); main.ExcelServerRcid = Rcid; main.ExcelServerRtid = rtId; main.客户名 = _pinhuaContext.往来单位.AsNoTracking().FirstOrDefault(p => p.单位编号 == Order.M.客户号).单位名称; if (Order?.D?.Count == 0) { ModelState.AddModelError("", "产品清单不可为空"); PartnerSelectList = _pinhuaContext.GetCustomerSelectList(); return(Page()); } foreach (var d in Order.D) { var newRecord = new 生产单d { ExcelServerRcid = Rcid, ExcelServerRtid = rtId, 长 = d.长, 宽 = d.宽, 高 = d.高, 片数 = d.片数, 刻线要求 = d.刻线要求, 拉丝要求 = d.拉丝要求, 开槽要求 = d.开槽要求, 油漆要求 = d.油漆要求, 描述 = d.描述, 其他要求 = d.其他要求, 是否刻线 = d.是否刻线, 是否拉丝 = d.是否拉丝, 是否开槽 = d.是否开槽, 是否油漆 = d.是否油漆, 图片name = d.图片name, 图片type = d.图片type, }; if (!string.IsNullOrEmpty(d.图片base64)) // base64非空,插入图片 { var picNo = _pinhuaContext.GetNewPicNo(); var newBase64 = d.图片base64.Substring(d.图片base64.IndexOf(',') + 1); _pinhuaContext.EsCasePic.Add(new EsCasePic { RcId = Rcid, PicNo = picNo, Img = Convert.FromBase64String(newBase64), FileType = string.IsNullOrEmpty(d.图片name) ? ".jpg" : d.图片name.Substring(d.图片name.LastIndexOf(".")), RtfId = 2573, Sh = 2, R = 21, C = 51, IsNew = 0, Rng = null, SaveInto = 0, NfsfolderId = 0, Nfsfolder = "", PhyFileName = "", RelaFolder = "" }); newRecord.图片 = picNo; } _pinhuaContext.生产单d.Add(newRecord); } _pinhuaContext.EsRepCase.Add(repCase); _pinhuaContext.生产单.Add(main); _pinhuaContext.SaveChanges(); return(RedirectToPage("Index")); } else { PartnerSelectList = _pinhuaContext.GetCustomerSelectList(); return(Page()); } }
public IActionResult OnPost() { var remoteOrder = _pinhuaContext.生产单.FirstOrDefault(p => p.单号 == Order.M.单号); if (remoteOrder == null) { ModelState.AddModelError("", $"单号为 {Order.M.单号} 的生产订单不存在,操作失败。"); PartnerSelectList = _pinhuaContext.GetCustomerSelectList(); return(Page()); } // 对主表的缺失信息赋值,ExcelServerRcid,ExcelServerRtid,其他 Order.M.ExcelServerRcid = remoteOrder.ExcelServerRcid; Order.M.ExcelServerRtid = remoteOrder.ExcelServerRtid; Order.M.客户名 = _pinhuaContext.往来单位.FirstOrDefault(p => p.单位编号 == Order.M.客户号).单位名称; // 将修改标记到数据库中跟踪的数据,remoteOrder _mapper.Map <dto生产单M, 生产单>(Order.M, remoteOrder); // 删除明细表的老数据 var remoteDetails = _pinhuaContext.生产单d.Where(p => p.ExcelServerRcid == remoteOrder.ExcelServerRcid); _pinhuaContext.生产单d.RemoveRange(remoteDetails); // 删除旧的图片数据 var oldCasePic = _pinhuaContext.EsCasePic.Where(p => p.RcId == remoteOrder.ExcelServerRcid); _pinhuaContext.EsCasePic.RemoveRange(oldCasePic); // 对明细表的缺失信息赋值 Order.D.ForEach(i => { var newRecord = new 生产单d { ExcelServerRcid = remoteOrder.ExcelServerRcid, ExcelServerRtid = remoteOrder.ExcelServerRtid, 长 = i.长, 宽 = i.宽, 高 = i.高, 片数 = i.片数, 刻线要求 = i.刻线要求, 拉丝要求 = i.拉丝要求, 开槽要求 = i.开槽要求, 油漆要求 = i.油漆要求, 描述 = i.描述, 其他要求 = i.其他要求, 是否刻线 = i.是否刻线, 是否拉丝 = i.是否拉丝, 是否开槽 = i.是否开槽, 是否油漆 = i.是否油漆, 图片name = i.图片name, 图片type = i.图片type, }; if (!string.IsNullOrEmpty(i.图片base64)) // base64非空,插入图片 { var picNo = _pinhuaContext.GetNewPicNo(); var newBase64 = i.图片base64.Substring(i.图片base64.IndexOf(',') + 1); _pinhuaContext.EsCasePic.Add(new EsCasePic { RcId = remoteOrder.ExcelServerRcid, PicNo = picNo, Img = Convert.FromBase64String(newBase64), FileType = string.IsNullOrEmpty(i.图片name) ? ".jpg" : i.图片name.Substring(i.图片name.LastIndexOf(".")), RtfId = 2573, Sh = 2, R = 21, C = 51, IsNew = 0, Rng = null, SaveInto = 0, NfsfolderId = 0, Nfsfolder = "", PhyFileName = "", RelaFolder = "" }); newRecord.图片 = picNo; } _pinhuaContext.生产单d.Add(newRecord); }); // 保存修改 _pinhuaContext.SaveChanges(); return(RedirectToPage("Index")); }
protected void ValidSubmit(EditContext context) { using (var transaction = PinhuaContext.Database.BeginTransaction()) { var affected = new List <string>(); var bAdd = PinhuaContext.TryRecordAdd <dto销售出库, tb_IO>(main, adding => { adding.类型 = base.category; adding.单号 = PinhuaContext.funcAutoCode("订单号"); adding.往来 = PinhuaContext.tb_往来表.AsNoTracking().FirstOrDefault(p => p.往来号 == adding.往来号)?.简称; }); if (bAdd) { var bAdd2 = PinhuaContext.TryRecordDetailsAdd <dto销售出库, dto销售出库D, tb_IO, tb_IOD>(main, detailsTableDataSource, adding => { if (string.IsNullOrWhiteSpace(adding.子单号)) { adding.子单号 = PinhuaContext.funcAutoCode("子单号"); } else { affected.Add(adding.子单号); //var item = PinhuaContext.tb_订单表D.FirstOrDefault(d => d.子单号 == adding.子单号); //if (item != null) // item.状态 = "已出库"; } } ); if (bAdd2) { 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 items1 = PinhuaContext.tb_订单表D.Where(d => childIds1.Contains(d.子单号)); var items2 = PinhuaContext.tb_订单表D.Where(d => childIds2.Contains(d.子单号)); foreach (var item in items1) { item.状态 = "已出库"; } ; foreach (var item in items2) { 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); } }
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); } }
public IActionResult OnPost(int yyyy, int mm, string jsonStr) { if (string.IsNullOrEmpty(jsonStr)) { return(Page()); } var Payrolls = Newtonsoft.Json.JsonConvert.DeserializeObject <IList <PayrollDetailsDTO> >(jsonStr); if (Payrolls == null) { return(Page()); } var Rcid = _pinhuaContext.GetNewRcId(); var rtId = _pinhuaContext.GetRtId("工资单"); var repCase = new EsRepCase { RcId = Rcid, RtId = rtId, LstFiller = 2, LstFillerName = User.Identity.Name, LstFillDate = DateTime.Now, }; var payrollMain = new PayrollMain { ExcelServerRcid = Rcid, ExcelServerRtid = rtId, Y = yyyy, M = mm }; var payrollDetails = new List <PayrollDetails>(); foreach (var payroll in Payrolls) { var pd = new PayrollDetails { ExcelServerRcid = Rcid, ExcelServerRtid = rtId, Y = yyyy, M = mm, }; _mapper.Map <PayrollDetailsDTO, PayrollDetails>(payroll, pd); payrollDetails.Add(pd); } _pinhuaContext.EsRepCase.Add(repCase); _pinhuaContext.PayrollMain.Add(payrollMain); _pinhuaContext.PayrollDetails.AddRange(payrollDetails); try { _pinhuaContext.SaveChanges(); } catch (DbUpdateException e) { ModelState.AddModelError("", e.InnerException.Message); return(Page()); } return(RedirectToPage("Index")); }
public async Task <IActionResult> OnPost(string jsonStr) { if (string.IsNullOrEmpty(jsonStr)) { return(Page()); } var data = Newtonsoft.Json.JsonConvert.DeserializeObject <AttendanceServiceDTO>(jsonStr); if (data == null) { return(Page()); } var report = _pinhuaContext.AttendanceReport.AsNoTracking().FirstOrDefault(r => r.Y == data.Y && r.M == data.M); if (report == null) { return(Page()); } var reportDetails = new List <AttendanceReportResults>(); foreach (var person in data.PersonList) { var detail = new AttendanceReportResults { ExcelServerRcid = report.ExcelServerRcid, ExcelServerRtid = report.ExcelServerRtid, Y = data.Y.Value, M = data.M.Value, 编号 = person.Id, 姓名 = person.Name, 是否全勤 = person.IsFullAttendance ? "是" : "否", 正班 = person.DaytimeHours, 加班 = person.OvertimeHours, 总工时 = person.TotalHours, 缺勤 = person.TimesOfAbsent, 迟到 = person.TimesOfLate, 早退 = person.TimesOfLeaveEarly, 请假 = person.TimesOfAskForLeave, 用餐 = person.TimesOfDinner, }; reportDetails.Add(detail); } reportDetails.ForEach(i => { var result = _pinhuaContext.AttendanceReportResults.FirstOrDefault(p => p.Y == i.Y && p.M == i.M && p.编号 == i.编号); if (result == null) { // 如果该条信息不存在,则添加 _pinhuaContext.AttendanceReportResults.Add(i); } else { // 如果该条信息存在,则修改 Copy.ShadowCopy(i, result); } }); await _pinhuaContext.AttendanceReportResults.Where(p => p.Y == data.Y && p.M == data.M).ForEachAsync(i => { var result = reportDetails.FirstOrDefault(p => p.编号 == i.编号); if (result == null) { // 如果该条信息多余,则删除 _pinhuaContext.AttendanceReportResults.Remove(i); } }); // 保存明细 var abc = new List <AttendanceReportDetails>(); foreach (var person in data.PersonList) { foreach (var detail in person.Results) { foreach (var range in detail.Details) { var o = new AttendanceReportDetails { 编号 = person.Id, 姓名 = person.Name, 日期 = detail.Date, 班段 = range.RangeId, 班段描述 = range.Range, 班 = range.Time1Fix, 班 = range.Time2Fix, 工时 = range.Hours, 考勤结果 = range.State, ExcelServerRcid = report.ExcelServerRcid, ExcelServerRtid = report.ExcelServerRtid, }; abc.Add(o); } } } var details = _pinhuaContext.AttendanceReportDetails.Where(d => d.ExcelServerRcid == report.ExcelServerRcid); _pinhuaContext.AttendanceReportDetails.RemoveRange(details); _pinhuaContext.AttendanceReportDetails.AddRange(abc); _pinhuaContext.SaveChanges(); return(RedirectToPage("Index")); }
public IActionResult OnPost(string jsonStr) { if (string.IsNullOrEmpty(jsonStr)) { return(Page()); } var data = Newtonsoft.Json.JsonConvert.DeserializeObject <AttendanceServiceDTO>(jsonStr); if (data == null) { return(Page()); } var Rcid = _pinhuaContext.GetNewRcId(); var rtId = _pinhuaContext.GetRtId("AttendanceReport"); var repCase = new EsRepCase { RcId = Rcid, RtId = rtId, LstFiller = 2, LstFillerName = User.Identity.Name, LstFillDate = DateTime.Now, }; var reportMain = new AttendanceReport { ExcelServerRcid = Rcid, ExcelServerRtid = rtId, Y = data.Y.Value, M = data.M.Value }; var reportDetails = new List <AttendanceReportResults>(); foreach (var person in data.PersonList) { var detail = new AttendanceReportResults { ExcelServerRcid = Rcid, ExcelServerRtid = rtId, Y = data.Y.Value, M = data.M.Value, 编号 = person.Id, 姓名 = person.Name, 是否全勤 = person.IsFullAttendance ? "是" : "否", 正班 = person.DaytimeHours, 加班 = person.OvertimeHours, 总工时 = person.TotalHours, 缺勤 = person.TimesOfAbsent, 迟到 = person.TimesOfLate, 早退 = person.TimesOfLeaveEarly, 请假 = person.TimesOfAskForLeave, 用餐 = person.TimesOfDinner, }; reportDetails.Add(detail); } // 保存明细 var abc = new List <AttendanceReportDetails>(); foreach (var person in data.PersonList) { foreach (var detail in person.Results) { foreach (var range in detail.Details) { var o = new AttendanceReportDetails { 编号 = person.Id, 姓名 = person.Name, 日期 = detail.Date, 班段 = range.RangeId, 班段描述 = range.Range, 班 = range.Time1Fix, 班 = range.Time2Fix, 工时 = range.Hours, 考勤结果 = range.State, ExcelServerRcid = Rcid, ExcelServerRtid = rtId, }; abc.Add(o); } } } _pinhuaContext.EsRepCase.Add(repCase); _pinhuaContext.AttendanceReport.Add(reportMain); _pinhuaContext.AttendanceReportResults.AddRange(reportDetails); _pinhuaContext.AttendanceReportDetails.AddRange(abc); _pinhuaContext.SaveChanges(); return(RedirectToPage("Index")); }