public void Delete(Guid Id) { var existstb_Sys_Menu = this.GetById(Id); if (existstb_Sys_Menu != null) { var detailList = this.planDetailRepository.GetMany(i => i.PlanId == existstb_Sys_Menu.Id).ToList(); foreach (var detail in detailList) { planDetailRepository.Delete(detail); } var materialList = this.planMaterialRepository.GetMany(i => i.PLNo == existstb_Sys_Menu.PLNo).ToList(); foreach (var material in materialList) { planMaterialRepository.Delete(material); } this.MES_M201_PlanRepository.Delete(existstb_Sys_Menu); this.runtimeService.Commit(); } }
public void Save(List <MES_M201_Plan_Material> materialList) { if (materialList.Count > 0) { Guid planDetailId = materialList[0].PlanDetailId; var existList = MES_M201_Plan_MaterialRepository.GetMany(i => i.PlanDetailId == planDetailId).ToList(); foreach (var exist in existList) { MES_M201_Plan_MaterialRepository.Delete(exist); } } tb_Sys_User tempUser = appCacheService.GetItem("user") as tb_Sys_User; foreach (var model in materialList) { model.CreateDt = DateTime.Now; model.CreateUser = tempUser.UserName; model.CompCode = tempUser.CompCode; model.Validate(); this.MES_M201_Plan_MaterialRepository.Add(model); } this.runtimeService.Commit(); }