/// <summary> /// 根据erp导出的物资采购中组织代码获取采购组织 /// </summary> /// <param name="owner">组织代码 S032,S000</param> /// <returns></returns> private int GetOwnerId(string owner) { var orderowner = Repository.SingleOrDefault<OrderOwner>(x => x.OwnerErpCode.Trim() == owner); if (orderowner != null) return orderowner.Id; orderowner = new OrderOwner { Name = "Erp表格导入采购组织(请修改名称)", CreatedBy = CurrentUser.UserName, CreatedOn = DateTime.Now, OwnerErpCode = owner, Description = "Erp表格导入新的采购组织" }; Repository.Add(orderowner); Repository.Save(); return orderowner.Id; }
private void FixupOrderOwner(OrderOwner previousValue) { if (previousValue != null && previousValue.EquipmentOrders.Contains(this)) { previousValue.EquipmentOrders.Remove(this); } if (OrderOwner != null) { if (!OrderOwner.EquipmentOrders.Contains(this)) { OrderOwner.EquipmentOrders.Add(this); } if (OwnerId != OrderOwner.Id) { OwnerId = OrderOwner.Id; } } else if (!_settingFK) { OwnerId = null; } }
public virtual ActionResult AddOrderOwner(OwnerEditModel owner) { if (ModelState.IsValid) { var newtype = new OrderOwner(); UpdateModel(newtype); Repository.Add(newtype); Repository.Save(); return RedirectToAction(MVC.AppSetting.OrderOwnerList()); } return View(owner); }