/// <summary> /// 更新实体数据 /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> public void UpdateForm(string keyValue, System_SetExcelImprotEntity entity) { try { if (!string.IsNullOrEmpty(keyValue)) { entity.Modify(keyValue); this.BaseRepository().Update(entity); } else { throw new System.Exception("找不到需要更新的数据"); } } catch (System.Exception) { throw; } }
/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体数据</param> /// <param name="filedList">字段列表</param> /// <returns></returns> public void SaveEntity(string keyValue, System_SetExcelImprotEntity entity, List <System_SetExcelImportFiledEntity> filedList) { var db = this.BaseRepository().BeginTrans(); try { if (!string.IsNullOrEmpty(keyValue)) { entity.Modify(keyValue); db.Update(entity); } else { entity.Create(); db.Insert(entity); } var expression = LinqExtensions.True <System_SetExcelImportFiledEntity>(); string f_ImportTemplateId = entity.F_Id; expression = expression.And(t => t.F_ImportTemplateId == f_ImportTemplateId); db.Delete(expression); foreach (var item in filedList) { item.F_ImportTemplateId = f_ImportTemplateId; item.Create(); db.Insert(item); } db.Commit(); } catch (System.Exception) { db.Rollback(); throw; } }