/// <summary> /// 根据数据填充价格映射模型 /// </summary> /// <param name="row"></param> /// <param name="logDate"></param> /// <returns></returns> private Supplier_RawMaterial CreateRawMaterialModel(IRow row, DateTime logDate) { if (row == null) { return(null); } var model = new Supplier_RawMaterial() { BU = row.GetCell(0)?.ToString(), SAPCode = row.GetCell(1)?.ToString(), Description = row.GetCell(2)?.ToString(), Category = row.GetCell(3)?.ToString(), LeadBuyer = row.GetCell(4)?.ToString(), SupplierCode = row.GetCell(5)?.ToString(), SupplierName = row.GetCell(6)?.ToString(), PriceFrequency = Tools.Enums.Tools.GetValueByName(typeof(Models.PriceFrequency), row.GetCell(7)?.ToString()), Currency = row.GetCell(8)?.ToString(), AddDate = logDate, AddUserId = MyInfo.Id, LastDate = logDate, LastUserId = MyInfo.Id }; if (string.IsNullOrEmpty(model.SAPCode) && string.IsNullOrEmpty(model.Description) && string.IsNullOrEmpty(model.SupplierCode)) { return(null); } return(model); }
public ActionResult Save(int id = 0) { Supplier_RawMaterial model = null; if (id > 0) { model = Bll.BllSupplier_RawMaterial.First(o => o.Id == id && o.Display != 2); if (model == null) { return(LayerAlertSuccessAndRefresh("加载原材料信息失败,未找到该原材料")); } } return(View(model)); }
public ActionResult Save(Supplier_RawMaterial supplierRawMaterial) { //数据是否重复 Supplier_RawMaterial model = Bll.BllSupplier_RawMaterial.First(o => o.Id != supplierRawMaterial.Id && o.SAPCode == supplierRawMaterial.SAPCode && o.Display != 2); if (model != null) { return(LayerMsgErrorAndReturn("添加原材料信息失败,原材料代码已存在,请重新输入!")); } model = Bll.BllSupplier_RawMaterial.First(o => o.Id == supplierRawMaterial.Id && o.Display != 2) ?? new Supplier_RawMaterial(); model.BU = supplierRawMaterial.BU; model.SAPCode = supplierRawMaterial.SAPCode; model.Description = supplierRawMaterial.Description; model.Category = supplierRawMaterial.Category; model.LeadBuyer = supplierRawMaterial.LeadBuyer; model.Currency = supplierRawMaterial.Currency; model.LastDate = DateTime.Now; model.LastUserId = MyInfo.Id; bool isok = false; //没有ID就新增,反之修改 if (supplierRawMaterial.Id < 1) { model.AddDate = model.LastDate; model.AddUserId = model.LastUserId; model.Display = 1; isok = Bll.BllSupplier_RawMaterial.Insert(model) > 0; } else { isok = Bll.BllSupplier_RawMaterial.Update(model) > 0; } return(LayerMsgSuccessAndRefresh("保存" + (isok ? "成功" : "失败"))); }