public void Create(ERP_M001_Material ERP_M001_Material) { ERP_M001_Material.CreateDt = DateTime.Now; tb_Sys_User tempUser = appCacheService.GetItem("user") as tb_Sys_User; ERP_M001_Material.CreateUser = tempUser.UserName; ERP_M001_Material.Validate(); this.ERP_M001_MaterialRepository.Add(ERP_M001_Material); this.runtimeService.Commit(); }
public void Save(ERP_M001_Material material, List <ERP_M001_Material_Supp> matSuppList) { tb_Sys_User tempUser = appCacheService.GetItem("user") as tb_Sys_User; var existsdevice = this.GetById(material.Id); if (existsdevice == null) { var existmatcode = this.GetMaterial().Where(a => a.MatCode == material.MatCode).FirstOrDefault(); if (existmatcode != null) { throw new AppException("物料代号已存在,请检查"); } material.CompCode = tempUser.CompCode; material.CreateDt = DateTime.Now; material.CreateUser = tempUser.UserName; material.Validate(); this.ERP_M001_MaterialRepository.Add(material); } else { material.ModifyDt = DateTime.Now; material.ModifyUser = tempUser.UserName; material.Validate(); this.ERP_M001_MaterialRepository.SetValues(material, existsdevice); } if (matSuppList != null) { string sql = string.Format("Delete ERP_M001_Material_Supp where MatCode = '{0}'", material.MatCode); this.matSuppRepository.GetDbContext().Database.ExecuteSqlCommand(sql); foreach (var matSupp in matSuppList) { matSupp.CompCode = tempUser.CompCode; matSupp.CreateDt = DateTime.Now; matSupp.CreateUser = tempUser.UserName; matSupp.MatCode = material.MatCode; matSupp.Validate(); this.matSuppRepository.Add(matSupp); } } this.runtimeService.Commit(); }
public void Save(ERP_M001_Material material, List <ERP_M001_Material_Supp> matSuppList) { tb_Sys_User tempUser = appCacheService.GetItem("user") as tb_Sys_User; var existsdevice = this.GetById(material.Id); if (existsdevice == null) { material.CompCode = tempUser.CompCode; material.CreateDt = DateTime.Now; material.CreateUser = tempUser.UserName; material.Validate(); this.ERP_M001_MaterialRepository.Add(material); } else { material.ModifyDt = DateTime.Now; material.ModifyUser = tempUser.UserName; material.Validate(); this.ERP_M001_MaterialRepository.SetValues(material, existsdevice); } foreach (var matSupp in matSuppList) { var existsmatSupp = matSuppRepository.GetByID(matSupp.Id); if (existsmatSupp == null) { matSupp.CompCode = tempUser.CompCode; matSupp.CreateDt = DateTime.Now; matSupp.CreateUser = tempUser.UserName; matSupp.Validate(); this.matSuppRepository.Add(matSupp); } else { matSupp.ModifyDt = DateTime.Now; matSupp.ModifyUser = tempUser.UserName; matSupp.Validate(); this.matSuppRepository.SetValues(matSupp, existsmatSupp); } } this.runtimeService.Commit(); }
public void Update(ERP_M001_Material ERP_M001_Material) { ERP_M001_Material.ModifyDt = DateTime.Now; tb_Sys_User tempUser = appCacheService.GetItem("user") as tb_Sys_User; ERP_M001_Material.ModifyUser = tempUser.UserName; ERP_M001_Material.Validate(); var existstb_Sys_Menu = this.GetById(ERP_M001_Material.Id); this.ERP_M001_MaterialRepository.SetValues(ERP_M001_Material, existstb_Sys_Menu); this.runtimeService.Commit(); }